内存数据库Redis安装笔记【Linux版】

     之前的工作中有几个项目的数据库架构中都以免费开源的内存数据库Redis作为辅助数据库(auxiliary database)。Redis的内存缓存和磁盘写出设计,保证了数据库系统赖以生存的性能和安全。


①安装

     Linux上建议源码编译安装,一方面Redis非常小(1M+)源码安装很快很方便;另一方面高级软件包管理工具apt或yum可能并未更新到最新版的Redis。这里安装当下最新的4.0.1版本。

cd /usr/local/
wget http://download.redis.io/releases/redis-4.0.1.tar.gz
tar xzf redis-4.0.1.tar.gz
cd redis-4.0.1
make

②配置

     做一些简单常用的配置。我这里主要是做一些启用远程访问、守护进程、修改文件目录和开启AOF记录的设置。

cp src/redis-server /usr/local/bin/redis-server
cp src/redis-cli /usr/local/bin/redis-cli
mkdir /etc/redis
mkdir -p /var/redis/6379
cp redis.conf /etc/redis/6379.conf
vim /etc/redis/6379.conf

	bind 0.0.0.0
	unixsocket /tmp/redis.sock
	daemonize yes
	pidfile /var/run/redis_6379.pid
	logfile /var/log/redis_6379.log
	stop-writes-on-bgsave-error no
	dir /var/redis/6379
	appendonly yes

③开启服务

grep ^# utils/redis_init_script > /etc/init.d/redis_6379
sed -ne '6, 19p' /etc/init.d/skeleton | sed -e '1, $s/skeleton/Redis/g' >> /etc/init.d/redis_6379
grep -v ^# utils/redis_init_script >> /etc/init.d/redis_6379
update-rc.d redis_6379 defaults
service redis_6379 start

④连接调试

root@ubuntu:/usr/local/redis-4.0.1# redis-cli
127.0.0.1:6379> set welcome "Hello Redis"
OK
127.0.0.1:6379> get welcome
"Hello Redis"
127.0.0.1:6379> del welcome
(integer) 1
127.0.0.1:6379> shutdown
8103:M 18 Sep 00:15:11.972 # User requested shutdown...
8103:M 18 Sep 00:15:11.972 * Calling fsync() on the AOF file.
8103:M 18 Sep 00:15:11.972 * Saving the final RDB snapshot before exiting.
8103:M 18 Sep 00:15:11.976 * DB saved on disk
8103:M 18 Sep 00:15:11.976 * Removing the pid file.
8103:M 18 Sep 00:15:11.977 # Redis is now ready to exit, bye bye...
not connected> 
not connected> quit
[1]+  完成                  ./src/redis-server redis.conf
root@ubuntu:/usr/local/redis-4.0.1# 



参考:

https://redis.io/download

https://redis.io/topics/quickstart

《Redis in Action》( https://book.douban.com/subject/10597898/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值