CentOS6.4 Configuring the MySQL server to start multiple ports, synchronizing single-table data

Source: Internet
Author: User
Tags mkdir

============================================================

= = multi-Port start = =

============================================================

Create Data Catalog

mkdir/usr/local/mysql/var1/

mkdir/usr/local/mysql/var2/

============================================================

assigning permissions

Chown-r mysql:mysql/usr/local/mysql/var1/

Chown-r mysql:mysql/usr/local/mysql/var2/

Chown-r mysql:mysql/usr/local/mysql/var1/.

Chown-r mysql:mysql/usr/local/mysql/var2/.

============================================================

Copying and configuring MY.CNF

Cp/etc/my.cnf/etc/my3307.cnf

Vi/etc/my3307.cnf

[Client]

Port = 3307

Socket =/usr/local/mysql/mysql3307.sock

[Mysqld]

Port = 3307

Socket =/usr/local/mysql/mysql3307.sock

----------

Cp/etc/my.cnf/etc/my3308.cnf

Vi/etc/my3308.cnf

[Client]

Port = 3308

Socket =/usr/local/mysql/mysql3308.sock

[Mysqld]

Port = 3308

Socket =/usr/local/mysql/mysql3308.sock

============================================================

Initializing the database

Cd/usr/local/mysql

scripts/mysql_install_db--user=mysql--datadir=/usr/local/mysql/var1/

scripts/mysql_install_db--user=mysql--datadir=/usr/local/mysql/var2/

============================================================

Start MySQL to specify the. cnf file and directory to start

/usr/local/mysql/bin/mysqld_safe--defaults-file=/etc/my3307.cnf--basedir=/usr/local/mysql/--datadir=/usr/local /mysql/var1/--user=mysql &

/usr/local/mysql/bin/mysqld_safe--defaults-file=/etc/my3308.cnf--basedir=/usr/local/mysql/--datadir=/usr/local /mysql/var2/--user=mysql &

============================================================

Set the root user password

mysqladmin-u root password ' 123456 '-s/usr/local/mysql/mysql3307.sock-p 3307

Login

Mysql-uroot-p123456-s/usr/local/mysql/mysql3307.sock-p 3307

Setting up remote Logins

GRANT all privileges on * * to [E- Mail protected]"%" identified by "123456";

Flush privileges;

----------

Set the root user password

mysqladmin-u root password ' 123456 '-s/usr/local/mysql/mysql3308.sock-p 3308

Login

Mysql-uroot-p123456-s/usr/local/mysql/mysql3308.sock-p 3308

Setting up remote Logins

GRANT all privileges on * * to [E- Mail protected]"%" identified by "123456";

Flush privileges;

============================================================

Stop Service

mysqladmin-h10.10.3.161-uroot-p123456-p3307 shutdown

============================================================

= = = Synchronous Single Watch = = =

============================================================

Port 3307 is the primary library, and Port 3308 is the slave library

Modifying a configuration file with Port 3307

Vi/etc/my3307.cnf

Server-id = 1
Log-bin=mysql-bin
Replicate-do-db=ds
Log-bin-index=mysql-bin.index
Relay-log-index=mysql-relay-bin.index
Relay-log=mysql-relay-bin

Modifying a configuration file with Port 3308

Vi/etc/my3308.cnf

Server-id = 2
Replicate-wild-do-table=ds.test
Relay-log-index=dns-relay-bin.index
Relay-log=dns-relay-bin

Restart Service

Log on to the main library with Port 3307

Mysql-uroot-p123456-s/usr/local/mysql/mysql3307.sock-p 3307

View the status of the main library

Show master status;

assigning permissions

GRANT REPLICATION slave,file on * * to ' root ' @ ' 10.10.3.161 ' identified by ' 123456 ';

Flush privileges;

Log on to the slave library with Port 3308

Mysql-uroot-p123456-s/usr/local/mysql/mysql3307.sock-p 3308

Stop slave;

Change Master to master_host= ' 10.10.3.161 ', master_user= ' root ', master_password= ' 123456 ', master_port=3307,master_  Log_file= 'mysql-bin.000001', master_log_pos=907; ( The Scarlet Letter is the two values to be remembered above )

Start slave

View from library status

show slave status\g;

Http://www.cnblogs.com/kgdxpr/p/3347562.html

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.