主从的搭建+shell实现检测并邮件报警。 数据库分库分表备份+任务定时计划


数据库分库分表备份+任务定时计划)

两台服务器都要操作

关闭防火墙:

# systemctl stop firewalld
# setenforce 0

安装mysql服务:

# yum -y install mariadb mariadb-server

主mysql服务器上操作:修改mysql配置文件,进去添加:

# vi /etc/my.cnf 
server-id=1
log-bin=mysqlbin

保存退出后启动mysql服务

#  systemctl restart mariadb

登录mysql,进行授权并查看二进制日志信息

# mysql
mysql> grant all on *.* to a@'%' identified by 'a';
mysql> show master status;

从mysql服务器上操作: 修改配置文件,进去添加以下两项:

# vim /etc/my.cnf
server-id=2
relay-log=relays

保存退出后启动mysql服务

# systemctl restart mariadb

登录mysql进行同步连接

# mysql
mysql> stop slave;

连接设置

mysql> change master to master_host='192.168.231.133',master_user='a',master_password='a',master_log_file='mysqlbin.000003',master_log_pos=363;

开启同步

mysql> start slave;

查看是否双yes

mysql> show slave status \G;

验证:
请在主mysql上新建一个数据库,之后在从数据库中查看是否已经存在!!!如存在则成功

编写自动脚本进行邮件报警和任务定时

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_46023525/article/details/106770669