Mysql master-slave setup and Mysql O & M commands

Source: Internet
Author: User

Mysql master-slave setup and Mysql O & M related commands 1, install mysql, a lot of ways, rpm installation yum-y install mysql-server mysql-devel mysql-plugin mysql-test2, start/etc/init. d/mysqld start3, master edit/etc/my. cnf # Make sure that the name of the database to be backed up is as follows: server-id = 1log-bin = mysql-binbinlog-do-db = mysql # If multiple databases are backed up, repeat this option to binlog-ignore-db = mysql # The database name that does not need to be backed up. If you back up multiple databases, repeat setting this option to log-slave-updates # This parameter must be added, otherwise it will not record the updates to the binary file. slave-skip-errors # Skipping errors, continue to perform the copy operation linux: useradd Repl_user passwd repl_usermysql> grant replication slave on *. * 'repl _ user' @ 'slave _ ip' identified by 'repl _ password'; backup flush tables with read lock; reset master should not exit the terminal, and then start a terminal linux: cd/var/lib # mysql data directory tar zcvf mysql.tar.gz mysql scp mysql.tar.gz root @ slave_ip:/var/lib mysl> unlock tables; show master status; 4, salve tar zxvf mysql.tar.gz chown-R mysql: mysql edit/etc/my. cnfserver-id = 2log-b In = mysql-binmaster-host = 192.168.0.1master-user = slavemaster-password = 111111master-port = 3306replicate-do-db = test # Name of the database to be backed up replicate-ignore-db = mysql # ignored database master- connect-retry = 60 # If the master server is disconnected from the server, reconnect time difference (SEC) log-slave-updates # This parameter must be added, otherwise it will not record the updates to the binary file slave-skip-errors # skip the error, continue with replication verify connection to MASTER # mysql-h192.168.0.1-uslave-ppasswordmysql> show grants for slave@192.168.0.2; Set synchronization settings on SLAVE to connect to MASTER M ASTER_LOG_FILE is the File of the MASTER database, and MASTER_LOG_POS is the Positionmysql> slave stop of the MASTER database; mysql> change master to MASTER_HOST = '2017. 168.0.1 ', MASTER_USER = 'slave', MASTER_PASSWORD = '000000', MASTER_LOG_FILE = 'mysql-bin.000001 ', MASTER_LOG_POS = 111111; start the slave service mysql> SLAVE stop; mysql> slave start; view the slave status mysql> show slave status \ G. The values in the Slave_IO_Running and Slave_ SQL _Running columns are "Yes", indicating that the Slave I/O and SQL threads are running properly. Common mysql O & M commands: show processlistshow full processlistshow open tables; show status; show variablesshow engine innodb status; \ G; linux Command line connecting to the database and executing the command printf "SELECT SYSTEM_USER () from DUAL "| mysql-h192.1.1.161-uroot-proot-P3306 test-N

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.