centOS 7 安装redis

如果使用yum 安装的redis不会是最新版的redis

yum install redis
如果要安装最新的redis,则需要安装Remi的软件源,官网地址:http://rpms.famillecollet.com/
yum install -y http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
执行安装:

yum --enablerepo=remi install redis
启动redis服务
service redis start
或者
systemctl start redis

redis安装完毕后,我们来查看下redis安装时创建的相关文件,如下:

rpm -qa |grep redis


rpm -ql redis


查看redis版本:

redis-cli --version


设置为开机自动启动:
chkconfig redis on
或者
systemctl enable redis.service
redis开启远程登录连接,redis认只能localhost访问,所以需要开启远程登录解决方法如下:
在redis配置文件/etc/redis.conf中

将bind 127.0.0.1 改成了 bind 0.0.0.0

然后要配置防火墙 开放端口6379
[root@localhost ~]# firewall-cmd --query-port=6379/tcp
no

CentOS 7.0认使用的是firewall作为防火墙,使用iptables必须重新设置一下

1、直接关闭防火墙

systemctl stop firewalld.service        #停止firewall
systemctl disable firewalld.service     #禁止firewall开机启动

2、设置 iptables service
yum -y install iptables-services
如果要修改防火墙配置,如增加防火墙端口6379,编辑iptables

vim /etc/sysconfig/iptables

增加规则 (允许6379使用tcp协议连接)
- A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT
保存退出
systemctl restart iptables.service #重启防火墙使配置生效

systemctl enable iptables.service #设置防火墙开机启动

重启centOS

shutdown -r Now

服务器连接redis

redis-cli


客户端连接redis



相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native