当前位置:网站首页>MySQL master master
MySQL master master
2022-07-28 06:50:00 【[dissimilarity space]】
MySQL Lord
Prepare the environment
- host
| Host name | IP Address 1( Extranet ) | IP Address 2( Intranet ) | System | other |
|---|---|---|---|---|
| mysql-master-01 | 192.168.72.130 | 202.207.240.130 | CentOS7.5.1804 | MEM:2G;CPU:2P/2C;DISK:15G |
| mysql-master-02 | 192.168.72.131 | 202.207.240.131 | CentOS7.5.1804 | MEM:2G;CPU:2P/2C;DISK:15G |
- Configure domain name resolution
- stay mysql-master-01 and mysql-master-02 I'll do it MySQL service
mysql-master-01 Host configuration
- Modify the configuration file /etc/my.cnf
[mysqld]
basedir = /application/mysql
datadir = /application/mysql/data
socket = /tmp/mysql.sock
server_id = 1
log-bin = mysql-bin
binlog-ignore-db = mysql,information_schema
binlog-do-db = master_master
auto_increment_offset = 1
auto_increment_increment = 2
log_bin_trust_function_creators = 1
port = 3306
log_error = /application/mysql/data/error_mysql.err
[mysql]
socket = /tmp/mysql.sock
prompt = wjz [\d]>
| Options | function |
|---|---|
| server_id = 1 | mysql-master-01 Node database ID |
| log-bin = mysql-bin | Turn on log-bin journal |
| binlog-ignore-db = mysql,information_schema | Ignore the databases of primary replication |
| binlog-do-db = master_master | Specify which databases the master replicates |
| auto_increment_offset = 1 | This parameter is generally used in master synchronization , Used to stagger self increment , Prevent key value conflicts |
| auto_increment_increment = 2 | This parameter is usually used in master master synchronization , Used to stagger self increment , Prevent key value conflicts |
| log_bin_trust_function_creators = 1 | Copy the function to slaver【 take SQL from mstaer-01 Copied to the mater-02】 |
Restart the database service
Sign in mysql-master-01 Node database , to grant authorization
Be careful :IP The address needs to log in to this computer IP Address , Not the machine IP Address
grant replication slave,replication client on *.* to 'repl'@'192.168.72.131' identified by '123456';
flush privileges;
show master status;

mysql-master-02 Host configuration
- Modify the configuration file /etc/my.cnf
[mysqld]
basedir = /application/mysql
datadir = /application/mysql/data
socket = /tmp/mysql.sock
port = 3306
log_error = /application/mysql/data/error_mysql.err
server_id = 2
log-bin = mysql-bin
binlog-ignore-db = mysql,information_schema
binlog-do-db = master_master
auto_increment_offset = 2
auto_increment_increment = 2
log_bin_trust_function_creators = 1
[mysql]
socket = /tmp/mysql.sock
prompt = wjz [\d]>
- Restart the database service
- Sign in mysql-master-02 Node database , to grant authorization
grant replication slave,replication client on *.* to 'repl'@'192.168.72.130' identified by '123456';
flush privileges;
show master status;

To configure mysql-master-02 Sync mysql-master-01
- Sign in mysql-master-02 database , do mysql-master-02 Sync mysql-master-01
stop slave;
change master to master_host='192.168.72.130',master_user='repl',master_password='123456',master_log_file='mysql-bin.000001',master_log_pos=1110;
start slave;
show slave status\G;

To configure mysql-master-01 Sync mysql-master-02
- Sign in mysql-master-01 database , do mysql-master-01 Sync mysql-master-02
stop slave;
change master to master_host='192.168.72.131',master_user='repl',master_password='123456',master_log_file='mysql-bin.000003',master_log_pos=632;
start slave;
show slave status\G;

Verify master configuration
Method :
- Log in separately mysql-master-01 and mysql-master-02 database , Select any node to create a database master_master, Check whether the database exists from another node .
- Select any node , Get into master_master database , Create table , And insert data , View table data on another node , And make changes , Return to the first node to check whether the data has been modified successfully .
边栏推荐
- Battle plague Cup -- strange shape
- [untitled]
- Everything you don't know about time complexity is here
- Dynamic planning -- multi-step stair climbing (advanced version of stair climbing)
- Network communication and tcp/ip protocol
- PKU-2524-Ubiquitous Religions(并查集模板)
- Which is the best and most cost-effective air conduction headset recommended
- Mongodb replica set and partitioned cluster
- HDU-1159-CommonSubsequence(LCS最长公共子序列)
- NIO示例
猜你喜欢
![[pta-- use queues to solve the problem of monkeys choosing kings]](/img/54/94359fb3557ac07f7786ecf61a5409.png)
[pta-- use queues to solve the problem of monkeys choosing kings]

What's a good gift for Tanabata? Niche and advanced product gift recommendation
![[C language] string library function introduction and simulation](/img/83/b23fdcbbbd792029083b310c89d4bc.png)
[C language] string library function introduction and simulation
![[hash table basics]](/img/8f/54a4780a02f81e5de3d92c25248e1e.png)
[hash table basics]

Redis cache design and performance optimization

Leetcode brush questions diary sword finger offer II 047. Binary tree pruning

cocos2d-x 学习笔记——瓦片地图TiledMap

Leetcode brush question diary sword finger offer II 053. Medium order successor in binary search tree

It is recommended to wear air conduction earphones, which do not need to wear in ear
![[dynamic planning -- the best period series for buying and selling stocks]](/img/90/9060eabc9b9e7f660504806fde282d.png)
[dynamic planning -- the best period series for buying and selling stocks]
随机推荐
Battle plague Cup -- my account book
数组转链表
网络——网络层
Dynamic planning -- multi-step stair climbing (advanced version of stair climbing)
技术分享 | 实战详解接口测试请求方式Get、post
Water bottle effect production
Dynamic programming -- simple question type of climbing stairs
archery数据库审核平台部署
How to simulate the implementation of strcpy library functions
Graphic pipeline foundation (I)
[hash table basics]
技术分享 | 如何模拟真实使用场景?mock 技术来帮你
HDU-5806-NanoApeLovesSequenceⅡ(尺取法)
OJ 1018 counting game
[dynamic planning -- the best period series for buying and selling stocks]
yapi漏洞挂马程序chongfu.sh处理
Redis cache design and performance optimization
[C language] custom structure type
软件开发中常见模型
Array solution script