当前位置:网站首页>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 ).
边栏推荐
- Blood spitting finishing nanny level series tutorial - playing Fiddler bag capturing tutorial (7) - Fiddler status panel -quickexec command line
- mysql导入数据时已改成csv utf8文件且文件名为英文,为什么还是导入失败
- An interview question combining defer and function in golang
- mysql8.0 mha实现高可用《mha》
- JMeter distributed pressure measurement
- [manageengine]itsm application in retail industry
- 租房二三事
- Cesium polygon gradient texture (canvas)
- Focus on data | Haitai Fangyuan directly hits the construction idea of data security governance in the securities industry
- 数据库sql语句练习题「建议收藏」
猜你喜欢

Vivo official website app full model UI adaptation scheme

Face and key point detection: yolo5face practice

Pychart automatically enters the test mode when running the program

Add startup software items when the win system starts up

DDD go practice

When facing complex problems, systematic thinking helps you understand the essence of the problem

Focus on data | Haitai Fangyuan directly hits the construction idea of data security governance in the securities industry

浅谈web性能优化(一)
What's special about Huawei's innovative solutions to consolidate the foundation of ERP for small and medium-sized enterprises?

【FiddlerTX插件】使用Fiddler抓包腾讯课堂视频下载(抓不到包解决方案)
随机推荐
Please give an example of how to optimize MySQL index (sqlserver index optimization)
mysql8.0 mha实现高可用《mha》
一道golang中defer和函数结合的面试题
The inexplicability of Intel disassembly
Airtest solves the problem that a password needs to be entered in the process of "automatic packaging" (the same applies to random bullet frame processing)
As a test, how to understand thread synchronization and asynchrony
An interview question combining defer and function in golang
腾讯云数据库的可信可控之路
一道golang中关于map的并发读写的面试题
NPM module removal_ [solved] after NPM uninstalls the module, the module is not removed from package.json [easy to understand]
Advanced technology management - how can the team be broken?
Experience sharing of system architecture designers preparing for the exam: from point to surface
接口测试工具 restlet client
Database SQL statement exercise "suggestions collection"
How to choose sentinel vs. hystrix current limiting?
人脸与关键点检测:YOLO5Face实战
两数,三数之和
Job interviews are always a second kill? After reading the seckill system notes secretly stored by JD T8, I have given my knees
Fastjson deserialization vulnerability utilization analysis collection
Too many passwords, don't know how to record? Why don't you write a password box applet yourself