日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長(zhǎng)提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢(xún)客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

1.機(jī)器說(shuō)明

Mysql雙主雙從(實(shí)戰(zhàn)干貨,好文章!!)

 


Mysql雙主雙從(實(shí)戰(zhàn)干貨,好文章!!)

 

因?yàn)橹?,從2,都是通過(guò)同一個(gè)鏡像生成的系統(tǒng),所以MySQL的 server-uuid 是一樣的,在配置前,需要做以下操作

重命名 /var/lib/mysql/auto.cnf 文件

mv auto.cnf auto.cnf.bak

重啟mysql 重新生成 auto.cnf 文件

Mysql雙主雙從(實(shí)戰(zhàn)干貨,好文章!!)

 


Mysql雙主雙從(實(shí)戰(zhàn)干貨,好文章!!)

 


Mysql雙主雙從(實(shí)戰(zhàn)干貨,好文章!!)

 


Mysql雙主雙從(實(shí)戰(zhàn)干貨,好文章!!)

 

因?yàn)橹芭渲眠^(guò) ali-shuidi01,ali-shuidi02的主從關(guān)系,所以先將兩者之前的主從關(guān)系取消,在master1上執(zhí)行

 
  1. mysql> stop slave;
  2. Query OK, 0 rows affected, 1 warning (0.00 sec)
  3.  
  4. mysql> reset master;
  5. Query OK, 0 rows affected (0.01 sec)

 

2. master1 配置文件修改

vim /etc/my.cnf

 

 
  1. #主服務(wù)器唯一ID
  2. server-id=1
  3. #啟用二進(jìn)制日志
  4. log-bin=mysql-bin
  5. # 設(shè)置不要復(fù)制的數(shù)據(jù)庫(kù)(可設(shè)置多個(gè))
  6. binlog-ignore-db=mysql
  7. binlog-ignore-db=information_schema
  8. binlog-ignore-db=performance_schema
  9. binlog-ignore-db=sys
  10. #設(shè)置需要復(fù)制的數(shù)據(jù)庫(kù)
  11. binlog-do-db=copydb2
  12. #設(shè)置logbin格式
  13. binlog_format=STATEMENT
  14. # 在作為從數(shù)據(jù)庫(kù)的時(shí)候,有寫(xiě)入操作也要更新二進(jìn)制日志文件
  15. log-slave-updates
  16. #表示自增長(zhǎng)字段每次遞增的量,指自增字段的起始值,其默認(rèn)值是1,取值范圍是1 .. 65535
  17. auto-increment-increment=2
  18. # 表示自增長(zhǎng)字段從哪個(gè)數(shù)開(kāi)始,指字段一次遞增多少,他的取值范圍是1 .. 65535
  19. auto-increment-offset=1

 

3. master2 配置文件修改

vim /etc/my.cnf

 

 
  1. #主服務(wù)器唯一ID
  2. server-id=3
  3. #啟用二進(jìn)制日志
  4. log-bin=mysql-bin
  5. # 設(shè)置不要復(fù)制的數(shù)據(jù)庫(kù)(可設(shè)置多個(gè))
  6. binlog-ignore-db=mysql
  7. binlog-ignore-db=information_schema
  8. binlog-ignore-db=performance_schema
  9. binlog-ignore-db=sys
  10. #設(shè)置需要復(fù)制的數(shù)據(jù)庫(kù)
  11. binlog-do-db=copydb2
  12. #設(shè)置logbin格式
  13. binlog_format=STATEMENT
  14. # 在作為從數(shù)據(jù)庫(kù)的時(shí)候,有寫(xiě)入操作也要更新二進(jìn)制日志文件
  15. log-slave-updates
  16. #表示自增長(zhǎng)字段每次遞增的量,指自增字段的起始值,其默認(rèn)值是1,取值范圍是1 .. 65535
  17. auto-increment-increment=2
  18. # 表示自增長(zhǎng)字段從哪個(gè)數(shù)開(kāi)始,指字段一次遞增多少,他的取值范圍是1 .. 65535
  19. auto-increment-offset=2

 

4. slave1 配置文件修改

vim /etc/my.cnf

 

 
  1. #從服務(wù)器唯一ID
  2. server-id=2
  3. #啟用中繼日志
  4. relay-log=mysql-relay

 

5. slave2配置文件修改

 

vim /etc/my.cnf

 

 
  1. #從服務(wù)器唯一ID
  2. server-id=4 #啟用中繼日志
  3. relay-log=mysql-relay

 

6. 雙主機(jī)、雙從機(jī)重啟 mysql 服務(wù), 主機(jī)從機(jī)都關(guān)閉防火墻

 

 
  1. [root@shuidi01 etc]# systemctl restart mysqld
  2. [root@shuidi01 etc]# systemctl status mysqld
  3. ● mysqld.service - MySQL Server
  4. Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
  5. Active: active (running) since 一 2020-03-30 20:38:23 CST; 6s ago
  6. Docs: man:mysqld(8)
  7. http://dev.mysql.com/doc/refman/en/using-systemd.html
  8. Process: 9985 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  9. Process: 9946 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
  10. Main PID: 9990 (mysqld)
  11. CGroup: /system.slice/mysqld.service
  12. └─9990 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
  13.  
  14. 3月 30 20:38:22 shuidi01 systemd[1]: Starting MySQL Server...
  15. 3月 30 20:38:23 shuidi01 systemd[1]: Started MySQL Server.

 

 
  1. [root@shuidi02 etc]# systemctl restart mysqld
  2. [root@shuidi02 etc]# systemctl status mysqld
  3. ● mysqld.service - MySQL Server
  4. Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
  5. Active: active (running) since 一 2020-03-30 20:39:10 CST; 7s ago
  6. Docs: man:mysqld(8)
  7. http://dev.mysql.com/doc/refman/en/using-systemd.html
  8. Process: 868 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  9. Process: 845 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
  10. Main PID: 873 (mysqld)
  11. CGroup: /system.slice/mysqld.service
  12. └─873 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
  13.  
  14. 3月 30 20:39:09 shuidi02 systemd[1]: Starting MySQL Server...
  15. 3月 30 20:39:10 shuidi02 systemd[1]: Started MySQL Server.

 

 
  1. [root@shuidi03 etc]# systemctl restart mysqld
  2. [root@shuidi03 etc]# systemctl status mysqld
  3. ● mysqld.service - MySQL Server
  4. Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
  5. Active: active (running) since 一 2020-03-30 20:39:42 CST; 5s ago
  6. Docs: man:mysqld(8)
  7. http://dev.mysql.com/doc/refman/en/using-systemd.html
  8. Process: 8507 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  9. Process: 8485 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
  10. Main PID: 8512 (mysqld)
  11. CGroup: /system.slice/mysqld.service
  12. └─8512 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
  13.  
  14. 3月 30 20:39:41 shuidi03 systemd[1]: Starting MySQL Server...
  15. 3月 30 20:39:42 shuidi03 systemd[1]: Started MySQL Server.

 

 
  1. [root@shuidi04 etc]# systemctl restart mysqld
  2. [root@shuidi04 etc]# systemctl status mysqld
  3. ● mysqld.service - MySQL Server
  4. Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
  5. Active: active (running) since 一 2020-03-30 20:40:13 CST; 8s ago
  6. Docs: man:mysqld(8)
  7. http://dev.mysql.com/doc/refman/en/using-systemd.html
  8. Process: 8861 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  9. Process: 8839 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
  10. Main PID: 8866 (mysqld)
  11. CGroup: /system.slice/mysqld.service
  12. └─8866 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
  13.  
  14. 3月 30 20:40:12 shuidi04 systemd[1]: Starting MySQL Server...
  15. 3月 30 20:40:13 shuidi04 systemd[1]: Started MySQL Server.

 

7. 在兩臺(tái)主機(jī)上建立賬戶(hù)并授權(quán) slave

master1:

 
  1. mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave'@'%' IDENTIFIED BY 'Zan_666888';
  2. Query OK, 0 rows affected, 1 warning (0.00 sec)
  3. #查詢(xún)Master1的狀態(tài)
  4. mysql> show master status;
  5. +------------------+----------+--------------+-------------------------------------------------+-------------------+
  6. | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
  7. +------------------+----------+--------------+-------------------------------------------------+-------------------+
  8. | mysql-bin.000002 | 435 | copydb2 | mysql,information_schema,performance_schema,sys | |
  9. +------------------+----------+--------------+-------------------------------------------------+-------------------+
  10. 1 row in set (0.00 sec)

master2:

 
  1. mysql> GRANT REPLICATION SLAVE ON *.* TO 'slave'@'%' IDENTIFIED BY 'Zan_666888';
  2. Query OK, 0 rows affected, 1 warning (0.01 sec)
  3. #查詢(xún)Master2的狀態(tài)
  4. mysql> show master status;
  5. +------------------+----------+--------------+-------------------------------------------------+-------------------+
  6. | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
  7. +------------------+----------+--------------+-------------------------------------------------+-------------------+
  8. | mysql-bin.000001 | 435 | copydb2 | mysql,information_schema,performance_schema,sys | |
  9. +------------------+----------+--------------+-------------------------------------------------+-------------------+
  10. 1 row in set (0.00 sec)

#分別記錄下File和Position的值

#執(zhí)行完此步驟后不要再操作主服務(wù)器MYSQL,防止主服務(wù)器狀態(tài)值變化

 

8. 在從機(jī)上配置需要復(fù)制的主機(jī)

Slava1 復(fù)制 Master1,Slava2 復(fù)制 Master2

 

 
  1. #復(fù)制主機(jī)的命令
  2. CHANGE MASTER TO MASTER_HOST='主機(jī)的IP地址',
  3. MASTER_USER='slave',
  4. MASTER_PASSword='123123',
  5. MASTER_LOG_FILE='mysql-bin.具體數(shù)字',MASTER_LOG_POS=具體值;

slave1:

 
  1. CHANGE MASTER TO MASTER_HOST='172.16.94.131',
  2. MASTER_USER='slave',
  3. MASTER_PASSWORD='Zan_666888',
  4. MASTER_LOG_FILE='mysql-bin.000002',MASTER_LOG_POS=435;

slave2:

 
  1. CHANGE MASTER TO MASTER_HOST='172.16.94.133',
  2. MASTER_USER='slave',
  3. MASTER_PASSWORD='Zan_666888',
  4. MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=435;

#啟動(dòng)兩臺(tái)從服務(wù)器復(fù)制功能

slave1:

 
  1. mysql> start slave;
  2. #查看從服務(wù)器狀態(tài)
  3. show slave statusG;
Mysql雙主雙從(實(shí)戰(zhàn)干貨,好文章!!)

 

slave2:

mysql> start slave; #查看從服務(wù)器狀態(tài) show slave statusG;

Mysql雙主雙從(實(shí)戰(zhàn)干貨,好文章!!)

 

#下面兩個(gè)參數(shù)都是Yes,則說(shuō)明主從配置成功!

# Slave_IO_Running: Yes

# Slave_SQL_Running: Yes

 

9. 兩個(gè)主機(jī)互相復(fù)制

Master2 復(fù)制 Master1,Master1 復(fù)制 Master2

 

master2:

 
  1. mysql> CHANGE MASTER TO MASTER_HOST='172.16.94.131',
  2. -> MASTER_USER='slave',
  3. -> MASTER_PASSWORD='Zan_666888',
  4. -> MASTER_LOG_FILE='mysql-bin.000002',MASTER_LOG_POS=435;
  5. Query OK, 0 rows affected, 2 warnings (0.02 sec)
  6.  
  7. mysql> start slave;
  8. Query OK, 0 rows affected (0.00 sec)
  9.  
  10. mysql> show slave statusG;

 

Mysql雙主雙從(實(shí)戰(zhàn)干貨,好文章!!)

 

master1:

 

 
  1. mysql> CHANGE MASTER TO MASTER_HOST='172.16.94.133',
  2. -> MASTER_USER='slave',
  3. -> MASTER_PASSWORD='Zan_666888',
  4. -> MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=435;
  5. Query OK, 0 rows affected, 2 warnings (0.02 sec)
  6.  
  7. mysql> start slave;
  8. Query OK, 0 rows affected (0.00 sec)
  9.  
  10. mysql> show slave statusG;

 

Mysql雙主雙從(實(shí)戰(zhàn)干貨,好文章!!)

 

#下面兩個(gè)參數(shù)都是Yes,則說(shuō)明主從配置成功!

# Slave_IO_Running: Yes

# Slave_SQL_Running: Yes

 

10. Master1 主機(jī)新建庫(kù)、新建表、insert 記錄,Master2 和從機(jī)復(fù)制

 
  1. mysql> CREATE DATABASE copydb2;
  2. Query OK, 1 row affected (0.00 sec)
  3.  
  4. mysql> show databases;
  5. +--------------------+
  6. | Database |
  7. +--------------------+
  8. | information_schema |
  9. | copydb |
  10. | copydb2 |
  11. | mysql |
  12. | nacos_config |
  13. | performance_schema |
  14. | seata |
  15. | seata_account |
  16. | seata_order |
  17. | seata_storage |
  18. | sys |
  19. +--------------------+
  20. 11 rows in set (0.00 sec)
  21.  
  22. mysql> use copydb2;
  23. Database changed
  24. mysql> CREATE TABLE mytbl(id INT,NAME VARCHAR(20));
  25. Query OK, 0 rows affected (0.01 sec)
  26.  
  27. mysql> INSERT INTO mytbl VALUES(1,'zhang3');
  28. Query OK, 1 row affected (0.01 sec)
  29.  
  30. mysql> select * from mytbl;
  31. +------+--------+
  32. | id | NAME |
  33. +------+--------+
  34. | 1 | zhang3 |
  35. +------+--------+
  36. 1 row in set (0.00 sec)

 

Mysql雙主雙從(實(shí)戰(zhàn)干貨,好文章!!)

 

四個(gè)節(jié)點(diǎn)數(shù)據(jù)均實(shí)現(xiàn)了同步

 

11.如何停止從服務(wù)復(fù)制功能

stop slave;

如何重新配置主從

stop slave; reset master;

 

12.修改 Mycat 的配置文件
/usr/local/mycat/conf/schema.xml

修改<dataHost>的balance屬性,通過(guò)此屬性配置讀寫(xiě)分離的類(lèi)型

 

負(fù)載均衡類(lèi)型,目前的取值有4 種:

(1)balance="0", 不開(kāi)啟讀寫(xiě)分離機(jī)制,所有讀操作都發(fā)送到當(dāng)前可用的 writeHost 上。

(2)balance="1",全部的 readHost 與 stand by writeHost 參與 select 語(yǔ)句的負(fù)載均衡,簡(jiǎn)單地說(shuō),當(dāng)雙主雙從

模式(M1->S1,M2->S2,并且 M1 與 M2 互為主備),正常情況下,M2,S1,S2 都參與 select 語(yǔ)句的負(fù)載均衡。

(3)balance="2",所有讀操作都隨機(jī)的在 writeHost、readhost 上分發(fā)。

(4)balance="3",所有讀請(qǐng)求隨機(jī)的分發(fā)到 readhost 執(zhí)行,writerHost 不負(fù)擔(dān)讀壓力

 

為了雙主雙從讀寫(xiě)分離balance設(shè)置為1

 

 
  1. <?xml version="1.0"?>
  2. <!DOCTYPE mycat:schema SYSTEM "schema.dtd">
  3. <mycat:schema xmlns:mycat="http://io.mycat/">
  4.  
  5. <schema name="TESTDB" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
  6.  
  7. </schema>
  8.  
  9. <dataNode name="dn1" dataHost="host1" database="copydb2" />
  10.  
  11. <dataHost name="host1" maxCon="1000" minCon="10" balance="1"
  12. writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
  13. <heartbeat>select user()</heartbeat>
  14.  
  15. <writeHost host="hostM1" url="172.16.94.131:3306" user="root"
  16. password="Zan_123456">
  17.  
  18. <readHost host="hostS1" url="172.16.94.132:3306" user="root" password="Zan_123456" />
  19. </writeHost>
  20.  
  21. <writeHost host="hostM2" url="172.16.94.133:3306" user="root"
  22. password="Zan_123456">
  23.  
  24. <readHost host="hostS2" url="172.16.94.134:3306" user="root" password="Zan_123456" />
  25. </writeHost>
  26.  
  27. </dataHost>
  28.  
  29. </mycat:schema>

#balance="1": 全部的readHost與stand by writeHost參與select語(yǔ)句的負(fù)載均衡。

#writeType="0": 所有寫(xiě)操作發(fā)送到配置的第一個(gè)writeHost,第一個(gè)掛了切到還生存的第二個(gè)

#writeType="1",所有寫(xiě)操作都隨機(jī)的發(fā)送到配置的 writeHost,1.5 以后廢棄不推薦

#writeHost,重新啟動(dòng)后以切換后的為準(zhǔn),切換記錄在配置文件中:dnindex.properties 。

#switchType="1": 1 默認(rèn)值,自動(dòng)切換。

# -1 表示不自動(dòng)切換

# 2 基于 MySQL 主從同步的狀態(tài)決定是否切換。

 

13.啟動(dòng) Mycat,驗(yàn)證讀寫(xiě)分離

 
  1. [root@shuidi01 bin]# ./mycat stop
  2. Stopping Mycat-server...
  3. Mycat-server was not running.
  4. [root@shuidi01 bin]# ./mycat start
  5. Starting Mycat-server...

 

 

 
  1. #登錄mycat
  2. mysql -umycat -pzan123456 -P 8066 -h 127.0.0.1
  3. #插入數(shù)據(jù)
  4. mysql> show databases;
  5. +----------+
  6. | DATABASE |
  7. +----------+
  8. | TESTDB |
  9. +----------+
  10. 1 row in set (0.00 sec)
  11.  
  12. mysql> use TESTDB;
  13. Reading table information for completion of table and column names
  14. You can turn off this feature to get a quicker startup with -A
  15.  
  16. Database changed
  17. mysql> show tables;
  18. +-------------------+
  19. | Tables_in_copydb2 |
  20. +-------------------+
  21. | mytbl |
  22. +-------------------+
  23. 1 row in set (0.00 sec)
  24. mysql> INSERT INTO mytbl VALUES(2,@@hostname);
  25. Query OK, 1 row affected, 1 warning (0.00 sec)
  26.  
  27. mysql> select * from mytbl;
  28. +------+----------+
  29. | id | NAME |
  30. +------+----------+
  31. | 1 | zhang3 |
  32. | 2 | shuidi03 |
  33. +------+----------+
  34. 2 rows in set (0.00 sec)
  35.  
  36. mysql> select * from mytbl;
  37. +------+----------+
  38. | id | NAME |
  39. +------+----------+
  40. | 1 | zhang3 |
  41. | 2 | shuidi02 |
  42. +------+----------+
  43. 2 rows in set (0.00 sec)
  44. mysql> select * from mytbl;
  45. +------+----------+
  46. | id | NAME |
  47. +------+----------+
  48. | 1 | zhang3 |
  49. | 2 | shuidi04 |
  50. +------+----------+
  51. 2 rows in set (0.00 sec)

 

#在Mycat里查詢(xún)mytbl表,可以看到查詢(xún)語(yǔ)句在Master2(shuidi03)、Slava1(shuidi02)、Slava2(shuidi04)主從三個(gè)主機(jī)間切換

 

14.抗風(fēng)險(xiǎn)能力

#停止數(shù)據(jù)庫(kù)Master1

 
  1. [root@shuidi01 logs]# systemctl stop mysqld
  2. [root@shuidi01 logs]# systemctl status mysqld
  3. ● mysqld.service - MySQL Server
  4. Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
  5. Active: inactive (dead) since 一 2020-03-30 21:31:28 CST; 4s ago
  6. Docs: man:mysqld(8)
  7. http://dev.mysql.com/doc/refman/en/using-systemd.html
  8. Process: 9985 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  9. Process: 9946 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
  10. Main PID: 9990 (code=exited, status=0/SUCCESS)
  11.  
  12. 3月 30 20:38:22 shuidi01 systemd[1]: Starting MySQL Server...
  13. 3月 30 20:38:23 shuidi01 systemd[1]: Started MySQL Server.
  14. 3月 30 21:31:16 shuidi01 systemd[1]: Stopping MySQL Server...
  15. 3月 30 21:31:28 shuidi01 systemd[1]: Stopped MySQL Server.

 

#在Mycat里插入數(shù)據(jù)依然成功,Master2自動(dòng)切換為寫(xiě)主機(jī)

 
  1. mysql> INSERT INTO mytbl VALUES(3,@@hostname);
  2. Query OK, 1 row affected, 1 warning (0.00 sec)
  3. mysql> select * from mytbl;
  4. +------+----------+
  5. | id | NAME |
  6. +------+----------+
  7. | 1 | zhang3 |
  8. | 2 | shuidi04 |
  9. | 3 | shuidi04 |
  10. +------+----------+
  11. 3 rows in set (0.00 sec)

 

#啟動(dòng)數(shù)據(jù)庫(kù)Master1

 
  1. [root@shuidi01 logs]# systemctl start mysqld
  2. [root@shuidi01 logs]# systemctl status mysqld
  3. ● mysqld.service - MySQL Server
  4. Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
  5. Active: active (running) since 一 2020-03-30 21:33:39 CST; 2s ago
  6. Docs: man:mysqld(8)
  7. http://dev.mysql.com/doc/refman/en/using-systemd.html
  8. Process: 3527 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  9. Process: 3473 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
  10. Main PID: 3531 (mysqld)
  11. CGroup: /system.slice/mysqld.service
  12. └─3531 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
  13.  
  14. 3月 30 21:33:38 shuidi01 systemd[1]: Starting MySQL Server...
  15. 3月 30 21:33:39 shuidi01 systemd[1]: Started MySQL Server.

 

 
  1. mysql> select * from mytbl;
  2. +------+----------+
  3. | id | NAME |
  4. +------+----------+
  5. | 1 | zhang3 |
  6. | 2 | shuidi01 |
  7. | 3 | shuidi01 |
  8. +------+----------+
  9. 3 rows in set (0.00 sec)
  10. mysql> select * from mytbl;
  11. +------+----------+
  12. | id | NAME |
  13. +------+----------+
  14. | 1 | zhang3 |
  15. | 2 | shuidi02 |
  16. | 3 | shuidi02 |
  17. +------+----------+
  18. 3 rows in set (0.00 sec)
  19. mysql> select * from mytbl;
  20. +------+----------+
  21. | id | NAME |
  22. +------+----------+
  23. | 1 | zhang3 |
  24. | 2 | shuidi04 |
  25. | 3 | shuidi04 |
  26. +------+----------+
  27. 3 rows in set (0.00 sec)

 

#在Mycat里查詢(xún)mytbl表,可以看到查詢(xún)語(yǔ)句在Master1(shuidi01)、Slava1(shuidi02)、Slava2(shuidi04)

主從三個(gè)主機(jī)間切換

Master1、Master2 互做備機(jī),負(fù)責(zé)寫(xiě)的主機(jī)宕機(jī),備機(jī)切換負(fù)責(zé)寫(xiě)操作,保證數(shù)據(jù)庫(kù)讀寫(xiě)分離高

可用性。

分享到:
標(biāo)簽:Mysql
用戶(hù)無(wú)頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過(guò)答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫(kù),初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績(jī)?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績(jī)?cè)u(píng)定