grant replication slave on *.* to repl@‘ip‘ identified by ‘xxx‘;
flush privileges;
change master to master_host=‘192.168.1.103‘,master_port=3306,master_user=‘repl‘,master_password=‘ffffff‘,master_auto_position=1;
start slave;
show slave status\G
my.cnf文件
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[client]
port = 3306
socket = /tmp/mysqld1.sock
[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
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql1
datadir = /data/mysql1
port = 3306
socket = /tmp/mysqld1.sock
server-id = 1
#binlog
log-bin = /data/mysql1/logs/mysql1-bin
binlog_format = row
binlog-row-image = minimal
binlog_cache_size = 512K
max_binlog_size = 100M
gtid-mode=on
enforce-gtid-consistency=true
log-slave-updates=true
slave_parallel_workers = 2
sync_binlog = 1
#relay log
relay-log = /data/mysql1/logs/relay1-log
max_relay_log_size = 100M
#check binlog
binlog_checksum = CRC32
slave_allow_batching = 1
master_verify_checksum = 1
slave_sql_verify_checksum = 1
binlog_rows_query_log_events = 1
master-info-repository=TABLE
relay-log-info-repository=TABLE
sync-master-info=1
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
replicate-ignore-db=mysql
replicate-ignore-db=information_schema
replicate-ignore-db=performance_schema
auto-increment-increment=10
auto-increment-offset=1
# 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
原文地址:http://y920895.blog.51cto.com/7857176/1784328