当前位置:网站首页>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 .
边栏推荐
- Two dimensional array practice: spiral matrix
- 测试面试题集锦(三)| 计算机网络和数据库篇(附答案)
- Compilation and preprocessing of C language
- rancher部署实战
- ISO 3.0-server three power separation configuration
- [dynamic planning -- the best period for buying and selling stocks Series 2]
- Water rendering example
- 链表中结点的插入和删除
- Which is the best and most cost-effective air conduction headset recommended
- 遍历 二叉树
猜你喜欢
随机推荐
等保3.0-服务器三权分立配置
Scratch command
设计测试用例的方法
技术分享 | 使用 cURL 发送请求
Mongodb replica set and partitioned cluster
js 变量等于0也等也' '问题
进程和线程的区别
如何描述一个BUG以及BUG级别的定义、生命周期
Graphic pipeline foundation (part outside)
Which is the best and most cost-effective air conduction headset recommended
How to calculate the size of structure, segment and Consortium (common body)
mongo ssl 配置实战
feignclient @RequestMapping参数设置及请求头简易方式设置
Feignclient @requestmapping parameter setting and simple method setting of request header
软件测试的生命周期(流程)
Graphic pipeline foundation (II)
Mysql-8.0.17-winx64 (additional Navicat) manual configuration version installation
什么是线性表?
elastic常用高频命令
JS逆向100题——第1题









