images\cherry_red.png1 实训二前期LNMP简易架构
      images\cherry_blue.png1.1 php server安装
      images\cherry_blue.png1.2 安装初始化数据库
   images\cherry_red.png2 Mysql数据库
      images\cherry_blue.png2.1 Mysql5.7安装
         images\cherry_orange.png2.1.1 rpm安装
         images\cherry_orange.png2.1.2 yum安装
         images\cherry_orange.png2.1.3 源码安装
         images\cherry_orange.png2.1.4 编译好的非rpm包安装
         images\cherry_orange.png2.1.5 my.cnf常见选项
      images\cherry_blue.png2.2 Mysql基础
         images\cherry_orange.png2.2.1 MySql数据库操作
         images\cherry_orange.png2.2.2 MySql数据类型
            images\cherry_cyan.png2.2.2.1 整型
            images\cherry_cyan.png2.2.2.2 浮点数和定数
            images\cherry_cyan.png2.2.2.3 字符串类型
            images\cherry_cyan.png2.2.2.4 日期和时间类型
            images\cherry_cyan.png2.2.2.5 字段修饰和约束
            images\cherry_cyan.png2.2.2.6 业务建表练习
         images\cherry_orange.png2.2.3 MySql表操作
         images\cherry_orange.png2.2.4 MySql体系结构
         images\cherry_orange.png2.2.5 MySql存储引擎
      images\cherry_blue.png2.3 MySql操作
         images\cherry_orange.png2.3.1 MySql数据操作
         images\cherry_orange.png2.3.2 MySql单表查询
         images\cherry_orange.png2.3.3 MySql多表查询
         images\cherry_orange.png2.3.4 MySql存储过程与函数
      images\cherry_blue.png2.4 MySql操作-2
         images\cherry_orange.png2.4.1 MySql安全机制
         images\cherry_orange.png2.4.2 MySql日志管理
         images\cherry_orange.png2.4.3 MySql复制概述
         images\cherry_orange.png2.4.4 主从同步
      images\cherry_blue.png2.5 最基本sql语句及主从架构
      images\cherry_blue.png2.6 MyCat中间件
         images\cherry_orange.png2.6.1 部署Mycat
         images\cherry_orange.png2.6.2 配置读写分离
            images\cherry_cyan.png2.6.2.1 安全的读写分离
         images\cherry_orange.png2.6.3 XML语法格式
         images\cherry_orange.png2.6.4 mycat 分表分库
      images\cherry_blue.png2.7 Mysql MHA
         images\cherry_orange.png2.7.1 MHA-部署
         images\cherry_orange.png2.7.2 MHA-故障切换VIP透明
            images\cherry_cyan.png2.7.2.1 VIP切换脚本内容
            images\cherry_cyan.png2.7.2.2 VIP-手动在线切换脚本
         images\cherry_orange.png2.7.3 MHA+Mycat高可用Mysql读写分离
         images\cherry_orange.png2.7.4 MHA+VIP+Mycat
         images\cherry_orange.png2.7.5 MHA-故障切换邮件报警
         images\cherry_orange.png2.7.6 自动配置Slave主机
   images\cherry_red.png3 实验
      images\cherry_blue.png3.1 mysql授权问题
      images\cherry_blue.png3.2 1.单节点数据库
      images\cherry_blue.png3.3 2.主从同步
      images\cherry_blue.png3.4 3.实验(高可用)
         images\cherry_orange.png3.4.1 高可用keepalived
            images\cherry_cyan.png3.4.1.1 keepalived install
      images\cherry_blue.png3.5 4.实验(高可用+大并发)
         images\cherry_orange.png3.5.1 HAproxy代理
      images\cherry_blue.png3.6 4.实验(mycat-读写分离)
         images\cherry_orange.png3.6.1 mycat安装部署
         images\cherry_orange.png3.6.2 读写分离高可用
         images\cherry_orange.png3.6.3 mycat管理端口命令
      images\cherry_blue.png3.7 5.双主双从-读写分离-高可用
      images\cherry_blue.png3.8 6.mycat分库操作
      images\cherry_blue.png3.9 7.mycat分表
      images\cherry_blue.png3.10 8.mycat分库分表之下实现读写分离
   images\cherry_red.png4 Shell脚本编程
   images\cherry_red.png5 Zabbix监控
      images\cherry_blue.png5.1 zabbix设置邮件报警--自定义报警媒介
      images\cherry_blue.png5.2 zabbix解决中文界面乱码问题
      images\cherry_blue.png5.3 ziabbix自带的template Linux OS
      images\cherry_blue.png5.4 zabbix-agent自定义收集数据
      images\cherry_blue.png5.5 zabbix监控Nginx性能
      images\cherry_blue.png5.6 综合配置
      images\cherry_blue.png5.7 实验:监控nginx端口实现告警
   images\cherry_red.png6 ELK日志分析
      images\cherry_blue.png6.1 PS
      images\cherry_blue.png6.2 es-head插件安装
      images\cherry_blue.png6.3 安装filebeat nginx日志模板
以下为故障自动恢复MHA集群的参考脚本,注意标红处 可能是你需要根据自己实际情况修改的


# vim /home/autofailover.sh
#! /bin/bash
#该脚本用于mha故障切换后自动恢复
#
#MHA manger节点IP
manger_ip="192.168.182.151"
#mha 管理mysql数据库的用户和密码
user="mha"
pas="Uplooking_123"
#用于同步的用户和密码
slave_user="sync"
slave_pas="Uplooking_123"
#MHA Manger配置文件
mha_conf="/etc/mha/app1.cnf"


###########################################################################
if [ $# -ne 1 ]
then
echo "脚本使用错误!!!!!!"
echo "使用方法:${0} <master IP>"
exit 11
fi

master_ip=${1}


#检查数据据库是否已经启动
netstat -nlpt | grep -w "mysqld" &> /dev/null
if [ $? -ne 0 ]
then
echo "Mysqld server not start."
exit 1
fi

#从新 主库 备份数据
mysqldump -u${user} -p${pas} -h${master_ip} -B -A > /tmp/bak.sql
if [ $? -ne 0 ]
then
echo "!!!!!!备份主库失败."
exit 4
fi

#恢复
mysql
-uroot -pUplooking_123 -e "set sql_log_bin=0;source /tmp/bak.sql;set sql_log_bin=1;"
if [ $? -ne 0 ]
then
echo "!!!!!!!恢复数据失败."
exit 2
fi
#####
mysql
-uroot -pUplooking_123 -e "set global relay_log_purge=0;set global read_only=on;"

#连接主
values=($(mysql -u${user} -p${pas} -h${master_ip} -e "show master status;" | grep "master" |awk '{print $1,$2}'))
mysql
-uroot -pUplooking_123 -e "change master to master_host='${master_ip}',master_user='${slave_user}',master_password='${slave_pas}',master_log_file='${values[0]}',master_log_pos=${values[1]};start slave;"


ret=$(mysql
-uroot -pUplooking_123 -e"show slave status\G" | grep -i "yes" | wc -l)
count=0
while [ ${ret} -ne 2 ]
do
sleep 1
ret=$(mysql
-uroot -pUplooking_123 -e"show slave status\G" | grep -i "yes" | wc -l)
let "count++"

if [ ${count} -ge 3 ]
then
echo "!!!!!连接主库失败."
exit 5
fi
done

echo "数据库同步数据 及连接主库成功,可以解锁主库....."


####################处理MHA#######################################

ssh ${manger_ip} "echo
[server1] >> ${mha_conf}"
ssh ${manger_ip} "echo
hostname=192.168.182.150 >> ${mha_conf}"
ssh ${manger_ip} "echo
port=3306 >> ${mha_conf}"

ssh ${manger_ip} "masterha_check_ssh --conf=${mha_conf}"
if [ $? -ne 0 ]
then
echo "!!!!!!!!!!!!!MHA Manger互信检查失败"
exit 5
fi

ssh ${manger_ip} "masterha_check_repl --conf=${mha_conf}"
if [ $? -ne 0 ]
then
echo "!!!!!!!!!!!!!MHA Manger 主从机制检查失败"
exit 6
fi

ssh ${manger_ip} "nohup masterha_manager --conf=${mha_conf} --remove_dead_master_conf --ignore_last_failover < /dev/null> /var/log/mha/app1/manager.log 2>&1 &"


#检查运行状态(因为mha启动需要做N多检查,因此需要一定的时间等待)
count=0
while :
do
ssh ${manger_ip} "masterha_check_status --conf=${mha_conf}"
if [ $? -eq 0 ]
then
echo "MHA Start 成功,故障恢复完成!!!!!!!"
exit 0
fi

let "count++"
sleep 2

if [ ${count} -ge 10 ]
then
break
fi
done

echo "!!!!!!!MHA Start 失败."
exit 7



>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
在出现故障的机器上执行脚本实现 一键式恢复
# chmod a+x /home/autofailover.sh
#/home/autofailover.sh