根據文檔搭建...https://dev.MySQL.com/doc/refman/8.0/en/mysql-innodb-cluster-production-deployment.html
創新互聯公司專業為企業提供大足網站建設、大足做網站、大足網站設計、大足網站制作等企業網站建設、網頁設計與制作、大足企業網站模板建站服務,十載大足做網站經驗,不只是建網站,更提供有價值的思路和整體網絡服務。
環境準備:
1 下載和安裝需要的軟件(本人的軟件版本--都是mysql Community中的Linux Generic版本)
mysql-server(mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz)
mysql-router(mysql-router-8.0.17-linux-glibc2.12-x86_64.tar.xz)
mysql-shell(mysql-shell-8.0.17-linux-glibc2.12-x86-64bit.tar.gz)
安裝(以mysql server為例,其他類似,以下都是Mysql_tar操作系統用戶操作):
cd /home/mysql_tar
tar -xvf mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz
ln -s mysql-8.0.17-linux-glibc2.12-x86_64 mysql_install(方便升級)
...mysql-router...
....mysql_shell...
#MYSQL SHELL
MYSQL_SHELL_HOME=/home/mysql_tar/mysql_shell
PATH=$PATH:$MYSQL_SHELL_HOME/bin
export MYSQL_SHELL_HOME
#MYSQL_ROUTER
MYSQL_ROUTER=/home/mysql_tar/mysql_router
PATH=$PATH:$MYSQL_ROUTER/bin
export MYSQL_ROUTER
export PATH
default-authentication-plugin=mysql_native_password
lower_case_table_names=1
datadir=/data_test
socket=/data_test/mysql.sock
log-error=/data_test/mysqld.log
pid-file=/data_test/mysqld.pid
This instance reports its own address as mysql_host_a:3306
Clients and other cluster members will communicate with it through this address by default. If this is not correct, the report_host MySQL system variable should be changed.
Checking whether existing tables comply with Group Replication requirements...
No incompatible tables detected
Checking instance configuration...
NOTE: Some configuration options need to be fixed:
+--------------------------+---------------+----------------+--------------------------------------------------+
| Variable | Current Value | Required Value | Note |
+--------------------------+---------------+----------------+--------------------------------------------------+
| binlog_checksum | CRC32 | NONE | Update the server variable |
| enforce_gtid_consistency | OFF | ON | Update read-only variable and restart the server |
| gtid_mode | OFF | ON | Update read-only variable and restart the server |
| server_id | 1 | <unique ID> | Update read-only variable and restart the server |
+--------------------------+---------------+----------------+--------------------------------------------------+
Some variables need to be changed, but cannot be done dynamically on the server.
NOTE: Please use the dba.configureInstance() command to repair these issues.
{
"config_errors": [
{
"action": "server_update",
"current": "CRC32",
"option": "binlog_checksum",
"required": "NONE"
},
{
"action": "server_update+restart",
"current": "OFF",
"option": "enforce_gtid_consistency",
"required": "ON"
},
{
"action": "server_update+restart",
"current": "OFF",
"option": "gtid_mode",
"required": "ON"
},
{
"action": "server_update+restart",
"current": "1",
"option": "server_id",
"required": "<unique ID>"
}
],
"status": "error"
}
MySQL mysql_host_a:33060+ ssl JS > \exit
Bye!
根據錯誤往/etc/my.cnf添加以下參數:
#for innodb cluster
binlog_checksum=none
enforce_gtid_consistency=on
gtid_mode=on
server_id=1234
Validating instance at mysql_host_a:3306...
This instance reports its own address as mysql_host_a:3306
Instance configuration is suitable.
Creating InnoDB cluster 'mjjcluster' on 'mysql_host_a:3306'...
Adding Seed Instance...
Cluster successfully created. Use Cluster.addInstance() to add MySQL instances.
At least 3 instances are needed for the cluster to be able to withstand up to
one server failure.
10 可以通過cluster.status();命令查看集群狀態
MySQL mysql_host_a:33060+ ssl JS > cluster.status();
{
"clusterName": "mjjcluster",
"defaultReplicaSet": {
"name": "default",
"primary": "mysql_host_a:3306",
"ssl": "REQUIRED",
"status": "OK_NO_TOLERANCE",
"statusText": "Cluster is NOT tolerant to any failures.",
"topology": {
"mysql_host_a:3306": {
"address": "mysql_host_a:3306",
"mode": "R/W",
"readReplicas": {},
"role": "HA",
"status": "ONLINE",
"version": "8.0.17"
}
},
"topologyMode": "Single-Primary"
},
"groupInformationSourceMember": "mysql_host_a:3306"
}
11, 其他機子也安裝軟件和準備環境(dba.checkInstanceConfiguration()通過即可,步驟與主節點類似)
NOTE: The target instance 'mysql_host_b:3306' has not been pre-provisioned (GTID set
is empty). The Shell is unable to decide whether incremental distributed state
recovery can correctly provision it.
The safest and most convenient way to provision a new instance is through
automatic clone provisioning, which will completely overwrite the state of
'mysql_host_b:3306' with a physical snapshot from an existing cluster member.
To use this method by default, set the 'recoveryMethod' option to 'clone'.
The incremental distributed state recovery may be safely used if you are sure
all updates ever executed in the cluster were done with GTIDs enabled, there
are no purged transactions and the new instance contains the same GTID set as
the cluster or a subset of it. To use this method by default, set the
'recoveryMethod' option to 'incremental'.
Please select a recovery method [C]lone/[I]ncremental recovery/[A]bort (default Clone):
Validating instance at mysql_host_b:3306...
This instance reports its own address as mysql_host_b:3306
Instance configuration is suitable.
A new instance will be added to the InnoDB cluster. Depending on the amount of
data on the cluster this might take from a few seconds to several hours.
Adding instance to the cluster...
Monitoring recovery process of the new cluster member. Press ^C to stop monitoring and let it continue in background.
Clone based state recovery is now in progress.
NOTE: A server restart is expected to happen as part of the clone process. If the
server does not support the RESTART command or does not come back after a
while, you may need to manually start it back.
NOTE: mysql_host_b:3306 is shutting down...
State recovery already finished for 'mysql_host_b:3306'
The instance 'mysql_host_b:3306' was successfully added to the cluster.
。。。完成了,基本的步驟就這些吧。
主要方法:
dba.configureInstance()
dba.createCluster()
Cluster.addInstance()----cluster=dba.getCluster()獲取cluster變量
Cluster.removeInstance()
Cluster.rejoinInstance()
網站標題:mysqlinnodbcluster搭建
分享路徑:http://www.yahangbao.cn/article48/pspoep.html
成都網站建設公司_創新互聯,為您提供定制網站、網站設計、網站維護、小程序開發、網站內鏈、軟件開發
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯