1、解压
[root@localhost software]# tar -zxvf redis-5.0.14.tar.gz
2、编译
[root@localhost software]# cd redis-5.0.14
[root@localhost redis-5.0.14]# make
[root@localhost redis-5.0.14]# make install
3、启动server验证
[root@localhost redis-5.0.14]# src/redis-server
[root@localhost redis-5.0.14]# src/redis-cli
127.0.0.1:6379> set foo 1
OK
127.0.0.1:6379> get foo
"1"
127.0.0.1:6379>
4、redis配置文件
4.1 配置后台启动:
4.2 配置远程访问:
(1)把 redis.conf配置文件中的 bind 127.0.0.1 这一行给注释掉,这里的bind指的是只有指定的网段才能远程访问这个redis,注释掉后,就没有这个限制了。
(2)把 redis.conf配置文件中的 protected-mode 设置成no(默认是设置成yes的, 防止了远程访问,在redis3.2.3版本后)
4.3 配置密码:
5、 配置文件启动:
[root@localhost redis-5.0.14]# src/redis-server redis.conf
[root@localhost redis-5.0.14]# src/redis-cli -a 123456
6、主机连接不上虚拟机的redis
6.1 开放端口
# 查询6379端口是否开放
firewall-cmd --query-port=6379/tcp
# 开放6379端口
firewall-cmd --permanent --add-port=6379/tcp
#重启防火墙(修改配置后要重启防火墙)
firewall-cmd --reload
# 查看防火墙规则
firewall-cmd --list-all
# 移除端口
firewall-cmd --permanent --remove-port=6379/tcp
6.2 关闭防火墙
systemctl stop firewalld,
systemctl disable firewalld ,需要重启系统。