国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

Mysql服務(wù)添加 iptables防火墻策略的方案

瀏覽:6日期:2023-10-03 15:17:08

如果你的Mysql數(shù)據(jù)庫安裝在centos7的系統(tǒng)上,并且你的操作系統(tǒng)啟用了防火墻。應(yīng)用要訪問mysql數(shù)據(jù)庫,你有2個(gè)解決方案。

方案一:停止防火墻服務(wù)方案二:在防火墻中添加策略,讓應(yīng)用能正常訪問mysql服務(wù)端口

停止Centos7防火墻

查看防火墻運(yùn)行狀態(tài)

[root@mysql ~]# firewall-cmd --staterunning

停止防火墻服務(wù)

[root@mysql ~]# systemctl stop firewalld.service

啟動Centos7防火墻

查看防火墻運(yùn)行狀態(tài)

[root@mysql ~]# firewall-cmd --statenot running

啟動防火墻服務(wù)

[root@mysql ~]# systemctl start firewalld.service

配置防火墻開機(jī)啟動

[root@mysql ~]# systemctl enable firewalld.service訪問Mysql服務(wù)測試連接Mysql服務(wù)

[mysql@mysql ~]$ mysql -utony -ptony -h 192.168.112.131 -P 3306mysql: [Warning] Using a password on the command line interface can be insecure.ERROR 2003 (HY000): Can’t connect to MySQL server on ’192.168.112.131’ (113)主從復(fù)制連接測試[root@localhost] 15:23:46 [(none)]>show slave statusG;*************************** 1. row *************************** Slave_IO_State: Connecting to master Master_Host: 192.168.112.131 Master_User: repl Master_Port: 3306Connect_Retry: 60 Master_Log_File: binlog.000034 Read_Master_Log_Pos: 194 Relay_Log_File: mysql-relay-bin.000007Relay_Log_Pos: 401Relay_Master_Log_File: binlog.000034 Slave_IO_Running: Connecting Slave_SQL_Running: Yes .....Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 2003Last_IO_Error: error connecting to master ’repl@192.168.112.131:3306’ - retry-time: 60 retries: 1 Last_SQL_Errno: 0

主從的IO線程已斷開,并且報(bào)2003錯(cuò)誤,這里就確認(rèn)是網(wǎng)絡(luò)不通,訪問不了主庫的服務(wù)。

在防火墻中添加Mysql服務(wù)訪問策略

查看防火墻策略

[root@mysql ~]# iptables -L -n --line-number|grep 3306

由于在防火墻中沒有添加3306端口的訪問策略,外部應(yīng)用是無法mysql服務(wù)的。

[mysql@mysql ~]$ mysql -utony -ptony -h 192.168.112.131 -P 3306mysql: [Warning] Using a password on the command line interface can be insecure.ERROR 2003 (HY000): Can’t connect to MySQL server on ’192.168.112.131’ (113)

添加3306端口訪問策略

# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT[root@mysql ~]# iptables -L -n --line-number|grep 33061 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:3306

可以看到已經(jīng)添加了3306端口的訪問策略,外部應(yīng)用可以通過TCP協(xié)議訪問3306端口。

刪除防火墻策略

[root@mysql ~]# iptables -D INPUT 1[root@mysql ~]# iptables -L -n --line-number|grep 3306

到此這篇關(guān)于給Mysql服務(wù)添加 iptables防火墻策略的文章就介紹到這了,更多相關(guān)Mysql服務(wù)添加 iptables防火墻內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: MySQL 數(shù)據(jù)庫
相關(guān)文章:
主站蜘蛛池模板: 芜湖市| 临安市| 南江县| 多伦县| 电白县| 龙陵县| 金塔县| 正安县| 龙山县| 安龙县| 黑水县| 永福县| 交城县| 会宁县| 黑水县| 江阴市| 益阳市| 斗六市| 灵石县| 富阳市| 沭阳县| 淅川县| 彭州市| 安平县| 辽阳市| 三都| 江孜县| 昌图县| 什邡市| 孝义市| 涪陵区| 中西区| 思茅市| 巴彦县| 乳源| 日土县| 东乌| 太保市| 昭苏县| 灵寿县| 元江|