Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Build master-slave replication based on gtid MySQL 5.7via mysqldump

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Install Master and Slave MySQL 5.7

# main MySQL5.7useradd mysql / sbin/nologincd / usr/localtar-xvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gzmv mysql-5.7.23-linux-glibc2.12-x86_64/ mysqlcd mysqlmkdir data confvim conf/my.cnf--- [mysqld] basedir=/usr/local/mysqldatadir=/usr / local/mysql/datasocket=/tmp/mysql.socksymbolic-links=0log-error=/tmp/mysqld.logpid-file=/usr/local/mysql/data/mysqld.pidserver-id=10port=3388gtid_mode=onenforce_gtid_consistency=onlog_binbinlog_format=row---export PATH=$PATH:/usr/local/mysql/binmysqld-defaults-file=/usr/local/mysql/conf/my.cnf- -initialize-- user=mysqlmysqld_safe-- defaults-file=/usr/local/mysql/conf/my.cnf-- user=mysql & # from MySQL5.7useradd mysql/ sbin/nologincd / usr/localtar-xvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gzmv mysql-5.7.23-linux-glibc2.12-x86_64/ mysqlcd mysqlmkdir data confvim conf/my.cnf-- -[mysqld] basedir=/usr/local/mysqldatadir=/usr/local/mysql/datasocket=/tmp/mysql.socksymbolic-links=0log-error=/tmp/mysqld.logpid-file=/usr/local/mysql/data/mysqld.pidserver-id=20port=3388gtid_mode=onenforce_gtid_consistency=onlog_binbinlog_format=row---export PATH=$PATH:/usr/local/mysql/binmysqld-defaults-file=/usr/local/mysql/conf/my.cnf-initialize-user=mysqlmysqld_safe-defaults-file=/usr/local/mysql/conf/my.cnf-user=mysql &

Master-slave node changes root@'localhost' password and creates replication account

Set sql_log_bin=0;alter user root@'localhost' identified by 'MySQL5.7';create user root@'%' identified by' MySQL5.7';grant all on *. * to root@'%';flush privileges; set sql_log_bin=1

Generate test data on the master node

#! / bin/bashsysbench / usr/share/sysbench/tests/include/oltp_legacy/oltp.lua\-- mysql-host=192.168.1.225\-- mysql-port=3388\-- mysql-user=root\-- mysql-password=MySQL5.7\-- oltp-test-mode=complex\-- oltp-tables-count=10\-- oltp-table-size=1000000\-- threads=10\-time=120\-- report-interval=10\-- db-driver=mysql prepare

Transfer the data from the master node to the slave node

Mysqldump-S / tmp/mysql.sock-u root-pMySQL5.7\-- all-databases-- triggers-- routines-- events\-- single-transaction-- quick | mysql-h 192.168.1.226-P 3388-u root-pMySQL5.7

Assign the slave server to the master server

Change master to master_host='192.168.1.225',master_port=3388,master_user='root',master_password='MySQL5.7',master_auto_position=1;start slave;show slave status\ G

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report