Linux下的MySQL主主复制

在这个配置文件中,需要特别注意的三处地方:
log-bin=mysql-bin:这个选项基本默认都是开着的,如果没有打开,可以手动打开。
log-slave-updates:这个选项特别的重要它是为了让slave也能充当master,同时也为了更好的服务于 m-m + s 的环境,保证slave挂在任何一台master上都会接收到另一个master的写入信息。当然不局限于这个架构,级联复制的架构同样也需要log-slave-updates的支持。
server-id = 1:这个ID为服务器ID如果配置一样会出现冲突,而不能复制
接着再看下HA2(192.168.1.232)的mysql配置文件
vim /etc/my.cnf
# Example MySQL config file for very large systems.
#
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
#password      = your_password
port            = 3306
socket          = /usr/local/mysql/tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port            = 3306
socket          = /usr/local/mysql/tmp/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M
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
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
log-slave-updates
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id      = 10
# Replication Slave (comment out master section to use this)

在HA2的mysql配置文件中,除了server-id不一样,其他几乎一模一样。配置文件写好后,我们把两台服务器上的mysql服务器启动起来。

推荐阅读:

相关推荐