mysql5.1.73 双主的玩法

版权声明:本文为博主原创文章,未经博主允许可以转载。 https://blog.csdn.net/ccagy/article/details/82147126

A机:

[client]
#password       = your_password
port            = 3306
socket          = /tmp/mysql.sock

# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-locking
key_buffer_size = 384M
max_allowed_packet = 128M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

log-bin=mysql-bin
binlog-do-db=t_test
server-id       = 1
auto-increment-increment=2
auto-increment-offset=1

log-slave-updates

[mysqldump]
quick
max_allowed_packet = 128M


[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

B机:

[client]
#password       = your_password
port            = 3306
socket          = /tmp/mysql.sock

# Here follows entries for some specific programs
server_id=2
# The MySQL server
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-locking
key_buffer_size = 384M
max_allowed_packet = 128M
table_open_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
server_id=2

# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

# binary logging is required for replication
log-bin=mysql-bin
binlog-do-db=t_test   ----指定数据库名称
server-id       = 2
auto-increment-increment=2
auto-increment-offset=2

log-slave-updates

[mysqldump]
quick
max_allowed_packet = 128M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
--------------------------------------

A机先搞一下

GRANT REPLICATION SLAVE ON *.* TO 'root' @'%' IDENTIFIED BY '';

mysql> flush privileges;

mysql> show master status;

记录下position的值

B机也搞一下

GRANT REPLICATION SLAVE ON *.* TO 'root' @'%' IDENTIFIED BY '';

mysql> flush privileges;

mysql> show master status;

也记录position的值

然后

A 机B机相互授权

B机

CHANGE MASTER TO MASTER_HOST='172.16.108.71',MASTER_USER='root',MASTER_PASSWORD='',MASTER_LOG_FILE='mysql-bin.000005',MASTER_LOG_POS=235;

START SLAVE;
 

A机

CHANGE MASTER TO MASTER_HOST='172.16.108.72',MASTER_USER='root',MASTER_PASSWORD='',MASTER_LOG_FILE='mysql-bin.000011',MASTER_LOG_POS=430;

START SLAVE;
 

然后测试增删改查

猜你喜欢

转载自blog.csdn.net/ccagy/article/details/82147126