mysql lvs keepalive_Keepalive+LVS+MySQL的高可用的双机解决方案

第三:MySQL在备用节点上的设置

[root@localhost ~]# /etc/init.d/mysqld start

[root@localhost ~]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.0.77-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>  grant replication slave,file on *.* to 'repl2'@'192.168.1.196' identified by '123456';

Query OK, 0 rows affected (0.02 sec)

mysql> \q

Bye

[root@localhost ~]# /etc/init.d/mysqld stop

[root@localhost ~]# vi /etc/my.cnf

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

log-bin=mysql-bin

server-id=2

binlog-do-db=test

binlog-ignore-db=mysql

replicate-do-db=test

replicate-ignore-db=mysql

log-slave-updates

slave-skip-errors=all

sync_binlog=1

auto_increment_increment=2

auto_increment_offset=2

[root@localhost ~]# /etc/init.d/mysqld start

[root@localhost ~]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.0.77-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>  flush tables with read lock\G

Query OK, 0 rows affected (0.00 sec)

mysql>  show master status\G

*************************** 1. row ***************************

File: mysql-bin.000001

Position: 98

Binlog_Do_DB: test

Binlog_Ignore_DB: mysql

1 row in set (0.00 sec)

mysql> change master to  master_host='192.168.1.196', master_user='repl1', master_password='123456',  master_log_file='mysql-bin.000001', master_log_pos=98;

mysql> slave start;

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show processlist\G      //可以看到以下三句话表示成功

State: Waiting for master to send event

State: Has read all relay log; waiting for the slave I/O thread to update it

State: Has sent all binlog to slave; waiting for binlog to be updated

mysql> unlock tables;

Query OK, 0 rows affected (0.15 sec)

mysql> show slave status\G;    //这个步骤关键是看到以下两项开启

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)0b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值