标签:emc 本地 cep firewalld ESS 成功 pre mariadb save
首先:centos 7 使用的防火墙为:firewall 不是iptables
查看已经开放的端口:此处我已经开启了mysql的端口
[root@Aserver ~]# firewall-cmd --list-ports
3306/tcp
开启端口: 提示success表示开启成功
[root@Aserver ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
命令的含义:
--zone # 表示作用域
--add-port=3306/tcp #添加端口,格式为:端口号/通讯协议
--permanent #永久生效,没有此参数重启后失效
需要重启防火墙:
firewall-cmd --reload #重启firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
查看监听(Listen)的端口
netstat -lntp
检查端口被哪个进程占用
netstat -lnp|grep 8080
重启防火墙后,需要在mysql中设置可以远程访问的账号
[root@Aserver ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]> create user ‘username‘@‘%‘ identified by ‘password‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all on *.* ‘username‘@‘%‘;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘‘zhengwei‘@‘%‘‘ at line 1
MariaDB [(none)]> grant all on *.* to ‘zhengwei‘@‘%‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
然后再本地测试连接是否成功!
如要开放80,22,8080 端口,输入以下命令即可
1、/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
2、/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
3、/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
然后保存:
/etc/rc.d/init.d/iptables save
查看打开的端口:
/etc/init.d/iptables status
关闭防火墙
1) 永久性生效,重启后不会复原
开启: chkconfig iptables on
关闭: chkconfig iptables off
2) 即时生效,重启后复原
开启: service iptables start
关闭: service iptables stop
标签:emc 本地 cep firewalld ESS 成功 pre mariadb save
原文地址:https://www.cnblogs.com/key-l731/p/9570559.html