{ mysql } MySQL单机多实例及主从复制

没有过多的,直接上码

my.cnf


[mysql_multi]
mysqld      = /usr/bin/mysqld_safe
mysqladmin  = /usr/bin/mysqladmin
user        = multi_admin
password    = multi_pass
log         = /var/log/mysqld_multi.log

[mysqld1]
socket     = /var/lib/mysql/mysql.sock1
port       = 3306
log-error  = /var/log/mysqld1.log
pid-file   = /var/run/mysqld/mysqld1.pid
datadir    = /var/lib/mysql/data
user       = mysql
#master
log-bin     = mysql-bin
server-id   = 1

[mysqld2]
socket     = /var/lib/mysql/mysql.sock2
port       = 3307
log-error  = /var/log/mysqld2.log
pid-file   = /var/run/mysqld/mysqld2.pid
datadir    = /var/lib/mysql/data2
user       = mysql
#slave
log-bin     = mysql-bin
server-id   = 2

---------- operate  ----------------------------------------
#enter master mysql console ,mysqld1
#>mysql -uroot -p -S /var/lib/mysql/mysql.sock1
#>show master status\G
#>show master status;
#>grant replication slave, replication client on *.* to slave@'10.249.145.197' identified by 'password';
#>flush privileges;

#enter slave mysql console ,mysqld2
#>mysql -uroot -p -S /var/lib/mysql/mysql.sock2
#>show slave status\G
#>show slave status;
#>change master to master_host='192.168.10.107',
master_port=3306, master_user='slave', master_password='password', master_log_file='mysql-bin.000018', master_log_pos=107;
#>start slave;

#mysqld_multi opt
#>mysqld_multi [start|stop|report]

你可能感兴趣的:({ mysql } MySQL单机多实例及主从复制)