博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

今天在学些redis的时候碰到个问题,发现主机Redis Destop Manager不能访问虚拟机Redis server的解决方案,找了一些网上的资料,原因可能有两个,整理记录下来:

1. Redis.conf文件中打开了

# By default Redis listens for connections from all the network interfaces
# available on the server. It is possible to listen to just one or multiple
# interfaces using the "bind" configuration directive, followed by one or
# more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 
#如果上面这一行打开了,请关闭它。

 

2. 如果发现配置文件里面的bind没有打开,请尝试下面的步骤:

centos默认使用firewalld来管理netfilter子系统,不过底层调用的命令仍然是iptables等,所以先关掉firewalld:

systemctl stop firewalld

#屏蔽(让它不能启动)或显示该服务 systemctl mask firewalld

然后安装iptables服务包:

yum install iptables-services

让服务在系统启动的时候启动:

systemctl enable iptables

下面是iptables的命令example:

systemctl [stop|start|restart] iptables

保存防火墙的规则:

service iptables save

or

/usr/libexec/iptables/iptables.init save

试一下看是不是你的Redis Destop Manager是不是可以连接到虚拟机的Redis server了。