问题描述:
按照官网步骤,虚拟机里安装并启动memcached,
虚拟机里自己telnet11211端口可以连接,
使用Xmanager22端口可以连接到虚拟机,但是始终telnet不同11211端口
问题原因:请求被防火墙拦截
解决办法:关闭防火墙
关闭防火墙时遇到问题:
Failed to restart iptables.service: Unit iptables.service failed to load: No such file or directory.
解决办法:
防火墙配置后执行service iptables save 出现"Failed to restart iptables.service: Unit iptables.service failed to load: No such file or directory."错误,在CentOS 7或RHEL 7或Fedora中防火墙由firewalld来管理,当然你可以还原传统的管理方式。或则使用新的命令进行管理。
1,查看状态: /bin/systemctl status firewalld.service
2,启用: /bin/systemctl start firewalld.service
3,停用: /bin/systemctl stop firewalld.service
启用状态:
[root@vm-xiluhua][/install]# /bin/systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 六 -- :: CST; months days ago
Main PID: (firewalld)
CGroup: /system.slice/firewalld.service
└─ /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
停用状态:
[root@vm-xiluhua][/install]# /bin/systemctl stop firewalld.service [root@vm-xiluhua][/install]# /bin/systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since 六 -- :: CST; 9s ago
Main PID: (code=exited, status=/SUCCESS)
centos 7 防火墙和端口配置
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2.开启端口,修改防火墙配置文件
vi /etc/sysconfig/iptables 加入端口配置
-A RH-Firewall--INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A RH-Firewall--INPUT -m state --state NEW -m tcp -p tcp --dport :-j ACCEPT //开放3306到3690之间的端口 service iptables save
service iptables restart
iptables防火墙原理: http://blog.chinaunix.net/uid-20556798-id-273714.html