Ansible Automation to build MySQL server fast configuration master-Slave architecture

Source: Internet
Author: User
Tags mkdir iptables

Procedure Note: First stop the Selinx and iptables and make sure that the server CD-ROM has a disc and is linked
/etc/init.d/iptables Stop (C6)
Systemctl Stop Firewalld (C7)
Setenforce 0 temporarily close SELinux

1: Install Epel source
1:yum-y Install Lrzsz
2:rz + Epel with script and source database binaries
3: Installation
Example: Rpm-ivh epel-release-latest-6.noarch (C6)

2: Install Ansible
Yum-y Install Ansible

3: Copy the Hosts file to the/etc/ansible directory in the hosts IP can be set to its own server
Create the directory mkdir-pv/etc/ansible/sh and copy the script mysql.sh msyql.yml mysql2.sh to the current directory

4: Create a free-secret link
1:ssh-keygen-t Rsa-p '
2:ssh-copy-id-i ~/.ssh/id_rsa.pub [email protected] (host IP)
If the prompt command does not find the installation yum-y install Openssh-clients
3:ansible all-m Ping Check to see if you can link properly

5: Provide packages and configuration files
1: Copy the binary database package to/opt and rename it to MySQL
2: Create master slave Directory Mkdir-pv/opt/{master,slave}
3: Move my0.cnf and rename to/opt/master/my.cnf
4: Move my1.cnf and rename to/opt/slave/my.cnf
5:MV my.sh/etc/ansible/sh Add PATH environment variable

6: Start the installation and start the database
1:cd/etc/ansible/sh directory (where the mysql.sh script resides)
2: Execute ansible all-m script-a mysql.sh
If the card is stuck Scp/opt/mysql 192.168.11.144:/opt/mysql
Scp/opt/mysql 192.168.11.144:/opt/mysql
and comment out the SCP in the msyql.sh script (it's not clear why the script doesn't send the past).
Execute Ansible-playbook mysql.yml
Execute ansible all-m script-a mysql2.sh

7: Check if MySQL is starting up:

Then you can configure the master-slave, semi-synchronous. Do not have to knock every time that command, and the configuration file Server-id also changed.

8: Primary server: Master
Show Master status note the log location and log file name.

OK, the master server is here!

9: From the server configuration:
Help change Master to: You can use this to apply, if the memory is not good. -。 -

Then go back to the main server to create the library and look at the table.

Complete, small experiment, insufficient place also many, continue to optimize in.

The script is as follows:

Ansible Automation to build MySQL server fast configuration master-Slave architecture

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.