Deploying and Tuning 2.8 MySQL master-slave configuration-2

Source: Internet
Author: User

Configure Master-Slave preparation

Create a test database in our Lord

First log in to master MySQL, or use the absolute path/usr/local/mysql/bin/mysql

Mysql
> CREATE Database db1; > Quit

Copy MySQL Library

123. sql

Copy MySQL Library

123. sql

Log in to master MySQL and view the table. The cuff has been sent over.

MySQL> Use db1; > Show tables;
> Quit

Preparing the configuration file

Vim/etc/my.cnf
Server-id       1if  want to log updateslog-bin=bin-log changed to server-id       1if you want to log updateslog-bin=Wangshaojun
Binlog-ignore-db=mysql

The server ID is not the same as other

Log-bin can be customized

BINLOG-DO-DB=DB1,DB2 List of Confessions

Binlog-ignore-db=mysql List blacklist

Restart MySQL

/etc/init.d/mysqld restart

View the new Binlog

Ls/data/mysql

wangshaojun.000001 Wangshaojun.index
Wangshaojun.err Wangshaojun.pid

Authorized

Log in to master MySQL, create a user


' Repl ' @'127.0.0.1'123123';

Grant replication rights user name Repl password 123123

Refresh

> Flush Privileges;

Lock dead Table Read

lock;

Read Master

Show master status;

File wangshaojun.000001

Position 331

Edit the configuration file from MySQL

Vim/usr/local/mysql_slave/my.cnf
Server-id       1 changed to server-id       111

Create a MySQL library and copy the same table as the master MySQL

" CREATE DATABASE DB1 "
Mysql-s/tmp/mysql_slave.sock  123. sql

Log in from MySQL

Mysql-s/tmp/mysql_slave.sock

Stop the operation first,

> slave stop;> change Master to master_host='127.0.0.1', master_port=  3306, master_user='repl', master_password='123123', master_log_file='wangshaojun.000001', master_log_pos=331;

Open

> Slave start;

To see if the configuration was successful

show slave status\g;

Slave_io_running:no
Slave_sql_running:yes

Whether it is two Yes

Let's just stop MySQL.

> slave stop; > Quit

Restart

/etc/init.d/mysqldslave restart

Log in from MySQL

Mysql-s/tmp/mysql_slave.sock
>  slave start; > Show slave status\g;

Slave_io_running:yes
Slave_sql_running:yes

The configuration file failed because it was not restarted.

Deploying and Tuning 2.8 MySQL master-slave configuration-2

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.