一、从github下载mysqltools工具包

  github地址:https://github.com/Neeky/mysqltools

二、环境规划:

主机名              ip            mysql中的角色

master-slave17          10.186.19.17        master

master-slave18          10.186.19.18        slave

master-slave19          10.186.19.19        slave

三、执行自动化安装配置:

ansible-playbook install_master_slaves.yaml 

PLAY [ms1] ****************************************************************************************

TASK [Gathering Facts] ****************************************************************************
ok: [master-slave17]
ok: [master-slave19]
ok: [master-slave18] TASK [create mysql user] **************************************************************************
changed: [master-slave17]
changed: [master-slave18]
changed: [master-slave19] TASK [create and config /etc/my.cnf] **************************************************************
changed: [master-slave18]
changed: [master-slave17]
changed: [master-slave19] TASK [transfer mysql install package to remote host and unarchive to /usr/local/] *****************
changed: [master-slave17]
changed: [master-slave18]
changed: [master-slave19] TASK [change owner to mysql user] *****************************************************************
changed: [master-slave18]
changed: [master-slave17]
changed: [master-slave19] TASK [make link /usr/local/mysql-xx.yy.zz to /usr/local/mysql] ************************************
changed: [master-slave17]
changed: [master-slave18]
changed: [master-slave19] TASK [export mysql share object (*.os)] ***********************************************************
ok: [master-slave17]
ok: [master-slave18]
ok: [master-slave19] TASK [load share object] **************************************************************************
changed: [master-slave18]
changed: [master-slave17]
changed: [master-slave19] TASK [export path env variable] *******************************************************************
ok: [master-slave17]
ok: [master-slave18]
ok: [master-slave19] TASK [export path env to /root/.bashrc] ***********************************************************
ok: [master-slave17]
ok: [master-slave18]
ok: [master-slave19] TASK [make link /usr/local/mysql-xx.yy.zz to /usr/local/mysql] ************************************
ok: [master-slave17]
ok: [master-slave18]
ok: [master-slave19] TASK [create libmysqlclient_r.so file for php-5.6] ************************************************
changed: [master-slave17]
changed: [master-slave18]
changed: [master-slave19] TASK [create datadir] *****************************************************************************
changed: [master-slave17]
changed: [master-slave18]
changed: [master-slave19] TASK [initialize-insecure] ************************************************************************
changed: [master-slave17]
changed: [master-slave18]
changed: [master-slave19] TASK [create systemd config file] *****************************************************************
changed: [master-slave17]
changed: [master-slave19]
changed: [master-slave18] TASK [enable mysqld service] **********************************************************************
changed: [master-slave19]
changed: [master-slave17]
changed: [master-slave18] TASK [start mysql(sytemctl)] **********************************************************************
changed: [master-slave17]
changed: [master-slave18]
changed: [master-slave19] TASK [config mysql.service start up on boot] ******************************************************
changed: [master-slave18]
changed: [master-slave17]
changed: [master-slave19] TASK [config sysv start script] *******************************************************************
skipping: [master-slave17]
skipping: [master-slave18]
skipping: [master-slave19] TASK [start mysql(service)] ***********************************************************************
skipping: [master-slave17]
skipping: [master-slave18]
skipping: [master-slave19] TASK [config mysql.service start up on boot] ******************************************************
skipping: [master-slave17]
skipping: [master-slave18]
skipping: [master-slave19] TASK [stransfer sql to remote host] ***************************************************************
changed: [master-slave18]
changed: [master-slave17]
changed: [master-slave19] TASK [create replication user on master / start slave on slave] ***********************************
changed: [master-slave17]
changed: [master-slave19]
changed: [master-slave18] ---
TASK [transfer sql statement to remonte] **********************************************************
skipping: [master-slave18]
skipping: [master-slave19]
changed: [master-slave17] TASK [make mysql secure] **************************************************************************
skipping: [master-slave18]
skipping: [master-slave19]
changed: [master-slave17] TASK [remove temp file /tmp/make_mysql_secure.sql] ************************************************
skipping: [master-slave18]
skipping: [master-slave19]
systemctl stop mysql
changed: [master-slave17] PLAY RECAP ****************************************************************************************
master-slave17 : ok= changed= unreachable= failed=
master-slave18 : ok= changed= unreachable= failed=
master-slave19 : ok= changed= unreachable= failed=

      

四、在slave上测试配置是否正确:

mysql -uroot -pmtls0352
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is
Server version: 5.7.-log MySQL Community Server (GPL) Copyright (c) , , Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show slave status \G
*************************** . row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.186.19.17
Master_User: rple
Master_Port:
Connect_Retry:
Master_Log_File: mysql-bin.
Read_Master_Log_Pos:
Relay_Log_File: mtls19-relay-bin.
Relay_Log_Pos:
Relay_Master_Log_File: mysql-bin.
Slave_IO_Running: Yes
Slave_SQL_Running: Yes

结论:

  mysql复制环境正确的配置好了!

  整个安装配置的过程用了不到3分钟、通过mysqltools可以大大的节省时间。所以mysqltools是一个提高生产力的好工具!

----

通过mysqltools全自动安装配置mysql复制环境的更多相关文章

  1. (转载)Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记

    Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记 Linux下配LMAP环境,花了我好几天的时间.之前没有配置过,网上的安装资料比较混乱,加上我用的版本问题,安装过程 ...

  2. Windows平台安装配置mysql数据库

    Windows平台安装配置mysql数据库 作者:Eric 微信:loveoracle11g 去下载mysql软件 https://www.mysql.com/downloads/ https://d ...

  3. 详解在Linux中安装配置MySQL

    最近在整理自己私人服务器上的各种阿猫阿狗,正好就顺手详细记录一下清理之后重装的步骤,今天先写点数据库的内容,关于在Linux中安装配置MySQL 安装环境 CentOS7 + MySQL5.7 下载安 ...

  4. CentOS 7.2 安装配置mysql主从服务器

    MySQL官方压缩包安装: 1:下载mysql官方版本,此处以目前最新版本5.7.14为例,下载的64位版本文件为: mysql-5.7.14-linux-glibc2.5-x86_64.tar 2: ...

  5. Windows 7上安装配置TensorFlow-GPU运算环境

    Windows 7上安装配置TensorFlow-GPU运算环境 1. 概述 在深度学习实践中,对于简单的模型和相对较小的数据集,我们可以使用CPU完成建模过程.例如在MNIST数据集上进行手写数字识 ...

  6. mac安装配置mysql

    目录 mac安装配置mysql 1.mysql的安装 2.设置root用户的密码 3.分别执行一下命令 4.配置mysql环境变量 mac安装配置mysql 1.mysql的安装 ​ 安装过程十分简单 ...

  7. CentOS 7安装配置MySQL 5.7

    概述 前文记录了在Windows系统中安装配置MySQL 5.7(前文连接:https://www.cnblogs.com/Dcl-Snow/p/10513925.html),由于安装部署大数据环境需 ...

  8. Windows下安装配置MySQL

    Windows下安装配置MySQL的基本步骤 一.MySQL下载 MySQL官方下载地址https://dev.mysql.com/downloads/mysql/5.7.html#downloads ...

  9. CentOS6.5下安装配置MySQL

    CentOS6.5下安装配置MySQL,配置方法如下: 安装mysql数据库:# yum install -y mysql-server mysql mysql-deve 查看mysql-server ...

随机推荐

  1. 在Linux上自动调整屏幕亮度保护眼睛

    导读 Lightbot当你开始在计算机前花费大量时间的时候,问题自然开始显现.这健康吗?怎样才能舒缓我眼睛的压力呢?为什么光线灼烧着我?尽管解答这些问题的研究仍然在不断进行着,许多程序员已经采用了一些 ...

  2. MySql无法远程登录以及IP被锁解决办法

    授权 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;Query OK, 0 rows aff ...

  3. const char * 转换为char*

    可以用const_cast     const char* aa = "this is a const string.";     char* bb = const_cast< ...

  4. IDA Pro基本简介

    IDA Pro基本简介 IDA加载完程序后,3个立即可见的窗口分别为IDA-View,Named,和消息输出窗口(output Window). IDA图形视图会有执行流,Yes箭头默认为绿色,No箭 ...

  5. Memcached 的一些用法

    public interface ICache { object Get(string key); /// <summary> /// 根据 key 从缓存中读取数据 /// </s ...

  6. ZH奶酪:PHP遍历目录/文件的3种方法

    其实PHP中内建函数scandir()就可以返回目录下全部文件和目录了... ========================== 1.使用$obj = dir($dir)返回目录对象$obj,然后使 ...

  7. 用Postfix + Dovecot 搭建的邮件server被垃圾邮件其中转server的处理

    今天发邮件. 发送失败.然后到server上看日志, 发现硬盘被垃圾邮件的缓存队列和日志塞满了. tail    -f    /var/log/maillog   发现疯狂刷屏.部分日志例如以下 : ...

  8. 安装 启动sshd服务:

    .先确认是否已安装ssh服务: [root@localhost ~]# rpm -qa | grep openssh-server openssh-server-.3p1-.fc12.i686 (这行 ...

  9. java如何将毫秒数转为相应的年月日格式

    public static void main(String[] args) { Date date = new Date(); Long time = date.getTime(); System. ...

  10. 〖Linux〗Ubuntu13.10,配置tftp服务器

    前言,配置了好久没有发现老是出问题tftp: server error: (2) Access violation,一般侦测之后... 1. 安装软件包:apt-getsudo apt-get ins ...