CentOS安装Redis

1
2
3
4
5
6

//如果没有yum源
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum install -y http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum install redis

启动

1
2
3
service redis start 
or
nohup redis-server > /dev/null 2>&1 &

客户端

1
redis-cli

配置文件

1
/etc/redis.conf

修改为允许远程连接

1
2
bind ip注释掉
protected-mode no

打开防火墙端口,

1
2
3
vim /etc/sysconfig/iptables
追加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT

重启防火墙,重启redis

1
2
service iptables restart
service redis restart

如果发现redis没有重启,

1
ps -ef | grep redis

找到,kill, start

远程测试

1
redis-cli -h 192.168.2.22

Ryan Miao wechat
关注我的公众账号,接收最新文章
Donate
0%