In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you the "Percona xtrabackup2.4 version of remote backup and build slave database example analysis", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn the "Percona xtrabackup2.4 version of remote backup and build slave database example analysis" this article.
Environment introduction:
Server operating system version:
CentOS 6.9
Main library: 192.168.0.1
Slave library: 192.168.0.2
MySQL version: 5.7.20
Data file directory: / data/mysql/data
Because there is not enough space in the local directory of the master library, an error will be reported if the backup is local, so you can build a slave library by backing up the local remote backup to the destination machine, that is, the so-called streaming xbstream backup method, which does not take up the local disk space of the master library.
Step one:
You need to configure the Mysql master-slave server to trust each other locally, and log in with the public key without a password.
Log in to the main server:
# ssh-keygen-t rsa
Hit enter
Copy the id_rsa.pub to the slave server:
# ssh-copy-id-I. ssh / id_rsa.pub "- p22 root@192.168.0.1"
Step 2:
1. Install xtrabackup2.4: (note: version 2.4 must be installed for both master and slave libraries)
# wget http://www.percona.com/downloads/percona-release/redhat/0.1-4/\percona-release-0.1-4.noarch.rpm
# rpm-ivH percona-release-0.1-4.noarch.rpm
# yum list | grep percona
# yum install percona-xtrabackup-24
2. Create a backup of the master database:
# / usr/bin/innobackupex-defaults-file=/etc/my.cnf-user=root-password='123456'-host=192.168.0.1-stream=xbstream / data/backup | ssh root@192.168.0.2 "xbstream-x-C / data/backup"
3. Restore from the library:
Stop Mysql from the library first:
# mysqladmin-uroot-p shutdown; (or / etc/init.d/mysqld stop)
# mv / data/mysql/data / data/mysql/data.old # move go to the old database file directory
# mkdir / data/mysql/data
Application log (can be written as a script):
# cat resume.sh
/ usr/bin/innobackupex-defaults-file=/etc/my.cnf-user root-socket=/tmp/mysql.sock-apply-log / data/backup
Restore the database file:
# cat move-back.sh
/ usr/bin/innobackupex-defaults-file=/etc/my.cnf-user root-socket=/tmp/mysql.sock-move-back / home/mysql/backup
Note: you can also use copy-back, which is suitable for situations where there is enough disk space in the slave library)
Start the slave Mysql:
# chown-R mysql:mysql / data/mysql/*
# / usr/data/mysql/bin/mysqld_safe-- user=mysql &
Log in to the slave library after startup, and find the xtrabackup_binlog_info file in the / data/backup directory:
# cat / data/backup/xtrabackup_binlog_info
Mysql-bin.000008 229003653
Log in from the library and do change master:
Mysql > change master to master_host='192.168.0.1',master_user='slave',master_password='123456',master_log_file='mysql-bin.000008',master_log_pos=229003653,master_connect_retry=10
Mysql > start slave
Note: before building the slave library, remember to create a slave account.
The above is all the contents of the article "sample Analysis of remote backup and Building slave Library in Percona xtrabackup2.4 version". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.