centos7.2 x86_64 最小化安裝。3臺vm 時間同步,關(guān)閉iptables,selinux.,firewalld。3臺rpm包安裝MariaDB10.5.1 .172.16.0.130機(jī)器單獨安裝 maxscale-2.3.7
創(chuàng)新互聯(lián)建站一直在為企業(yè)提供服務(wù),多年的磨煉,使我們在創(chuàng)意設(shè)計,網(wǎng)絡(luò)營銷推廣到技術(shù)研發(fā)擁有了開發(fā)經(jīng)驗。我們擅長傾聽企業(yè)需求,挖掘用戶對產(chǎn)品需求服務(wù)價值,為企業(yè)制作有用的創(chuàng)意設(shè)計體驗。核心團(tuán)隊擁有超過10年以上行業(yè)經(jīng)驗,涵蓋創(chuàng)意,策化,開發(fā)等專業(yè)領(lǐng)域,公司涉及領(lǐng)域有基礎(chǔ)互聯(lián)網(wǎng)服務(wù)綿陽電信機(jī)房、成都app開發(fā)、手機(jī)移動建站、網(wǎng)頁設(shè)計、網(wǎng)絡(luò)整合營銷。
172.16.0.130 master maxscale
172.16.0.131 slave1
172.16.0.132 slave2
如何配置MariaDB MaxScale,并介紹了一些可能的使用方案。 MariaDB MaxScale在設(shè)計時考慮了靈活性,它由事件處理核心和各種支持功能以及可定制程序行為的插件模塊組成
MariaDB MaxScale是一種數(shù)據(jù)庫代理,可擴(kuò)展MariaDB Server的高可用性,可伸縮性和安全性,同時通過將其與基礎(chǔ)數(shù)據(jù)庫基礎(chǔ)架構(gòu)分離來簡化應(yīng)用程序開發(fā)。
MariaDB MaxScale采用可擴(kuò)展的體系結(jié)構(gòu)進(jìn)行工程設(shè)計,以支持插件,從而將其功能擴(kuò)展到透明負(fù)載平衡之外,從而成為例如數(shù)據(jù)庫防火墻。
借助用于多個路由器,過濾器和協(xié)議的內(nèi)置插件,可以將MariaDB MaxScale配置為轉(zhuǎn)發(fā)數(shù)據(jù)庫請求并根據(jù)業(yè)務(wù)和技術(shù)要求修改數(shù)據(jù)庫響應(yīng),例如,以屏蔽敏感數(shù)據(jù)或擴(kuò)展讀取
MariaDB MaxScale是一種數(shù)據(jù)庫代理,可將數(shù)據(jù)庫語句轉(zhuǎn)發(fā)到一個或多個數(shù)據(jù)庫服務(wù)器。
使用基于數(shù)據(jù)庫語句的語義理解以及數(shù)據(jù)庫后端集群中服務(wù)器的角色的規(guī)則執(zhí)行轉(zhuǎn)發(fā)。
MariaDB MaxScale旨在向應(yīng)用程序透明地提供負(fù)載平衡和高可用功能。
MariaDB MaxScale具有可擴(kuò)展且靈活的體系結(jié)構(gòu),其插件組件可支持不同的協(xié)議和路由方法
MariaDB MaxScale充分利用了Linux操作系統(tǒng)的異步I / O功能以及固定數(shù)量的工作線程。
epoll用于為通過套接字的輸入和輸出提供事件驅(qū)動的框架。
MariaDB MaxScale提供的許多服務(wù)都實現(xiàn)為在運(yùn)行時加載的外部共享對象模塊。
這些模塊支持固定接口,并通過由一組功能指針組成的結(jié)構(gòu)傳遞入口點。該結(jié)構(gòu)稱為“模塊對象”。可以創(chuàng)建其他模塊以與MariaDB MaxScale一起使用。
常用的模塊類型是協(xié)議,路由器和過濾器。協(xié)議模塊實現(xiàn)了客戶端與MariaDB MaxScale之間以及MariaDB MaxScale與后端服務(wù)器之間的通信。
路由器檢查來自客戶端的查詢并確定目標(biāo)后端。這些決定通?;诼酚梢?guī)則和后端服務(wù)器狀態(tài)。
過濾器對通過MariaDB MaxScale傳遞的數(shù)據(jù)進(jìn)行處理。
篩選器通常用于記錄查詢或修改服務(wù)器響應(yīng)。
支持源碼包編譯安裝,支持rpm包安裝,也支持二進(jìn)制tar包安裝
官方安裝文檔:
提問地址:
https://github.com/mariadb-corporation/MaxScale/tree/2.3/Documentation
反饋bug地址:
https://jira.mariadb.org/browse/MXS
本演示環(huán)境安裝的是maxscale 是2.3.7 ,下面是官方的安裝文檔介紹
https://mariadb.com/kb/en/mariadb-maxscale-23-mariadb-maxscale-installation-guide/
本博文采用的是rpm包安裝,最簡單
yum install libaio.x86_64 libaio-devel.x86_64 novacom-server.x86_64 libedit -y
wget https://downloads.mariadb.com/MaxScale/centos/7/x86_64/maxscale-2.3.7-1.centos.7.x86_64.rpm
rpm -ivh maxscale-2.3.7-1.centos.7.x86_64.rpm
關(guān)閉和啟動命令:
service maxscale status|start|stop|restart
systemctl enable maxscale
systemctl status|start|stop maxscale
maxadmin shutdown maxscale
maxscale 管理賬戶登錄: 默認(rèn)賬戶:admin
[root@mgr01 ~]# maxadmin -h227.0.0.1 -P6603 -uadmin -p'mariadb'
默認(rèn)配置文件在/etc/maxscale.cnf
官方模塊參數(shù)介紹地址:
https://mariadb.com/kb/en/mariadb-maxscale-23-contents/#routers
配置文件參數(shù)介紹:
https://mariadb.com/kb/en/mariadb-maxscale-23-mariadb-maxscale-configuration-usage-scenarios/
在名為[MaxScale]的部分中的全局設(shè)置允許調(diào)整影響整個MariaDB MaxScale的各種參數(shù)。此部分必須在默認(rèn)為/etc/maxscale.cnf的根配置文件中定義
參數(shù):threads 介紹:threads=[
將工作線程數(shù)量增加到超過處理器內(nèi)核數(shù)量并不會提高性能,反而可能降低性能,并且可能不必要地消耗資源。
演示成功的配置文件內(nèi)容:
[root@mgr03 ~]# cat /etc/maxscale.cnf
#https://mariadb.com/kb/en/mariadb-maxscale-23-mariadb-maxscale-configuration-usage-scenarios/
[maxscale]
#threads=auto
threads=1
log_info=1
logdir=/tmp/
auth_read_timeout=10
#提取用戶身份驗證數(shù)據(jù)時,MySQL與后端數(shù)據(jù)庫的連接的讀取超時(以秒為單位)。增加此參數(shù)的值將導(dǎo)致在主動獲取用戶數(shù)據(jù)時,MariaDB MaxScale等待更長的時間來等待來自后端服務(wù)器的響應(yīng)。如果身份驗證失敗,并且您有大量的數(shù)據(jù)庫用戶和授權(quán),或者與后端服務(wù)器的連接速度很慢,則增加此值是個好主意。默認(rèn)為1秒.
auth_write_timeout=10
#提取用戶身份驗證數(shù)據(jù)時,MySQL與后端數(shù)據(jù)庫的連接的寫入超時(以秒為單位),當(dāng)前,MariaDB MaxScale不會在后端服務(wù)器中寫入或修改數(shù)據(jù)。默認(rèn)值為2秒。官方建議10s
query_retries=1
#被重試的內(nèi)部查詢的次數(shù)。默認(rèn)值為重試一次.中斷查詢是指任何因網(wǎng)絡(luò)錯誤而中斷的查詢。連接超時包括在網(wǎng)絡(luò)錯誤中,因此建議確保將query_retry_timeout的值設(shè)置為適當(dāng)?shù)闹怠?.3.0之后默認(rèn)開啟
query_retry_timeout=5
##任何重試查詢的總超時時間(以秒為單位)。默認(rèn)值為5秒,
ms_timestamp=1
# ms_timestamp=<0|1>。
# 在日志文件中啟用或禁用高精度時間戳。啟用此選項可以為所有日志文件時間戳增加毫秒精度。
skip_permission_checks=false
#默認(rèn)是false.
#當(dāng)您知道權(quán)限確定并且想要加快啟動過程時,此功能很有用。此參數(shù)為布爾值,默認(rèn)情況下處于禁用狀態(tài)
#建議不要禁用權(quán)限檢查,以便在啟動maxscale時檢測到任何缺少的特權(quán)。如果由于在檢查權(quán)限時發(fā)生大量連接超時而導(dǎo)致MaxScale啟動緩慢,則禁用權(quán)限檢查可以加快啟動過程。
syslog=1
# syslog=<0|1>.
#啟用或禁用將消息記錄到syslog。默認(rèn)情況下,啟用到syslog的日志記錄
maxlog=1
# 啟用以禁用將消息記錄到MariaDB MaxScale的日志文件中. 默認(rèn)情況下,啟用對maxlog的日志記錄。
# 要啟用到MariaDB MaxScale日志文件的日志記錄,請使用值1,而禁用則使用值0。
log_warning=1
# log_warning=<0|1>,
# 啟用或禁用系統(tǒng)日志優(yōu)先級為警告的消息的日志記錄。默認(rèn)情況下,啟用此優(yōu)先級的消息.
log_notice=1
#啟用或禁用系統(tǒng)日志優(yōu)先級為notice的消息的日志記錄。此優(yōu)先級的消息提供有關(guān)MariaDB MaxScale的功能的信息,并且默認(rèn)情況下處于啟用狀態(tài)。
##要禁用這些消息,請使用值0,而要啟用它們,請使用值1
log_debug=0
[server1]
type=server
address=172.16.0.131
port=3306
#protocol=MySQLBackend
protocol=MariaDBBackend
#server_weight=1
serversize=1
[server2]
type=server
address=172.16.0.132
port=3306
#protocol=MySQLBackend
protocol=MariaDBBackend
#server_weight=1
serversize=1
[server3]
type=server
address=172.16.0.130
port=3306
#protocol=MySQLBackend
protocol=MariaDBBackend
#server_weight=1
serversize=1
# https://mariadb.com/kb/en/mariadb-maxscale-23-mariadb-monitor/
[MySQL Monitor]
type=monitor
module=mariadbmon
servers=server1,server2,server3
user=maxmonuser
password=maxmonpwd
monitor_interval=10000
##monitor_interval=10000 #探測間隔,單位毫秒,默認(rèn)2000
auto_failover=true
#是否故障自動切換
auto_rejoin=true
#故障實例恢復(fù)后自動加入集群
detect_standalone_master=true
#探測獨立的master,是否允許集群中最后一個實例成為主庫
#switchover_on_low_disk_space=true
##為了使此參數(shù)生效,必須為服務(wù)器或監(jiān)視器指定disk_space_threshold。另外,必須為監(jiān)視器定義disk_space_check_interval
#allow_cluster_recovery=true
failcount=3
#在集群中最后一個實例成為主庫前檢查其它從庫是否存活的次數(shù),默認(rèn)為5
detect_stale_master=true
#此參數(shù)從2.0版本開始默認(rèn)就是開啟的,即使復(fù)制停止或配置錯誤,也允許先前的主服務(wù)器可用。所有從屬服務(wù)器均不可訪問或復(fù)制由于某種原因而中斷,master依然可以繼續(xù)提供服務(wù)。
detect_stale_slave=true
#此參數(shù)默認(rèn)是開啟的,將沒有主服務(wù)器的正在運(yùn)行的從服務(wù)器視為有效的從服務(wù)器。slave丟失master時,slave仍可用于讀取。
failover_timeout=90
#此參數(shù)默認(rèn)是90s,如果在配置的時間段內(nèi)未成功進(jìn)行故障轉(zhuǎn)移/切換,則會記錄一條消息,并禁用自動故障轉(zhuǎn)移。這樣可以防止對行為異常的群集進(jìn)行進(jìn)一步的自動修改.
verify_master_failure=true
master_failure_timeout=10
#啟用其他主服務(wù)器故障驗證以進(jìn)行自動故障轉(zhuǎn)移.verify_master_failure默認(rèn)開啟,是布爾值,master_failure_timeout默認(rèn)是10.
script=/tmp/reset_slave.sh
events=master_down
#檢查到master掛掉的話,執(zhí)行上面的腳本/tmp/reset_slave.sh
# https://mariadb.com/kb/en/mariadb-maxscale-23-readconnroute/
[Read-Only-Service]
type=service
router=readconnroute
servers=server1,server2,server3
user=maxuser
password=maxpwd
router_options=slave
#router_options=master,slave
#weightby=server_weight
# ReadWriteSplit documentation:
# https://mariadb.com/kb/en/mariadb-maxscale-23-readwritesplit/
[Read-Write-Service]
type=service
router=readwritesplit
servers=server1,server2,server3
user=maxuser
password=maxpwd
#max_slave_connections=100%
max_slave_connections=2
#設(shè)置路由器會話隨時使用的最大從站數(shù)量。默認(rèn)值是每個客戶端連接最多使用255個從屬連接。在舊版本中,默認(rèn)設(shè)置是不加限制地使用所有可用的從站。
# 例如,如果您為MaxScale配置了一個主機(jī)和三個從機(jī),并設(shè)置max_slave_connections = 2,則對于每個客戶端連接,將打開到主機(jī)的連接和兩個從機(jī)連接。然后,在這兩個從屬服務(wù)器之間完成讀查詢負(fù)載平衡,并將寫操作發(fā)送到主服務(wù)器.
max_slave_replication_lag=4
#指定從站被允許落后于主站多少秒。如果滯后時間大于配置的值,則不能使用從站進(jìn)行路由.
master_accept_reads=true
#默認(rèn)讀是不被路由到master的。允許將主服務(wù)器用于讀取。如果您使用的服務(wù)器數(shù)量較少,并且希望也使用主服務(wù)器進(jìn)行讀取,則啟用此選項非常有用
#weightby=server_weight
# This service enables the use of the MaxAdmin interface
# MaxScale administration guide:
# https://mariadb.com/kb/en/mariadb-maxscale-23-maxadmin-admin-interface/
[MaxAdmin-Service]
type=service
router=cli
[Read-Only-Listener]
type=listener
service=Read-Only-Service
#protocol=MySQLClient
protocol=MariaDBClient
port=4008
[Read-Write-Listener]
type=listener
service=Read-Write-Service
#protocol=MySQLClient
protocol=MariaDBClient
port=4006
[MaxAdmin-Listener]
type=listener
service=MaxAdmin-Service
protocol=maxscaled
#socket=default
port=6603
注意:在配置主從復(fù)制時,maxscale監(jiān)控集群不識別主機(jī)名,只識別ip地址所以在 CHANGE MASTER TO MASTER_HOST='172.16.0.130',MASTER_PORT=3306,MASTER_USER='repuser',MASTER_PASSWORD='JuwoSdk21TbUser',master_use_gtid=slave_pos;start slave;show slave status\G 時,記得MASTER_HOST必須填寫ip地址,
否則會導(dǎo)致監(jiān)控主從復(fù)制集群失敗。
例如slave上:
CHANGE MASTER TO MASTER_HOST='mgr01',MASTER_PORT=3306,MASTER_USER='repuser',MASTER_PASSWORD='JuwoSdk21TbUser',master_use_gtid=slave_pos;start slave;show slave status\G
[root@mgr01 ~]# maxadmin -h227.0.0.1 -P6603 -uadmin -p'mariadb'
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
server1 | 172.16.0.131 | 3306 | 0 | Master, Slave of External Server, Running
server2 | 172.16.0.132 | 3306 | 0 | Slave of External Server, Running
server3 | 172.16.0.130 | 3306 | 0 | Slave, Running
-------------------+-----------------+-------+-------------+--------------------
Master, Slave of External Server, Running 像這樣的代表監(jiān)控主從復(fù)制集群關(guān)系失敗。
Slave of External Server, Running
例如slave上:
CHANGE MASTER TO MASTER_HOST='172.16.0.130',MASTER_PORT=3306,MASTER_USER='repuser',MASTER_PASSWORD='JuwoSdk21TbUser',master_use_gtid=slave_pos;start slave;show slave status\G
[root@mgr01 ~]# maxadmin -h227.0.0.1 -P6603 -uadmin -p'mariadb'
MaxScale> list servers
Servers.
-------------------+-----------------+-------+-------------+--------------------
Server | Address | Port | Connections | Status
-------------------+-----------------+-------+-------------+--------------------
server1 | 172.16.0.131 | 3306 | 0 | Slave, Running
server2 | 172.16.0.132 | 3306 | 0 | Slave, Running
server3 | 172.16.0.130 | 3306 | 0 | Master, Running
-------------------+-----------------+-------+-------------+--------------------
以上status代表正常
1.監(jiān)控后端mysql服務(wù)的狀態(tài)
2.復(fù)制集群操作(failover,switchover,rejoin,reset-replication)
要求監(jiān)視用戶具有以下特權(quán):
create user 'maxmonuser'@'%' identified by 'maxmonpwd';
grant super, REPLICATION SLAVE,replication client, reload, process, show databases,event on *.* to 'maxmonuser'@'%';
權(quán)限作用介紹:
SUPER, to modify slave connections and set globals such as read_only
REPLICATION CLIENT, to list slave connections
RELOAD, to flush binary logs
PROCESS, to check if the event_scheduler process is running
SHOW DATABASES and EVENT, to list and modify server events
授權(quán)注意事項:
grant super, replication client, reload, process, show databases,event on *.* to 'maxmonuser'@'172.16.0.%';
MariaDB不支持上述方式的授權(quán),只能采用下面方法授權(quán)。
grant super, replication client, reload, process, show databases,event on *.* to 'maxmonuser'@'%';
創(chuàng)建讀寫分離操作后端mysql服務(wù)的賬戶:
create user 'maxuser'@'172.16.0.%' identified by 'maxpwd';
grant SELECT on mysql.* to 'maxuser'@'172.16.0.%';
GRANT SHOW DATABASES,super ON *.* TO 'maxuser'@'172.16.0.%';
select user,host from mysql.user;
創(chuàng)建測試用戶:
grant all on *.* to 'maxscale'@'172.16.0.%' identified by 'maxscalepass'; flush privileges;
或者
grant all on *.* to 'maxscale'@'%' identified by 'maxscalepass'; flush privileges;
通過maxscale機(jī)器ip 和maxscale.cnf配置文件中指定的4006端口來登錄進(jìn)行讀寫庫
mysql -umaxscale -p'maxscalepass' -h 172.16.0.130 -P4006
讀寫分離配置:
https://mariadb.com/kb/en/mariadb-maxscale-23-readwritesplit/#readwritesplit
讀寫分割路由決策:
下面的動作會被路由到master上:
write statements,
all statements within an open transaction,
stored procedure calls
user-defined function calls
DDL statements (DROP|CREATE|ALTER TABLE … etc.)
EXECUTE (prepared) statements that modify the database
all statements using temporary tables
如果用max_slave_replication_lag參數(shù)配置了readwritesplit服務(wù),并且如果所有從屬服務(wù)器都遭受過多的復(fù)制滯后,則語句將被路由到主服務(wù)器或者其他的slave上。
加入設(shè)定為:max_slave_replication_lag=4
#指定從站被允許落后于主站多少秒。如果滯后時間大于配置的值,則不能使用從站進(jìn)行路由.
日志內(nèi)容warning如下:
2020-02-28 21:52:59.040 info : (4) Route query to master: server3 [172.16.0.130]:3306 <
2020-02-28 21:52:59.057 info : (4) Reply complete, last reply from server3
2020-02-28 21:52:59.059 info : (4) > Autocommit: [enabled], trx is [not open], cmd: (0x03) COM_QUERY, plen: 29, type: QUERY_TYPE_READ, stmt: select * from test_event
2020-02-28 21:52:59.059 info : (4) Route query to slave: server1 [172.16.0.131]:3306 <
2020-02-28 21:52:59.060 info : (4) Reply complete, last reply from server1
2020-02-28 21:52:59.495 info : (4) > Autocommit: [enabled], trx is [not open], cmd: (0x03) COM_QUERY, plen: 90, type: QUERY_TYPE_WRITE, stmt: insert into test_event(username,password,create_time) values("李四","tomcat",now())
2020-02-28 21:52:59.495 info : (4) Route query to master: server3 [172.16.0.130]:3306 <
2020-02-28 21:52:59.511 info : (4) Reply complete, last reply from server3
2020-02-28 21:52:59.513 info : (4) > Autocommit: [enabled], trx is [not open], cmd: (0x03) COM_QUERY, plen: 29, type: QUERY_TYPE_READ, stmt: select * from test_event
2020-02-28 21:52:59.513 warning: (4) Replication lag of 'server1' is 48s, which is above the configured limit 4s. 'server1' is excluded from query routing.
2020-02-28 21:52:59.514 info : (4) Route query to slave: server2 [172.16.0.132]:3306 <
2020-02-28 21:52:59.535 info : (4) Reply complete, last reply from server2
2020-02-28 21:52:59.906 info : (4) > Autocommit: [enabled], trx is [not open], cmd: (0x03) COM_QUERY, plen: 90, type: QUERY_TYPE_WRITE, stmt: insert into test_event(username,password,create_time) values("李四","tomcat",now())
2020-02-28 21:52:59.908 info : (4) Route query to master: server3 [172.16.0.130]:3306 <
2020-02-28 21:52:59.929 info : (4) Reply complete, last reply from server3
2020-02-28 21:52:59.935 info : (4) > Autocommit: [enabled], trx is [not open], cmd: (0x03) COM_QUERY, plen: 29, type: QUERY_TYPE_READ, stmt: select * from test_event
2020-02-28 21:52:59.935 info : (4) Route query to slave: server2 [172.16.0.132]:3306 <
2020-02-28 21:52:59.950 info : (4) Reply complete, last reply from server2
2020-02-28 21:53:00.304 info : (4) > Autocommit: [enabled], trx is [not open], cmd: (0x03) COM_QUERY, plen: 90, type: QUERY_TYPE_WRITE, stmt: insert into test_event(username,password,create_time) values("李四","tomcat",now())
被路由到slave上的情況:
可以路由到從站的查詢必須是自動提交的,并且屬于以下組之一
read-only database queries,
read-only queries to system, or user-defined variables,
SHOW statements
system function calls.
6.1選擇舊主機(jī)的最新從機(jī)作為新主機(jī)。選擇標(biāo)準(zhǔn)按降序排列
1.gtid_IO_pos (latest event in relay log)
2.gtid_current_pos (most processed events)
3.log_slave_updates is on
4.disk space is not low
6.2如果新的主服務(wù)器具有未處理的中繼日志項目,請取消并稍后重試
6.3 準(zhǔn)備新的master
1.從舊的主服務(wù)器上刪除新主服務(wù)器用來復(fù)制的從服務(wù)器連接。
2.關(guān)閉新master上的read_only參數(shù)
3.啟用計劃的服務(wù)器事件(如果啟用了事件處理)。僅啟用在舊主機(jī)上啟用的事件
4運(yùn)行promotion_sql_file中的命令
5.如果存在外部主服務(wù)器,則開始復(fù)制
6.4重定向所有其他從屬服務(wù)器以從新的主服務(wù)器復(fù)制
STOP SLAVE and RESET SLAVE
CHANGE MASTER TO
START SLAVE
6.5檢查所有從屬是否正在復(fù)制
如果步驟6.1到6.3成功,則故障轉(zhuǎn)移被視為成功,因為群集至少具有一個有效的主服務(wù)器
1.準(zhǔn)備降級的舊的master:
Stop any external replication.
Kill connections from super-users since read_only does not affect them.
Enable the read_only-flag to stop writes.
Disable scheduled server events (if event handling is on).
Run the commands in demotion_sql_file.
Flush the binary log (FLUSH LOGS) so that all events are on disk.
2.等待新的master趕上舊的master
3.像故障轉(zhuǎn)移步驟3和4一樣,升級新的主服務(wù)器并重定向從服務(wù)器。還要重定向已降級的舊主服務(wù)器
4.檢查所有從屬是否正在復(fù)制
提示:Failover/switchover requires MariaDB 10.0.2 or later
Rejoin將獨立服務(wù)器加入群集,或重定向從非主服務(wù)器復(fù)制的從服務(wù)器。獨立服務(wù)器通過以下方式加入:
Run the commands in demotion_sql_file.
Enable the read_only-flag.
Disable scheduled server events (if event handling is on).
Start replication: CHANGE MASTER TO and START SLAVE.
從錯誤的主服務(wù)器復(fù)制的服務(wù)器僅通過STOP SLAVE,RESET SLAVE,CHANGE MASTER TO和START SLAVE命令進(jìn)行重定向
提示數(shù)據(jù)庫賬戶權(quán)限:
(root@'mgr03':mysql.sock)[(none)]>show grants for maxmonuser@'%';
+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for maxmonuser@% |
+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT RELOAD, SUPER, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO `maxmonuser`@`%` IDENTIFIED BY PASSWORD '*DE290C4A038E4E06BB0AF2C0B8B01ABB51572796' |
+----------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
(root@'mgr03':mysql.sock)[(none)]>show grants for maxscale@'%';
+------------------------------------------------------------------------------------------------------------------+
| Grants for maxscale@% |
+------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO `maxscale`@`%` IDENTIFIED BY PASSWORD '*E7ACDE28142BFC311A2CE191B3CB3E510A27EB60' |
+------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
(root@'mgr03':mysql.sock)[(none)]>show grants for maxuser@'172.16.0.%';
+---------------------------------------------------------------------------------------------------------------------------------+
| Grants for maxuser@172.16.0.% |
+---------------------------------------------------------------------------------------------------------------------------------+
| GRANT SHOW DATABASES, SUPER ON *.* TO `maxuser`@`172.16.0.%` IDENTIFIED BY PASSWORD '*5EDBD32E469DAE0CE10E6999C3899DEFCB9F12E0' |
| GRANT SELECT ON `mysql`.* TO `maxuser`@`172.16.0.%` |
+---------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
(root@'mgr03':mysql.sock)[(none)]>show grants for repuser@'172.16.0.%';
+-----------------------------------------------------------------------------------------------------------------------------+
| Grants for repuser@172.16.0.% |
+-----------------------------------------------------------------------------------------------------------------------------+
| GRANT REPLICATION SLAVE ON *.* TO `repuser`@`172.16.0.%` IDENTIFIED BY PASSWORD '*15BB449A1D5BDA166BB45F5989B2417834A13C23' |
+-----------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)