MySQL Master-slave replication

Source: Internet
Author: User

Two redhat virtual machines with MySQL in the environment

[Email protected] etc]# ifconfig-a # #记录下master的ip为192.168.88.145

[Email protected] ~]# Find/-name my-medium.cnf # #查找mysql的配置文件
/usr/local/mysql/mysql-5.5.32/support-files/my-medium.cnf
/usr/local/mysql/support-files/my-medium.cnf

[Email protected] ~]# CP/USR/LOCAL/MYSQL/MYSQL-5.5.32/SUPPORT-FILES/MY-MEDIUM.CNF/ETC # #复制配置文件到etc目录下
[Email protected] ~]# cd/etc
[[email protected] etc]# ls my-medium.cnf
My-medium.cnf

[Email protected] etc]# MV MY-MEDIUM.CNF my.cnf

[email protected] etc] #vi my.cnf # #修改my. cnf

Log-bin=mysql-bin # #开启master日志]

Server-id = 1 # #设置server-id

Log in to MySQL

[Email protected] etc]# mysql-uroot-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 2
Server Version:5.5.32-log Source Distribution

Copyright (c) and/or, Oracle, its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>

Mysql> Show master status; # #show Master status;
+------------------+----------+--------------+------------------+
| File | Position | binlog_do_db | binlog_ignore_db |
+------------------+----------+--------------+------------------+
|      mysql-bin.000001 |              107 |                  | |
+------------------+----------+--------------+------------------+
1 row in Set (0.00 sec)

Configure slave mysql in the same vein


[Email protected] etc]# ifconfig-a # #记录下slave的ip192.168.88.146



[Email protected] ~]# Find/-name my-medium.cnf # #查找mysql的配置文件
/usr/local/mysql/mysql-5.5.32/support-files/my-medium.cnf
/usr/local/mysql/support-files/my-medium.cnf

[Email protected] ~]# CP/USR/LOCAL/MYSQL/MYSQL-5.5.32/SUPPORT-FILES/MY-MEDIUM.CNF/ETC # #复制配置文件到etc目录下
[Email protected] ~]# cd/etc
[[email protected] etc]# ls my-medium.cnf
My-medium.cnf

[Email protected] etc]# MV MY-MEDIUM.CNF my.cnf

[email protected] etc] #vi my.cnf # #修改my. cnf

Log-bin=mysql-bin # #开启master日志]

Server-id = 1 # #设置server-id

Log in to MySQL

[Email protected] etc]# mysql-uroot-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 2
Server Version:5.5.32-log Source Distribution

Copyright (c) and/or, Oracle, its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.


Connect the master on the slave

mysql> Change Master to master_host= ' 192.168.88.145 ', master_user= ' root ', master_password= ' admin ',
-master_log_file= ' mysql-bin.000001 ', master_log_pos=107;
Query OK, 0 rows affected (0.07 sec)


Mysql> show Slave status\g;
1. Row ***************************
Slave_io_state:
master_host:192.168.88.145
Master_user:root
master_port:3306
Connect_retry:60
master_log_file:mysql-bin.000001
read_master_log_pos:107
relay_log_file:localhost-relay-bin.000001
Relay_log_pos:4
relay_master_log_file:mysql-bin.000001
Slave_io_running:no
Slave_sql_running:no
replicate_do_db:
replicate_ignore_db:
Replicate_do_table:
Replicate_ignore_table:
Replicate_wild_do_table:
Replicate_wild_ignore_table:
last_errno:0
Last_error:
skip_counter:0
exec_master_log_pos:107
relay_log_space:107
Until_condition:none
Until_log_file:
until_log_pos:0
Master_ssl_allowed:no
Master_ssl_ca_file:
Master_ssl_ca_path:
Master_ssl_cert:
Master_ssl_cipher:
Master_ssl_key:
Seconds_behind_master:null
Master_ssl_verify_server_cert:no
last_io_errno:0
Last_io_error:
last_sql_errno:0
Last_sql_error:
Replicate_ignore_server_ids:
master_server_id:0
1 row in Set (0.00 sec)

ERROR:
No query specified







MySQL Master-slave replication

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.