Centos 7 systemctl和防火墙firewalld命令

Centos 7 systemctl和防火墙firewalld命令


今天自己在Hyper-v下搭建三台Linux服务器集群,用于学习ELKstack(即大数据日志解决技术栈Elasticsearch,Logstash,Kibana的简称),下载的Linux版本为centos 7系列,装完才知道相比于centos 6做了很大的改动,很多命令都不一样了,例如:系统服务都用systemctl命令来开启service,它是CentOS7的服务管理中主要的工具,融合了之前service和chkconfig的功能,据说,systemctl与以往启动系统服务使用/etc/init.d脚本的方式相比,大幅提高了系统服务的执行效率。由于在配置集群时,很多问题都是因为防火墙导致,需要经常配置,所以特别把防火墙的操作命令记录下来。

一、防火墙的开启、关闭、禁用命令

(1)设置开机启用防火墙:systemctl enable firewalld.service

(2)设置开机禁用防火墙:systemctl disable firewalld.service

(3)启动防火墙:systemctl start firewalld

(4)关闭防火墙:systemctl stop firewalld

(5)检查防火墙状态:systemctl status firewalld

(6) 重启后永久性生效:
  开启:chkconfig iptables on
  关闭:chkconfig iptables off

(7) 即时生效,重启后失效:
  开启:service iptables start
  关闭:service iptables stop

二、使用firewall-cmd配置端口

(1)查看防火墙状态:firewall-cmd --state

(2)重新加载配置:firewall-cmd --reload

(3)查看开放的端口:firewall-cmd --list-ports

(4)开启防火墙端口:firewall-cmd --zone=public --add-port=9200/tcp --permanent

命令含义:

–zone #作用域

–add-port=9200/tcp #添加端口,格式为:端口/通讯协议

–permanent #永久生效,没有此参数重启后失效

注意:添加端口后,必须用命令firewall-cmd --reload重新加载一遍才会生效

(5)关闭防火墙端口:firewall-cmd --zone=public --remove-port=9200/tcp --permanent

启动redis服务:./redis-server /usr/local/softs/redis-4.0.6/redis.conf

MQ启动顺序:启动顺序要先启动nameserver,再启动broker,启动broker时加上autoCreateTopicEnable=true
例如 nohup sh mqbroker -n localhost:9876 autoCreateTopicEnable=true &

猜你喜欢

转载自blog.csdn.net/weixin_39248420/article/details/88788106