Python automation manages MySQL master-slave synchronization

Source: Internet
Author: User

Mysql

Multi-instance


1.my.cnf

By defining Mysqldconfig class Mysqld_vars = {} Get a lot of configuration file related parameter write dictionary from inside

mysql.py


2.init DB

Initializing the database


3. Modify Permissions


4.rc Script Startup


5.check Check the configuration file, the configuration file is synchronized with the MySQL variable


6. The value is actually the same, do not let the display

7.Popen Call MYSQL-E command


Sql

Io

seconds_behind_master:0 Look at this threshold, greater than two seconds


8.mysql Master-Slave

Master configuration file:

Bin-log

Server-id

Create Grant Replication permissions


From the configuration file:

Server-id

Master-host

Master-user

Master-port


"" can be wrapped

"" "Can not


./mymantea.py-c Backup-n Master01


./mymantea.py-n slave15-p 3315-c restore 192.168.1.14 3306/var/mysqlmanager/backup/master01/2014-05-10.02.11.21. Sql


./mymantea.py-n slave06-c Create slave 7 192.168.1.16 3306-p 3312


./myman.py-c Create master 1-p 3306-n Master01


./mymantea.py-n slave15-c Start-p 3315


Mysql> show global variables like ' server_id ';


Mysql> show global variables like ' log_bin% ';


Mysql> select User,host,password from Mysql.user;


This article is from the "Muzinan Technology blog" blog, make sure to keep this source http://muzinan110.blog.51cto.com/684213/1437987

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.