redis安装文档

 

一、下载源码包并解压编译

redis官网地址:http://www.redis.io/

tar xf redis-stable.tar.gz
cd redis-stable
make

 

 

 

编译完成后,在src目录下,有3个可执行文件redis-server、redis-benchmark、redis-cli。然后拷贝到redis目录下。

mkdir /usr/local/redis
cp redis-server redis-benchmark redis-cli /usr/local/redis

 

 

拷贝配置文件到redis目录下

cp  redis.conf  /usr/local/redis

 

二、启动与关闭服务

启动redis服务:

cd /usr/local/redis
./redis-server ./redis.conf

 

不加redis.conf则使用安装目录的默认配置文件启动

后台启动要把daemonize改为yes

 

关闭redis服务:

redis-cli shutdown(有密码的情况为:redis-cli shutdown -a 密码 shutdown)

三、客户端连接及基本操作

本地连接:redis-cli

远程连接:./redis-cli -h host -p port -a password

(远程连接需关闭连接限制:编辑redis.conf,找到bind 127.0.0.1注释掉)

redis默认是无需密码登录的,开启密码需编辑redis.conf,添加requirepass "密码"

 

查询所有的key:keys *

查询当前版本:info

四、遇到的一些问题

1、浏览器访问应用服务时,报Could not get a resource from the pool ,网上有很多报错原因和解决方法,需要对应的情况才能有效解决。这里最终是发现,应用程序中的redis连接配置文件中指定的ip地址还是原内网redis, 修改该ip为新的redis服务器地址,问题解决。

 

2、报错:(error) MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error.

原因:强制关闭Redis快照导致不能持久化。

解决方法:127.0.0.1:6379> config set stop-writes-on-bgsave-error no

 

3、主从复制不成功,从库报错:Opening the temp file needed for MASTER <-> SLAVE synchronization: Permission denied

原因:多半是因为从库上启动redis-server时不是root用户启动,而普通用户无法对redis目录进行写操作,导致无法在redis目录产生dump.rdb

解决方法:

1、从库上用root启动redis

2、更改redis目录为启动用户可写

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值