主库配置:
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
server_id=1 (主库的值为1)
#datadir=/var/lib/mysql
datadir=/xxx/mysql
#socket=/var/lib/mysql/mysql.sock
socket=/xxx/mysql/mysql.sock
#log-bin = mysql-bin
#binlog_format = mixed
#log-bin=ON
#####binlog-ignore-db为忽略同步哪个库,忽略多个库就添加多行
binlog-ignore-db=xxxx
binlog-ignore-db=xxxx
binlog-ignore-db=xxxx
###开启binlong日志
log-bin=/xxxx/binlogs/mysql-bin
#log-bin=/var/log/mariadb/mysql-bin
symbolic-links=0
####独立表存储空间
innodb_file_per_table=1
#event_scheduler=ON
max_allowed_packet=64M
###开启满查询日志
slow-query-log=On
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
####错误日志
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
----------------------------------------------------------------------------------------
从库主要配置:
[mysqld]
server-id=2 (从库的serverId为2)
skip-slave-start=true
read_only=ON (控制从库只读模式)
relay-log=relay-bin
relay-log-index=relay-bin.index
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
datadir=/xxx/mysql
socket=/xxx/mysql/mysql.sock