MySQL主从数据库配置
?公司有未知臺服務器,以后都要自己來接管。MySQL主從是必需要會的技術,所以加強學習一下以圖以后安穩日子啊!
主服務器(master): 192.168.30.204,用yum安裝的MySQL.(內有多個庫)
從服務器(slave) : 192.168.30.3, ?用yum安裝的MySQL(新安裝)
配置的主要流程是:
主服務器(master):?
數據庫的設置
?
從服務器(slave):
新安裝MySQL之后設置root用戶密碼,并導入主服務器中的數據
| ?mysql -uroot -p < all.sql? |
最后,分別在主服務器和從服務上開啟服務:
最后的檢查驗證:
?
mysql> show slave status\G
*************************** 1. row ***************************
? ? ? ? ? ? ? ?Slave_IO_State: Waiting for master to send event
? ? ? ? ? ? ? ? ? Master_Host: 192.168.30.204
? ? ? ? ? ? ? ? ? Master_User: root
? ? ? ? ? ? ? ? ? Master_Port: 3306
? ? ? ? ? ? ? ? Connect_Retry: 60
? ? ? ? ? ? ? Master_Log_File: mysql-bin.000002
? ? ? ? ? Read_Master_Log_Pos: 3268381
? ? ? ? ? ? ? ?Relay_Log_File: mysqld-relay-bin.000005
? ? ? ? ? ? ? ? Relay_Log_Pos: 3268526
? ? ? ? Relay_Master_Log_File: mysql-bin.000002
? ? ? ? ? ? ?Slave_IO_Running: Yes
? ? ? ? ? ? Slave_SQL_Running: Yes
? ? ? ? ? ? ? Replicate_Do_DB:?
? ? ? ? ? Replicate_Ignore_DB:?
? ? ? ? ? ?Replicate_Do_Table:?
? ? ? ?Replicate_Ignore_Table:?
? ? ? Replicate_Wild_Do_Table:?
? Replicate_Wild_Ignore_Table:?
? ? ? ? ? ? ? ? ? ?Last_Errno: 0
? ? ? ? ? ? ? ? ? ?Last_Error:?
? ? ? ? ? ? ? ? ?Skip_Counter: 0
? ? ? ? ? Exec_Master_Log_Pos: 3268381
? ? ? ? ? ? ? Relay_Log_Space: 3268827
? ? ? ? ? ? ? Until_Condition: None
? ? ? ? ? ? ? ?Until_Log_File:?
? ? ? ? ? ? ? ? Until_Log_Pos: 0
? ? ? ? ? ?Master_SSL_Allowed: No
? ? ? ? ? ?Master_SSL_CA_File:?
? ? ? ? ? ?Master_SSL_CA_Path:?
? ? ? ? ? ? ? Master_SSL_Cert:?
? ? ? ? ? ? Master_SSL_Cipher:?
? ? ? ? ? ? ? ?Master_SSL_Key:?
? ? ? ? Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
? ? ? ? ? ? ? ? Last_IO_Errno: 0
? ? ? ? ? ? ? ? Last_IO_Error:?
? ? ? ? ? ? ? ?Last_SQL_Errno: 0
? ? ? ? ? ? ? ?Last_SQL_Error:?
1 row in set (0.09 sec)
?
mysql>?
?
有高亮顏色字體的語句結果表明主從服務正常開啟并運行了。
在主服務器上新增一個表,再到從服務器上查看是否有這個新增的表就可驗證主從服務器是否正常了。
?
?
?
?
轉載于:https://blog.51cto.com/fengzhige/1029755
總結
以上是生活随笔為你收集整理的MySQL主从数据库配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux的搜索和时间
- 下一篇: 梦到手机断了三截是什么意思