centos出现“FirewallD is not running”怎么办

本文涉及的产品
云防火墙,500元 1000GB
简介: centos出现“FirewallD is not running”怎么办

centos出现“FirewallD is not running”怎么办


最近在阿里云服务器centos上安装了mysql数据库,默认是不开启远端访问功能,需要设置一下防火墙,在开放默认端口号 3306时提示FirewallD is not running,经过排查发现是防火墙就没打开造成的,出于安装考虑还是把防火墙开上吧,以下步骤仅供参考啦。


先说下systemctl命令


https://www.cnblogs.com/zwcry/p/9602756.html

https://blog.csdn.net/skh2015java/article/details/94012643


Linux 服务管理两种方式service和systemctl


systemd是Linux系统最新的初始化系统(init),作用是提高系统的启动速度,尽可能启动较少的进程,尽可能更多进程并发启动。


systemd对应的进程管理命令是systemctl


1. systemctl命令兼容了service

即systemctl也会去/etc/init.d目录下,查看,执行相关程序

systemctl redis start
systemctl redis stop
# 开机自启动
systemctl enable redis
2.systemctl命令管理systemd的资源Unit


systemd的Unit放在目录/usr/lib/systemd/system(Centos)或/etc/systemd/system(Ubuntu)


主要有四种类型文件.mount,.service,.target,.wants

.mount文件


.mount文件定义了一个挂载点,[Mount]节点里配置了What,Where,Type三个数据项

等同于以下命令:

mount -t hugetlbfs /dev/hugepages hugetlbfs

.service文件

.service文件定义了一个服务,分为[Unit],[Service],[Install]三个小节

[Unit]

Description:描述,
After:在network.target,auditd.service启动后才启动
ConditionPathExists: 执行条件

[Service]

EnvironmentFile:变量所在文件
ExecStart: 执行启动脚本
Restart: fail时重启

[Install]

Alias:服务别名
WangtedBy: 多用户模式下需要的

.target文件


.target定义了一些基础的组件,供.service文件调用
.wants文件
.wants文件定义了要执行的文件集合,每次执行,.wants文件夹里面的文件都会执行

方法/步骤

  1. 执行firewall-cmd --permanent --zone=public --add-port=3306/tcp,提示FirewallD is not running,如下图所示。


  1. 通过systemctl status firewalld查看firewalld状态,发现当前是dead状态,即防火墙未开启。


  1. 通过systemctl start firewalld开启防火墙,没有任何提示即开启成功。


  1. 再次通过systemctl status firewalld查看firewalld状态,显示running即已开启了。


  1. 如果要关闭防火墙设置,可能通过systemctl stop firewalld这条指令来关闭该功能。

  2. 再次执行执行firewall-cmd --permanent --zone=public --add-port=3306/tcp,提示success,表示设置成功,这样就可以继续后面的设置了。

    END


相关文章
|
Linux 网络安全 数据库
CentOS7开启Firewalld防火墙日志记录获取被拦截的IP
CentOS7开启Firewalld防火墙日志记录获取被拦截的IP
1733 0
CentOS7开启Firewalld防火墙日志记录获取被拦截的IP
|
4月前
|
XML 安全 Linux
【Linux】深入探究CentOS防火墙(Firewalld):基础概念、常用命令及实例操作
【Linux】深入探究CentOS防火墙(Firewalld):基础概念、常用命令及实例操作
|
11月前
|
网络协议 Linux 网络安全
【Linux环境】centos出现“FirewallD is not running”怎么办,如何解决
【Linux环境】centos出现“FirewallD is not running”怎么办,如何解决
438 0
|
4月前
|
运维 Linux 应用服务中间件
Centos7如何配置firewalld防火墙规则
Centos7如何配置firewalld防火墙规则
133 0
|
4月前
|
Linux 网络安全
CentOS7下操作iptables防火墙和firewalld防火墙
CentOS7下操作iptables防火墙和firewalld防火墙
351 3
|
Linux 网络安全
iptables防火墙限制 centos中有 firewalld selinux 还有 iptables
iptables防火墙限制 centos中有 firewalld selinux 还有 iptables
112 0
iptables防火墙限制 centos中有 firewalld selinux 还有 iptables
|
Linux 网络安全 数据安全/隐私保护
CentOS7下如何利用Firewalld防火墙实现IP+Port细粒度访问控制
CentOS7下如何利用Firewalld防火墙实现IP+Port细粒度访问控制
453 0
CentOS7下如何利用Firewalld防火墙实现IP+Port细粒度访问控制
|
运维 Linux 网络安全
Centos 运维之防火墙篇——②firewalld
防火墙 一般来说,iptables和firewalld启用一个即可
228 0
|
网络协议 Linux 网络安全
Centos Firewalld防火墙使用
Centos Firewalld防火墙使用