国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

mysql innodb cluster 創(chuàng)建

2024-07-24 12:31:58
字體:
來源:轉載
供稿:網(wǎng)友
        環(huán)境準備:
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操作系統(tǒng)用戶操作):
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...
 
      編輯環(huán)境變量:
vim /home/mysql_tar/.bash_profile
#FOR MYSQL
MYSQL_HOME=/home/mysql_tar/mysql_install
PATH=$PATH:$MYSQL_HOME/bin
export MYSQL_HOME
#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
 
準備mysql 配置文件my.cnf
vim /etc/my.cnf
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
 
創(chuàng)建數(shù)據(jù)目錄文件/data_test(用戶和用戶組均為mysql_tar)
初始化mysql
cd /home/mysql_tar/mysql_install/bin(環(huán)境變量設置正確,該步可有可無)
./mysqld --initialize --user=mysql_tar(初始化mysql系統(tǒng)表空間和其他重要文件,initialize 拼錯的話不會報錯,只會提示數(shù)據(jù)目錄找不到)
啟動Mysql
mysqld_safe --user=mysql_tar &
連接Mysql并且修改root賬戶密碼:
./mysql -u root -S /data_test/mysql.sock -p(也可以通過TCP/IP登陸,這里通過套接字登陸)
mysql>alter user root@localhost identified by 'mjj';
通過mysqlsh登陸mysql、檢查環(huán)境并創(chuàng)建集群
/home/mysql_tar/mysql_shell/bin/mysqlsh
MySQL SQL > /connect root@mysql_host_a(加粗的是我的命令)
Creating a session to 'root@mysql_host_a'
Please provide the password for 'root@mysql_host_a': *
Save password for 'root@mysql_host_a'? [Y]es/[N]o/Ne[v]er (default No): ~~
MySQL mysql_host_a:33060+ ssl JS > dba.checkInstanceConfiguration();
Validating local MySQL instance listening at port 3306 for use in an InnoDB cluster...**
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...
 
10 可以通過cluster.status();命令查看集群狀態(tài)
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, 其他機子也安裝軟件和準備環(huán)境(dba.checkInstanceConfiguration()通過即可,步驟與主節(jié)點類似)
 
加入節(jié)點:
MySQL mysql_host_a:33060+ ssl JS > cluster.addInstance('root@mysql_host_b:3306');(本人另一臺機子的主機名是mysql_host_b)
Cluster.addInstance: Connection 'root@mysql_host_b:3306' is not valid: unable to resolve the IPv4 address. (ArgumentError)
MySQL mysql_host_a:33060+ ssl JS > cluster.addInstance('root@mysql_host_b:3306');
Please provide the password for 'root@mysql_host_b:3306': ***
Save password for 'root@mysql_host_b:3306'? [Y]es/[N]o/Ne[v]er (default No):
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'.
 
Waiting for clone to finish...
NOTE: mysql_host_b:3306 is being cloned from mysql_host_a:3306
Stage DROP DATA: Completed
Clone Transfer
FILE COPY ############################################################ 100% Completed
PAGE COPY ############################################################ 100% Completed
REDO COPY ############################################################ 100% Completed
NOTE: mysql_host_b:3306 is shutting down...
 
Waiting for server restart... ready
mysql_host_b:3306 has restarted, waiting for clone to finish...
** Stage RESTART: Completed
Clone process has finished: 58.50 MB transferred in about 1 second (~inf TB/s)
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()

(編輯:武林網(wǎng))

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 安远县| 分宜县| 高安市| 博乐市| 伊金霍洛旗| 高陵县| 孟州市| 孝感市| 长岭县| 岐山县| 盐源县| 兴山县| 霍州市| 康乐县| 中宁县| 阿坝| 石泉县| 伊春市| 桃园市| 昭苏县| 穆棱市| 清水县| 富阳市| 翼城县| 贵阳市| 江阴市| 岑溪市| 沙湾县| 广德县| 那坡县| 湟源县| 磴口县| 阳谷县| 洛阳市| 东阿县| 赞皇县| 喀喇沁旗| 富川| 蒙自县| 康定县| 武强县|