日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

【DB宝40】MySQL高可用管理工具Orchestrator简介及测试

發布時間:2023/12/19 综合教程 28 生活家
生活随笔 收集整理的這篇文章主要介紹了 【DB宝40】MySQL高可用管理工具Orchestrator简介及测试 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

目錄一、Orchestrator簡介二、快速搭建Orchestrator環境三、添加主從環境四、修改集群別名五、拖動界面修改主從關系六、自動failover

一、Orchestrator簡介

Orchestrator是一款開源,對MySQL復制提供高可用、拓撲的可視化管理工具,采用go語言編寫,它能夠主動發現當前拓撲結構和主從復制狀態,支持MySQL主從復制拓撲關系的調整、支持MySQL主庫故障自動切換(failover)、手動主從切換(switchover)等功能。

Orchestrator后臺依賴于MySQL或者SQLite存儲元數據,能夠提供Web界面展示MySQL集群的拓撲關系及實例狀態,通過Web界面可更改MySQL實例的部分配置信息,同時也提供命令行和api接口,以便更加靈活的自動化運維管理。Orchestrator 對MySQL主庫的故障切換分為自動切換和手動切換。手動切換又分為recover、force-master-failover、force-master-takeover以及graceful-master-takeover。

相比于MHA,Orchestrator更加偏重于復制拓撲關系的管理,能夠實現MySQL任一復制拓撲關系的調整,并在此基礎上,實現MySQL高可用。另外,Orchestrator自身也可以部署多個節點,通過raft分布式一致性協議,保證自身的高可用。

Orchestrator主要有以下幾個特征:

自動監測數據庫復制的結構及其狀態
提供了GUI,CLI,API等接口來檢查復制拓撲的狀態以及做一些調整的操作
支持自動的master failover,當復制結構的server掛掉以后(不管手動還是自動的),能夠重新形成復制的拓撲結構
不依賴于特定的server版本或分支(MySQL, Percona Server, MariaDB or even MaxScale binlog servers)
支持多種類型的拓撲結構,不管是單個的主從還是成百上千個server組成的多級復制都不在話下
它的GUI不只是向你report拓撲狀態,還可以在Orchestrator web頁面通過拖拽或者刪除節點來改變復制拓撲(CLI和API也能做)

Orchestrator的GitHub地址:

https://github.com/openark/orchestrator

https://github.com/outbrain/orchestrator/wiki/Orchestrator-Manual

https://github.com/github/orchestrator/tree/master/docs

Orchestrator的所有參數:

https://github.com/github/orchestrator/blob/master/go/config/config.go

官方建議的生產配置示例:

https://github.com/github/orchestrator/blob/master/docs/configuration-sample.md

二、快速搭建Orchestrator環境

-- 拉取小麥苗的鏡像
docker pull registry.cn-hangzhou.aliyuncs.com/lhrbest/lhrorchestrator:1.0

-- 創建容器
docker run -d --name lhrorchestrator -h lhrorchestrator 
  -p 233:22 -p 3087:3389 -p 3000:3000 
  --privileged=true lhrbest/lhrorchestrator:1.0 
  /usr/sbin/init
  
  
-- 進入容器 
docker exec -it lhrorchestrator bash

-- 啟動后端存儲MySQL庫
systemctl status mysqld
MySQL用戶名和密碼:root/lhr

-- 啟動orchestrator
systemctl start orchestrator
systemctl status orchestrator


-- web訪問:
http://192.168.66.35:3000
用戶名和密碼:lhr/lhr

-- 日志:
tailf /var/log/messages

-- 參數文件
/usr/local/orchestrator/orchestrator.conf.json

web界面如下所示:

三、添加主從環境

把配置好的復制實例加入到orchestrator,因為orch可以自動發現整個拓撲的所有實例,所以只需要添加任意一臺實例即可。

這里,我有一套1主2從的環境,拓撲圖如下所示:

[root@docker35 log]# mysqlrplshow --master=root:lhr@172.72.0.2:3306 --discover-slaves-login=root:lhr --verbose
WARNING: Using a password on the command line interface can be insecure.
# master on 172.72.0.2: ... connected.
# Finding slaves for master: 172.72.0.2:3306

# Replication Topology Graph
172.72.0.2:3306 (MASTER)
   |
   +--- 172.72.0.3:3306 [IO: Yes, SQL: Yes] - (SLAVE)
   |
   +--- 172.72.0.4:3306 [IO: Yes, SQL: Yes] - (SLAVE)

下面開始把這套環境添加到orchestrator中:

添加成功。

我們再添加一套雙主雙從的環境:

選擇任意一臺MySQL服務器進行Discover操作,添加完成后,刷新頁面如下:

四、修改集群別名

修改完成后,刷新頁面:

注意:集群別名不支持中文。

五、拖動界面修改主從關系

手動修改主從關系:

六、自動failover

要實現自動failover,需要修改2個參數:

[root@lhrorchestrator orchestrator]# more orchestrator.conf.json | grep  ClusterFilters
  "RecoverMasterClusterFilters": ["*"],
  "RecoverIntermediateMasterClusterFilters": ["*"],

這2個參數表示定義哪些集群可以自動failover和recover。

自動failover之前:

宕掉主庫:

[root@lhrorchestrator /]# mysql -uroot -plhr -h172.72.0.2 -P3306
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 11357
Server version: 5.7.30-log MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> shutdown ;
Query OK, 0 rows affected (0.00 sec)

刷新頁面:

172.72.0.2自動被剔除,新主庫變為172.72.0.3。

172.72.0.4指向了新的主庫172.72.0.3。

172.72.0.2已宕機,邊框為黑色:

接下來啟動172.72.0.2,啟動完成后:

需要我們手動加入集群:

[root@docker35 log]#  mysql -uroot -plhr -h172.72.0.2 -P3306
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 13
Server version: 5.7.30-log MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> show slave hosts;
Empty set (0.00 sec)

mysql> show slave status;
Empty set (0.00 sec)

mysql> change master to
    -> master_host='172.72.0.3',
    -> master_port=3306,
    -> master_user='repl',
    -> master_password='lhr',
    -> master_auto_position=1;
show slave status G;
Query OK, 0 rows affected, 1 warning (0.02 sec)

mysql> 
mysql> start slave; 
Query OK, 0 rows affected (0.01 sec)

mysql> show slave status G;
*************************** 1. row ***************************
               Slave_IO_State: Checking master version
                  Master_Host: 172.72.0.3
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: 
          Read_Master_Log_Pos: 4
               Relay_Log_File: master-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: 
             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: 0
              Relay_Log_Space: 154
              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: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 0
                  Master_UUID: 
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: bacfcde8-69dc-11eb-b240-0242ac480002:1-70574,
bc6d26f0-69dc-11eb-bfa7-0242ac480003:1-5
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
1 row in set (0.00 sec)

ERROR: 
No query specified

mysql> 

刷新頁面:

可以看到,又回到了一主2從的環境。

About Me


● 本文作者:小麥苗,部分內容整理自網絡,若有侵權請聯系小麥苗刪除
● 本文在個人微 信公眾號(DB寶)上有同步更新
● QQ群號: 230161599 、618766405,微信群私聊
● 個人QQ號(646634621),微 信號(db_bao),注明添加緣由
● 于 2021年2月 在西安完成
● 最新修改時間:2021年2月
● 版權所有,歡迎分享本文,轉載請保留出處


●小麥苗的微店: https://weidian.com/?userid=793741433
●小麥苗出版的數據庫類叢書: http://blog.itpub.net/26736162/viewspace-2142121/
●小麥苗OCP、OCM、高可用、DBA學習班(Oracle、MySQL、NoSQL): http://blog.itpub.net/26736162/viewspace-2148098/
●數據庫筆試面試題庫及解答: https://mp.weixin.qq.com/s/Vm5PqNcDcITkOr9cQg6T7w


使用微信客戶端掃描下面的二維碼來關注小麥苗的微信公眾號(DB寶)及QQ群(DBA寶典)、添加小麥苗微信, 學習最實用的數據庫技術。


............................................................................................

● 小麥苗的微店:https://weidian.com/s/793741433?wfr=c&ifr=shopdetail

● 小麥苗出版的數據庫類叢書:http://blog.itpub.net/26736162/viewspace-2142121/

● 小麥苗OCP、OCM、高可用網絡班:http://blog.itpub.net/26736162/viewspace-2148098/

............................................................................................

使用微信客戶端掃描下面的二維碼來關注小麥苗的微信公眾號(DB寶),學習最實用的數據庫技術。

總結

以上是生活随笔為你收集整理的【DB宝40】MySQL高可用管理工具Orchestrator简介及测试的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。