slave服务器不小心写入数据的解决方案
mysql> set GLOBAL sql_slave_skip_counter=N # n代表跳过的n个事务
基于gtids的主从复制搭建
mysql> set @@global.read_only=ON;
Query OK, 0 rows affected (0.01 sec)
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> reset slave;
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> change master to
-> master_host='192.168.118.20',
-> master_user='slave',
-> master_password='slave',
-> master_port=3306,
-> master_auto_position=1;
Query OK, 0 rows affected, 8 warnings (0.01 sec)
mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.01 sec)
*************************** 1. row ***************************
Slave_IO_State: Waiting for source to send event
Master_Host: 192.168.118.20
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: binlog.000015
Read_Master_Log_Pos: 157
Relay_Log_File: relaylog.000002
Relay_Log_Pos: 367
Relay_Master_Log_File: binlog.000015
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
mysql> set @@global.read_only=OFF;
Query OK, 0 rows affected (0.00 sec)
LVS
一个调度主机,有两个网卡
vip:对外,公网
dip:对内,局域网
主机名称 | ip地址 | 功能 |
web01 | 192.168.118.200 | rs |
web02 | 192.168.118.201 | realserver |
nat | vip:192.168.118.135 dip:192.168.118.10 | directorserver,ntp |
dns | 192.168.118.110 | dns |
web服务器:
下载nginx,在index.html写入内容,启动nginx,编写计划任务
yum -y install nginx
echo "web-----01" > /usr/share/nginx/html/index.html
[root@web01 ~]# nginx
[root@web01 ~]# crontab -e
30 3 * * * /usr/sbin/ntpdate 192.168.118.10 //时间服务器的IP
nat服务器:
需要两块网卡,再添加一块网卡
同步时间,编写计划任务,配置时间服务器,启动服务,设置开机自启动
142 yum -y install ntpdate.x86_64
143 ntpdate cn.ntp.org.cn
144 which ntpdate
145 crontab -e
* 2 * * * /usr/sbin/ntpdate cn.ntp.org.cn
147 yum -y install ntp
148 systemctl start ntpd
149 systemctl enable ntpd
dns服务器:
[root@dns ~]# yum -y install bind
[root@dns ~]# vim /etc/named.conf //添加any
[root@dns ~]# vim /etc/named.rfc1912.zones
zone "yuanyu.zhangmin" IN {
type master;
file "yuanyu.zhangmin.zone";
allow-update { none; };
};
[root@dns ~]# cd /var/named/
[root@dns named]# cp -p named.localhost yuanyu.zhangmin.zone
[root@dns named]# vim yuanyu.zhangmin.zone
[root@dns named]# named-checkconf /etc/named.conf
[root@dns named]# named-checkconf /etc/named.rfc1912.zones
[root@dns named]# named-checkzone yuanyu.zhangmin.zone yuanyu.zhangmin.zone
[root@dns named]# systemctl restart named
client客户端:
[root@allow ~]# echo "nameserver 192.168.118.110" > /etc/resolve.conf
[root@allow ~]# ping nat.yuanyu.zhangmin -c2
PING nat.yuanyu.zhangmin (192.168.118.135) 56(84) bytes of data.
64 bytes from 192.168.118.135 (192.168.118.135): icmp_seq=1 ttl=64 time=0.639 ms
64 bytes from 192.168.118.135 (192.168.118.135): icmp_seq=2 ttl=64 time=0.305 ms
nat配置规则:
安装ipvsadm
[root@nat ~]# yum -y install ipvsadm.x86_64
-A:添加一个虚拟主机,是vip地址,对外
[root@nat ~]# ipvsadm -A -t 192.168.118.135:80 -s rr