Description: There are many students can not be a one-time experiment to do success, it is not familiar with, suggest at least do 3 times
17.1 MySQL Master-slave introduction
17.2 preparatory work
Prepare two computers, both of which are installed MySQL, and start with the same operation as follows;
#ps aux | grep MySQL
Download MySQL, #wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz // Download MySQL
#cd/usr/local/src/
#ls
Unzip MySQL, #tar zxvf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
#mv Mysql-5.6.36/usr/local/mysql
#cd/usr/local/mysql/
Create a MySQL user beforehand, then next
#./scripts/mysql_install_db--user=mysql--datadir=/data/mysql
#echo $? If 0, the installation is successful, or the installation process, prompted two OK;
#vim/ETC/MY.CNF//Modify the following content
Datadir=/data/mysql
Socket=/tmp/mysql.sock
#cp Support-files/mysql.server/etc/init.d/mysqld
#vim/etc/init.d/mysqld//Modify the following content
Basedir=/usr/local/mysql
Datadir=/data/mysql
#/etc/init.d/mysqld start
If you start an error, check the errors log below
#cd/data/mysql
#ls
#tail Aminglinux-01.err
#less!$
#ls-L/data/mysql
#chown-R Mysql:mysql
#/etc/init.d/mysqld start
#!ps
Set boot #chkconfig mysqld on
17.3 Configuring the Master
#vim/etc/my.cnf
Add the following two lines in [Mysqld]
server-id=130
Log_bin=aminglinux1
#/etc/init.d/mysqld restart
#ls-LT//Can see a number of files beginning with aminglinux1, very important;
#mysqldump-uroot-paminglinux Blog >/tmp/blog.sql
#du-sh/tmp/blog.sql
#mysql-uroot-e "CREATE Database Aming"
#mysql-uroot aming </tmp/blog.sql
#mysql-uroot-paminglinux
mysql> Grant replication Slave on * * to ' repl ' @slave_ip identified by ' password '
mysql> flush tables with read lock;
mysql> Show master status; Remember File,position,
Mysql> quit
Backup, #mysqldump-uroot-paminglinux mysql2 >/tmp/my2.sql
Backup, #mysqldump-uroot-paminglinux zrlog >/tmp/zrlog.sql
17.4 Configuration from
#vim/etc/my.cnf//Increase server-id=131,131 as the last number of IP, can also be arbitrarily defined;
#/etc/init.d/mysqld restart
#ls/data/mysql
#scp 192.168.133.130:/tmp/*.sql/tmp/
#alias ' Mysql=/usr/local/mysql/bin/mysql '
#alias ' mysqldump=/usr/local/mysql/bin/mysqldump '
#mysql-uroot
mysql> CREATE database aming;
mysql> CREATE database Zrlog;
mysql> CREATE database blog;
mysql> CREATE database mysql2;
mysql> quit
#mysql-uroot Blog </tmp/blog.sql
#mysql-uroot zrlog</tmp/zrlog.sql
#mysql-uroot aming </tmp/blog.sql
#mysql-uroot Mysql2 </tmp/my2.sql
#mysql-uroot
mysql> stop slave;
mysql> Change master to master_host= ' 192.168.133.130 ', master_user= ' repl ', master_password= ' aminglinux111 ', Master_log _file= ' aminglinux1.000001 ', master_log_pos=474566;
mysql> start slave;
mysql> Show Slave Status\g
17.5 testing master-Slave synchronization
The Lord operates as follows:
#mysql-uroot aming
Mysql>select Count (*) from DB;
mysql>truncate table db;
From the top actions are as follows:
#mysql-uroot aming
Mysql>select Count (*) from DB;
Some classmates, encounter the master-slave can not be normal synchronization, prompt uuid the same error. This is because the cloning machine is causing.
Https://www.2cto.com/database/201412/364479.html
Linux Learning Note May 16 task