您的位置:首页 > 其它

主主+ lvs keepalived 配置文件

2016-02-24 13:17 351 查看
主主+ lvs keepalived 配置文件

主主搭建

rpm -qa | grep mysql

yum remove -y

yum install -y

/etc/init.d/mysql stop

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

use mysql;

UPDATE user SET Password=PASSWORD('mysql') where USER='root';

/etc/init.d/mysql restart

mysql -uroot -pmysql

SET PASSWORD=password('mysql');

GRANT all privileges on *.* TO 'root'@'%' identified by 'mysql' WITH GRANT OPTION;

SET PASSWORD FOR 'root'@'%' = PASSWORD('mysql');

grant replication slave on *.* to 'rep'@'%' identified by 'rep';

grant replication slave on *.* to 'rep'@'172.16.15.%' identified by 'rep';

change master to master_host='172.16.15.28',master_user='rep',master_password='rep',

master_log_file='mysql-bin.000001',master_log_pos=317;

1 搭建keepalived

! Configuration File for keepalived

global_defs {

router_id mm1

}

vrrp_sync_group VG1 {

group {

VI_1

}

}

vrrp_instance VI_1 {

state BACKUP

interface eth0

virtual_router_id 60

priority 80

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

172.16.15.29

}

}

virtual_server 172.16.15.29 3306 {

delay_loop 6

lb_algo wrr

lb_kind DR

nat_mask 255.255.254.0

persistence_timeout 50

protocol TCP

real_server 172.16.15.28 3306 {

weight 1

notify_down /usr/local/mysql/bin/mysql.sh

TCP_CHECK {

connect_timeout 10

nb_get_retry 3

connect_port 3306

}

}

}

2主机

! Configuration File for keepalived

global_defs {

router_id mm2

}

vrrp_sync_group VG1 {

group {

VI_1

}

}

vrrp_instance VI_1 {

state BACKUP

interface eth1

virtual_router_id 60

priority 100

advert_int 1

nopreempt

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

172.16.15.29

}

}

virtual_server 172.16.15.29 3306 {

delay_loop 6

lb_algo wrr

lb_kind DR

nat_mask 255.255.254.0

persistence_timeout 50

protocol TCP

real_server 172.16.15.27 3306 {

weight 1

notify_down /usr/local/mysql/bin/mysql.sh

TCP_CHECK {

connect_timeout 10

nb_get_retry 3

connect_port 3306

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: