In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "mysql master-slave replication steps", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn the "mysql master-slave replication steps"!
I. description of the environment
Master server ip:192.168.0.2
Ip:192.168.0.3 from the database server
The master-slave server has been newly installed, but it is not put into production, so no data is generated.
Second, master-slave replication configuration
1. Primary database server master configuration
(1) authorize the slave server slave
Mysql > grant replication slave on *. * to identified by "123"
(2) View master status
Mysql > show master status
+-+
| | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | |
+-+
| | mysql-bin.000003 | 400 | |
+-+
1 row in set (0.00 sec)
Make a note of file and position, which you will need to configure slave later. (file is the file of the mysql log, and position is the thread number of the log, which will be copied from this location on the server)
two。 Slave configuration from database server
(1) modify the server id of slave to avoid duplication with other my
Vi / etc/my.cnf
Server-id = 2
(2) execute the synchronization of sql statements
Mysql > change master to master_host=192.168.0.2, master_user=slave, master_password=123, master_log_file=mysql-bin.000003, master_log_pos=400
(3) start the synchronization function of slave
Mysql > start slave
(4) View slave status
Mysql > show slave status G
* * 1. Row *
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.2
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 548
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 399
Relay_Master_Log_File: mysql-bin.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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: 548
Relay_Log_Space: 554
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: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.02 sec)
ERROR:
No query specified
Note: Slave_IO_Running: Yes
Slave_SQL_Running: Yes when both IO and SQL processes are Yes,master and slave, master-slave replication can be performed.
Third, verification testing
1. Create a test table (root user) on master
Mysql > use test
Mysql > create table tbs (id int)
Mysql > insert into tbs values (1)
two。 Check on slave to see if the replication was successful (root user)
Mysql > use test
Mysql > show tables
Mysql > select * from tbs
+-+
| | id |
+-+
| | 1 |
+-+
1 row in set (0.00 sec)
Shows that the copy was successful!
Thank you for your reading, the above is the content of "mysql master-slave replication steps". After the study of this article, I believe you have a deeper understanding of the steps of mysql master-slave replication, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.