页面“Linux下MySQL主从同步监控shell脚本”与“Vps”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
(导入1个版本)
 
→‎2020
 
第1行: 第1行:
Linux下MySQL主从同步监控shell脚本
 
#ps 不过我还没用过
 
==1、创建脚本文件==
 
  
vi /home/crontab/check_mysql_slave.sh  #编辑,添加下面代码
 
<pre>
 
#!/bin/sh
 
  
# check_mysql_slave status
+
=2020=
 +
多看一些相关的 评测和站点
  
# author www.osyunwei.com
+
还有要评测什么的
  
ip=eth0  #网卡名称
+
[https://www.vultryhw.cn/vultr-speedtest/ Vultr各节点官方测速地址]
  
mysql_binfile=/usr/local/mysql/bin/mysql
+
洛杉矶 和硅谷还可以
  
mysql_user=root  #MySQL数据库账号
+
=免费升级=
  
mysql_pass=123456  #密码
+
==vultr ==
 +
servers -->settings -->change plan
  
mysql_sockfile=/tmp/mysql.sock
+
== digitalocean==
 +
--> resize -->Disk, CPU and RAM
  
datetime=`date +"%Y-%m-%d/%H:%M:%S"`  #获取当前时间
+
<pre> #150这个样子
 +
evan@bsd-latop:~ % ping linuxchina.net
 +
PING linuxchina.net (138.197.220.125): 56 data bytes
 +
64 bytes from 138.197.220.125: icmp_seq=0 ttl=51 time=154.269 ms
 +
64 bytes from 138.197.220.125: icmp_seq=1 ttl=51 time=153.722 ms
 +
64 bytes from 138.197.220.125: icmp_seq=2 ttl=51 time=153.646 ms
 +
64 bytes from 138.197.220.125: icmp_seq=3 ttl=51 time=153.907 ms
 +
64 bytes from 138.197.220.125: icmp_seq=4 ttl=51 time=153.740 ms
 +
64 bytes from 138.197.220.125: icmp_seq=5 ttl=51 time=152.701 ms
 +
64 bytes from 138.197.220.125: icmp_seq=6 ttl=51 time=153.862 ms
  
mysql_slave_logfile=/home/logs/check_mysql_slave.log  #日志文件路径,必须提前创建好
 
  
slave_ip=`ifconfig $ip|grep "inet addr" | awk -F[:" "]+ '{print $4}'`
+
在HK的机器好一点点
 +
</pre>
  
status=$($mysql_binfile -u$mysql_user -p$mysql_pass -S $mysql_sockfile -e "show slave status\G" | grep -i "running")
+
[https://www.zhihu.com/question/25529727 DigitalOcean 选择 Region 的问题?]
  
Slave_IO_Running=`echo $status | grep Slave_IO_Running | awk ' {print $2}'`
 
  
Slave_SQL_Running=`echo $status | grep Slave_SQL_Running | awk '{print $2}'`
+
[https://digitalocean.youhuima.cc/digitalocean%e5%93%aa%e4%b8%aa%e6%9c%ba%e6%88%bf%e5%bf%ab%e5%92%8c%e7%a8%b3%e5%ae%9a.html Digitalocean哪个机房快和稳定]
  
if [ "$Slave_IO_Running" = "Yes" -a "$Slave_SQL_Running" = "Yes" ]
 
  
then echo "Slave is Running!"
+
https://digitalocean.youhuima.cc/
  
else
+
这些不错, 过有点小贵
 +
http://www.ehostidc.cn
  
echo " $datetime $slave_ip Slave is not running!" >> $mysql_slave_logfile
+
国内到韩国的网络线路,应该是最好的,甚至可以媲美中国国内的双线机房。
  
$mysql_binfile -u$mysql_user -p$mysql_pass -S $mysql_sockfile -e "SLAVE STOP;"
+
<pre>北京联通 ping zyan.cc:
 +
root@linaro-alip:~# ping zyan.cc
 +
PING zyan.cc (27.255.71.186) 56(84) bytes of data.
 +
64 bytes from 27.255.71.186: icmp_req=1 ttl=50 time=68.3 ms</pre>
  
$mysql_binfile -u$mysql_user -p$mysql_pass -S $mysql_sockfile -e "SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1;"
+
=aws  and  cloud.google=
  
$mysql_binfile -u$mysql_user -p$mysql_pass -S $mysql_sockfile -e "SLAVE START;"
+
==防火墙配置==
 +
GCE 默认开启了防火墙且不能关闭,只能允许你自己指定的协议和端口的流量;经过我自己的实际测试,GCE 能够自动过滤相当的 DDOS 攻击流量。
  
$mysql_binfile -u$mysql_user -p$mysql_pass -S $mysql_sockfile -e "EXIT"
+
由于防火墙不能关闭,所以不能配置类似 IPv6 Tunnel 的服务,所以导致目前的 GCE 是不能够支持 IPv6 的,不过相信以后 Google 还是会启用 IPv6 支持。
  
fi</pre>
+
在 “网络” 里,可以找到 [https://console.cloud.google.com/networking/firewalls/list 防火墙规则],然后可以 [https://console.cloud.google.com/networking/firewalls/add 添加防火墙规则]。
  
 +
默认已经允许了 SSH 和 ICMP 等(以 default 开头的)
  
chmod +x /home/crontab/check_mysql_slave.sh #添加脚本执行权限
+
=Billing=
 +
2018年 04月 30日 星期一 就算为5月一号 $10
  
==2、添加任务计划,修改/etc/crontab==
+
2018年 09月 03日 星期一 10:18:48 CST $10 就是 70+70 rmb
  
 +
2018年 11月 02日  2019年 01月 02日 星期三
 +
2019年3.1  5.1给10刀
 +
Mon Jul  1 13:37:10 UTC 2019
  
crontab -e  #在最后一行添加
+
2019年 9月 1日 星期日 13时19分13秒 CST 只先给了5刀
  
*/10 * * * * root /home/crontab/check_mysql_slave.sh #表示每10分钟执行一次
+
Wed 06 Nov 2019
 +
digita
 +
$3.33 Remaining
  
 +
用了 $7.36 应该可以到12月才 给钱
  
 +
2019年12月 1日
  
==3、重新启动crond使设置生效==
 
  
/etc/rc.d/init.d/crond restart  #yum install -y vixie-cron安装计划任务,某些系统上可能没有预装
+
2020年 1月28日 星期二  digio 5刀 ;  vultr没理
  
chkconfig crond on #设为开机启动
+
=ec2=
 +
aws web用firefox打开 不然好慢
 +
=google=
 +
cloud.google.com
  
service crond start #启动
+
2019.02.06 过期
  
可以根据日志文件/home/logs/check_mysql_slave.log查看MySQL主从同步状态
+
=SEE ALSO=
  
参考
+
[https://guozeyu.com/2016/10/asia-google-compute-engine/ Google Compute Engine 新手教程]
http://www.osyunwei.com/archives/7240.html
 
  
[[category:mysql]]
+
[https://blog.51cto.com/wzlinux/2382381 国外 VPS 购买列表]
 +
 
 +
 
 +
[https://github.com/wuyao721/51docs/blob/master/it/aws-ec2-price.org 亚马逊EC2收费笔记]
 +
 
 +
[https://cloud.google.com/compute/docs/instances/connecting-to-instance#standardssh 连接到 Linux 实例]
 +
 
 +
[https://cloud.google.com/compute/pricing?hl=zh_CN&_ga=2.171515555.-221994790.1518005746 Google Compute Engine 价格]
 +
 
 +
[[category:ops]] [[category:linux]]

2020年2月28日 (五) 07:37的版本


2020

多看一些相关的 评测和站点

还有要评测什么的

Vultr各节点官方测速地址

洛杉矶 和硅谷还可以

免费升级

vultr

servers -->settings -->change plan

digitalocean

--> resize -->Disk, CPU and RAM

 #150这个样子
evan@bsd-latop:~ % ping linuxchina.net
PING linuxchina.net (138.197.220.125): 56 data bytes
64 bytes from 138.197.220.125: icmp_seq=0 ttl=51 time=154.269 ms
64 bytes from 138.197.220.125: icmp_seq=1 ttl=51 time=153.722 ms
64 bytes from 138.197.220.125: icmp_seq=2 ttl=51 time=153.646 ms
64 bytes from 138.197.220.125: icmp_seq=3 ttl=51 time=153.907 ms
64 bytes from 138.197.220.125: icmp_seq=4 ttl=51 time=153.740 ms
64 bytes from 138.197.220.125: icmp_seq=5 ttl=51 time=152.701 ms
64 bytes from 138.197.220.125: icmp_seq=6 ttl=51 time=153.862 ms


在HK的机器好一点点 

DigitalOcean 选择 Region 的问题?


Digitalocean哪个机房快和稳定


https://digitalocean.youhuima.cc/

这些不错, 过有点小贵 http://www.ehostidc.cn

国内到韩国的网络线路,应该是最好的,甚至可以媲美中国国内的双线机房。

北京联通 ping zyan.cc:
root@linaro-alip:~# ping zyan.cc
PING zyan.cc (27.255.71.186) 56(84) bytes of data.
64 bytes from 27.255.71.186: icmp_req=1 ttl=50 time=68.3 ms

aws and cloud.google

防火墙配置

GCE 默认开启了防火墙且不能关闭,只能允许你自己指定的协议和端口的流量;经过我自己的实际测试,GCE 能够自动过滤相当的 DDOS 攻击流量。

由于防火墙不能关闭,所以不能配置类似 IPv6 Tunnel 的服务,所以导致目前的 GCE 是不能够支持 IPv6 的,不过相信以后 Google 还是会启用 IPv6 支持。

在 “网络” 里,可以找到 防火墙规则,然后可以 添加防火墙规则

默认已经允许了 SSH 和 ICMP 等(以 default 开头的)

Billing

2018年 04月 30日 星期一 就算为5月一号 $10

2018年 09月 03日 星期一 10:18:48 CST $10 就是 70+70 rmb

2018年 11月 02日 2019年 01月 02日 星期三 2019年3.1 5.1给10刀 Mon Jul 1 13:37:10 UTC 2019

2019年 9月 1日 星期日 13时19分13秒 CST 只先给了5刀

Wed 06 Nov 2019 digita $3.33 Remaining

用了 $7.36 应该可以到12月才 给钱

2019年12月 1日


2020年 1月28日 星期二 digio 5刀 ; vultr没理

ec2

aws web用firefox打开 不然好慢

google

cloud.google.com

2019.02.06 过期

SEE ALSO

Google Compute Engine 新手教程

国外 VPS 购买列表


亚马逊EC2收费笔记

连接到 Linux 实例

Google Compute Engine 价格