Configure Master-Slave preparation
Create a test database in our Lord
First log in to master MySQL, or use the absolute path/usr/local/mysql/bin/mysql
Mysql
> CREATE Database db1; > Quit
Copy MySQL Library
123. sql
Copy MySQL Library
123. sql
Log in to master MySQL and view the table. The cuff has been sent over.
MySQL> Use db1; > Show tables;
> Quit
Preparing the configuration file
Vim/etc/my.cnf
Server-id 1if want to log updateslog-bin=bin-log changed to server-id 1if you want to log updateslog-bin=Wangshaojun
Binlog-ignore-db=mysql
The server ID is not the same as other
Log-bin can be customized
BINLOG-DO-DB=DB1,DB2 List of Confessions
Binlog-ignore-db=mysql List blacklist
Restart MySQL
/etc/init.d/mysqld restart
View the new Binlog
Ls/data/mysql
wangshaojun.000001 Wangshaojun.index
Wangshaojun.err Wangshaojun.pid
Authorized
Log in to master MySQL, create a user
' Repl ' @'127.0.0.1'123123';
Grant replication rights user name Repl password 123123
Refresh
> Flush Privileges;
Lock dead Table Read
lock;
Read Master
Show master status;
File wangshaojun.000001
Position 331
Edit the configuration file from MySQL
Vim/usr/local/mysql_slave/my.cnf
Server-id 1 changed to server-id 111
Create a MySQL library and copy the same table as the master MySQL
" CREATE DATABASE DB1 "
Mysql-s/tmp/mysql_slave.sock 123. sql
Log in from MySQL
Mysql-s/tmp/mysql_slave.sock
Stop the operation first,
> slave stop;> change Master to master_host='127.0.0.1', master_port= 3306, master_user='repl', master_password='123123', master_log_file='wangshaojun.000001', master_log_pos=331;
Open
> Slave start;
To see if the configuration was successful
show slave status\g;
Slave_io_running:no
Slave_sql_running:yes
Whether it is two Yes
Let's just stop MySQL.
> slave stop; > Quit
Restart
/etc/init.d/mysqldslave restart
Log in from MySQL
Mysql-s/tmp/mysql_slave.sock
> slave start; > Show slave status\g;
Slave_io_running:yes
Slave_sql_running:yes
The configuration file failed because it was not restarted.
Deploying and Tuning 2.8 MySQL master-slave configuration-2