In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
MySQL replication technology: master-slave
Establishing the most basic replication in MySQL can be summarized into the following three steps:
1. Configure a server as a Master
two。 Configure a server as a Slave
3. Connect Slave to Master.
1) configure Master
1. Configuration of parameters in my.cnf
Configure the server as Master. Make sure that the server has an active binary log (binary log) and a unique server ID.
a. If the logs on Master have not been deleted, the binary log records all the changes on Master, and it would be nice to re-execute these logs on Slave.
b. Server ID is used to distinguish between servers
Both the creation of binary logs and the server ID are set in my.cnf
The other parameters are not shown here.
Log-bin = / data/mysql/log/vm1-bin.log
Log-bin-index = / data/mysql/log/master-bin.index
Server-id = 1
The log-bin option gives the base name of all files generated by the binary log (the default is hostname-bin); the log-bin-index option gives the file name of the binary index file, which is known to be a list of all binary files.
Each server has a unique server-id
Restart the service mysqld service restart according to the above configuration to make the parameters take effect.
two。 Create a replication user on master and grant permissions
For example:
Create user repuser
Grant replication slave on *. * to repuser identified by 'aa12AA,.'
2) configure Slave
1. Configuration of parameters in my.cnf
Relay-log-index = / data/mysql/log/vm2-slave-bin.index
Relay-log=/data/mysql/log/vm2-slave-bin.log
Server-id = 2
The relay-log-index option is the relay log index file, and the relay-log option is the relay log file name.
two。 Restart the service so that the parameters take effect.
3) Connect Master and Slave
First find the server information of Master 1. Hostname 2. Port number (available in master's my.cnf) accounts and passwords with replication slave permissions on 3.Master (such as the reply_user we just established)
Execute the statement to establish the connection on the slave:
Change master to
Master_host = '192.168.12.181'
Master_port = 3306
Master_user = 'repuser'
Master_password = 'aa12AA,.'
-- start replication
Start slave
-- View the status of replication
Show slave status\ G
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.