技术控

    今日:62| 主题:49471
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] Perform Hot Backups of MySQL Databases with Percona XtraBackup on Ubuntu 16.04

[复制链接]
惊梦 发表于 2016-10-1 01:34:51
144 1

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
Percona XtraBackupis an open source backup utility for MySQL. It supports all MySQL flavours like Percona Server, MariaDB, and (Oracle) MySQL. Percona Xtrabackup performs a Hot Backup for MySQL. Hot Backup means to create a backup of a MySQL server while it is running without a downtime.
  In this tutorial, I will show you how to create a hot MySQL database backup with the OpenSource tool Percona XtraBackup on Ubuntu 16.04 (Xenial Xerus). I will use MariaDB as the database server to perform the backup but th same setup will work for MySQL servers as well.
  Prerequisite

  
       
  • Ubuntu server 16.04 - (Xenial Xerus)   
  • MySQL or MariaDB server   
  • Root Privileges  
  Step 1 - Install Percona XtraBackup

  The first step is to install latest Percona XtraBackup software on our Ubuntu server. Log in to your server by SSH (or on the console):
   ssh[email protected]
  TYPE YOUR PASSWORD
  Percona XtraBackup is available in the Ubuntu repository, but we want to use the latest version from the Percona repository.
  Add the Percona repository by downloading the deb package from the web and install it with the dpkg command:
  wget https://repo.percona.com/apt/percona-release_0.1-3.$(lsb_release -sc)_all.deb
  sudo dpkg -i percona-release_0.1-3.$(lsb_release -sc)_all.deb
  Next, update the repository and install Ppercona XtraBackup 2.4 (the latest version at the moment):
  sudo apt-get update
  sudo apt-get install percona-xtrabackup-24
  Percona XtraBackup is installed.
  Step 2 - Configure User and Backup Directory

  To perform the hot backup, we need to create a new mysql user with special privileges and permissions. In this tutorial, I will use MariaDB 10.0 as the database server. If you have not installed a MySQL compatible database yet then you can install with command below:
  sudo apt-get install mariadb-server mariadb-client
  Set a secure password for the root user with this command:
  mysql_secure_installation
  If the MariaDB is installed, access the MariaDB/MySQL shell as root user with mysql client command:
  mysql -u root -p
  TYPE MySQL PASSWORD
   Create a new user called ' bekupuser ' with the password ' mypassword ' (chose a secure password for your server!):
  CREATE USER 'bekupuser'@'localhost' IDENTIFIED BY 'mypassword';
  Grant the user the following privileges: 'RELOAD, PROCESS, LOCK TABLES, REPLICATION CLIENT'.
  GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO 'bekupuser'@'localhost';
  FLUSH PRIVILEGES;
  exit
  Next, create a new directory to store the MySQL backup files:
  mkdir -p /data/backups/mysql/
  The new backup user and a backup directory have been created.
  Step 3 - Perform Backup with Innobackupex

   Innobackupexis a Perl script wrapper for the xtrabackup program. It's a patched version of the innobackup script provided by oracle, distributed with InnoDB Backup tool. Innobackupex provides backup for a whole MySQL database instance, using xtrabackup in combination with xbstream and xbcrypt.
  In this step, we will create and prepare a full backup for the MySQL instance.
  A. Create a backup with Innobackupex

  In step 2, we've created a new directory for the backup and added a new mysql backup user. We will use them now to create a backup with innobackupex command.
  Create a MySQL backup with the innobackupex to new directory '/data/backups/my_backup':
  innobackupex --user=bekupuser  --password=mypassword --no-timestamp /data/backups/my_backup
  Note:

   --user = user with required backup privileges (step-2).
   --password = password of the backup user.
   --no-timestamp = disable the creation of a new time-stamped subdirectory in the backup root dir.
   /data/backups/my_backup = directory for the backup, it will be created automatically during backup process. If the directory exists, you will get an error message.
   
Perform Hot Backups of MySQL Databases with Percona XtraBackup on Ubuntu 16.04-1 (available,software,database,running,without)

  Another option:
  mkdir -p /data/backups/my_backup2
  innobackupex --user=bekupuser --password=mypassword /data/backups/my_backup2
  or
  innobackupex --user=bekupuser --password=mypassword /data/backups/
  Note:

   If there is no directory ' my_backup2 ', you will get your directory based on ' timestamp ' format.
  Results:

Perform Hot Backups of MySQL Databases with Percona XtraBackup on Ubuntu 16.04-2 (available,software,database,running,without)

  B. Prepare a Full Backup with Innobackupex

  After creating a new backup, the data isn't ready for a restore. There is one more step so the data is ready to be restored. We need the 'prepare stage' so the data can be restored.
   Prepare backup using innobackupex with option --apply-log to the backup directory '/data/backups/my_backup ':
  innobackupex --apply-log /data/backups/my_backup
  Make sure the process is complete without error before you proceed.
12下一页
友荐云推荐




上一篇:Highlights of RubyConf Brazil 2016
下一篇:How can a computer deal a poker hand?
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

帅美俊 发表于 2016-10-2 02:39:54
开往春天的坦克!
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表