真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

MySQL5.7實現(xiàn)GTID功能的實驗流程及結(jié)果

下文給大家?guī)鞰ySQL5.7實現(xiàn)GTID功能的實驗流程及結(jié)果,希望能夠給大家在實際運用中帶來一定的幫助,

創(chuàng)新互聯(lián)是專業(yè)的肅南裕固族自治網(wǎng)站建設(shè)公司,肅南裕固族自治接單;提供做網(wǎng)站、成都做網(wǎng)站,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進行肅南裕固族自治網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!

MYSQL涉及的東西比較多,理論也不多,網(wǎng)上有很多書籍,今天我們就用創(chuàng)新互聯(lián)在行業(yè)內(nèi)累計的經(jīng)驗來做一個解答。

192.168.205.37: as master server 
192.168.205.47: as slave server 
OS: centos 7 1810 with mini install 
mysql-5.7.26-el7-x86_64.tar.gz

GTID(global transaction ID)全局事務(wù)標(biāo)識符,mysql5.6版本開始支持,GTID復(fù)制不像傳統(tǒng)的復(fù)制方式(異步延復(fù)制、半同步復(fù)制)需要找到binlog和pos點,只需要知道m(xù)aster的IP、端口、賬號、密碼即可,開啟GDIT后,執(zhí)行change master to master_auto_position=1即可,它會自動尋找同步。我們使用mysql5.7開啟兩個server,一個為主另一個為從,測試GDIT功能。

  1. 解壓縮文件
    [root@centos7 mysql]#tar xvf mysql-5.7.26-el7-x86_64.tar.gz -C /usr/local/  
  2. 創(chuàng)建軟鏈接
    [root@centos7 local]#ln -s mysql-5.7.26-el7-x86_64/ mysql
  3. 添加mysql帳號
    [root@centos7 local]#useradd -r -s /bin/false mysql
  4. 準(zhǔn)備環(huán)境變量
    [root@centos7 mysql]#echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
    [root@centos7 mysql]#echo $PATH  
  5. 準(zhǔn)備數(shù)據(jù)目錄(可以不建,初始化數(shù)據(jù)庫時會自動創(chuàng)建)
    [root@centos7 mysql]#mkdir /data/mysql
    [root@centos7 mysql]#chown mysql:mysql /data/mysql
  6. 安裝相關(guān)包(跟據(jù)需要安裝,初始化時會提示)
    [root@centos7 mysql]#yum install libaio
  7. 初步化數(shù)據(jù)庫
    [root@centos7 mysql]#mysqld --initialize --user=mysql --datadir=/data/mysql
    2019-08-12T00:43:03.799485Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
    2019-08-12T00:43:04.007086Z 0 [Warning] InnoDB: New log files created, LSN=45790
    2019-08-12T00:43:04.043130Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
    2019-08-12T00:43:04.100702Z 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: 24ddb90b-bc9a-11e9-856e-000c2956e1ea.
    2019-08-12T00:43:04.101693Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
    2019-08-12T00:43:04.102159Z 1 [Note] A temporary password is generated for root@localhost: Ia-ClrMga7L/
  8. 修改數(shù)據(jù)庫配置文件
    [root@centos7 mysql]#cp -b /etc/my.cnf{,.bak}
    [root@centos7 mysql]#rpm -qf /etc/my.cnf
    mariadb-libs-5.5.60-1.el7_5.x86_64
    [root@centos7 mysql]#vi /etc/my.cnf
    [mysqld]
    datadir=/data/mysql
    socket=/data/mysql/mysql.sock                                                                                                      
    log-error=/data/mysql/mysql.log
    pid-file=/data/mysql/mysql.pid
    [client]
    socket=/data/mysql/mysql.sock
  9. 準(zhǔn)備啟動腳本
    [root@centos7 mysql]#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
    [root@centos7 mysql]#chkconfig --list
    [root@centos7 mysql]#chkconfig --add mysqld
    [root@centos7 mysql]#chkconfig --list      
    [root@centos7 mysql]#service mysqld start
    Starting MySQL.Logging to '/data/mysql/mysql.log'.
     SUCCESS! 
  10. 修改密碼
    [root@centos7 mysql]#mysql -p"Ia-ClrMga7L/"
    [root@centos7 mysql]#mysqladmin -uroot -p"Ia-ClrMga7L/" password centos
    [root@centos7 mysql]#mysql -pcentos
  11. 數(shù)據(jù)庫的用戶帳號存放的表發(fā)生了變化,沒有password,用authentication_string代替
    mysql> desc user;
    mysql>  select user,host,authentication_string from user;
    +---------------+-----------+-------------------------------------------+
    | user          | host      | authentication_string                     |
    +---------------+-----------+-------------------------------------------+
    | root          | localhost | *128977E278358FF80A246B5046F51043A2B1FCED |
    | mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
    | mysql.sys     | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
    +---------------+-----------+-------------------------------------------+
    3 rows in set (0.00 sec)
  12. 編輯配置文件設(shè)置主云服務(wù)器,開啟GTID功能
    [root@centos7 ~]#vi /etc/my.cnf        
    [mysqld]
    server-id=37
    log-bin                                                                                                                            
    gtid_mode=ON
    enforce_gtid_consistency
    datadir=/data/mysql
    socket=/data/mysql/mysql.sock
    log-error=/data/mysql/mysql.log
    pid-file=/data/mysql/mysql.pid
    [client]
    socket=/data/mysql/mysql.sock
    [root@centos7 ~]#service mysqld restart
    Shutting down MySQL. SUCCESS! 
    Starting MySQL. SUCCESS! 
  13. 創(chuàng)建復(fù)制帳號
    mysql> grant replication slave on *.* to repluser@'192.168.205.%' identified by 'centos';
    Query OK, 0 rows affected, 1 warning (0.00 sec)
  14. 在從服務(wù)器上設(shè)置配置文件
    [root@centos7 ~]#vi /etc/my.cnf         
    [mysqld]
    server-id=47
    gtid_mode=ON
    enforce_gtid_consistency
    datadir=/data/mysql
    socket=/data/mysql/mysql.sock
    log-error=/data/mysql/mysql.log
    pid-file=/data/mysql/mysql.pid                                                                                                     
    [client]
    socket=/data/mysql/mysql.sock
    [root@centos7 ~]#service  mysqld restart
    Shutting down MySQL.. SUCCESS! 
    Starting MySQL. SUCCESS! 
  15. 在從服務(wù)器上登錄,并修改change master to, 不需要指位置和文件名
    [root@centos7 ~]#mysql -pcentos
    mysql> CHANGE MASTER TO
        ->   MASTER_HOST='192.168.205.37',
        ->   MASTER_USER='repluser',
        ->   MASTER_PASSWORD='centos',
        ->   MASTER_PORT=3306,
        ->   MASTER_AUTO_POSITION=1;
    Query OK, 0 rows affected, 2 warnings (0.01 sec)
  16. 查看復(fù)制狀態(tài)
    mysql> start slave;
    Query OK, 0 rows affected (0.01 sec)
    mysql> show slave status\G
    *************************** 1. row ***************************
                   Slave_IO_State: Waiting for master to send event
                      Master_Host: 192.168.205.37
                      Master_User: repluser
                      Master_Port: 3306
                    Connect_Retry: 60
                  Master_Log_File: centos7-bin.000005
              Read_Master_Log_Pos: 453
                   Relay_Log_File: centos7-relay-bin.000002
                    Relay_Log_Pos: 670
            Relay_Master_Log_File: centos7-bin.000005
                 Slave_IO_Running: Yes
                Slave_SQL_Running: Yes
  17. 測試數(shù)據(jù)庫的復(fù)制
    mysql> create database db1;
    Query OK, 1 row affected (0.01 sec)
  18. 在從服務(wù)器上查看復(fù)制狀態(tài),復(fù)制成功
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | db1                |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    5 rows in set (0.00 sec
  19. 看了以上關(guān)于MySQL5.7實現(xiàn)GTID功能的實驗流程及結(jié)果,如果大家還有什么地方需要了解的可以在創(chuàng)新互聯(lián)行業(yè)資訊里查找自己感興趣的或者找我們的專業(yè)技術(shù)工程師解答的,創(chuàng)新互聯(lián)技術(shù)工程師在行業(yè)內(nèi)擁有十幾年的經(jīng)驗了。 


分享名稱:MySQL5.7實現(xiàn)GTID功能的實驗流程及結(jié)果
鏈接URL:http://weahome.cn/article/pcshph.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部