当前位置:网站首页>MySQL master-slave configuration
MySQL master-slave configuration
2022-07-25 21:28:00 【Taro cub】
One 、 Main service name master, From the server slave
master server : master
From the server : slave
The master and slave servers must have the same mysql To configure , Versions need to be consistent , You also need to build a similar database .
Modify the main service my.cnf The configuration file
[[email protected] mysql]# vi /etc/my.cnf # Main database side ID Number [ must ] The server is unique ID Cannot be connected with the slave server id identical server_id = 1 # Turn on binary log log-bin = mysql-bin # Database name to be copied , If you copy multiple databases , Repeat this option binlog-do-db = imModify from server my.cnf The configuration file
# From the server only ID [ must ] The server is unique ID, Can't communicate with the main server id identical server-id=2 # Enable relay logging relay-log=mysql-relaySet up an account on the primary server and authorize slave:
## master_test: account number ## root123456: password ## From the server ip: 127.0.0.1 ## Get into mysql Execute the following command grant replication slave on *.* to [email protected].0.0.1 identified by "root123456"; ## Generally do not use root Account number ,“%” Indicates that all clients may be connected to , Just account number , The password is correct , Specific clients are available here IP Instead of , Such as 192.168.145.226, Enhance security .Log in to the main server mysql, Inquire about master The state of
mysql> show master status; +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000001 | 16316 | im | | | +------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)File : mysql-bin.000001 Position 16316
These two values need to be copied in advance from the server configuration for standbyConfigure slave Slave:
mysql>change master to master_host=' master server ip',master_user='master_test',master_password='root123456', master_log_file='mysql-bin.000001',master_log_pos=16316; //308 There is no single quotation mark around the number .Start copy from server
start slave;Check the status of the copy function from the server
show slave status\G;These two values must be equal to Yes To synchronize successfully

notes :Slave_IO And Slave_SQL The process must run properly , namely YES state , Otherwise, it's all wrong ( Such as : One of them NO It's all wrong ).
边栏推荐
猜你喜欢

零基础学习CANoe Panel(17)—— Panel CAPL Function

基于腾讯地图实现精准定位,实现微信小程序考勤打卡功能

Interface testing tool restlet client

SSH private key realizes login to remote target server

Programmer's Guide to health quenching 5: introduction to sports Basics
What's special about Huawei's innovative solutions to consolidate the foundation of ERP for small and medium-sized enterprises?

Pychart automatically enters the test mode when running the program
![[fiddlertx plug-in] use Fiddler to capture the package Tencent classroom video download (unable to capture the package solution)](/img/de/7a288ee8e6001235d4869c10503932.png)
[fiddlertx plug-in] use Fiddler to capture the package Tencent classroom video download (unable to capture the package solution)

函数栈帧的创建和销毁

Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
随机推荐
Isn't it too much to play Gobang in idea?
一道golang中关于recover的面试题
cv图像翻转,EmguCV图像旋转「建议收藏」
strcpy()
腾讯云数据库的可信可控之路
【FiddlerTX插件】使用Fiddler抓包腾讯课堂视频下载(抓不到包解决方案)
Record the transfer of domain names from Alibaba cloud service providers to Huawei cloud
Pychart automatically enters the test mode when running the program
Fastjson deserialization vulnerability utilization analysis collection
The inexplicability of Intel disassembly
Debugged PEB (beingdebugged, ntglobalflag)
cts测试步骤(卡西欧cts200测试)
Job interviews are always a second kill? After reading the seckill system notes secretly stored by JD T8, I have given my knees
C#Socket
Experience sharing of system architecture designers preparing for the exam: from point to surface
The international summit osdi included Taobao system papers for the first time, and end cloud collaborative intelligence was recommended by the keynote speech of the conference
Zero basic learning canoe panel (17) -- panel CAPL function
MPI learning notes (II): two implementation methods of matrix multiplication
Product principles of non-financial decentralized application
Interviewer of large factory: how to quickly query a table with tens of millions of data?