MySQL?InnoDB?Cluster搭建安裝教程
環(huán)境介紹:
這里的MySQL Innodb Cluster搭建環(huán)境如下所示,總共有三臺(tái)機(jī)器搭建MySQL InnoDB Cluster:
操作系統(tǒng): Red Hat Enterprise Linux release 8.8 (Ootpa)
數(shù)據(jù)庫(kù)版本:8.0.35 MySQL Community Server - GPL

第一步:環(huán)境檢查與配置
1:防火墻配置
測(cè)試環(huán)境可以關(guān)閉防火墻,生產(chǎn)環(huán)境一般會(huì)開啟防火墻。在防火墻上設(shè)置相關(guān)IP和端口。根據(jù)實(shí)際情況進(jìn)行設(shè)置(需要root權(quán)限,一般由系統(tǒng)管理員設(shè)置)
關(guān)于如何設(shè)置防火墻限定IP地址,這里不做過(guò)多介紹,其實(shí)配置也很簡(jiǎn)單。端口號(hào)根據(jù)實(shí)際情況配置。
# systemctl status firewalld.service # systemctl stop firewalld.service # systemctl status firewalld.service # systemctl disable firewalld.service
2:關(guān)閉或配置SELinux
檢查是否關(guān)閉selinux
# /usr/sbin/sestatus SELinux status: disabled
修改SELinux配置文件
如果沒(méi)有關(guān)閉selinux的話,我們建議關(guān)閉selinux,可以通過(guò)修改selinux的配置文件,將SELINUX=enforcing改為SELINUX=disabled。
#vi /etc/selinux/config SELINUX=disabled
如果不想重啟,如果想驗(yàn)證一下,可以重啟一下服務(wù)器。
setenforce 0 getenforce
如果公司要求開啟SELinux的話, 必須設(shè)置SELinux 策略,在SELinux 下允許MySQL連接
sudo setsebool -P mysql_connect_any 1
3:配置IP與主機(jī)名映射
編輯/etc/hosts
#MySQL InnoDB Cluster 192.168.9.200 mysqlu01 192.168.9.201 mysqlu02 192.168.9.202 mysqlu03
[注意]:三臺(tái)MySQL服務(wù)器都必須設(shè)置,不能只設(shè)置一臺(tái)服務(wù)器。請(qǐng)注意,不要遺漏。
4:修改內(nèi)核參數(shù)
/etc/security/limits.conf mysql hard nofile 65536 mysql soft nofile 65536 或者 * hard nofile 65536 * soft nofile 65536
5:配置標(biāo)準(zhǔn)大頁(yè)???????
grep -i huge /proc/meminfo
建議開啟標(biāo)準(zhǔn)大頁(yè),這樣更有利于性能。
6:禁用透明大頁(yè)
第二步:安裝MySQL實(shí)例
1:安裝MySQL實(shí)例
使用mysql_auto_install.sh腳本自動(dòng)安裝MySQL單實(shí)例,如果常規(guī)的安裝MySQL實(shí)例,參考文檔“MySQL 8.0的二進(jìn)制安裝文檔.docx” ,三臺(tái)(多臺(tái))服務(wù)器上安裝MySQL實(shí)例
$ cd /data/soft $ sh mysql_auto_install.sh
2:修改參數(shù)文件中MGR參數(shù)配置
修改server_id=xxxx #規(guī)則,取IP地址的最后一位,然后在my.cnf中添加下面配置
########################################################################################################################## # GTID SETTING ########################################################################################################################## plugin_dir=/opt/mysql/mysql8.0/lib/plugin #設(shè)置plugin的路徑 enforce_gtid_consistency = ON #強(qiáng)制GTID的一致性 gtid-mode=ON #開啟GTID,必須開啟 master-info-repository=TABLE relay-log-info-repository=TABLE #記錄同步的信息,便于管理和恢復(fù) log-slave-updates = ON #需要記錄事務(wù)的binlog,用作以后的恢復(fù)用,哪怕不是寫入點(diǎn),也需要 binlog-checksum=NONE #MGR本身不支持binlog的checksum校驗(yàn) slave-parallel-workers=8 #GTID的SQL線程 slave_preserve_commit_order=ON #GTID配置,SQL線程按照順序重放事物 #slave-parallel-type=LOGICAL_CLOCK #SQL線程工作模式。有兩種。 disabled_storage_engines="MyISAM,BLACKHOLE,FEDERATED,ARCHIVE,MEMORY" ########################################################################################################################## ########################################################################################################################## # 組復(fù)制設(shè)置 ########################################################################################################################## #記錄事務(wù)的算法,官網(wǎng)建議設(shè)置該參數(shù)使用 XXHASH64 算法 transaction_write_set_extraction = XXHASH64 plugin_load_add='group_replication.so' #是否隨服務(wù)器啟動(dòng)而自動(dòng)啟動(dòng)組復(fù)制,不建議直接啟動(dòng),怕故障恢復(fù)時(shí)有擾亂數(shù)據(jù)準(zhǔn)確性的特殊情況 #loose-group_replication_start_on_boot = OFF group_replication_start_on_boot = OFF #開啟引導(dǎo)模式,添加組成員,用于第一次搭建MGR或重建MGR的時(shí)候使用,只需要在集群內(nèi)的其中一臺(tái)開啟, #loose-group_replication_bootstrap_group = OFF group_replication_bootstrap_group = OFF #IP地址白名單,默認(rèn)只添加127.0.0.1,不會(huì)允許來(lái)自外部主機(jī)的連接,按需安全設(shè)置 #loose-group_replication_ip_whitelist = '127.0.0.1/8,192.168.9.0/24' group_replication_ip_allowlist = '127.0.0.1/8,192.168.9.0/24' #是否啟動(dòng)單主模式,如果啟動(dòng),則本實(shí)例是主庫(kù),提供讀寫,其他實(shí)例僅提供讀,如果為off就是多主模式了 loose-group_replication_single_primary_mode = ON ##ssl for mgr group_replication_ssl_mode = REQUIRED group_replication_recovery_use_ssl = ON binlog_transaction_dependency_tracking=WRITESET ##########################################################################################################################
注意,這里使用mysql shell創(chuàng)建InnoDB Cluster時(shí),不需要在參數(shù)文件中設(shè)置group_replication_group_name等參數(shù),有些版本的參數(shù)也有所出入,請(qǐng)以實(shí)際情況為準(zhǔn)。
修改后重啟每一臺(tái)MySQL服務(wù)。
$ sudo systemctl stop mysqld.service $ sudo systemctl start mysqld.service $ sudo systemctl status mysqld.service
安裝MySQL Shell??????
# yum localinstall mysql-shell-8.0.35-1.el8.x86_64.rpm
這里使用root用戶安裝。因?yàn)閙ysql用戶沒(méi)有權(quán)限安裝??梢灾话惭b一臺(tái)MySQL服務(wù)器,也可以三臺(tái)都安裝。
創(chuàng)建數(shù)據(jù)庫(kù)用戶
##手動(dòng)創(chuàng)建需要設(shè)置log bin 為0,創(chuàng)建完成后設(shè)置回1,所有服務(wù)器執(zhí)行
SET SQL_LOG_BIN=0; CREATE USER icadmin@'192.168.9.%' IDENTIFIED BY '******'; GRANT ALL ON *.* TO icadmin@'192.168.9.%' WITH GRANT OPTION; SET SQL_LOG_BIN=1;
注意:所有MySQL節(jié)點(diǎn)需要執(zhí)行創(chuàng)建用戶操作,此用戶臨時(shí)使用,配置完集群后刪除。
mysqlsh \cicadmin@192.168.9.200:7306
或
mysqlsh-h192.168.9.200-P7306-uicadmin-p
檢查實(shí)例是否符合InnoDB Cluster的參數(shù)及權(quán)限配置要求
dba.checkInstanceConfiguration('icadmin@192.168.9.200:7306')
dba.checkInstanceConfiguration('icadmin@192.168.9.201:7306')
dba.checkInstanceConfiguration('icadmin@192.168.9.202:7306')檢查符合InnoDB Cluster的參數(shù)、權(quán)限配置符合要求的話,則會(huì)返回status為OK,否則會(huì)提示不符合要求信息。
MySQL192.168.9.200:7306sslJS>dba.checkInstanceConfiguration('icadmin@192.168.9.201:7306')
Pleaseprovidethepasswordfor'icadmin@192.168.9.201:7306':****************
Savepasswordfor'icadmin@192.168.9.201:7306'?[Y]es/[N]o/Ne[v]er(defaultNo):yes
ValidatingMySQLinstanceatmysqlu02:7306foruseinanInnoDBcluster...
Thisinstancereportsitsownaddressasmysqlu02:7306
Clientsandotherclustermemberswillcommunicatewithitthroughthisaddressbydefault.Ifthisisnotcorrect,thereport_hostMySQLsystemvariableshouldbechanged.
CheckingwhetherexistingtablescomplywithGroupReplicationrequirements...
Noincompatibletablesdetected
Checkinginstanceconfiguration...
InstanceconfigurationiscompatiblewithInnoDBcluster
Theinstance'mysqlu02:7306'isvalidtobeusedinanInnoDBcluster.
{
"status":"ok"
}
MySQL192.168.9.200:7306sslJS>如果MySQL的參數(shù)不符合要求,則上面輸出信息"status"不為"ok",則必須修改相關(guān)參數(shù)參數(shù),重新檢測(cè)。
初始化InnoDB Cluster相關(guān)配置
dba.configureInstance('icadmin@192.168.9.200:7306',{clusterAdmin:"'icadmin'@'192.168.9.%'"});
dba.configureInstance('icadmin@192.168.9.201:7306',{clusterAdmin:"'icadmin'@'192.168.9.%'"});
dba.configureInstance('icadmin@192.168.9.202:7306',{clusterAdmin:"'icadmin'@'192.168.9.%'"});或者
dba.configureInstance('root@192.168.9.200:7306',{clusterAdmin:"'icadmin'@'192.168.9.%'"},clusterAdminPassword:"*****"});
dba.configureInstance('root@192.168.9.201:7306',{clusterAdmin:"'icadmin'@'192.168.9.%'"},clusterAdminPassword:"*****"});
dba.configureInstance('root@192.168.9.202:7306',{clusterAdmin:"'icadmin'@'192.168.9.%'"},clusterAdminPassword:"*****"});具體執(zhí)行過(guò)程如下所示:
MySQL192.168.9.200:7306sslJS>dba.configureInstance('icadmin@192.168.9.200:7306',{clusterAdmin:"'icadmin'@'192.168.9.%'"});
ConfiguringlocalMySQLinstancelisteningatport7306foruseinanInnoDBcluster...
Thisinstancereportsitsownaddressasmysqlu01:7306
Clientsandotherclustermemberswillcommunicatewithitthroughthisaddressbydefault.Ifthisisnotcorrect,thereport_hostMySQLsystemvariableshouldbechanged.
User'icadmin'@'192.168.9.%'alreadyexistsandwillnotbecreated.
applierWorkerThreadswillbesettothedefaultvalueof4.
Theinstance'mysqlu01:7306'isvalidtobeusedinanInnoDBcluster.
Theinstance'mysqlu01:7306'isalreadyreadytobeusedinanInnoDBcluster.
Successfullyenabledparallelappliers.
MySQL192.168.9.200:7306sslJS>dba.configureInstance('icadmin@192.168.9.201:7306',{clusterAdmin:"'icadmin'@'192.168.9.%'"});
ConfiguringMySQLinstanceatmysqlu02:7306foruseinanInnoDBcluster...
Thisinstancereportsitsownaddressasmysqlu02:7306
Clientsandotherclustermemberswillcommunicatewithitthroughthisaddressbydefault.Ifthisisnotcorrect,thereport_hostMySQLsystemvariableshouldbechanged.
User'icadmin'@'192.168.9.%'alreadyexistsandwillnotbecreated.
applierWorkerThreadswillbesettothedefaultvalueof4.
Theinstance'mysqlu02:7306'isvalidtobeusedinanInnoDBcluster.
Theinstance'mysqlu02:7306'isalreadyreadytobeusedinanInnoDBcluster.
Successfullyenabledparallelappliers.
MySQL192.168.9.200:7306sslJS>dba.configureInstance('icadmin@192.168.9.202:7306',{clusterAdmin:"'icadmin'@'192.168.9.%'"});
ConfiguringMySQLinstanceatmysqlu03:7306foruseinanInnoDBcluster...
Thisinstancereportsitsownaddressasmysqlu03:7306
Clientsandotherclustermemberswillcommunicatewithitthroughthisaddressbydefault.Ifthisisnotcorrect,thereport_hostMySQLsystemvariableshouldbechanged.
User'icadmin'@'192.168.9.%'alreadyexistsandwillnotbecreated.
applierWorkerThreadswillbesettothedefaultvalueof4.
Theinstance'mysqlu03:7306'isvalidtobeusedinanInnoDBcluster.
Theinstance'mysqlu03:7306'isalreadyreadytobeusedinanInnoDBcluster.
Successfullyenabledparallelappliers.
MySQL192.168.9.200:7306sslJS>創(chuàng)建集群
varcluster=dba.createCluster('gsp_cluster');具體操作如下所示:
MySQL192.168.9.200:7306sslJS>varcluster=dba.createCluster('gsp_cluster');
AnewInnoDBClusterwillbecreatedoninstance'mysqlu01:7306'.
Validatinginstanceconfigurationat192.168.9.200:7306...
Thisinstancereportsitsownaddressasmysqlu01:7306
Instanceconfigurationissuitable.
NOTE:GroupReplicationwillcommunicatewithothermembersusing'mysqlu01:7306'.UsethelocalAddressoptiontooverride.
*CheckingconnectivityandSSLconfiguration...
CreatingInnoDBCluster'gsp_cluster'on'mysqlu01:7306'...
AddingSeedInstance...
Clustersuccessfullycreated.UseCluster.addInstance()toaddMySQLinstances.
Atleast3instancesareneededfortheclustertobeabletowithstandupto
oneserverfailure.
MySQL192.168.9.200:7306sslJS>查看創(chuàng)建集群狀態(tài)
varcluster=dba.getCluster() cluster.status()
具體輸出如下所示:
MySQL192.168.9.200:7306sslJS>varcluster=dba.getCluster()
MySQL192.168.9.200:7306sslJS>cluster.status()
{
"clusterName":"gsp_cluster",
"defaultReplicaSet":{
"name":"default",
"primary":"mysqlu01:7306",
"ssl":"REQUIRED",
"status":"OK_NO_TOLERANCE",
"statusText":"ClusterisNOTtoleranttoanyfailures.",
"topology":{
"mysqlu01:7306":{
"address":"mysqlu01:7306",
"memberRole":"PRIMARY",
"mode":"R/W",
"readReplicas":{},
"replicationLag":"applier_queue_applied",
"role":"HA",
"status":"ONLINE",
"version":"8.0.33"
}
},
"topologyMode":"Single-Primary"
},
"groupInformationSourceMember":"mysqlu01:7306"
}
MySQL192.168.9.200:7306sslJS>添加節(jié)點(diǎn)到集群
varcluster=dba.getCluster()
cluster.addInstance('icadmin@192.168.9.201:7306')
cluster.status()
cluster.addInstance('icadmin@192.168.9.202:7306')
cluster.status()部分輸出如下所示:
MySQL192.168.9.200:7306sslJS>cluster.addInstance('icadmin@192.168.9.202:7306')
NOTE:Thetargetinstance'mysqlu03:7306'hasnotbeenpre-provisioned(GTIDsetisempty).TheShellisunabletodecidewhetherincrementalstaterecoverycancorrectlyprovisionit.
Thesafestandmostconvenientwaytoprovisionanewinstanceisthroughautomaticcloneprovisioning,whichwillcompletelyoverwritethestateof'mysqlu03:7306'withaphysicalsnapshotfromanexistingclustermember.Tousethismethodbydefault,setthe'recoveryMethod'optionto'clone'.
TheincrementalstaterecoverymaybesafelyusedifyouaresureallupdateseverexecutedintheclusterweredonewithGTIDsenabled,therearenopurgedtransactionsandthenewinstancecontainsthesameGTIDsetastheclusterorasubsetofit.Tousethismethodbydefault,setthe'recoveryMethod'optionto'incremental'.
Pleaseselectarecoverymethod[C]lone/[I]ncrementalrecovery/[A]bort(defaultClone):C
Validatinginstanceconfigurationat192.168.9.202:7306...
Thisinstancereportsitsownaddressasmysqlu03:7306
Instanceconfigurationissuitable.
NOTE:GroupReplicationwillcommunicatewithothermembersusing'mysqlu03:7306'.UsethelocalAddressoptiontooverride.
*CheckingconnectivityandSSLconfiguration...
AnewinstancewillbeaddedtotheInnoDBCluster.Dependingontheamountof
dataontheclusterthismighttakefromafewsecondstoseveralhours.
Addinginstancetothecluster...
Monitoringrecoveryprocessofthenewclustermember.Press^Ctostopmonitoringandletitcontinueinbackground.
Clonebasedstaterecoveryisnowinprogress.
NOTE:Aserverrestartisexpectedtohappenaspartofthecloneprocess.Ifthe
serverdoesnotsupporttheRESTARTcommandordoesnotcomebackaftera
while,youmayneedtomanuallystartitback.
*Waitingforclonetofinish...
NOTE:mysqlu03:7306isbeingclonedfrommysqlu02:7306
**StageDROPDATA:Completed
**CloneTransferFILECOPY============================================================0%NotStartedPAGECOPY============================================================0%NotStartedREDOCOPY============================================================0%NotStarted**CloneTransferFILECOPY============================================================0%InProgressPAGECOPY============================================================0%NotStartedREDOCOPY============================================================0%NotStarted**CloneTransferFILECOPY############################################################100%CompletedPAGECOPY############################################################100%CompletedREDOCOPY############################################################100%Completed
NOTE:mysqlu03:7306isshuttingdown...
*Waitingforserverrestart...ready
*mysqlu03:7306hasrestarted,waitingforclonetofinish...
**StageRESTART:Completed
*Cloneprocesshasfinished:73.65MBtransferredinabout1second(~73.65MB/s)
Staterecoveryalreadyfinishedfor'mysqlu03:7306'
Theinstance'mysqlu03:7306'wassuccessfullyaddedtothecluster.
MySQL192.168.9.200:7306sslJS>cluster.status()
{
"clusterName":"gsp_cluster",
"defaultReplicaSet":{
"name":"default",
"primary":"mysqlu01:7306",
"ssl":"REQUIRED",
"status":"OK",
"statusText":"ClusterisONLINEandcantolerateuptoONEfailure.",
"topology":{
"mysqlu01:7306":{
"address":"mysqlu01:7306",
"memberRole":"PRIMARY",
"mode":"R/W",
"readReplicas":{},
"replicationLag":"applier_queue_applied",
"role":"HA",
"status":"ONLINE",
"version":"8.0.33"
},
"mysqlu02:7306":{
"address":"mysqlu02:7306",
"memberRole":"SECONDARY",
"mode":"R/O",
"readReplicas":{},
"replicationLag":"applier_queue_applied",
"role":"HA",
"status":"ONLINE",
"version":"8.0.33"
},
"mysqlu03:7306":{
"address":"mysqlu03:7306",
"memberRole":"SECONDARY",
"mode":"R/O",
"readReplicas":{},
"replicationLag":"applier_queue_applied",
"role":"HA",
"status":"ONLINE",
"version":"8.0.33"
}
},
"topologyMode":"Single-Primary"
},
"groupInformationSourceMember":"mysqlu01:7306"
}
MySQL192.168.9.200:7306sslJS>檢查集群狀態(tài)
最后再檢查一次集群的狀態(tài) varcluster=dba.getCluster() cluster.status();

MySQL Router安裝
MySQL Router有兩種配置方式,如下所示:
手工配置,手工填寫后端 MGR 節(jié)點(diǎn)的地址,但是這樣MySQL Router就沒(méi)法感知 Primary 節(jié)點(diǎn)的變化,手工創(chuàng)建 MGR 時(shí)只能這么配置
引導(dǎo)模式自動(dòng)進(jìn)行配置,通過(guò) mysql_innodb_cluster_metadata 元數(shù)據(jù)庫(kù)動(dòng)態(tài)感知 Primary 節(jié)點(diǎn)的變化,實(shí)現(xiàn)對(duì)應(yīng)用的透明,這也是 InnoDB Cluster 的標(biāo)準(zhǔn)配置方法。
bootstrap模式
bootstrap模式支持failover,但是必須結(jié)合InnoDB Cluster使用,在--directory指定的路徑下自動(dòng)生成安裝目錄,配置文件里的端口為6446和6447
$cd/data/soft $tarxvfmysql-router-8.0.35-linux-glibc2.28-x86_64.tar.xz-C/opt/mysql $cd/opt/mysql/ $ln-smysql-router-8.0.35-linux-glibc2.28-x86_64/router
配置環(huán)境變量
#在mysql用戶下編輯,加入下面配置信息
exportPATH=$PATH:/opt/mysql/router/bin
執(zhí)行下面命令,使之生效。
$source~/.bash_profile #查看幫助信息 mysqlrouter--help #創(chuàng)建目錄 mkdir-p/data/mysqlrouter
初始化腳本(例子1)
mysqlrouter--bootstrapicadmin@mysqlu01:7306--directory/data/mysqlrouter--name='icrouter'--force-password-validation
具體如下所示:
$mysqlrouter--bootstrapicadmin@mysqlu01:7306--directory/data/mysqlrouter--name='iicrouter'--force-password-validation PleaseenterMySQLpasswordforicadmin: #BootstrappingMySQLRouter8.0.35(MySQLCommunity-GPL)instanceat'/data/mysqlrouter'... -Creatingaccount(s)(onlythosethatareneeded,ifany) -Verifyingaccount(usingittorunSQLqueriesthatwouldberunbyRouter) -Storingaccountinkeyring -Adjustingpermissionsofgeneratedfiles -Creatingconfiguration/data/mysqlrouter/mysqlrouter.conf #MySQLRouter'iicrouter'configuredfortheClusterSet'yicticcset' AfterthisMySQLRouterhasbeenstartedwiththegeneratedconfiguration $mysqlrouter-c/data/mysqlrouter/mysqlrouter.conf ClusterSet'yicticcset'canbereachedbyconnectingto: ##MySQLClassicprotocol -Read/WriteConnections:localhost:6446 -Read/OnlyConnections:localhost:6447 ##MySQLXprotocol -Read/WriteConnections:localhost:6448 -Read/OnlyConnections:localhost:6449
初始化腳本(例子2):
mysqlrouter--bootstrapicadmin@mysqlu01:7306\ --directory/data/mysqlrouter\ --accounticcrouter\ --usermysql--nameicrouter\ --conf-bind-address="0.0.0.0"\ --account-host="192.168.9.%"--force-password-validation
注意:--conf-bind-address,如果想任何其它機(jī)器都能訪問(wèn)mysql router的話,那么--conf-bind-address應(yīng)該設(shè)置為0.0.0.0,如果設(shè)置為某個(gè)IP,表示只能在這個(gè)IP訪問(wèn)mysql router,根據(jù)具體情況設(shè)置。
具體輸出如下所示:
[mysql@mysqlu01mysqlrouter]$mysqlrouter--bootstrapicadmin@mysqlu01:7306\ >--directory/data/mysqlrouter\ >--accounticcrouter\ >--usermysql--nameicrouter\ >--conf-bind-address="192.168.9.200"\ >--account-host="192.168.9.%"--force-password-validation PleaseenterMySQLpasswordforicadmin: #ReconfiguringMySQLRouter8.0.35(MySQLCommunity-GPL)instanceat'/data/mysqlrouter'... PleaseenterMySQLpasswordforiccrouter: -Creatingaccount(s)(onlythosethatareneeded,ifany) -Usingexistingcertificatesfromthe'/data/mysqlrouter/data'directory -Verifyingaccount(usingittorunSQLqueriesthatwouldberunbyRouter) -Storingaccountinkeyring -Adjustingpermissionsofgeneratedfiles -Creatingconfiguration/data/mysqlrouter/mysqlrouter.conf Existingconfigurationsbackedupto'/data/mysqlrouter/mysqlrouter.conf.bak' #MySQLRouter'icrouter'configuredfortheInnoDBCluster'gsp_cluster' AfterthisMySQLRouterhasbeenstartedwiththegeneratedconfiguration $mysqlrouter-c/data/mysqlrouter/mysqlrouter.conf InnoDBCluster'gsp_cluster'canbereachedbyconnectingto: ##MySQLClassicprotocol -Read/WriteConnections:localhost:6446 -Read/OnlyConnections:localhost:6447 ##MySQLXprotocol -Read/WriteConnections:localhost:6448 -Read/OnlyConnections:localhost:6449 [mysql@mysqlu01mysqlrouter]$
查看MySQL Router信息
varcluster=dba.getCluster() cluster.listRouters()
具體信息如下所示

配置MySQL Router的systemd服務(wù),編輯配置/usr/lib/systemd/system/mysqlrouter.service
[Unit] Description=MySQLRouter After=syslog.target After=network.target [Service] Type=simple User=mysql Group=mysql PIDFile=/data/mysqlrouter/mysqlrouter.pid ExecStart=/opt/mysql/router/bin/mysqlrouter-c/data/mysqlrouter/mysqlrouter.conf Restart=on-failure PrivateTmp=true [Install] WantedBy=multi-user.target
然后執(zhí)行下面命令
#systemctldaemon-reload #systemctlenablemysqlrouter.service #systemctlstatusmysqlrouter.service #systemctlstartmysqlrouter.service
啟動(dòng)MySQL Router后,可以通過(guò)下面命令查看/驗(yàn)證其監(jiān)聽端口是否開啟。
$netstat-ntlp|grepmysqlrouter $ps-ef|grepmysqlrouter|grep-vgrep
然后依葫蘆畫瓢,在另外一臺(tái)服務(wù)器上安裝MySQL Router,關(guān)于MySQL Router的安裝,一般應(yīng)該在應(yīng)用服務(wù)器或單獨(dú)的服務(wù)器上安裝MySQL Router,結(jié)合Keepalvied實(shí)現(xiàn)MySQL Router的高可用性,這里不做展開介紹。
到此這篇關(guān)于MySQL InnoDB Cluster搭建安裝 的文章就介紹到這了,更多相關(guān)MySQL InnoDB Cluster安裝 內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
MySql中sql語(yǔ)句執(zhí)行過(guò)程詳細(xì)講解
天天和數(shù)據(jù)庫(kù)打交道,一天能寫上幾十條 SQL 語(yǔ)句,但你知道我們的系統(tǒng)是如何和數(shù)據(jù)庫(kù)交互的嗎?下面這篇文章主要給大家介紹了關(guān)于MySql中sql語(yǔ)句執(zhí)行過(guò)程詳細(xì)講解的相關(guān)資料,需要的朋友可以參考下2023-02-02
詳解MySql存儲(chǔ)過(guò)程參數(shù)的入門使用
這篇文章主要介紹了MySql存儲(chǔ)過(guò)程參數(shù)的入門使用,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04
在MySQL concat里面使用多個(gè)單引號(hào),三引號(hào)的問(wèn)題
今天小編就為大家分享一篇在MySQL concat里面使用多個(gè)單引號(hào),三引號(hào)的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-03-03
深入學(xué)習(xí)MySQL表數(shù)據(jù)操作
這篇文章主要介紹了深入學(xué)習(xí)MySQL表數(shù)據(jù)操作,基于表操作內(nèi)容圍繞主題展開詳細(xì)介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-08-08

