MySQL master-Slave Synchronization instance

Source: Internet
Author: User

MySQL version: mysql-5.5.19.tar.gz (placed under/root)

CMake This edition: cmake-3.0.2.tar.gz

Main Library 192.168.5.204 from library 192.168.5.203

  1. Install MySQL on the primary server (install CMake first to compile MySQL)

    [Email protected] ~]# tar zxvf cmake-3.0.2.tar.gz

    [Email protected] ~]# CD cmake-3.0.2

    [Email protected] cmake-3.0.2]#./bootstrap

    [[email protected] cmake-3.0.2]# make && make install

    [Email protected] ~]# tar zxvf mysql-5.5.19.tar.gz

    [Email protected] ~]# CD mysql-5.5.19

    [Email protected] mysql-5.5.19]# CMAKE-DCMAKE_INSTALL_PREFIX=/USR/LOCAL/MYSQL-DMYSQL_DATADIR=/USR/LOCAL/MYSQ                               L/data-dsysconfdir=/usr/local/mysql/etc-dmysql_unix_addr=/tmp/mysql.sock-ddefault_charset=utf8 -ddefault_collation=utf8_general_ci-dwith_extra_charsets=all-dwith_readline=1-denabled_lo Cal_infile=on-dwith_debug=0-dwith_innobase_storage_engine=1-dwith_federated_storage_engine=1-dwith_blackh Ole_storage_engine=1-dwith_partition_storage_engine=1-dwithout_example_storage_engine=1-denable_dtrac E=0

    [[email protected] mysql-5.5.19]# make && make install

2. Adding MySQL Users and Groups

[[email protected] ~]# Groupadd MySQL

[[email protected] ~]# useradd-g MySQL MySQL

3. Configuration files

[Email protected] ~]# Cd/usr/local/mysql

[Email protected] mysql]# mkdir etc

[Email protected] mysql]# cp/root/mysql-5.5.19/support-files/my-medium.cnf/usr/local/mysql/etc/

#chown-R Mysql:mysql/usr/local/mysql

4. Initialize MySQL

# cd/usr/local/mysql/scripts/

#./mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql

4. Start MySQL

#/bin/sh/usr/local/mysql/bin/mysqld_safe--DEFAULTS-FILE=/USR/LOCAL/MYSQL/ETC/MY-MEDIUM.CNF &

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4C/B6/wKiom1REYnbz5x9JAAHJaLOeNCs239.jpg "title=" 1.png " alt= "Wkiom1reynbz5x9jaahjaloencs239.jpg"/>650) this.width=650; src= http://s3.51cto.com/wyfs02/M01/4C/B6/ Wkiom1reyomaycrgaalo-mmcjqc468.bmp "title=" 2.bmp "alt=" wkiom1reyomaycrgaalo-mmcjqc468.bmp "/> Add global variables

#echo ' Export path= $PATH:/usr/local/mysql/bin ' >>/etc/profile

Boot auto Start

# echo '/bin/sh/usr/local/mysql/bin/mysqld_safe--defaults-file=/usr/local/mysql/etc/my-medium.cnf & ' >>/ Etc/rc.local

5. Edit MySQL profile my-medium.cnf (open Binlog log, Server-id =1)

[Email protected] ~]# VIM/USR/LOCAL/MYSQL/ETC/MY-MEDIUM.CNF

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4C/B6/wKiom1REZPig-CSSAADvFOLFskc161.jpg "title=" 3.png " alt= "Wkiom1rezpig-cssaadvfolfskc161.jpg"/>

Restarting the MySQL process

6. Log in to MySQL

[Email protected] ~]# mysql-s/tmp/mysql.sock

mysql> grant replication Slave on * * to [email protected] '% ' identified by ' repl ';

mysql> flush Privileges;



On the primary library server, view the primary log file name and the main log current POS number

Mysql>show Master Status\g

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4C/B9/wKiom1REgnbSR-7hAACHsuzBpiA483.jpg "title=" 6.png " alt= "Wkiom1regnbsr-7haachsuzbpia483.jpg"/>

In the From library settings

Mysql>stop slave;

Mysql>change MASTER to master_host= ' 192.168.5.204 ', master_port=3306,master_user= ' repl ', master_password= ' repl ', Master_connect_retry=60,master_log_file= ' mysql-bin.000007 ', master_log_pos=1482;

Mysql>start slave;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4C/BA/wKioL1REg5-grdE8AAFbXD8MH5A164.jpg "title=" 8.png " alt= "Wkiol1reg5-grde8aafbxd8mh5a164.jpg"/>

When you see two yes, it means that the synchronization was successful

#新建库和表测试是否同步

Create Tabl e Test (id int,name char);



This article from "Dream Three" blog, declined reprint!

MySQL master-Slave Synchronization instance

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.