主:192.168.232.141
辅:192.168.232.144
一、辅助端(192.168.232.144)
需要安装的软件包:
[root@mysql ~]# yum list | grep perl-DBD-MySQL perl-DBD-MySQL.x86_64 4.013-3.el6 @base [root@mysql ~]# [root@mysql ~]# rpm -qa | grep perl-DBD-MySQL perl-DBD-MySQL-4.013-3.el6.x86_64 [root@mysql ~]#
配置:Percona的YUM源:
[root@mysql ~]# wget http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm --2016-07-12 00:51:04-- http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm Resolving www.percona.com... 74.121.199.234 Connecting to www.percona.com|74.121.199.234|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm [following] --2016-07-12 00:51:15-- https://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm Connecting to www.percona.com|74.121.199.234|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 6566 (6.4K) [application/x-redhat-package-manager] Saving to: “percona-release-0.1-3.noarch.rpm” 100%[============================================================>] 6,566 --.-K/s in 0s 2016-07-12 00:51:21 (68.8 MB/s) - “percona-release-0.1-3.noarch.rpm” saved [6566/6566] [root@mysql ~]# ls anaconda-ks.cfg install.log install.log.syslog percona-release-0.1-3.noarch.rpm [root@mysql ~]# [root@mysql ~]# rpm -ivh percona-release-0.1-3.noarch.rpm warning: percona-release-0.1-3.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY Preparing... ########################################### [100%] 1:percona-release ########################################### [100%] [root@mysql ~]#
安装成功后:
[root@mysql ~]# rpm -qlp percona-release-0.1-3.noarch.rpm warning: percona-release-0.1-3.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY /etc/pki/rpm-gpg/RPM-GPG-KEY-Percona /etc/yum.repos.d/percona-release.repo /usr/share/doc/percona-release-0.1 /usr/share/doc/percona-release-0.1/RPM-GPG-KEY-Percona [root@mysql ~]# [root@mysql ~]# ll /etc/yum.repos.d/percona-release.repo -rw-r--r--. 1 root root 2501 Sep 22 2014 /etc/yum.repos.d/percona-release.repo [root@mysql ~]# [root@mysql ~]# cat /etc/yum.repos.d/percona-release.repo ######################################## # Percona releases and sources, stable # ######################################## [percona-release-$basearch] name = Percona-Release YUM repository - $basearch baseurl = http://repo.percona.com/release/$releasever/RPMS/$basearch enabled = 1 gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Percona [percona-release-noarch] name = Percona-Release YUM repository - noarch baseurl = http://repo.percona.com/release/$releasever/RPMS/noarch enabled = 1 gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Percona [percona-release-source] name = Percona-Release YUM repository - Source packages baseurl = http://repo.percona.com/release/$releasever/SRPMS enabled = 0 gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Percona #################################################################### # Testing & pre-release packages. You don't need it for production # #################################################################### [percona-testing-$basearch] name = Percona-Testing YUM repository - $basearch baseurl = http://repo.percona.com/testing/$releasever/RPMS/$basearch enabled = 0 gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Percona [percona-testing-noarch] name = Percona-Testing YUM repository - noarch baseurl = http://repo.percona.com/testing/$releasever/RPMS/noarch enabled = 0 gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Percona [percona-testing-source] name = Percona-Testing YUM repository - Source packages baseurl = http://repo.percona.com/testing/$releasever/SRPMS enabled = 0 gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Percona ############################################ # Experimental packages, use with caution! # ############################################ [percona-experimental-$basearch] name = Percona-Experimental YUM repository - $basearch baseurl = http://repo.percona.com/experimental/$releasever/RPMS/$basearch enabled = 0 gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Percona [percona-experimental-noarch] name = Percona-Experimental YUM repository - noarch baseurl = http://repo.percona.com/experimental/$releasever/RPMS/noarch enabled = 0 gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Percona [percona-experimental-source] name = Percona-Experimental YUM repository - Source packages baseurl = http://repo.percona.com/experimental/$releasever/SRPMS enabled = 0 gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Percona [root@mysql ~]#
使用该源,检索并安装:percona-xtrabackup。
[root@mysql ~]# yum list | grep percona-xtrabackup percona-xtrabackup.x86_64 2.3.5-1.el6 percona-release-x86_64 percona-xtrabackup-20.x86_64 2.0.8-587.rhel6 percona-release-x86_64 percona-xtrabackup-20-debuginfo.x86_64 2.0.8-587.rhel6 percona-release-x86_64 percona-xtrabackup-20-test.x86_64 2.0.8-587.rhel6 percona-release-x86_64 percona-xtrabackup-21.x86_64 2.1.9-746.rhel6 percona-release-x86_64 percona-xtrabackup-21-debuginfo.x86_64 2.1.9-746.rhel6 percona-release-x86_64 percona-xtrabackup-22.x86_64 2.2.13-1.el6 percona-release-x86_64 percona-xtrabackup-22-debuginfo.x86_64 2.2.13-1.el6 percona-release-x86_64 percona-xtrabackup-24.x86_64 2.4.3-1.el6 percona-release-x86_64 percona-xtrabackup-24-debuginfo.x86_64 2.4.3-1.el6 percona-release-x86_64 percona-xtrabackup-debuginfo.x86_64 2.3.5-1.el6 percona-release-x86_64 percona-xtrabackup-test.x86_64 2.3.5-1.el6 percona-release-x86_64 percona-xtrabackup-test-21.x86_64 2.1.9-746.rhel6 percona-release-x86_64 percona-xtrabackup-test-22.x86_64 2.2.13-1.el6 percona-release-x86_64 percona-xtrabackup-test-24.x86_64 2.4.3-1.el6 percona-release-x86_64 [root@mysql ~]# [root@mysql ~]# yum install -y percona-xtrabackup Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * extras: mirrors.tuna.tsinghua.edu.cn * updates: mirrors.163.com Resolving Dependencies --> Running transaction check ---> Package percona-xtrabackup.x86_64 0:2.3.5-1.el6 will be installed --> Processing Dependency: perl(DBD::mysql) for package: percona-xtrabackup-2.3.5-1.el6.x86_64 --> Running transaction check ---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed --> Processing Dependency: perl(DBI::Const::GetInfoType) for package: perl-DBD-MySQL-4.013-3.el6.x86_64 --> Processing Dependency: perl(DBI) for package: perl-DBD-MySQL-4.013-3.el6.x86_64 --> Running transaction check ---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================== Package Arch Version Repository Size ====================================================================================================== Installing: percona-xtrabackup x86_64 2.3.5-1.el6 percona-release-x86_64 5.4 M Installing for dependencies: perl-DBD-MySQL x86_64 4.013-3.el6 base 134 k perl-DBI x86_64 1.609-4.el6 base 705 k Transaction Summary ====================================================================================================== Install 3 Package(s) Total download size: 6.3 M Installed size: 7.4 M Downloading Packages: (1/3): percona-xtrabackup-2.3.5-1.el6.x86_64.rpm | 5.4 MB 00:33 (2/3): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm | 134 kB 00:00 (3/3): perl-DBI-1.609-4.el6.x86_64.rpm | 705 kB 00:01 ------------------------------------------------------------------------------------------------------ Total 174 kB/s | 6.3 MB 00:36 warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Percona Importing GPG key 0xCD2EFD2A: Userid : Percona MySQL Development Team Package: percona-release-0.1-3.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-Percona Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : perl-DBI-1.609-4.el6.x86_64 1/3 Installing : perl-DBD-MySQL-4.013-3.el6.x86_64 2/3 Installing : percona-xtrabackup-2.3.5-1.el6.x86_64 3/3 Verifying : perl-DBD-MySQL-4.013-3.el6.x86_64 1/3 Verifying : perl-DBI-1.609-4.el6.x86_64 2/3 Verifying : percona-xtrabackup-2.3.5-1.el6.x86_64 3/3 Installed: percona-xtrabackup.x86_64 0:2.3.5-1.el6 Dependency Installed: perl-DBD-MySQL.x86_64 0:4.013-3.el6 perl-DBI.x86_64 0:1.609-4.el6 Complete! [root@mysql ~]#
注意,这个安装过程可能会遇到错误。
具体参考:http://d-prototype.com/archives/5342
如果你没有MySQL,你需要安装MySQL:
[root@mysql ~]# yum list | grep --color Percona-Server-server Percona-Server-server-57.x86_64 5.7.13-6.1.el6 @Percona Percona-Server-server-51.x86_64 5.1.73-rel14.12.624.rhel6 percona-release-x86_64 Percona-Server-server-55.x86_64 5.5.50-rel38.0.el6 percona-release-x86_64 Percona-Server-server-56.x86_64 5.6.31-rel77.0.el6 percona-release-x86_64 [root@mysql ~]# [root@mysql ~]# [root@mysql ~]# rpm -qa | grep Percona Percona-Server-client-57-5.7.13-6.1.el6.x86_64 Percona-Server-server-57-5.7.13-6.1.el6.x86_64 Percona-Server-shared-57-5.7.13-6.1.el6.x86_64 [root@mysql ~]#
可以看到,我这里已经有MySQL了。
如果没有MySQL:
1. 你可以按照上面方法类似的,通过YUM安装:
yum install -y Percona-Server-server-57.x86_64
2. 或者,按照这个文档中的方法去安装:
登录MySQL:
[root@mysql ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.7.13-6 Percona Server (GPL), Release 6, Revision e3d58bb Copyright (c) 2009-2016 Percona LLC and/or its affiliates Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql>
该数据库会在后面作为192.168.232.143上的主库的辅助库。
主辅两端的“server_id”不能一样:
MySQL,辅助端:
mysql> show variables like 'server_id'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 0 | +---------------+-------+ 1 row in set (0.01 sec) mysql>
二、主库端(192.168.232.141)
按照之前辅助端的方法安装XtraBackup。
[root@python ~]# yum install -y Percona-Server-server-57.x86_64 percona-xtrabackup Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile * base: mirrors.sina.cn * extras: mirrors.sina.cn * updates: mirrors.tuna.tsinghua.edu.cn Resolving Dependencies --> Running transaction check ---> Package Percona-Server-server-57.x86_64 0:5.7.13-6.1.el6 will be installed --> Processing Dependency: Percona-Server-shared-57 for package: Percona-Server-server-57-5.7.13-6.1.el6.x86_64 --> Processing Dependency: Percona-Server-client-57 for package: Percona-Server-server-57-5.7.13-6.1.el6.x86_64 ---> Package percona-xtrabackup.x86_64 0:2.3.5-1.el6 will be installed --> Processing Dependency: perl(DBD::mysql) for package: percona-xtrabackup-2.3.5-1.el6.x86_64 --> Running transaction check ---> Package Percona-Server-client-57.x86_64 0:5.7.13-6.1.el6 will be installed ---> Package Percona-Server-shared-57.x86_64 0:5.7.13-6.1.el6 will be installed ---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed --> Processing Dependency: perl(DBI::Const::GetInfoType) for package: perl-DBD-MySQL-4.013-3.el6.x86_64 --> Processing Dependency: perl(DBI) for package: perl-DBD-MySQL-4.013-3.el6.x86_64 --> Running transaction check ---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================== Package Arch Version Repository Size ====================================================================================================== Installing: Percona-Server-server-57 x86_64 5.7.13-6.1.el6 percona-release-x86_64 40 M percona-xtrabackup x86_64 2.3.5-1.el6 percona-release-x86_64 5.4 M Installing for dependencies: Percona-Server-client-57 x86_64 5.7.13-6.1.el6 percona-release-x86_64 8.0 M Percona-Server-shared-57 x86_64 5.7.13-6.1.el6 percona-release-x86_64 903 k perl-DBD-MySQL x86_64 4.013-3.el6 base 134 k perl-DBI x86_64 1.609-4.el6 base 705 k Transaction Summary ====================================================================================================== Install 6 Package(s) Total download size: 55 M Installed size: 57 M Downloading Packages: (1/6): Percona-Server-client-57-5.7.13-6.1.el6.x86_64.rpm | 8.0 MB 01:07 (2/6): Percona-Server-server-57-5.7.13-6.1.el6.x86_64.rpm | 40 MB 05:14 (3/6): Percona-Server-shared-57-5.7.13-6.1.el6.x86_64.rpm | 903 kB 00:07 (4/6): percona-xtrabackup-2.3.5-1.el6.x86_64.rpm | 5.4 MB 00:48 (5/6): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm | 134 kB 00:01 (6/6): perl-DBI-1.609-4.el6.x86_64.rpm | 705 kB 00:03 ------------------------------------------------------------------------------------------------------ Total 128 kB/s | 55 MB 07:24 warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Percona Importing GPG key 0xCD2EFD2A: Userid : Percona MySQL Development Team Package: percona-release-0.1-3.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-Percona warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 Importing GPG key 0xC105B9DE: Userid : CentOS-6 Key (CentOS 6 Official Signing Key) Package: centos-release-6-8.el6.centos.12.3.x86_64 (@anaconda-CentOS-201605220104.x86_64/6.8) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : Percona-Server-shared-57-5.7.13-6.1.el6.x86_64 1/6 Installing : Percona-Server-client-57-5.7.13-6.1.el6.x86_64 2/6 Installing : perl-DBI-1.609-4.el6.x86_64 3/6 Installing : perl-DBD-MySQL-4.013-3.el6.x86_64 4/6 Installing : percona-xtrabackup-2.3.5-1.el6.x86_64 5/6 Installing : Percona-Server-server-57-5.7.13-6.1.el6.x86_64 6/6 Percona Server is distributed with several useful UDF (User Defined Function) from Percona Toolkit. Run the following commands to create these functions: mysql -e "CREATE FUNCTION fnv1a_64 RETURNS INTEGER SONAME 'libfnv1a_udf.so'" mysql -e "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'" mysql -e "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'" See http://www.percona.com/doc/percona-server/5.7/management/udf_percona_toolkit.html for more details Verifying : Percona-Server-server-57-5.7.13-6.1.el6.x86_64 1/6 Verifying : perl-DBD-MySQL-4.013-3.el6.x86_64 2/6 Verifying : perl-DBI-1.609-4.el6.x86_64 3/6 Verifying : Percona-Server-client-57-5.7.13-6.1.el6.x86_64 4/6 Verifying : Percona-Server-shared-57-5.7.13-6.1.el6.x86_64 5/6 Verifying : percona-xtrabackup-2.3.5-1.el6.x86_64 6/6 Installed: Percona-Server-server-57.x86_64 0:5.7.13-6.1.el6 percona-xtrabackup.x86_64 0:2.3.5-1.el6 Dependency Installed: Percona-Server-client-57.x86_64 0:5.7.13-6.1.el6 Percona-Server-shared-57.x86_64 0:5.7.13-6.1.el6 perl-DBD-MySQL.x86_64 0:4.013-3.el6 perl-DBI.x86_64 0:1.609-4.el6 Complete! [root@python ~]#
启动数据库,并登录:
[root@python ~]# cat /etc/my.cnf [mysqld] pid-file=/var/run/mysqld/mysqld.pid log-error=/var/log/mysqld.log datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [root@python ~]# [root@python ~]# ls -ltr /var/lib/mysql/ total 0 [root@python ~]# [root@python ~]# cat /var/log/mysqld.log [root@python ~]# [root@python ~]# ps -ef | grep mysql root 2603 2588 0 02:01 pts/1 00:00:00 tail -f /var/log/mysqld.log root 2606 2442 0 02:01 pts/0 00:00:00 grep mysql [root@python ~]# [root@python ~]# /etc/init.d/mysql status mysqld is stopped [root@python ~]# [root@python ~]# /etc/init.d/mysql start Initializing MySQL database: [ OK ] Installing validate password plugin: [ OK ] Starting mysqld: [ OK ] [root@python ~]# [root@python ~]# ps -ef | grep mysql root 2603 2588 0 02:01 pts/1 00:00:00 tail -f /var/log/mysqld.log root 2727 1 0 02:02 pts/0 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql mysql 2961 2727 5 02:02 pts/0 00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock root 2996 2442 0 02:02 pts/0 00:00:00 grep mysql [root@python ~]# [root@python ~]# cat /var/log/mysqld.log | grep --color "A temporary password" 2016-07-12T09:02:17.221010Z 1 [Note] A temporary password is generated for root@localhost: 6tnoG1?ReL)j [root@python ~]# [root@python ~]# mysql -u root -p'6tnoG1?ReL)j' mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.13-6 Copyright (c) 2009-2016 Percona LLC and/or its affiliates Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> mysql> set password for 'root'@'localhost' = password('xxxxxxxxx'); Query OK, 0 rows affected, 1 warning (0.01 sec) mysql>
查看一下主库的“server_id”:
mysql> show variables like 'server_id'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 0 | +---------------+-------+ 1 row in set (0.01 sec) mysql>
主辅之间的server_id不能一样。
修改主库的server_id:
mysql> set global server_id=2; Query OK, 0 rows affected (0.00 sec) mysql> show variables like 'server_id'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | server_id | 2 | +---------------+-------+ 1 row in set (0.01 sec) mysql>
主库准备测试数据:
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql> mysql> create database dilraba; Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | dilraba | | mysql | | performance_schema | | sys | +--------------------+ 5 rows in set (0.00 sec) mysql> mysql> use dilraba Database changed mysql> mysql> create table people( -> name varchar(30), -> location varchar(60), -> other varchar(90)); Query OK, 0 rows affected (0.09 sec) mysql> mysql> desc people; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | name | varchar(30) | YES | | NULL | | | location | varchar(60) | YES | | NULL | | | other | varchar(90) | YES | | NULL | | +----------+-------------+------+-----+---------+-------+ 3 rows in set (0.04 sec) mysql> mysql> insert into people values ('Dilraba','Xin Jiang','Actor'); Query OK, 1 row affected (0.00 sec) mysql> insert into people values ('Alen','Nan Ji','Science'); Query OK, 1 row affected (0.01 sec) mysql> commit; Query OK, 0 rows affected (0.00 sec) mysql> mysql> select * from people; +---------+-----------+---------+ | name | location | other | +---------+-----------+---------+ | Dilraba | Xin Jiang | Actor | | Alen | Nan Ji | Science | +---------+-----------+---------+ 2 rows in set (0.00 sec) mysql>
备份主库:
1. xtrabackup –user=root –password=’Abcd!234′ –backup –target-dir=/backup/mysql/
2. innobackupex –defaults-file=/etc/my.cnf –user=root –password=’Abcd!234′ /backup/mysql/
这个过程,你可能会遇到这样的错误:
Error: Unsupported server version: ‘5.7.13-6’.
XtraBackup:
[root@python ~]# xtrabackup --user=root --password='Abcd!234' --backup --target-dir=/backup/mysql/ 160712 02:21:20 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/var/lib/mysql/mysql.sock' as 'root' (using password: YES). 160712 02:21:20 version_check Connected to MySQL server 160712 02:21:20 version_check Executing a version check against the server... 160712 02:21:20 version_check Done. 160712 02:21:20 Connecting to MySQL server host: localhost, user: root, password: set, port: 0, socket: /var/lib/mysql/mysql.sock Error: Unsupported server version: '5.7.13-6'. Please report a bug at https://bugs.launchpad.net/percona-xtrabackup [root@python ~]#
innoBackupex
[root@python ~]# innobackupex --defaults-file=/etc/my.cnf --user=root --password='Abcd!234' /backup/mysql/ 160712 02:19:05 innobackupex: Starting the backup operation IMPORTANT: Please check that the backup run completes successfully. At the end of a successful backup run innobackupex prints "completed OK!". 160712 02:19:05 version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;mysql_socket=/var/lib/mysql/mysql.sock' as 'root' (using password: YES). 160712 02:19:05 version_check Connected to MySQL server 160712 02:19:05 version_check Executing a version check against the server... 160712 02:19:05 version_check Done. 160712 02:19:05 Connecting to MySQL server host: localhost, user: root, password: set, port: 0, socket: /var/lib/mysql/mysql.sock Error: Unsupported server version: '5.7.13-6'. Please report a bug at https://bugs.launchpad.net/percona-xtrabackup [root@python ~]#
检查当前安装的版本:
[root@python ~]# [root@python ~]# yum list | grep xtrabackup percona-xtrabackup.x86_64 2.3.5-1.el6 @percona-release-x86_64 percona-xtrabackup-20.x86_64 2.0.8-587.rhel6 percona-release-x86_64 percona-xtrabackup-20-debuginfo.x86_64 2.0.8-587.rhel6 percona-release-x86_64 percona-xtrabackup-20-test.x86_64 2.0.8-587.rhel6 percona-release-x86_64 percona-xtrabackup-21.x86_64 2.1.9-746.rhel6 percona-release-x86_64 percona-xtrabackup-21-debuginfo.x86_64 2.1.9-746.rhel6 percona-release-x86_64 percona-xtrabackup-22.x86_64 2.2.13-1.el6 percona-release-x86_64 percona-xtrabackup-22-debuginfo.x86_64 2.2.13-1.el6 percona-release-x86_64 percona-xtrabackup-24.x86_64 2.4.3-1.el6 percona-release-x86_64 percona-xtrabackup-24-debuginfo.x86_64 2.4.3-1.el6 percona-release-x86_64 percona-xtrabackup-debuginfo.x86_64 2.3.5-1.el6 percona-release-x86_64 percona-xtrabackup-test.x86_64 2.3.5-1.el6 percona-release-x86_64 percona-xtrabackup-test-21.x86_64 2.1.9-746.rhel6 percona-release-x86_64 percona-xtrabackup-test-22.x86_64 2.2.13-1.el6 percona-release-x86_64 percona-xtrabackup-test-24.x86_64 2.4.3-1.el6 percona-release-x86_64 [root@python ~]#
确实有更新的版本:percona-xtrabackup-24.x86_64。
删掉当前的版本,重新安装:
[root@python ~]# yum remove percona-xtrabackup Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package percona-xtrabackup.x86_64 0:2.3.5-1.el6 will be erased --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================== Package Arch Version Repository Size ====================================================================================================== Removing: percona-xtrabackup x86_64 2.3.5-1.el6 @percona-release-x86_64 21 M Transaction Summary ====================================================================================================== Remove 1 Package(s) Installed size: 21 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : percona-xtrabackup-2.3.5-1.el6.x86_64 1/1 Verifying : percona-xtrabackup-2.3.5-1.el6.x86_64 1/1 Removed: percona-xtrabackup.x86_64 0:2.3.5-1.el6 Complete! [root@python ~]# [root@python ~]# yum install -y percona-xtrabackup-24.x86_64 Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile * base: mirrors.sina.cn * extras: mirrors.sina.cn * updates: mirrors.tuna.tsinghua.edu.cn Resolving Dependencies --> Running transaction check ---> Package percona-xtrabackup-24.x86_64 0:2.4.3-1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================== Package Arch Version Repository Size ====================================================================================================== Installing: percona-xtrabackup-24 x86_64 2.4.3-1.el6 percona-release-x86_64 8.0 M Transaction Summary ====================================================================================================== Install 1 Package(s) Total download size: 8.0 M Installed size: 8.0 M Downloading Packages: percona-xtrabackup-24-2.4.3-1.el6.x86_64.rpm | 8.0 MB 01:05 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : percona-xtrabackup-24-2.4.3-1.el6.x86_64 1/1 Verifying : percona-xtrabackup-24-2.4.3-1.el6.x86_64 1/1 Installed: percona-xtrabackup-24.x86_64 0:2.4.3-1.el6 Complete! [root@python ~]#
再来备份主库:
[root@python ~]# ls /backup/mysql/ [root@python ~]# [root@python ~]# xtrabackup --version xtrabackup version 2.4.3 based on MySQL server 5.7.11 Linux (x86_64) (revision id: 6a46905) [root@python ~]# [root@python ~]# xtrabackup --user=root --password='Abcd!234' --backup --target-dir=/backup/mysql/ (... ... 过多的输出。) 160712 02:33:51 [01] Copying ./mysql/ndb_binlog_index.MYD to /backup/mysql/mysql/ndb_binlog_index.MYD 160712 02:33:51 [01] ...done 160712 02:33:51 [01] Copying ./mysql/event.MYD to /backup/mysql/mysql/event.MYD 160712 02:33:51 [01] ...done 160712 02:33:51 [01] Copying ./mysql/user.MYD to /backup/mysql/mysql/user.MYD 160712 02:33:51 [01] ...done 160712 02:33:51 [01] Copying ./mysql/db.MYI to /backup/mysql/mysql/db.MYI 160712 02:33:51 [01] ...done 160712 02:33:51 Finished backing up non-InnoDB tables and files 160712 02:33:51 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS... xtrabackup: The latest check point (for incremental): '2499923' xtrabackup: Stopping log copying thread. .160712 02:33:51 >> log scanned up to (2499932) 160712 02:33:51 Executing UNLOCK TABLES 160712 02:33:51 All tables unlocked 160712 02:33:51 [00] Copying ib_buffer_pool to /backup/mysql/ib_buffer_pool 160712 02:33:51 [00] ...done 160712 02:33:51 Backup created in directory '/backup/mysql' 160712 02:33:51 [00] Writing backup-my.cnf 160712 02:33:51 [00] ...done 160712 02:33:51 [00] Writing xtrabackup_info 160712 02:33:51 [00] ...done xtrabackup: Transaction log of lsn (2499923) to (2499932) was copied. 160712 02:33:51 completed OK! [root@python ~]#
可以看到,备份成功完成。
辅助端,创建接收主库全备的目录:
[root@mysql ~]# mkdir -p /backup/mysql [root@mysql ~]#
主库端,发起传输:
[root@python ~]# rsync -av /backup/mysql/ root@192.168.232.144:/backup/mysql/ The authenticity of host '192.168.232.144 (192.168.232.144)' can't be established. RSA key fingerprint is 57:7b:4c:ef:95:d3:52:57:a3:81:d4:08:88:36:d8:ef. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.232.144' (RSA) to the list of known hosts. root@192.168.232.144's password: (... ... 过多的输出。) sys/x@0024memory_global_total.frm sys/x@0024processlist.frm sys/x@0024ps_digest_95th_percentile_by_avg_us.frm sys/x@0024ps_digest_avg_latency_distribution.frm sys/x@0024ps_schema_table_statistics_io.frm sys/x@0024schema_flattened_keys.frm sys/x@0024schema_index_statistics.frm sys/x@0024schema_table_lock_waits.frm sys/x@0024schema_table_statistics.frm sys/x@0024schema_table_statistics_with_buffer.frm sys/x@0024schema_tables_with_full_table_scans.frm sys/x@0024session.frm sys/x@0024statement_analysis.frm sys/x@0024statements_with_errors_or_warnings.frm sys/x@0024statements_with_full_table_scans.frm sys/x@0024statements_with_runtimes_in_95th_percentile.frm sys/x@0024statements_with_sorting.frm sys/x@0024statements_with_temp_tables.frm sys/x@0024user_summary.frm sys/x@0024user_summary_by_file_io.frm sys/x@0024user_summary_by_file_io_type.frm sys/x@0024user_summary_by_stages.frm sys/x@0024user_summary_by_statement_latency.frm sys/x@0024user_summary_by_statement_type.frm sys/x@0024wait_classes_global_by_avg_latency.frm sys/x@0024wait_classes_global_by_latency.frm sys/x@0024waits_by_host_by_latency.frm sys/x@0024waits_by_user_by_latency.frm sys/x@0024waits_global_by_latency.frm sent 26032294 bytes received 5313 bytes 913600.25 bytes/sec total size is 26008353 speedup is 1.00 [root@python ~]#
这样,主库端的传输就完成了。
传输完成后,备库端查看:
[root@mysql ~]# du -sh /backup/mysql/ 26M /backup/mysql/ [root@mysql ~]# [root@mysql ~]# ls -ltr /backup/mysql/ total 12332 -rw-r-----. 1 root root 12582912 Jul 12 02:33 ibdata1 drwxr-x---. 2 root root 4096 Jul 12 02:33 dilraba drwxr-x---. 2 root root 4096 Jul 12 02:33 performance_schema drwxr-x---. 2 root root 12288 Jul 12 02:33 sys -rw-r-----. 1 root root 2560 Jul 12 02:33 xtrabackup_logfile -rw-r-----. 1 root root 445 Jul 12 02:33 xtrabackup_info -rw-r-----. 1 root root 113 Jul 12 02:33 xtrabackup_checkpoints drwxr-x---. 2 root root 4096 Jul 12 02:33 mysql -rw-r-----. 1 root root 346 Jul 12 02:33 ib_buffer_pool -rw-r-----. 1 root root 424 Jul 12 02:33 backup-my.cnf [root@mysql ~]#
看看这些文件都是些什么:
[root@mysql ~]# cd /backup/mysql/ [root@mysql mysql]# [root@mysql mysql]# file * backup-my.cnf: ASCII English text dilraba: directory ib_buffer_pool: ASCII text ibdata1: data mysql: directory performance_schema: directory sys: directory xtrabackup_checkpoints: ASCII text xtrabackup_info: ASCII text xtrabackup_logfile: data [root@mysql mysql]# [root@mysql mysql]# cat xtrabackup_info uuid = be2273fd-4813-11e6-a740-000c29f6ffc1 name = tool_name = xtrabackup tool_command = --user=root --password=... --backup --target-dir=/backup/mysql/ tool_version = 2.4.3 ibbackup_version = 2.4.3 server_version = 5.7.13-6 start_time = 2016-07-12 02:33:47 end_time = 2016-07-12 02:33:51 lock_time = 0 binlog_pos = innodb_from_lsn = 0 innodb_to_lsn = 2499923 partial = N incremental = N format = file compact = N compressed = N encrypted = N [root@mysql mysql]# [root@mysql mysql]# cat xtrabackup_checkpoints backup_type = full-backuped from_lsn = 0 to_lsn = 2499923 last_lsn = 2499932 compact = 0 recover_binlog_info = 1 [root@mysql mysql]# [root@mysql mysql]# cat ib_buffer_pool 3,2 3,1 3,3 10,2 10,1 10,3 11,2 11,1 11,3 9,2 9,1 9,3 8,2 8,1 8,3 12,2 12,1 12,3 20,2 20,1 20,3 19,2 19,1 19,3 18,1 18,3 13,1 21,3 21,2 21,1 21,0 7,13 7,12 7,11 7,10 7,9 7,8 7,7 7,6 7,1 7,5 7,4 7,3 6,6 6,5 6,4 6,3 6,2 6,1 6,0 4,83 4,82 4,81 4,80 4,79 4,78 4,77 4,76 4,75 4,74 4,73 4,72 4,71 4,70 4,69 4,68 4,67 4,66 4,65 4,64 4,40 4,39 4,38 4,37 [root@mysql mysql]# [root@mysql mysql]# cat backup-my.cnf # This MySQL options file was generated by innobackupex. # The MySQL server [mysqld] innodb_checksum_algorithm=innodb innodb_log_checksum_algorithm=strict_crc32 innodb_data_file_path=ibdata1:12M:autoextend innodb_log_files_in_group=2 innodb_log_file_size=50331648 innodb_fast_checksum=false innodb_page_size=16384 innodb_log_block_size=512 innodb_undo_directory=. innodb_undo_tablespaces=0 server_id=0 redo_log_version=1 [root@mysql mysql]#
预备全备:
[root@mysql mysql]# innobackupex --apply-log /backup/mysql/ (... ... 过多的输出。) [root@mysql mysql]# innobackupex --apply-log /backup/mysql/ 160712 02:56:59 innobackupex: Starting the apply-log operation IMPORTANT: Please check that the apply-log run completes successfully. At the end of a successful apply-log run innobackupex prints "completed OK!". innobackupex version 2.4.3 based on MySQL server 5.7.11 Linux (x86_64) (revision id: 6a46905) xtrabackup: cd to /backup/mysql xtrabackup: This target seems to be not prepared yet. InnoDB: Number of pools: 1 xtrabackup: xtrabackup_logfile detected: size=8388608, start_lsn=(2499923) xtrabackup: using the following InnoDB configuration for recovery: xtrabackup: innodb_data_home_dir = . xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend xtrabackup: innodb_log_group_home_dir = . xtrabackup: innodb_log_files_in_group = 1 xtrabackup: innodb_log_file_size = 8388608 xtrabackup: using the following InnoDB configuration for recovery: xtrabackup: innodb_data_home_dir = . xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend xtrabackup: innodb_log_group_home_dir = . xtrabackup: innodb_log_files_in_group = 1 xtrabackup: innodb_log_file_size = 8388608 xtrabackup: Starting InnoDB instance for recovery. xtrabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter) InnoDB: PUNCH HOLE support available InnoDB: Mutexes and rw_locks use GCC atomic builtins InnoDB: Uses event mutexes InnoDB: GCC builtin __sync_synchronize() is used for memory barrier InnoDB: Compressed tables use zlib 1.2.3 InnoDB: Number of pools: 1 InnoDB: Using CPU crc32 instructions InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M InnoDB: Completed initialization of buffer pool InnoDB: page_cleaner coordinator priority: -20 InnoDB: Highest supported file format is Barracuda. InnoDB: Log scan progressed past the checkpoint lsn 2499923 InnoDB: Doing recovery: scanned up to log sequence number 2499932 (0%) InnoDB: Doing recovery: scanned up to log sequence number 2499932 (0%) InnoDB: Database was not shutdown normally! InnoDB: Starting crash recovery. InnoDB: Creating shared tablespace for temporary tables InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... InnoDB: File './ibtmp1' size is now 12 MB. InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active. InnoDB: 32 non-redo rollback segment(s) are active. InnoDB: 5.7.11 started; log sequence number 2499932 xtrabackup: starting shutdown with innodb_fast_shutdown = 1 InnoDB: FTS optimize thread exiting. InnoDB: Starting shutdown... InnoDB: Shutdown completed; log sequence number 2499951 InnoDB: Number of pools: 1 xtrabackup: using the following InnoDB configuration for recovery: xtrabackup: innodb_data_home_dir = . xtrabackup: innodb_data_file_path = ibdata1:12M:autoextend xtrabackup: innodb_log_group_home_dir = . xtrabackup: innodb_log_files_in_group = 2 xtrabackup: innodb_log_file_size = 50331648 InnoDB: PUNCH HOLE support available InnoDB: Mutexes and rw_locks use GCC atomic builtins InnoDB: Uses event mutexes InnoDB: GCC builtin __sync_synchronize() is used for memory barrier InnoDB: Compressed tables use zlib 1.2.3 InnoDB: Number of pools: 1 InnoDB: Using CPU crc32 instructions InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M InnoDB: Completed initialization of buffer pool InnoDB: page_cleaner coordinator priority: -20 InnoDB: Setting log file ./ib_logfile101 size to 48 MB InnoDB: Setting log file ./ib_logfile1 size to 48 MB InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 InnoDB: New log files created, LSN=2499951 InnoDB: Highest supported file format is Barracuda. InnoDB: Log scan progressed past the checkpoint lsn 2500108 InnoDB: Doing recovery: scanned up to log sequence number 2500117 (0%) InnoDB: Doing recovery: scanned up to log sequence number 2500117 (0%) InnoDB: Database was not shutdown normally! InnoDB: Starting crash recovery. InnoDB: Removed temporary tablespace data file: "ibtmp1" InnoDB: Creating shared tablespace for temporary tables InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... InnoDB: File './ibtmp1' size is now 12 MB. InnoDB: 96 redo rollback segment(s) found. 1 redo rollback segment(s) are active. InnoDB: 32 non-redo rollback segment(s) are active. InnoDB: Waiting for purge to start InnoDB: page_cleaner: 1000ms intended loop took 4095ms. The settings might not be optimal. (flushed=0 and evicted=0, during the time.) InnoDB: 5.7.11 started; log sequence number 2500117 xtrabackup: starting shutdown with innodb_fast_shutdown = 1 InnoDB: FTS optimize thread exiting. InnoDB: Starting shutdown... InnoDB: Shutdown completed; log sequence number 2500136 160712 02:57:16 completed OK! [root@mysql mysql]# [root@mysql mysql]# pwd /backup/mysql [root@mysql mysql]# [root@mysql mysql]# ls -ltr total 131112 drwxr-x---. 2 root root 4096 Jul 12 02:33 dilraba drwxr-x---. 2 root root 4096 Jul 12 02:33 performance_schema drwxr-x---. 2 root root 12288 Jul 12 02:33 sys -rw-r-----. 1 root root 445 Jul 12 02:33 xtrabackup_info drwxr-x---. 2 root root 4096 Jul 12 02:33 mysql -rw-r-----. 1 root root 346 Jul 12 02:33 ib_buffer_pool -rw-r-----. 1 root root 424 Jul 12 02:33 backup-my.cnf -rw-r-----. 1 root root 8388608 Jul 12 02:57 xtrabackup_logfile -rw-r-----. 1 root root 113 Jul 12 02:57 xtrabackup_checkpoints -rw-r-----. 1 root root 50331648 Jul 12 02:57 ib_logfile1 -rw-r-----. 1 root root 12582912 Jul 12 02:57 ibtmp1 -rw-r-----. 1 root root 50331648 Jul 12 02:57 ib_logfile0 -rw-r-----. 1 root root 12582912 Jul 12 02:57 ibdata1 [root@mysql mysql]#
可以看到,预备全备,完成。
关闭数据库:
[root@mysql mysql]# /etc/init.d/mysql status mysqld (pid 27430) is running... [root@mysql mysql]# [root@mysql mysql]# /etc/init.d/mysql stop Stopping mysqld: [ OK ] [root@mysql mysql]#
创建一个新的路径,存放恢复后的数据库的数据。
[root@mysql mysql]# mkdir -p /data/mysql_db/salve [root@mysql mysql]#
修改my.cnf中的数据路径的指向:
[root@mysql mysql]# cat /etc/my.cnf [mysqld] pid-file=/var/run/mysqld/mysqld.pid log-error=/var/log/mysqld.log #datadir=/var/lib/mysql datadir=/data/mysql_db/salve socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [root@mysql mysql]#
或者,把原来的路径中的数据清空:
[root@mysql mysql]# rm -rf /var/lib/mysql/* [root@mysql mysql]#
恢复数据库:
[root@mysql mysql]# innobackupex --copy-back /backup/mysql/ (... ... 过多的输出。) 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/slave_relay_log_info.frm to /data/mysql_db/salve/mysql/slave_relay_log_info.frm 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/proxies_priv.MYI to /data/mysql_db/salve/mysql/proxies_priv.MYI 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/innodb_table_stats.ibd to /data/mysql_db/salve/mysql/innodb_table_stats.ibd 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/time_zone_transition.frm to /data/mysql_db/salve/mysql/time_zone_transition.frm 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/procs_priv.frm to /data/mysql_db/salve/mysql/procs_priv.frm 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/time_zone.frm to /data/mysql_db/salve/mysql/time_zone.frm 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/help_category.ibd to /data/mysql_db/salve/mysql/help_category.ibd 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/servers.ibd to /data/mysql_db/salve/mysql/servers.ibd 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/slow_log.CSV to /data/mysql_db/salve/mysql/slow_log.CSV 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/server_cost.ibd to /data/mysql_db/salve/mysql/server_cost.ibd 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/proc.frm to /data/mysql_db/salve/mysql/proc.frm 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/user.MYI to /data/mysql_db/salve/mysql/user.MYI 160712 03:06:57 [01] ...done 160712 03:06:57 [01] Copying ./mysql/time_zone_leap_second.frm to /data/mysql_db/salve/mysql/time_zone_leap_second.frm 160712 03:06:57 [01] ...done 160712 03:06:57 completed OK! [root@mysql mysql]#
查看数据路径中的状态:
[root@mysql mysql]# ls -ltr /var/lib/mysql total 122912 -rw-r-----. 1 root root 50331648 Jul 12 03:19 ib_logfile0 -rw-r-----. 1 root root 50331648 Jul 12 03:19 ib_logfile1 -rw-r-----. 1 root root 12582912 Jul 12 03:19 ibdata1 drwxr-x---. 2 root root 4096 Jul 12 03:19 performance_schema -rw-r-----. 1 root root 445 Jul 12 03:19 xtrabackup_info drwxr-x---. 2 root root 4096 Jul 12 03:19 dilraba -rw-r-----. 1 root root 12582912 Jul 12 03:19 ibtmp1 drwxr-x---. 2 root root 12288 Jul 12 03:19 sys -rw-r-----. 1 root root 346 Jul 12 03:19 ib_buffer_pool drwxr-x---. 2 root root 4096 Jul 12 03:19 mysql [root@mysql mysql]#
修改数据文件的所属人与用户组:
[root@mysql mysql]# chown -R mysql.mysql /var/lib/mysql/* [root@mysql mysql]# ls -ltr /var/lib/mysql total 122912 -rw-r-----. 1 mysql mysql 50331648 Jul 12 03:19 ib_logfile0 -rw-r-----. 1 mysql mysql 50331648 Jul 12 03:19 ib_logfile1 -rw-r-----. 1 mysql mysql 12582912 Jul 12 03:19 ibdata1 drwxr-x---. 2 mysql mysql 4096 Jul 12 03:19 performance_schema -rw-r-----. 1 mysql mysql 445 Jul 12 03:19 xtrabackup_info drwxr-x---. 2 mysql mysql 4096 Jul 12 03:19 dilraba -rw-r-----. 1 mysql mysql 12582912 Jul 12 03:19 ibtmp1 drwxr-x---. 2 mysql mysql 12288 Jul 12 03:19 sys -rw-r-----. 1 mysql mysql 346 Jul 12 03:19 ib_buffer_pool drwxr-x---. 2 mysql mysql 4096 Jul 12 03:19 mysql [root@mysql mysql]#
启动数据库:
[root@mysql mysql]# /etc/init.d/mysql start Starting mysqld: [ OK ] [root@mysql mysql]#
登录看看:
[root@mysql mysql]# mysql -u root -p'Abcd!234' mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.13-6 Percona Server (GPL), Release 6, Revision e3d58bb Copyright (c) 2009-2016 Percona LLC and/or its affiliates Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | dilraba | | mysql | | performance_schema | | sys | +--------------------+ 5 rows in set (0.00 sec) mysql> mysql> select * from dilraba.people; +---------+-----------+---------+ | name | location | other | +---------+-----------+---------+ | Dilraba | Xin Jiang | Actor | | Alen | Nan Ji | Science | +---------+-----------+---------+ 2 rows in set (0.00 sec) mysql> exit Bye [root@mysql mysql]#
————————————————————
Done。