当前位置:网站首页>MySQL master-slave configuration
MySQL master-slave configuration
2022-06-30 15:49:00 【Bug trendsetter】
How to install mysql database , There's no more here , Just the master-slave copy of it , Steps are as follows :
1、 The master and slave servers perform the following operations respectively : 1.1、 Versions, 1.2、 Initialize the table , And start in the background mysql 1.3、 modify root Password 2、 Modify the master server master: #vi /etc/my.cnf [mysqld] log-bin=mysql-bin //[ must ] Enable binary logging server-id=222 //[ must ] The server is unique ID, The default is 1, Usually take IP The last paragraph 3、 Modify from server slave: #vi /etc/my.cnf [mysqld] log-bin=mysql-bin //[ It's not necessary ] Enable binary logging server-id=226 //[ must ] The server is unique ID, The default is 1, Usually take IP The last paragraph 4、 Restart two servers mysql /etc/init.d/mysql restart 5、 Set up an account on the primary server and authorize slave: #/usr/local/mysql/bin/mysql -uroot -pmttang mysql>GRANT REPLICATION SLAVE ON *.* to 'mysync'@'%' identified by 'q123456'; // 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 . 6、 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 | +------------------+----------+--------------+------------------+ | mysql-bin.000004 | 308 | | | +------------------+----------+--------------+------------------+ 1 row in set (0.00 sec) notes : Do not operate the master server after this step MYSQL, Prevent the state value of the primary server from changing 7、 Configure slave Slave: mysql>change master to master_host='192.168.145.222',master_user='mysync',master_password='q123456', master_log_file='mysql-bin.000004',master_log_pos=308; // Be careful not to disconnect ,308 There is no single quotation mark around the number . Mysql>start slave; // Start copy from server 8、 Check the status of the copy function from the server : mysql> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.2.222 // Primary server address Master_User: mysync // Authorized account name , Avoid using root Master_Port: 3306 // Database port , Some versions don't have this trip Connect_Retry: 60 Master_Log_File: mysql-bin.000004 Read_Master_Log_Pos: 600 //# Where to synchronously read binary logs , Greater than or equal to Exec_Master_Log_Pos Relay_Log_File: ddte-relay-bin.000003 Relay_Log_Pos: 251 Relay_Master_Log_File: mysql-bin.000004 Slave_IO_Running: Yes // This state must be YES Slave_SQL_Running: Yes // This state must be YES ...... 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 ). The above operation process , Master slave server configuration completed . 9、 Master slave server test : master server Mysql, Building a database , And create a table in this library to insert a piece of data : mysql> create database hi_db; Query OK, 1 row affected (0.00 sec) mysql> use hi_db; Database changed mysql> create table hi_tb(id int(3),name char(10)); Query OK, 0 rows affected (0.00 sec) mysql> insert into hi_tb values(001,'bobu'); Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | hi_db | | mysql | | test | +--------------------+ 4 rows in set (0.00 sec) From the server Mysql Inquire about : mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | hi_db | //I'M here, You see | mysql | | test |
+--------------------+ 4 rows in set (0.00 sec) mysql> use hi_db Database changed mysql> select * from hi_tb; // View the specific data added on the main server +------+------+ | id | name | +------+------+ | 1 | bobu | +------+------+ 1 row in set (0.00 sec)
10、 complete :
Write a shell Script , use nagios monitor slave Of the two yes(Slave_IO And Slave_SQL process ), If only one or zero is found yes, It shows that there is something wrong with the master and the slave , Send a text alert .
边栏推荐
- [sub matrix quantity statistics] cf1181c flag sub matrix quantity statistics
- 容器常用命令
- Review 2021, embrace change and live up to Shaohua
- With as subquery in Oracle
- 4.2 escape characters
- How to browse mobile web pages on your computer
- CVPR 2022丨特斯联AI提出:基于图采样深度度量学习的可泛化行人重识别
- 交调与互调的区别
- 《你的灯亮着吗》开始解决问题前,得先知道“真问题”是什么
- 《网络是怎么样连接的》读书笔记 - 汇总篇
猜你喜欢

Smart wind power: operation and maintenance of digital twin 3D wind turbine intelligent equipment

Policy Center > Google Play‘s Target API Level Policy

Policy Center > Deceptive Behavior
![Warning: [antd: Menu] `children` will be removed in next major version. Please use `items` instead.](/img/c1/99ad29789a669c4498fb93ce1fb009.png)
Warning: [antd: Menu] `children` will be removed in next major version. Please use `items` instead.

Policy Center > Device and Network Abuse

Chapter III installation and use of jupyter

Summary of gradient descent optimizer (rmsprop, momentum, Adam)

Policy Center > Misrepresentation

Phone number shielding function

什么是XR扩展现实,XR云串流平台有哪些
随机推荐
Policy Center-User Data
How does sd-rtn ensure the high availability of RTE services after infrastructure failure
Teach you a learning method to quickly master knowledge
互联网研发效能之去哪儿网(Qunar)核心领域DevOps落地实践
Flask Sqlalchemy - how to use custom query criteria ---orm (7)
ASP. Net core Middleware
On which platform is it safer to buy Treasury reverse repo?
Specific steps for installing mysql8.0 on Windows system
C language foundation - pointer array - initialization method & constant pointer array, pointer constant array
Expressions in if statements
Go micro installation
Visualization of provincial GDP with CSV metabase processing
Pycharm----xx. So cannot open shared object file problem solving
Policy Center > Misrepresentation
iMeta | 叶茂/时玉等综述环境微生物组中胞内与胞外基因的动态穿梭与生态功能...
Policy Center-User Data
Policy Center > Google Play‘s Target API Level Policy
Deep understanding Net (2) kernel mode 1 Kernel mode construct event event
Policy Center > Deceptive Behavior
4.12 input() input function and comments