91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MySQLmaster-master如何配置

發布時間:2021-09-16 15:51:05 來源:億速云 閱讀:139 作者:chen 欄目:數據庫

本篇內容介紹了“MySQLmaster-master如何配置”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!

  MySQLmaster-master怎么配置

  1、修改MySQL配置文件
  兩臺MySQL均如要開啟binlog日志功能,開啟方法:在MySQL配置文件[MySQLd]段中加上log-bin=MySQL-bin選項
  兩臺MySQL的server-ID不能一樣,默認情況下兩臺MySQL的serverID都是1,需將其中一臺修改為2即可
  2、將192.168.1.201設為192.168.1.202的主服務器
  在192.168.1.201上新建授權用戶
  MySQL>grantreplicationslaveon*.*to'replication'@'%'identifiedby'replication';QueryOK,0rowsaffected(0.00sec)MySQL>showmasterstatus;+------------------+----------+--------------+------------------+|File|Position|Binlog_Do_DB|Binlog_Ignore_DB|+------------------+----------+--------------+------------------+|MySQL-bin.000003|374|||+------------------+----------+--------------+------------------+1rowinset(0.00sec)
  在192.168.1.202上將192.168.1.201設為自己的主服務器
  MySQL>changemastertomaster_host='192.168.1.201',master_user='replication',master_password='replication',master_log_file='MySQL-bin.000003',master_log_pos=374;QueryOK,0rowsaffected(0.05sec)MySQL>startslave;QueryOK,0rowsaffected(0.00sec)MySQL>showslavestatus\G***************************1.row***************************Slave_IO_State:WaitingformastertosendeventMaster_Host:192.168.1.201Master_User:replicationMaster_Port:3306Connect_Retry:60Master_Log_File:MySQL-bin.000003Read_Master_Log_Pos:374Relay_Log_File:MySQL-master2-relay-bin.000002Relay_Log_Pos:235Relay_Master_Log_File:MySQL-bin.000003Slave_IO_Running:YesSlave_SQL_Running:YesReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno:0Last_Error:Skip_Counter:0Exec_Master_Log_Pos:374Relay_Log_Space:235Until_Condition:NoneUntil_Log_File:Until_Log_Pos:0Master_SSL_Allowed:NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master:01rowinset(0.00sec)
  3、將192.168.1.202設為192.168.1.201的主服務器
  在192.168.1.202上新建授權用戶
  MySQL>grantreplicationslaveon*.*to'replication'@'%'identifiedby'replication';QueryOK,0rowsaffected(0.00sec)MySQL>showmasterstatus;+------------------+----------+--------------+------------------+|File|Position|Binlog_Do_DB|Binlog_Ignore_DB|+------------------+----------+--------------+------------------+|MySQL-bin.000003|374|||+------------------+----------+--------------+------------------+1rowinset(0.00sec)
  在192.168.1.201上,將192.168.1.202設為自己的主服務器
  MySQL>changemastertomaster_host='192.168.1.202',master_user='replication',master_password='replication',master_log_file='MySQL-bin.000003',master_log_pos=374;QueryOK,0rowsaffected(0.05sec)MySQL>startslave;QueryOK,0rowsaffected(0.00sec)MySQL>showslavestatus\G***************************1.row***************************Slave_IO_State:WaitingformastertosendeventMaster_Host:192.168.1.202Master_User:replicationMaster_Port:3306Connect_Retry:60Master_Log_File:MySQL-bin.000003Read_Master_Log_Pos:374Relay_Log_File:MySQL-master1-relay-bin.000002Relay_Log_Pos:235Relay_Master_Log_File:MySQL-bin.000003Slave_IO_Running:YesSlave_SQL_Running:YesReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno:0Last_Error:Skip_Counter:0Exec_Master_Log_Pos:374Relay_Log_Space:235Until_Condition:NoneUntil_Log_File:Until_Log_Pos:0Master_SSL_Allowed:NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master:01rowinset(0.00sec)
  4、MySQL同步測試
  如上述均正確配置,現在任何一臺MySQL上更新數據都會同步到另一臺MySQL,MySQL同步在此不再演示。
  keepalived怎么安裝及配置
  1、192.168.1.201服務器上keepalived安裝及配置
  安裝keepalived
  #tarzxvfkeepalived-1.1.20.tar.gz#cdkeepalived-1.1.20#./configure--prefix=/usr/local/keepalived--with-kernel-dir=/usr/src/kernels/2.6.18-164.el5-i686#make&&makeinstall
  配置keepalived
  我們自己在新建一個配置文件,默認情況下keepalived啟動時會去/etc/keepalived目錄下找配置文件
  #mkdir/etc/keepalived#vi/etc/keepalived/keepalived.conf!ConfigurationFileforkeepalivedglobal_defs{notification_email{luwenju@live.cn}notification_email_fromluwenju@live.cnsmtp_server127.0.0.1smtp_connect_timeout30router_idMySQL-ha}vrrp_instanceVI_1{stateBACKUP#兩臺配置此處均是BACKUPinterfaceeth0virtual_router_id51priority100#優先級,另一臺改為90advert_int1nopreempt#不搶占,只在優先級高的機器上設置即可,優先級低的機器不設置authentication{auth_typePASSauth_pass1111}virtual_ipaddress{192.168.1.200}}virtual_server192.168.1.2003306{delay_loop2#每個2秒檢查一次real_server狀態lb_algowrr#LVS算法lb_kindDR#LVS模式persistence_timeout60#會話保持時間protocolTCPreal_server192.168.1.2013306{weight3notify_down/usr/local/MySQL/bin/MySQL.sh#檢測到服務down后執行的腳本TCP_CHECK{connect_timeout10#連接超時時間nb_get_retry3#重連次數delay_before_retry3#重連間隔時間connect_port3306#健康檢查端口}}
  編寫檢測服務down后所要執行的腳本
  #vi/usr/local/MySQL/bin/MySQL.sh#!/bin/shpkillkeepalived#chmod+x/usr/local/MySQL/bin/MySQL.sh
  注:此腳本是上面配置文件notify_down選項所用到的,keepalived使用notify_down選項來檢查real_server的服務狀態,當發現real_server服務故障時,便觸發此腳本;我們看到的是,腳本就一個命令,通過pkillkeepalived強制殺死keepalived進程,從而實現了MySQL故障自動轉移。另外,我們不用擔心兩個MySQL會同時提供數據更新操作,因為每臺MySQL上的keepalived的配置里面只有本機MySQL的IP+VIP,而不是兩臺MySQL的IP+VIP
  啟動keepalived
  #/usr/local/keepalived/sbin/keepalived–D#ps-aux|grepkeepalived
  測試
  找一臺局域網PC,然后去pingMySQL的VIP,這時候MySQL的VIP是可以ping的通的
  停止MySQL服務,看keepalived健康檢查程序是否會觸發我們編寫的腳本
  2、192.168.1.202上keepalived安裝及配置
  安裝keepalived
  #tarzxvfkeepalived-1.1.20.tar.gz#cdkeepalived-1.1.20#./configure--prefix=/usr/local/keepalived--with-kernel-dir=/usr/src/kernels/2.6.18-164.el5-i686#make&&makeinstall
  配置keepalived
  這臺配置和上面基本一樣,但有三個地方不同:優先級為90、無搶占設置、real_server為本機IP
  #mkdir/etc/keepalived#vi/etc/keepalived/keepalived.conf!ConfigurationFileforkeepalivedglobal_defs{notification_email{luwenju@live.cn}notification_email_fromluwenju@live.cnsmtp_server127.0.0.1smtp_connect_timeout30router_idMySQL-ha}vrrp_instanceVI_1{stateBACKUPinterfaceeth0virtual_router_id51priority90advert_int1authentication{auth_typePASSauth_pass1111}virtual_ipaddress{192.168.1.200}}virtual_server192.168.1.2003306{delay_loop2lb_algowrrlb_kindDRpersistence_timeout60protocolTCPreal_server192.168.1.2023306{weight3notify_down/usr/local/MySQL/bin/MySQL.shTCP_CHECK{connect_timeout10nb_get_retry3delay_before_retry3connect_port3306}}
  編寫檢測服務down后所要執行的腳本
  #vi/usr/local/MySQL/bin/MySQL.sh#!/bin/shpkillkeepalived#chmod+x/usr/local/MySQL/bin/MySQL.sh啟動keepalived#/usr/local/keepalived/sbin/keepalived–D#ps-aux|grepkeepalived
  測試
  停止MySQL服務,看keepalived健康檢查程序是否會觸發我們編寫的腳本
  三、測試
  MySQL遠程登錄測試
  我們找一臺安裝有MySQL客戶端的windows,然后登錄VIP,看是否能登錄,在登錄之兩臺MySQL服務器都要授權允許從遠程登錄
  MySQL>grantallprivilegeson*.*to'root'@'%'identifiedby'123456';QueryOK,0rowsaffected(0.00sec)MySQL>flushprivileges;QueryOK,0rowsaffected(0.00sec)
  使用客戶端登錄VIP測試
  C:\MySQL\bin>MySQL.exe-uroot-p123456-h292.168.1.200-P3306WelcometotheMySQLmonitor.Commandsendwith;or\g.YourMySQLconnectionidis224Serverversion:5.0.89-logSourcedistributionType'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.MySQL>
  ●keepalived故障轉移測試
  ※在windows客戶端一直去pingVIP,然后關閉192.168.1.201上的keepalived,正常情況下VIP就會切換到192.168.1.202上面去
  ※開啟192.168.1.201上的keepalived,關閉192.168.1.202上的keepalived,看是否能自動切換,正常情況下VIP又會屬于192.168.1.201
  注:keepalived切換速度還是非常塊的,整個切換過程只需1-3秒
  ●MySQL故障轉移測試
  ※在192.168.1.201上關閉MySQL服務,看VIP是否會切換到192.168.1.202上
  ※開啟192.168.1.201上的MySQL和keepalived,然后關閉192.168.1.202上的MySQL,看VIP是否會切換到192.168.1.201上
  下面是用windows客戶端連接的MySQL的VIP,在切換時我執行了一個MySQL查詢命令,從執行showdatabases到顯示出結果時間為3-5秒(大家看到的是上面有個錯誤提示,不過不用擔心,因為我們的keepalived切換大概為3秒左右,這3秒左右VIP是誰都不屬于的)
  MySQL>showdatabases;ERROR2006(HY000):MySQLserverhasgoneawayNoconnection.Tryingtoreconnect...Connectionid:592Currentdatabase:***NONE***+--------------------+|Database|+--------------------+|information_schema||MySQL||test|+--------------------+3rowsinset(9.01sec)

“MySQLmaster-master如何配置”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

滦南县| 山阴县| 焉耆| 芜湖市| 苍山县| 永新县| 涡阳县| 孟连| 耒阳市| 依兰县| 普兰县| 宝应县| 思南县| 涿州市| 闽侯县| 柳江县| 黎平县| 吴堡县| 房产| 阿尔山市| 宁城县| 北安市| 霍州市| 远安县| 永定县| 榆树市| 商洛市| 肇庆市| 青州市| 抚远县| 东乡族自治县| 太原市| 深水埗区| 芦山县| 车致| 诸城市| 望都县| 项城市| 建水县| 迁安市| 元氏县|