一、安装redis
1、检查是否有redis yum 源
yum install redis

2、下载fedora的epel仓库
yum install epel-release

3、安装redis数据库
yum install redis

4、安装完毕后,使用下面的命令启动redis服务

# 启动redis
service redis start
# 停止redis
service redis stop
# 查看redis运行状态
service redis status
# 查看redis进程
ps -ef | grep redis


5、设置redis为开机自动启动
chkconfig redis on

6、进入redis服务
# 进入本机redis
redis-cli
# 列出所有key
keys *
7、防火墙开放相应端口
# 开启6379
/sbin/iptables -I INPUT -p tcp --dport6379-j ACCEPT
# 开启6380
/sbin/iptables -I INPUT -p tcp --dport6380-j ACCEPT
# 保存
/etc/rc.d/init.d/iptables save
# centos 7下执行
service iptables save
二、修改redis默认端口和密码
1、打开配置文件
vi /etc/redis.conf
2、修改默认端口,查找 port 6379 修改为相应端口即可

3、修改默认密码,查找 requirepass foobared 将 foobared 修改为你的密码

4、使用配置文件启动 redis
redis-server /etc/redis.conf &

5、使用端口登录,输入redis密码
redis-cli -h127.0.0.1-p6379

6、停止redis
命令方式关闭redis
redis-cli -h127.0.0.1-p6379shutdown
进程号杀掉redis
ps -ef | grep redis
kill -9XXX
三、使用redis desktop manager远程连接redis
欢迎查看https://www.cnblogs.com/chengxs/p/9090819.html
1、如果长时间连接不上,可能有两种可能性
a)bind了127.0.01:只允许在本机连接redis
b)protected-mode设置了yes(使用redis desktop manager工具需要配置,其余不用)
# 打开redis配置文件
vi /etc/redis.conf
# 找到 bind 127.0.0.1 将其注释
# 找到 protected-mode yes 将其改为protected-mode no
2、重启redis
service redis stop
service redis start
3、展示

网友评论