问题:
解决:
master:
- 编辑文件./master_conf.d/master.cnf
|
[mysqld] server-id=1 log-bin=mysql-bin |
2. 用./master_conf.d/master.cnf 启动mysql master
|
docker run -d -e MYSQL_ROOT_PASSWORD=123456 -p 4000:3306 -v $(pwd)/master_conf.d:/etc/mysql/conf.d --name mysql-master mysql |
3. create user
slave:
- 编辑文件 ./slave_conf.d/slave.cnf
- 用 ./slave_conf.d/slave.cnf 启动 mysql slave
|
docker run --link mysql-master:mysql-master -d -e MYSQL_ROOT_PASSWORD=123456 -p 4010:3306 -v $(pwd)/slave_conf.d:/etc/mysql/conf.d --name mysql-slave1 mysql |
- fdsa
|
change master to master_host='mysql-master', master_user='repl', master_password='12345678', master_log_file='mysql-bin.000004', master_log_pos=154; |
- fds
参考:
https://dev.mysql.com/doc/refman/5.6/en/replication-howto.html
|
There are some generic tasks that are common to all replication setups: On the master, you must enable binary logging and configure a unique server ID. This might require a server restart. See Section 17.1.1.1, “Setting the Replication Master Configuration”. On each slave that you want to connect to the master, you must configure a unique server ID. This might require a server restart. See Section 17.1.1.2, “Setting the Replication Slave Configuration”. Optionally, create a separate user for your slaves to use during authentication with the master when reading the binary log for replication. See Section 17.1.1.3, “Creating a User for Replication”. Before creating a data snapshot or starting the replication process, you should record the position of the binary log on the master. You will need this information when configuring the slave so that the slave knows where within the binary log to start executing events. See Section 17.1.1.4, “Obtaining the Replication Master Binary Log Coordinates”. If you already have data on your master and want to use it to synchronize your slave, you need to create a data snapshot. There are different methods to create the database snapshot, depending on the size of the database and the location of the files. Create a snapshot using mysqldump (see Section 17.1.1.5, “Creating a Data Snapshot Using mysqldump”) or by copying the data files directly (see Section 17.1.1.6, “Creating a Data Snapshot Using Raw Data Files”). Configure the slave with settings for connecting to the master, such as the host name, login credentials, and binary log file name and position. See Section 17.1.1.10, “Setting the Master Configuration on the Slave”. |