Maxscale--binlogserver 介紹和簡單部署手冊
一抹镊、Maxscale介紹
MariaDB MaxScale:號稱世界上最先進的數(shù)據(jù)庫代理,防火墻和查詢路由器
MariaDB MaxScale是MariaDB平臺的基本組件源武。它不僅為關鍵任務應用程序提供企業(yè)功能,包括自動故障轉移羞秤,數(shù)據(jù)屏蔽和拒絕服務保護控淡,而且還支持基于工作負載的查詢路由,以進行混合事務/分析處理忌警。擁有企業(yè)訂閱的所有客戶均可使用MariaDB MaxScale搁拙。
目前最新版本為2.4.2
我們用來搭建binlogserver,? 經(jīng)過maxscale 同步后的binlog? 與主庫完全保持一致法绵, 它的工作是只將主庫的binlog 拉去到本地箕速,對位點和內(nèi)容不做任何改變。
我們用到的是maxscale? 里的??Binlogrouter模塊朋譬。binlogrouter是MariaDB
MaxScale的復制協(xié)議代理模塊盐茎,此模塊允許 MaxScale連接到主服務器并檢索二進制日志,而從屬服務器可以連接到 MaxScale徙赢,就像它們連接到普通主服務器一樣字柠。
如果主服務器出現(xiàn)故障,則從服務器仍可以連接到 MaxScale并讀取二進制日志狡赐。您可以切換到新的主服務器募谎,而沒有從服務器通知實際的主服務器已更改。這允許在復制優(yōu)先級較高的情況下使用更高可用性的復制設置阴汇。
二、MaxScale安裝部署手冊
1节槐、下載 rpm 包搀庶, 報地址為:https://dlm.mariadb.com/758925/MaxScale/2.4.2/centos/7/x86_64/maxscale-2.4.2-1.centos.7.x86_64.rpm
rpm -ivhmaxscale-2.4.2-1.centos.7.x86_64.rpm安裝即可。
2铜异、修改配置文件哥倔, /etc/maxscale.cnf?
,? 我這邊配置從2臺數(shù)據(jù)庫主庫同步binlog日志,具體配置如下:
[maxscale]
threads=auto
[Replication1]
type=service
router=binlogrouter
user=maxscale
password=maxscale
server_id=3
binlogdir=/data/maxscale/binlogserver_1
mariadb10-compatibility=0
slave_hostname=master_slave
transaction_safety=on
heartbeat=30
send_slave_heartbeat=1
[Replication2]
type=service
router=binlogrouter
user=maxscale
password=maxscale
server_id=4
binlogdir=/data/maxscale/binlogserver_2
mariadb10-compatibility=0
slave_hostname=sso_slave
transaction_safety=on
heartbeat=30
send_slave_heartbeat=1
[Replication-Listener1]
type=listener
service=Replication1
protocol=MySQLClient
port=5308
[Replication-Listener2]
type=listener
service=Replication2
protocol=MySQLClient
port=5309
[MaxAdminService]
type=service
router=cli
[MaxAdminListener]
type=listener
service=MaxAdminService
protocol=maxscaled
socket=default
配置文件附件:
3揍庄、創(chuàng)建binlog 存儲目錄
mkdir /data/maxscale/binlogserver_1
mkdir /data/maxscale/binlogserver_2
創(chuàng)建主庫 1 的master.ini info信息咆蒿。
touch?/data/maxscale/binlogserver_1/master.ini
具體配置如下:
[binlog_configuration]
master_host=10.80.10.226
master_port=3306
master_user=repl
master_password=repl
master_heartbeat_period=300
master_connect_retry=60
filestem=mysql-bin
創(chuàng)建主庫 2 的master.ini info信息
touch?/data/maxscale/binlogserver_2/master.ini
具體配置如下:
[binlog_configuration]
master_host=10.80.10.224
master_port=3306
master_user=repl
master_password=repl
master_heartbeat_period=300
master_connect_retry=60
filestem=mysql-bin
修改目錄權限:
chown -R maxscale:maxscale /data/maxscale/
4、啟動maxscale
systemctl start maxscale
查看 /var/log/maxscale/maxscale.log? 日志, 確認啟動成功沃测, 但此時日志里可能會報錯缭黔,因為 我們還沒有設置同步主庫的位點信息,? 如果未設置蒂破,maxscale會從 mysql-bin.000001 開始同步馏谨。
5、登陸不同監(jiān)聽端口附迷,設置同步位點信息
?以master1 為例惧互, 其余類似。
輸入密碼后進入喇伯,maxscale 控制臺喊儡, 賬號密碼為/etc/maxscale.cnf 里的配置。
查看主庫的位點信息稻据, 然后在這里設置同步slave艾猜,
CHANGE MASTER TO MASTER_HOST='xxxx',MASTER_USER='master-user',MASTER_PASSWORD='master-pwd',MASTER_LOG_FILE='master_logfile', MASTER_LOG_POS=mater_pos,?MASTER_PORT=3306;
START SLAVE;
SHOW SALVE STATUS; 可以看到是否開始同步攀甚,
同時查看??/data/maxscale/binlogserver_1? 下的文件箩朴,可以看到, binlog文件已經(jīng)生成秋度,且和主庫完全保持一直炸庞。
至此binlog server 搭建完成, 其他的架構擴展荚斯,均與此安裝步驟類似埠居, 這里不再詳細介紹。