centos6.6 manually installing mysql5.5 and configuring Master-Slave synchronization

Source: Internet
Author: User
Tags mixed

0. Experimental environment

Host IP (master) 192.168.61.150 centos6.6
Slave IP (Slave) 192.168.61.157 centos6.6

1. View the CentOS system version
[Email protected] ~]# rpm-q centos-releasecentos-release-6-6. El6.centos. 12.2. x86_64

Detects if the system is installed with MySQL and uninstalls

Yum List Installed |  -y-Remove mysql-libs.x86_64

2. Download the MySQL installation package

Because the machine does not have extranet permissions, it cannot be installed using Yum, so you need to download the package locally.

wget http://Mirrors.sohu.com/mysql/mysql-5.5/mysql-5.5.55-1.el6.x86_64.rpm-bundle.tar
3. Install and start the MySQL service
Unzip the Tarball tar-xf Mysql-5.5.55-1.el6.x86_64.rpm-bundle.tar
Installing the service-side RPM-IVH mysql-server-5.5.55-1.el6.x86_64.rpm
If the following error occurs, you can perform the Yum install Libaio to resolve libaio.so.1 () (64bit) is needed by mysql-server-5.5.55-1.el6.x86_64 Libaio.so.1 (libaio_0.1) (64bit) is needed by mysql-server-5.5.55-1.el6.x86_64 Libaio.so.1 (libaio_0.4) (64b It) is needed by mysql-server-5.5.55-1.el6.x86_64 installation client RPM-IVH mysql-client-5.5.55-1.el6.x86_64.rpm

At this point the MySQL service can be started, the subsequent need to modify the configuration file, so here first put the configuration file before starting the service.

If MY.CNF is not found under/etc/, go to/usr/share/mysql and find my-medium.cnf and copy to/etc/renamed MY.CNF

4. Start the service and modify the root password
Start Services service MySQL start modify root password /usr/bin/mysqladmin-u root password  123456-u root-p

5. Allow root users to connect remotely
Execute after logging into server
GRANT all privileges on * * to ' root ' @ '% ' identified by ' 123456 ' with GRANT OPTION;

6. Configure the master-slave service

The same version installs the slave machine.

6.1 Master Authorization 6.1.1. Adding a telnet user to master
Mysql>grant REPLICATION SLAVE on * * to ' repl ' @ ' 192.168.61.157 ' identified by ' repl ';
6.1.2. Refreshing authorizations and viewing authorization results
mysql>flush Privileges;mysql for "repl" @ "192.168.61.157";
6.1.3 Test slave Telnet Master
Mysql-h 192.168.61.150-u Repl-prepl (note no spaces after-p)
6.2 Modify the master configuration file in My.cnf to find the following information, if not manually added:
[Mysqld]log-bin=mysql-Bin # Confirm open Binlog log binlog_format=mixed # confirm Binlog log format mixd mixed type Server-id=1 # Specify a unique server-id within the entire master-slave architecture 
6.3 Modifying the slave configuration file
[mysqld]log[mysqld] log-bin=mysql-bin # Confirm open Binlog log binlog_format=Mixed # Confirm that the Binlog log format is mixd mixed type server-id=2 # Specifies a unique server-id throughout the master-slave architecture
replicate_do_db=test0
Replicate_do_db=test1

Slave Other optional configurations:

1. White List-just want to copy a few libraries: replicate_do_db=TestDB #只复制testdb库 (configurable multiple)2. White List-just want to copy a certain (some) library (all tables) replicate_wild_do_table=testdb.%#复制testdb库的所有表 (configurable multiple)3. White List-just want to copy some (some) libraries (some of the tables) replicate_wild_do_table=testdb.t1 #复制testdb. T1 table Replicate_wild_do_table=testdb.t2 #复制testdb. t2 table4. Blacklist-want to ignore the replication of MySQL database replicate_ignore_db=MySQL #不复制mysql库 (configurable multiple)5. Blacklist-you want to ignore the replication of some tables for some libraries replicate_wild_ignore_table=mysql.users # mysql.users Table not replicated (configurable multiple)6. If you want to implement the "----------from" linked schema, because by default, the data copied from master is not written to the Binlog log in slave, but instead to the relay log (localhost-relay-bin.00000x), so slave if you still need to act as master for other machines, the data copied from master is also written to the slave local Binlog log, adding the following configuration: Log-slave-updates =1

6.4Master operation
Mysql>flush Logs (Refresh Master log record) MySQL>show master status (view host last log file and last start point)

6.5 Slave operation

1. Execute the command on slave, dynamically change the configuration to connect to master, generate or update the Master.info file:

Change Master to master_host= "192.168.61.150", master_port=3359, master_user= ' Repl ',  master_password= ' Repl ',  master_log_file= ' mysql-bin.000009 ',  master_log_pos=107;

Optional configuration:

master_heartbeat_period=60 #60秒探测一次Master是否在线master_connect_retry=10 #无法连接Master的时候重试连接的间隔时间为10秒

2. Start the IO thread

Responsible for copying the mysql-bin.00000x logs from the master side and putting all the copied data into the localhost-relay-bin.00000n log) and the SQL thread (responsible for reading the information in the relay log (RELAY-LOG.INFO). Writes the data in the localhost-relay-bin.00000n log to the local slave. and view the slave status. If no error indicates that the configuration was successful

mysql> start slave;mysql> show slave status;

6.6 Testing

Test0 and test1 on master Create tables or write data, and the same data will appear in slave

centos6.6 manually installing mysql5.5 and configuring Master-Slave synchronization

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.