日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

mysql5.7主从

發(fā)布時(shí)間:2024/9/30 数据库 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql5.7主从 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1:主mysql,創(chuàng)建復(fù)制用戶

mysql> create user 'repl'@'172.xx.xx.%' identified by 'xxxx'; Query OK, 0 rows affected (0.01 sec)mysql> grant replication slave on *.* to 'repl'@'172.xx.xx.%' identified by 'xxx'; Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)mysql> select user,host from mysql.user; +---------------+-------------+ | user | host | +---------------+-------------+ | jiangxin | % | | jxgitea | % | | repl | 172.19.30.% | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +---------------+-------------+ 6 rows in set (0.00 sec)

2:查看binlog

mysql> show master status; +------------------+-----------+--------------+-------------------------------------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+-----------+--------------+-------------------------------------------------+-------------------+ | mysql-bin.000039 | 212379497 | | information_schema,performance_schema,mysql,sys | | +------------------+-----------+--------------+-------------------------------------------------+-------------------+ 1 row in set (0.00 sec)mysql> show slave hosts; Empty set (0.00 sec)mysql> show slave hosts; +-----------+------+------+-----------+--------------------------------------+ | Server_id | Host | Port | Master_id | Slave_UUID | +-----------+------+------+-----------+--------------------------------------+ | 223 | | 3306 | 66 | f7378ba7-897d-11e8-88cd-00163e06c223 | +-----------+------+------+-----------+--------------------------------------+ 1 row in set (0.00 sec)

從配置成功,show slave hosts;才不為空

1:slave配置

stop slave;
change master to master_host='IP',master_user='xxx',master_password='xxxxxx',master_log_file='mysql-bin.000039',master_log_pos=212379497;
start slave;

------------------
stop slave;
set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
start slave;

配置過程中出現(xiàn)的問題

1:修改server-id

[root@izuf69ftqv2b857mlhbdvgz ~]# cat /etc/my.cnf
[mysqld]
server-id=223

2:The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.

[root@iZbpycie06u04lZ ~]# cat /usr/local/mysql/data/auto.cnf
[auto]
server-uuid=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[root@iZbpycie06u04lZ ~]# vi /usr/local/mysql/data/auto.cnf

3:Master command COM_REGISTER_SLAVE failed: Access denied for user 'root'@'%' (using password: YES) (Errno: 1045)

GRANT REPLICATION SLAVE ON *.* TO xxxxxx@'%' IDENTIFIED BY 'xxxxxx';
flush privileges;

?

4:?Slave failed to initialize relay log info structure from the repository

mysql> start slave; ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository mysql> reset slave; Query OK, 0 rows affected (0.01 sec)mysql> start slave; Query OK, 0 rows affected (0.01 sec)

slave reset執(zhí)行候做了這樣幾件事:
1、刪除slave_master_info ,slave_relay_log_info兩個(gè)表中數(shù)據(jù);
2、刪除所有relay log文件,并重新創(chuàng)建新的relay log文件;

?

總結(jié)

以上是生活随笔為你收集整理的mysql5.7主从的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。