1、 安装依赖包
yum install -y gcc tcl
2、 安装redis
tar -xzf redis-6.2.6.tar.gz
cd redis-6.2.6
make && make test && make install
默认的安装路径是在 /usr/local/bin目录下
3、 启动redis
cd /usr/local/bin && rediis-server redis.conf &
cd /usr/local/bin && redis-cli -h IP -p 6379
auth [password]
info
4、获取密码
config get requirepass
修改密码
config set requirepass
注:
1、make test报错You need tcl 8.5 or newer in order to run the Redis test
解决方法:
wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
tar xzvf tcl8.6.1-src.tar.gz -C /usr/local/
cd /usr/local/tcl8.6.1/unix/
./configure
make
make install
2、连接redis报错
DENIED Redis is running in protected mode because protected mode is enabled
解决方法:
• 用#号注释掉绑定ip
bind 127.0.0.1
• Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程,设置为no
daemonize no
• 保护模式,关闭保护模式,否则外部ip无法连接
protected-mode no
. /redis-server redis.conf