标签:oop prevent 信息 cat /etc ash port ase 启动脚本
Mysql | Lvs | keepalived | |
node2 | Y | Y | Y |
node3 | Y | Y | Y |
服务器名称 | ip | vip |
node2 | 192.168.0.12 | 192.168.0.200 |
node3 | 192.168.0.13 | 192.168.0.200 |
yum
install
-y mysql
service iptables stop
chkconfig iptables off
use mysql
delete from user where user=
‘‘
;
grant replication slave on *.* to
‘root‘
@
‘%‘
identified by
‘123456‘
;
[mysqld]
datadir=
/var/lib/mysql
socket=
/var/lib/mysql/mysql
.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-bin=mysql-bin
server-
id
=1
#需要记录二进制日志的数据库,如果有多个库,写多个binlog-do-db,用逗号隔开,测试时发现不能同步?有空在研究
binlog-
do
-db=amdb
binlog-
do
-db=hivedb
binlog-
do
-db=ooziedb
#不需要记录日志的数据库
binlog-ignore-db=mysql
#需要同步的数据库
replicate-
do
-db=amdb
replicate-
do
-db=hivedb
replicate-
do
-db=ooziedb
#不需要同步的库
replicate-ignore-db=mysql,information_schema
#默认值3600s
slave-net-timeout=60
#保证slave挂在任何一台master上都会接收到另一个master的写入信息
log-slave-updates
sync_binlog=1
slave-skip-errors=all
auto_increment_offset=1
auto_increment_increment=2
[mysqld_safe]
log-error=
/var/log/mysqld
.log
pid-
file
=
/var/run/mysqld/mysqld
.pid
[mysqld]
datadir=
/var/lib/mysql
socket=
/var/lib/mysql/mysql
.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-bin=mysql-bin
#设置不同的id
server-
id
=2
#需要记录二进制日志的数据库,如果有多个库,写多个binlog-do-db,用逗号隔开,测试时发现不能同步?有空在研究
binlog-
do
-db=amdb
binlog-
do
-db=hivedb
binlog-
do
-db=ooziedb
#不需要记录日志的数据库
binlog-ignore-db=mysql
#需要同步的数据库
replicate-
do
-db=amdb
replicate-
do
-db=hivedb
replicate-
do
-db=ooziedb
#不需要同步的库
replicate-ignore-db=mysql,information_schema
#默认值3600s
slave-net-timeout=60
#保证slave挂在任何一台master上都会接收到另一个master的写入信息
log-slave-updates
sync_binlog=1
slave-skip-errors=all
auto_increment_offset=1
auto_increment_increment=2
[mysqld_safe]
log-error=
/var/log/mysqld
.log
pid-
file
=
/var/run/mysqld/mysqld
.pid
mysql> flush tables with
read
lock;
#防止进入新的数据
Query OK, 0 rows affected (0.00 sec)
mysql> show master status\G;
*************************** 1. row ***************************
File: mysql-bin.000007
Position: 438
Binlog_Do_DB: db_rocky
Binlog_Ignore_DB: mysql
1 row
in
set
(0.00 sec)
mysql> flush tables with
read
lock;
Query OK, 0 rows affected (0.00 sec)
mysql> show master status\G;
*************************** 1. row ***************************
File: mysql-bin.000008
Position: 107
Binlog_Do_DB: db_rocky
Binlog_Ignore_DB: mysql
1 row
in
set
(0.01 sec)
mysql> change master to master_host=
‘10.211.55.54‘
,master_user=
‘root‘
,master_password=
‘123456‘
,master_log_file=
‘mysql-bin.000008‘
,master_log_pos=107;
Query OK, 0 rows affected (0.05 sec)
mysql> change master to master_host=
‘10.211.55.53‘
,master_user=
‘root‘
,master_password=
‘123456‘
,
-> master_log_file=
‘mysql-bin.000007‘
,master_log_pos=438;
Query OK, 0 rows affected (0.15 sec)
mysql> unlock tables;
mysql> start slave;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
yum
install
ipvsadm
vim
/etc/init
.d
/realserver
.sh
#!/bin/bash
#description: Config realserver lo and apply noarp
SNS_VIP=10.211.55.200
/etc/rc
.d
/init
.d
/functions
case
"$1"
in
start)
ifconfig
eth0:1 $SNS_VIP
/24
/sbin/route
add -host $SNS_VIP dev eth0:1
echo
"vip Start OK"
ifconfig
lo:0 $SNS_VIP netmask 255.255.255.255 broadcast $SNS_VIP
/sbin/route
add -host $SNS_VIP dev lo:0
echo
"1"
>
/proc/sys/net/ipv4/conf/lo/arp_ignore
echo
"2"
>
/proc/sys/net/ipv4/conf/lo/arp_announce
echo
"1"
>
/proc/sys/net/ipv4/conf/all/arp_ignore
echo
"2"
>
/proc/sys/net/ipv4/conf/all/arp_announce
sysctl -p >
/dev/null
2>&1
echo
"RealServer Start OK"
;;
stop)
ifconfig
eth0:1 down
route del $SNS_VIP >
/dev/null
2>&1
echo
"vip Stoped"
ifconfig
lo:0 down
route del $SNS_VIP >
/dev/null
2>&1
echo
"0"
>
/proc/sys/net/ipv4/conf/lo/arp_ignore
echo
"0"
>
/proc/sys/net/ipv4/conf/lo/arp_announce
echo
"0"
>
/proc/sys/net/ipv4/conf/all/arp_ignore
echo
"0"
>
/proc/sys/net/ipv4/conf/all/arp_announce
echo
"RealServer Stoped"
;;
*)
echo
"Usage: $0 {start|stop}"
exit
1
esac
exit
0
echo
"/etc/init.d/realserver.sh start"
>>
/etc/rc
.d
/rc
.
local
yum
install
keepalived
vim
/etc/keepalived/keepalived
.conf
! Configuration File
for
keepalived
global_defs {
notification_email {
yangyufans@qq.com
}
notification_email_from yangyufans@qq.com
smtp_server smtp.qq.com
smtp_connect_timeout 30
router_id LVS1
}
vrrp_sync_group
test
{
group {
loadbalance
}
}
vrrp_instance loadbalance {
state MASTER
lvs_sync_daemon_inteface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.211.55.200 dev eth0 label eth0:1
}
}
virtual_server 10.211.55.200 3306 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 20
protocol TCP
sorry_server 10.211.55.54 3306
real_server 10.211.55.53 3306 {
weight 3
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
connect_port 3306
}
}
}
标签:oop prevent 信息 cat /etc ash port ase 启动脚本
原文地址:https://www.cnblogs.com/lovelanglangyou/p/8890764.html