centos7mysql5.6.30单机多实例配置主主复制

1.在原来单实例的基础上修改配置/usr/my.cnf

[mysqld_multi]

mysqld=/usr/bin/mysqld_safe

mysqladmin=/usr/bin/mysqladmin

user=root

[mysqld3306]

port=3306

socket=/var/lib/mysql/mysql.sock

pid-file=/var/lib/mysql/localhost.localdomain.pid

datadir=/var/lib/mysql/

user=root

character_set_server=utf8

lower_case_table_names=1

max_connections=300

server-id=1

binlog-do-db=test

log-bin=master-bin

log-bin-index=master-bin.index

relay-log=slave-relay-bin

relay-log-index=slave-relay-bin.index

auto-increment-increment = 2

auto-increment-offset = 1

[mysqld3307]

port=3307

socket=/home/fuyouling/mutl_mysql/mysql_3307/mysql/mysql.sock

pid-file=/home/fuyouling/mutl_mysql/mysql_3307/mysql/localhost.localdomain.pid

datadir=/home/fuyouling/mutl_mysql/mysql_3307/mysql/

user=root

character_set_server=utf8

lower_case_table_names=1

max_connections=300

server_id=2

log-bin=master-bin

log-bin-index=master-bin.index

replicate-do-db=test

relay-log=slave-relay-bin

relay-log-index=slave-relay-bin.index

auto-increment-increment = 2

auto-increment-offset = 2

2.在3306服务器建立复制账户

mysqld_multi --defaults-extra-file=/usr/my.cnf start 3306 #开启3306服务

mysql -uroot -p123456 -S /var/lib/mysql/mysql.sock        #登录mysql

mysql>grant replication slave,replication client on *.* to [email protected]‘localhost‘ identified by ‘repl1‘; #在主服务器上建立复制用户

mysql>flush privileges;  #刷新权限

3.在3307服务器上建立复制账户

mysqld_multi --defaults-extra-file=/usr/my.cnf start 3307 #开启3307服务

mysql -uroot -p654321 -S /home/fuyouling/mutl_mysql/mysql_3307/mysql/mysql.sock #登录mysql

mysql>grant replication slave,replication client on *.* to [email protected]‘localhost‘ identified by ‘repl2‘; #在主服务器上建立复制用户

mysql>flush privileges;  #刷新权限

4.在3306服务器上建立slave 连接master的信息

Change Master to Master_host=‘127.0.0.1‘,Master_port=3307,Master_user=‘repl2‘,Master_Password=‘repl2‘;

5.在3307从服务器上建立slave 连接master的信息

Change Master to Master_host=‘127.0.0.1‘,Master_port=3306,Master_user=‘repl1‘,Master_Password=‘repl1‘;

6.在3306上检查主从信息:

mysql> show master status;

+-------------------+----------+--------------+------------------+-------------------+

| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

+-------------------+----------+--------------+------------------+-------------------+

| master-bin.000003 |      120 | test         |                  |                   |

+-------------------+----------+--------------+------------------+-------------------+

1 row in set (0.00 sec)

mysql> show slave status\G

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 127.0.0.1

Master_User: repl2

Master_Port: 3307

Connect_Retry: 60

Master_Log_File: master-bin.000003

Read_Master_Log_Pos: 120

Relay_Log_File: slave-relay-bin.000008

Relay_Log_Pos: 284

Relay_Master_Log_File: master-bin.000003

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: 120

Relay_Log_Space: 621

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

Master_UUID: 04793bcc-3e99-11e6-ab0c-000c29569f32

Master_Info_File: /var/lib/mysql/master.info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set:

Executed_Gtid_Set:

Auto_Position: 0

1 row in set (0.00 sec)

7.在3307上检查主从信息

mysql> show master status;

+-------------------+----------+--------------+------------------+-------------------+

| File              | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |

+-------------------+----------+--------------+------------------+-------------------+

| master-bin.000003 |      120 |              |                  |                   |

+-------------------+----------+--------------+------------------+-------------------+

1 row in set (0.00 sec)

mysql> show slave status\G

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 127.0.0.1

Master_User: repl1

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: master-bin.000003

Read_Master_Log_Pos: 120

Relay_Log_File: slave-relay-bin.000007

Relay_Log_Pos: 284

Relay_Master_Log_File: master-bin.000003

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB: test

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: 120

Relay_Log_Space: 621

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

Master_UUID: be707b89-20cf-11e6-a8d0-000c29569f32

Master_Info_File: /home/fuyouling/mutl_mysql/mysql_3307/mysql/master.info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set:

Executed_Gtid_Set:

Auto_Position: 0

1 row in set (0.00 sec)

8.测试

(1)

在3306上新建表test_table4

mysql> use test;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;

+----------------+

| Tables_in_test |

+----------------+

| test_table1    |

| test_table2    |

| test_table3    |

+----------------+

3 rows in set (0.00 sec)

mysql> create table test_table4(id int,str varchar(100));

Query OK, 0 rows affected (0.03 sec)

登录3307上查看

mysql> use test;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;

+----------------+

| Tables_in_test |

+----------------+

| test_table1    |

| test_table2    |

| test_table3    |

| test_table4    |

+----------------+

4 rows in set (0.00 sec)

(2)

在3307上创建新表test_table5

mysql> create table test_table5(id int,str varchar(100));

Query OK, 0 rows affected (0.05 sec)

在3306上查看

mysql> show tables;

+----------------+

| Tables_in_test |

+----------------+

| test_table1    |

| test_table2    |

| test_table3    |

| test_table4    |

| test_table5    |

+----------------+

5 rows in set (0.00 sec)

备注:这个其实是主主复制下的主动-主动模式。

时间: 2024-08-02 10:54:09

centos7mysql5.6.30单机多实例配置主主复制的相关文章

Tomcat(tomcat虚拟主机,Tomcat日志,单机多实例配置实战,JVM设置和连接数设置)

一.配置Tomcat的虚拟主机 一.Tomcat虚拟主机基本配置. 在介绍nginx和apache的时候,我们都有提过虚拟主机,在tomcat中也有这么一说, [[email protected] ~]# vim /usr/local/tomcat/conf/server.xml 搜索/Host,其中<Host>和</Host>之间的配置为虚拟主机配置部分,name定义域名,appBase定义应用的目录,Java的应用通常是一个Jar的压缩包,将jar的压缩包放到appBase目录

[转载]Tomcat单机多实例配置

Tomcat单机多实例配置 当一个进程的线程超过500个的话,那么这个进程的运行效率会变得很低.因为一个进程产生过多的线程,CPU资源会浪费在线程间切换过程当中.但当服务器配置很高的情况下,如:32G内存,16核的CPU.这样一台高配的机器上只装一个Tomcat实例,会有点浪费.其实我们可以根据服务器的硬件配置,配置多个Tomcat实例,充分利用硬件的资源.你第一时间可能会想到,直接下载多份Tomcat安装包,直接解压,改下端口跑起来不就可以了? 这样也是可以的,但不好维护.假设你在一台机器上安

centos7下mysql5.6.30配置单机多实例主从半同步复制

1.在master主服务器上执行: mysql> INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so'; Query OK, 0 rows affected (0.30 sec) mysql> SET GLOBAL rpl_semi_sync_master_enabled = 1; Query OK, 0 rows affected (0.02 sec) mysql> SET GLOBAL rpl_semi_syn

Redis的make,make test,make install、单机多实例配置,以及API程序写数据!

最近学习王家林老师的大数据蘑菇云行动,要实现将Spark Streaming分析的数据写入到Redis.今天正好开始入手.  一.Ubuntu16安装Redis3.2.1 遇到了不少的问题,其中,make倒是没问题,make test的时候,出现了: !!! WARNING The following tests failed: *** [err]: Slave should be able to synchronize with the master in tests/integration/

Tomcat单机多实例配置

配置多实例目录: 安装好tomcat后,创建三个实例目录,将主站点的:conf. work .temp.logs目录分别复制到3个实例目录下. 1 [[email protected] tomcat]# mkdir {bbs.fox.com,www.fox.com,e-mail.fox.com} 2 [[email protected] tomcat]# cp -r conf logs temp work ./bbs.fox.com 3 [[email protected] tomcat]# c

MySQL单机多实例配置

1.安装说明 (1).将所有的安装文件.配置文件.数据目录全部放存/data/mysql目录中,便于今后实现快速迁移.整体备份和快速复制: (2).在一台服务器上运行四个MySQL实例,分别绑定在3306.3307.3308.3309端口上 (3).四个实例都开启binlog日志,数据目录分别存放在/data/mysql/data1./data/mysql/data2./data/mysql/data3./data/mysql/data4 (4).四个实例均采用InnoDB作为默认的存储引擎,字

tomcat之 Tomcat 7.0.78 单机多实例配置

前言:JDK(JavaDevelopment Kit)是Sun Microsystems针对Java开发员的产品.自从Java推出以来,JDK已经成为使用最广泛的javaSDK. JDK是整个Java的核心,包括了Java运行环境,Java工具和Java基础的类库.所以要想运行jsp的程序必须要有JDK的支持,理所当然安装Tomcat的前提是安装好JDK. 一. JDK安装 1. 查看os版本[[email protected]MySQL ~]# uname -aLinux mysql 2.6.

MySQL单机多实例配置实战

本文主要介绍在CentOS6.9下快速安装和部署MySQL多实例 基本流程: 1.Mysql多实例介绍 2.安装MySQL多实例 3.创建MySQL多实例的数据文件目录以及配置文件 4.创建MySQL多实例的启动文件 5.配置文件权限和软链接 6.初始化MySQL多实例的数据库文件 7.启动MySQL多实例数据库 8.配置和管理MySQL多实例数据库 流程一:Mysql多实例介绍 简单的说,Mysql多实例就是在一台服务器上同时开启多个不同的服务端口(如 : 3306/3307/3308)同时运

mysql 单机多实例配置

如果你想在一台机器上进行主从配置实验,本篇可以帮助你实现愿望 [client] #password = your_password port = 3306 socket = /tmp/mysql.sock [mysqld] port = 3306 socket = /tmp/mysql.sock datadir = /data/mysqldata skip-external-locking key_buffer_size = 64M max_allowed_packet = 1M table_o