In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Master-slave replication configuration
a. Environment: CentOS7.4,IP address is the master library: 192.168.11.146, slave library: 192.168.11.238
The master library version should be less than or equal to the slave library version. MySQL 8.0.13 is used here.
b. Main library configuration / etc/my.cnf file
[mysqld]
# General configuration options
User=mysql
Port=3306
Server_id=1
Basedir= / usr/local/mysql
Datadir= / usr/app/mysqldata
Character_set_server=utf8
Pid_file=/usr/app/mysqldata/mysql.pid
Socket = / var/run/mysqld/mysqld.sock
# error Log
Log_error= / usr/app/mysqldata/myerror.log
# slow log
Slow_query_log=1
Slow_query_log_file=/usr/app/mysqllog/mysql.slow
Long_query_time=5
# bin_log Log
Log_bin=/usr/app/mysqllog/mysql_bin
Skip_external_locking
Skip_name_resolve
# enable independent tablespaces
Innodb_file_per_table = on
[mysql]
No-auto-rehash
Socket = / var/run/mysqld/mysqld.sock
# default-character-set=utf8
# safe-updates
[client]
Loose-default-character-set = utf8
Restart the MySQL service
/ etc/init.d/mysqld start
Authorized slvave user
Grant replication slave,replication client on. To 'slvae_rp' identified by' 111111'
Flush privileges
From the library configuration / etc/my.cnf file
[mysqld]
# General configuration options
User=mysql
Port=3306
Server_id=1
Basedir= / usr/local/mysql
Datadir= / usr/app/mysqldata
Character_set_server=utf8
Pid_file=/usr/app/mysqldata/mysql.pid
Socket = / var/run/mysqld/mysqld.sock
# error Log
Log_error= / usr/app/mysqldata/myerror.log
# slow log
Slow_query_log=1
Slow_query_log_file=/usr/app/mysqllog/mysql.slow
Long_query_time=5
# bin_log Log
Log_bin=/usr/app/mysqllog/mysql_bin
# enable Relay Log
Relay_log=/var/lib/mysql/relay-log
Log_slave_updates=1 # logs updates performed by its SQL threads from the server to the server's own binary log
Read_only=1 # read-only mode
Skip_external_locking
Skip_name_resolve
# enable independent tablespaces
Innodb_file_per_table = on
[mysql]
No-auto-rehash
Socket = / var/run/mysqld/mysqld.sock
# default-character-set=utf8
# safe-updates
[client]
Loose-default-character-set = utf8
Restart the mysql service
/ etc/init.d/mysqld restart
Main library:
Show master status
From the library:
Change master to
Master_host='192.168.11.146'
Master_port=3306
Master_user='slave_rp'
Master_password='111111'
Master_log_file='mysql-bin.000001'
Master_log_pos=154
Enable slave library slava
Start slave
View the status of slave libraries
Show slave status
Confirmed as normal:
Slave_io_running:yes
Slave_sql_running:yes
Seconds_behind_master 0
two。 Principle of master-slave replication
Two threads are generated from the library, one is an Icano thread and the other is a SQL thread
The iCompo thread requests the binlog of the main library and writes the resulting binlog log to the relay log (Relay Log) file.
The master library generates a log dump thread that is used to pass binlog to the slave library iUnix thread.
The SQL thread reads the log in the relay log file and parses it into specific operations to achieve the consistency of the master-slave operation and the final data consistency.
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.