mysql -uroot -p #登陆数据库
show master status; #查看binlog日志文件和pos点
**mysql-bin.000001 | 399**
grant replication slave on *.* to repl@'192.168.47.%' identified by 'repl'; #授权同步用户
mysql -uroot -p #登陆数据库
show master status; #查看binlog日志文件和pos点
**mysql-bin.000001 | 399**
grant replication slave on *.* to repl@'192.168.47.%' identified by 'repl'; #授权同步用户
CHANGE MASTER TO
MASTER_USER='repl',
MASTER_HOST='192.168.47.131',
MASTER_PASSWORD='repl',
MASTER_PORT=3306,
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=399; #设置主服务器为mysql1
start slave; #启动主从
show slave status\G
**Slave_IO_Running: Yes**
**Slave_SQL_Running: Yes**
5.安装keepalived
yum -y install keepalived
systemctl enable keepalived #开机启动keepalived
6.配置keepalive高可用
6.1 配置mysql为MASTER节点
vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
180311 18:31:34 [ERROR] Slave I/O: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; thesesame-server-id option must be used on slave but this does not always make sense; please check the manual before using it). Error_code:
180311 18:31:34 [Note] Slave I/O thread exiting, read up to log 'FIRST', position 4
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
[mysqld]
datadir=/var/lib/mysql
server-id=132
log-bin=mysql-bin
auto-increment-offset=2
auto-increment-increment=2
log-slave-updates=true
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd