当前位置:网站首页>MySQL master-slave configuration under CentOS
MySQL master-slave configuration under CentOS
2022-04-23 16:49:00 【A coir boat in the broken white clouds】
One 、 Basic configuration
On two mysql Create databases separately in ( name 、 structure 、 The codes must be consistent
Two 、 Main server configuration
modify my.cnf file
[mysqld]
slow_query_log=ON
long_query_time=5
pid-file=/var/run/mysqld/mysqld.pid
socket=/var/run/mysqld/mysqld.sock
datadir=/var/lib/mysql
server-id=001 # service id Must be unique
read-only=0
log-bin=mysql-bin
log_bin_trust_function_creators=1
transaction-isolation=READ-COMMITTED
character-set-server = utf8
server-id=001
binlog-do-db=db1 # The name of the synchronized database
binlog-do-db=db2 # The name of the synchronized database
expire_logs_days=10
binlog_format=MIXED
max_allowed_packet=256M
max_binlog_size=1024m
innodb_log_file_size=2GB
group_concat_max_len=1024000
lower_case_table_names=1
max_connect_errors=1000
symbolic-links=0
log-error=/var/log/mysqld.log
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Sign in mysql Configure the account authorization to log in to the master server from the server
-- Authorized operation
set global validate_password_policy=0;
set global validate_password_length=1;
grant replication slave on *.* to 'root'@'%' identified by '123456';
-- Refresh the permissions
flush privileges;
# restart mysql service
service mysqld restart
3、 ... and 、 Configure slave service area
modify my.cnf file
[mysql]
# Set up mysql Client default character set
default-character-set=utf8
[mysqld]
# Port number ( Can't repeat
port=3301
# Set up mysql Installation directory
basedir=/usr/local/mysql
# Set up mysql Database data storage directory
datadir=/data/mysql_platform/data
# Server's id( Can't repeat
server-id=101
socket=/data/mysql_platform/mysql.sock
# Error log storage directory
log_error=/data/mysql_platform/logs/mysql.log
# Binary log storage directory
log_bin=/data/mysql_platform/logs/mysql-bin
# Binary file format
binlog-format=MIXED
# Maximum connections allowed
max_connections=200
# The character set used by the server defaults to 8 Bit coded latin1 Character set
character-set-server=utf8
# The default storage engine that will be used when creating a new table
default-storage-engine=INNODB
# The name of the synchronized database
replicate-do-db=db1
replicate-do-db=db2
# establish slave_master_info Table of
master-info-repository = table
# establish mysql.slave_relay_info Table to record the location information of synchronization
relay-log-info-repository = table
1. restart mysql service
systemctl restart mysql_platform.service
2. Log in to the main library to view relevant information
# Sign in mysql database
mysql -urep_db_user -p
# see master The state of
show master status\G( Be careful : There's no semicolon
3. Log in from the library and connect
# Log in from library mysql
mysql -uroot -p -S /data/mysql_platform/mysql.sock
# Connect to the main server
change master to master_host='192.168.100.195',master_user='root',master_password='123456',master_port=3306,master_log_file='m y-logbin.000067 ',master_log_pos=970;
( Be careful : After disconnection ,master_log_file and master_log_pos It will change , Reconnection needs to be checked again )
4. start-up slave
start slave
5. see slave The state of
show slave status\G
Be careful : Only 【Slave_IO_Running】 and 【Slave_SQL_Running】 All are Yes, Then synchronization is normal . If it is No perhaps Connecting Neither. , Check the error log to find out the problem .
6、 The end! ~~ Let's have a try ~~
版权声明
本文为[A coir boat in the broken white clouds]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231400068295.html
边栏推荐
- 如何用Redis实现分布式锁?
- Detailed explanation of information abstract, digital signature, digital certificate, symmetric encryption and asymmetric encryption
- Take according to the actual situation, classify and summarize once every three levels, and see the figure to know the demand
- Execution plan calculation for different time types
- Loading order of logback configuration file
- 建站常用软件PhpStudy V8.1图文安装教程(Windows版)超详细
- 计算饼状图百分比
- 文件系统读写性能测试实战
- PyTorch:train模式与eval模式的那些坑
- Dancenn: overview of byte self-developed 100 billion scale file metadata storage system
猜你喜欢
Xinwangda: HEV and Bev super fast charging fist products are shipped on a large scale

SQL database

Dancenn: overview of byte self-developed 100 billion scale file metadata storage system

loggie 源码分析 source file 模块主干分析

博士申请 | 厦门大学信息学院郭诗辉老师团队招收全奖博士/博后/实习生

【Pygame小游戏】10年前风靡全球的手游《愤怒的小鸟》,是如何霸榜的?经典回归......

Kunteng full duplex digital wireless transceiver chip kt1605 / kt1606 / kt1607 / kt1608 is suitable for interphone scheme

STM32__ 03 - beginner timer

∑GL-透视投影矩阵的推导

TypeError: set_ figure_ params() got an unexpected keyword argument ‘figsize‘
随机推荐
如何用Redis实现分布式锁?
JMeter installation tutorial and solutions to the problems I encountered
拷贝构造函数 浅拷贝与深拷贝
Public variables of robotframework
RTKLIB 2.4.3源码笔记
Introduction to how to set up LAN
ACL 2022 | DialogVED:用于对话回复生成的预训练隐变量编码-解码模型
杂文 谈谈古典的《拆掉思维里的墙》
Do you really understand the principle of code scanning login?
Differences between MySQL BTREE index and hash index
05 Lua control structure
Flask如何在内存中缓存数据?
Deeply understand the relevant knowledge of 3D model (modeling, material mapping, UV, normal), and the difference between displacement mapping, bump mapping and normal mapping
SQL database
Sail soft calls the method of dynamic parameter transfer and sets parameters in the title
Custom implementation of Baidu image recognition (instead of aipocr)
关于 background-image 渐变gradient()那些事!
How magical is the unsafe class used by all major frameworks?
How to choose the wireless gooseneck anchor microphone and handheld microphone scheme
Introduction to new functions of camtasia2022 software