欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Mysql主從復(fù)制GTID

--------------------------------------------

創(chuàng)新互聯(lián)建站于2013年成立,是專(zhuān)業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元農(nóng)安做網(wǎng)站,已為上家服務(wù),為農(nóng)安各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18980820575

安裝準(zhǔn)備

配置/etc/my.cnf

主master grant 分配復(fù)制帳號(hào)

從slave  change ;開(kāi)啟slave;查看狀態(tài);

驗(yàn)證一致性

 

--------------------------------------------

當(dāng)一個(gè)事務(wù)在主庫(kù)端執(zhí)行并提交時(shí),產(chǎn)生GTID,一同記錄到binlog日志中。

binlog傳輸?shù)絪lave,并存儲(chǔ)到slave的relaylog后,讀取這個(gè)GTID值設(shè)置gtid_next變量,告訴slave,下一個(gè)要執(zhí)行的GTID值。sql線程從relay log中獲取GTID,然后對(duì)比slave端的binlog是否有該GTID。如果有記錄,說(shuō)明該GTID的事務(wù)已經(jīng)執(zhí)行過(guò),slave就會(huì)忽略。如果沒(méi)有記錄,slave就會(huì)執(zhí)行該GTID事務(wù),記錄該GTID到自身的binlog,再讀取執(zhí)行事務(wù)前會(huì)先檢查其他session持有該GTID,確保不被重復(fù)執(zhí)行。在解析過(guò)程中會(huì)判斷是否有主鍵,如果沒(méi)有就用二級(jí)索引,如果沒(méi)有就用全部掃面。

--------------------------------------------

MySQL-5.7.17-1.el6.x86_64.rpm-bundle.tar 

tar xf mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar

yum install -y mysql-community-client-5.7.17-1.el6.x86_64.rpm mysql-community-common-5.7.17-1.el6.x86_64.rpm mysql-community-libs-5.7.17-1.el6.x86_64.rpm mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm mysql-community-server-5.7.17-1.el6.x86_64.rpm

/etc/init.d/mysqld start             ##開(kāi)啟服務(wù),初始化,得到一個(gè)uuid和臨時(shí)秘密

2017-03-28T00:46:21.597691Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: f6701f68-134f-11e7-94e7-52540022095a.

2017-03-28T00:46:21.664060Z 1 [Note] A temporary password is generated for root@localhost: I-S>yshos7JT

[root@server3 ~]# mysql -uroot -p        ##修改密碼

Enter password: 

mysql> alter user root@localhost identified by 'Redhat-1024';

Query OK, 0 rows affected (0.09 sec)

vim /etc/my.cnf                    ##編輯文件,進(jìn)行配置

 server-id=3

 gtid-mode=ON

 enforce-gtid-consistency=1                ##開(kāi)啟gtid的一些安全限制

 log-bin=mysql-bin

 binlog-do-db=test

 binlog-ignore-db=mysql

 log-slave-updates

/etc/init.d/mysqld restart            ##更改配置,重啟服務(wù)

mysql> show master status;            ##查看主節(jié)點(diǎn)狀態(tài)

+------------------+----------+--------------+------------------+-------------------+

| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

+------------------+----------+--------------+------------------+-------------------+

| mysql-bin.000004 |      154 | test         | mysql            |                   |

+------

mysql> grant replication slave on *.* to ly@'172.25.38.%' identified by 'Redhat-1024';##分配復(fù)制帳號(hào)

Query OK, 0 rows affected, 1 warning (0.10 sec)

--------------------------------------------

[root@server4 ~]# /etc/init.d/mysqld start

2017-03-28T00:47:40.538466Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 257d874a-1350-11e7-b4ab-525400e717cb.

2017-03-28T00:47:40.661188Z 1 [Note] A temporary password is generated for root@localhost: Aozj4uC:4iff

[root@server4 ~]# mysql -uroot -p

Enter password: 

mysql> alter user root@localhost identified by 'Redhat-1024';

Query OK, 0 rows affected (0.40 sec)

 

[root@server4 ~]# /etc/init.d/mysqld restart

[root@server4 ~]# mysql -uroot -p

Enter password:

 

mysql> change master to master_host='172.25.38.3',master_user='ly',master_password='Redhat-1024',master_auto_position=1;##

mysql> show slave status\G;

   Slave_IO_Running: Yes

            Slave_SQL_Running: Yes

           Retrieved_Gtid_Set: f6701f68-134f-11e7-94e7-52540022095a:1

            Executed_Gtid_Set: f6701f68-134f-11e7-94e7-52540022095a:1

[root@server3 mysql]# mysql -p

Enter password: 

[root@server3 mysql]# cat auto.cnf 

[auto]

server-uuid=f6701f68-134f-11e7-94e7-52540022095a

mysql> show global variables like '%gtid%';

+----------------------------------+------------------------------------------+

| Variable_name                    | Value                                    |

+----------------------------------+------------------------------------------+

| binlog_gtid_simple_recovery      | ON                                       |

| enforce_gtid_consistency         | ON                                       |

| gtid_executed                    | f6701f68-134f-11e7-94e7-52540022095a:1-7 |

| gtid_executed_compression_period | 1000                                     |

| gtid_mode                        | ON                                       |

| gtid_owned                       |                                          |

| gtid_purged                      |                                          |

| session_track_gtids              | OFF                                      |

+----------------------------------+------------------------------------------+

[root@server4 mysql]# cat auto.cnf 

[auto]

server-uuid=257d874a-1350-11e7-b4ab-525400e717cb

mysql> show global variables like '%gtid%';

+----------------------------------+------------------------------------------+

| Variable_name                    | Value                                    |

+----------------------------------+------------------------------------------+

| binlog_gtid_simple_recovery      | ON                                       |

| enforce_gtid_consistency         | ON                                       |

| gtid_executed                    | f6701f68-134f-11e7-94e7-52540022095a:1-7 |

| gtid_executed_compression_period | 1000                                     |

| gtid_mode                        | ON                                       |

| gtid_owned                       |                                          |

| gtid_purged                      | f6701f68-134f-11e7-94e7-52540022095a:1-6 |

| session_track_gtids              | OFF                                      |

+----------------------------------+------------------------------------------+

mysql> grant replication slave on *.* to ly@'172.25.38.%' identified by 'Redhat-1024';

mysql> change master to master_host='172.25.38.3',master_user='ly',master_password='Redhat-1024',master_auto_position=1;

mysql> start slave;

mysql> show slave status\G;

*************************** 1. row ***************************

               Slave_IO_State: Waiting for master to send event

mysql> insert into usertb values(0004,'xiao');

Query OK, 1 row affected (0.13 sec)

Master_Host: 172.25.38.3

Master_User: ly

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000004

Read_Master_Log_Pos: 445

Relay_Log_File: server4-relay-bin.000002

Relay_Log_Pos: 658

Relay_Master_Log_File: mysql-bin.000004

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB: 

Replicate_Ignore_DB: 

Replicate_Do_Table: 

Replicate_Ignore_Table: 

Replicate_Wild_Do_Table: 

Replicate_Wild_Ignore_Table: 

Last_Errno: 0

Last_Error: 

Skip_Counter: 0

Exec_Master_Log_Pos: 445

Relay_Log_Space: 867

Until_Condition: None

Until_Log_File: 

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File: 

Master_SSL_CA_Path: 

Master_SSL_Cert: 

Master_SSL_Cipher: 

Master_SSL_Key: 

Seconds_Behind_Master: 0

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 0

Last_IO_Error: 

Last_SQL_Errno: 0

Last_SQL_Error: 

Replicate_Ignore_Server_Ids: 

Master_Server_Id: 3

Master_UUID: f6701f68-134f-11e7-94e7-52540022095a

Master_Info_File: /var/lib/mysql/master.info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates

Master_Retry_Count: 86400

Master_Bind: 

Last_IO_Error_Timestamp: 

Last_SQL_Error_Timestamp: 

Master_SSL_Crl: 

Master_SSL_Crlpath: 

Retrieved_Gtid_Set: f6701f68-134f-11e7-94e7-52540022095a:1

Executed_Gtid_Set: f6701f68-134f-11e7-94e7-52540022095a:1

Auto_Position: 1

Replicate_Rewrite_DB: 

Channel_Name: 

Master_TLS_Version: 

1 row in set (0.00 sec)

 

mysql> select * from test.usertb

    -> ;

+----+----------+

| id | name     |

+----+----------+

|  1 | zhangsan |

|  2 | wang     |

|  3 | lisi     |

+----+----------+

mysql> insert into usertb values(0004,'xiao');

Query OK, 1 row affected (0.13 sec)

 

mysql> select * from test.usertb;

+----+----------+

| id | name     |

+----+----------+

|  1 | zhangsan |

|  2 | wang     |

|  3 | lisi     |

|  4 | xiao     |

+----+----------+

 


網(wǎng)站標(biāo)題:Mysql主從復(fù)制GTID
URL標(biāo)題:http://chinadenli.net/article20/gisdco.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、企業(yè)建站、外貿(mào)建站營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、自適應(yīng)網(wǎng)站、App開(kāi)發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化