双主复制:

在两台server配置my.cnf
[root@localhost mysql]# egrep -v "^$|^#" /etc/my.cnf
datadir = /mydata/data
skip_name_resolve = ON
innodb_file_per_table = ON
relay-log = relay-log
auto-increment-offset = 1 表示自增长字段从那个数开始,他的取值范围是1 .. 65535
auto-increment-increment = 2 表示自增长字段每次递增的量,其默认值是1,取值范围是1 .. 65535
log-bin=mysql-bin
binlog_format=mixed
server-id = 1 两台server配置文件几乎一样,只需要指定auto-increment-offset = 1为偶数或者奇数; 在每台server创建可复制的用户和密码如下: 在192.168.8.200创建用户:
MariaDB [(none)]> grant replication slave,replication client ON *.* to 'glq'@'192.168.%.%' identified by '123123';
Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> show master logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001 | 245 |
| mysql-bin.000002 | 28799 |
| mysql-bin.000003 | 1069459 |
| mysql-bin.000004 | 500 |
+------------------+-----------+
4 rows in set (0.00 sec)
MariaDB [(none)]> change master to master_host='192.168.8.201',master_user='glq1',master_password='123123',master_log_file='mysql-bin.000004',master_log_pos=501;
Query OK, 0 rows affected (0.07 sec) MariaDB [(none)]> slave start
-> ;
Query OK, 0 rows affected (0.07 sec)
MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.8.201
Master_User: glq1
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000004
Read_Master_Log_Pos: 593
Relay_Log_File: relay-log.000002
Relay_Log_Pos: 621
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: 593
Relay_Log_Space: 909
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: 2
1 row in set (0.00 sec) 在192.168.8.201创建用户:
MariaDB [(none)]> grant replication slave,replication client on *.* to 'glq1'@'192.168.%.%' identified by '123123';
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> show binary logs;
+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000001 | 245 |
| mysql-bin.000002 | 28799 |
| mysql-bin.000003 | 1069459 |
| mysql-bin.000004 | 501 |
+------------------+-----------+
4 rows in set (0.00 sec)
MariaDB [(none)]> change master to master_host='192.168.8.200',master_user='glq',master_password='123123',master_log_file='mysql-bin.000004',master_log_pos=500;
Query OK, 0 rows affected (0.09 sec)
MariaDB [(none)]> start slave;
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.8.200
Master_User: glq
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000004
Read_Master_Log_Pos: 500
Relay_Log_File: relay-log.000002
Relay_Log_Pos: 529
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: 500
Relay_Log_Space: 817
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: 1
1 row in set (0.00 sec) 测试:
MariaDB [(none)]> create database mydata; //创建数据库;
Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydata |
| mysql |
| performance_schema |
| test |
| testdb |
+--------------------+
6 rows in set (0.00 sec)
MariaDB [(none)]> use mydata;
Database changed
MariaDB [mydata]> show tables;
+------------------+
| Tables_in_mydata |
+------------------+
| test |
+------------------+
1 row in set (0.00 sec) MariaDB [mydata]> desc test;
+--------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------------------+------+-----+---------+----------------+
| id | tinyint(3) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(20) | NO | | NULL | |
| CardID | varchar(20) | YES | | NULL | |
+--------+---------------------+------+-----+---------+----------------+
3 rows in set (0.07 sec) MariaDB [mydata]> insert into test(name,CardID)values('glq',1231223),('zyn',123123321);
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0 在200 server查看验证:
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydata |
| mysql |
| performance_schema |
| test |
| testdb |
+--------------------+
6 rows in set (0.00 sec) MariaDB [(none)]> use mydata;
Database changed
MariaDB [mydata]> create table test(id TINYINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,name varchar(20) not null,CardID varchar(20));
Query OK, 0 rows affected (0.06 sec) MariaDB [mydata]> select * from test;
+----+------+-----------+
| id | name | CardID |
+----+------+-----------+
| 2 | glq | 1231223 |
| 4 | zyn | 123123321 |
+----+------+-----------+
2 rows in set (0.00 sec)
至此主主复制配置完成

mysql master or master copy的更多相关文章

  1. Mysql主从---删除master.info和relya-log.info实验

    relay-log.info, master.info 这连个文件时在建立复制时产生的,现在主要说明以下问题: 1.如果修改删除master.info文件,复制会中断么? 不会,如果stop slav ...

  2. MYSQL 的 MASTER到MASTER的主主循环同步

    MYSQL 的 MASTER到MASTER的主主循环同步   刚刚抽空做了一下MYSQL的主主同步.把步骤写下来,至于会出现的什么问题,以后随时更新.这里我同步的数据库是TEST1.环境描述.   主 ...

  3. MySQL Replication(Master与Slave基本原理及配置)

    MySQL Replication(Master与Slave基本原理及配置) 1.  主从mysql server的工作原理:(如图及其过程分析) 过程:   Mysql的复制(replication ...

  4. Hbase集群master.HMasterCommandLine: Master exiting

    2016-12-15 17:01:57,473 INFO [main] impl.MetricsSystemImpl: HBase metrics system started 2016-12-15 ...

  5. ERROR [main] master.HMasterCommandLine Master exiting

    2018-05-18 07:07:26,257 INFO [main-SendThread(localhost:2181)] zookeeper.ClientCnxn: Opening socket ...

  6. 使用kubeadm进行单master(single master)和高可用(HA)kubernetes集群部署

    kubeadm部署k8s 使用kubeadm进行k8s的部署主要分为以下几个步骤: 环境预装: 主要安装docker.kubeadm等相关工具. 集群部署: 集群部署分为single master(单 ...

  7. git log master..origin/master --oneline | wc -l 怎么知道本地仓库是不是最新的

    git log master..origin/master --oneline | wc -l 怎么知道本地仓库是不是最新的 git fetch   # 一定要先 fetch git log mast ...

  8. org.apache.hadoop.hbase.master.HMasterCommandLine: Master exiting java.lang.RuntimeException: HMaster Aborted

    前一篇的问题解决了,是 hbase 下面lib 包的jar问题,之前写MR的时候加错了包,替换掉了原来的包后出现另一问题:@ubuntu:/home/hadoop/hbase-0.94.6-cdh4. ...

  9. Hbase启动的时候出现:[RpcServer.handler=28,port=60000] ipc.RpcServer: RpcServer.handler=28,port=60000: exiting,master.HMasterCommandLine: Master exiting

    hadoop 版本:CDH5.02 Hbase 版本:hbase-0.96.1.1-cdh5.0.2 配置文件:hbase-site.xml <configuration> <pro ...

随机推荐

  1. win10下搭建深度学习--总结【学习笔记】

    win10 下搭建深度学习开发环境总结: 1.本人环境如下:win10,GTX1050TI.i7,anaconda3,vs2015,cuda9.0,cudnn7.1.4,tensorflow-gpu= ...

  2. 如何解决ubuntu报的错误:You must put some 'source' URIs in your sources.list

    答:添加deb-src开头的源,如 deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-updates multiverse

  3. 使用4K显示器遇到的坑

    第一大坑:鼠标移动变慢,有强烈的滞后感 让人怀疑是不是系统因为要支持4K屏而变慢了,或者是鼠标坏了!甚至猜想是不是4K显示器的屏幕,因为分辨率太高,导致鼠标需要移动的点太多,因而耗时,产生了滞后感. ...

  4. LINQ 学习路程 -- 查询操作 GroupBy ToLookUp

    Grouping Operators Description GroupBy GroupBy操作返回根据一些键值进行分组,每组代表IGrouping<TKey,TElement>对象 To ...

  5. BZOJ 2226 【SPOJ 5971】 LCMSum

    题目链接:LCMSum 这个题显然就是要我们推式子了……那么就来推一波: \begin{aligned}&\sum_{i=1}^n lcm(i,n) \\=&\sum_{i=1}^n\ ...

  6. php while循环

    <html> <body> <?php $i=; ) { echo "The number is " . $i . "<br>& ...

  7. 《F4+2 团队项目需求分析改进》

    a.分析<动态的太阳系模型项目需求规格说明书>初稿的不足. 任务概述描述的有些不具体,功能的规定不详细,在此次作业进行了修改. b.参考<构建之法>8.5节功能的定位和优先级, ...

  8. lvs+keepalived+bind实现负载均衡高可用智能dns【转】

    转:https://www.cnblogs.com/mikeluwen/p/7068356.html 整体架构: 1.IP地址规划: Dns1:172.28.0.54 Dns2:172.28.0.55 ...

  9. 021PHP基础知识——代码重用

    <?php /** * 代码重用 * include() require() 载入文件 * include() 如果载入的文件不存在,提示警告错误. * require() 如果载入的文件不存在 ...

  10. SGU 141.Jumping Joe 数论,拓展欧几里得,二元不等式 难度:3

    141. Jumping Joe time limit per test: 0.25 sec. memory limit per test: 4096 KB Joe is a frog who lik ...