CentOS7 下 MySQL 5.7.23 & XtraBackup 24 做數據備份——安裝軟件
阿新 • • 發佈:2018-08-23
解決方法 conf install name urn ace 初始化 示例 from
在兩臺機子上同時操作下面的步驟
首先安裝MySQL,從官網下載相對應版本的RPM包
- mysql-community-client-5.7.23-1.el7.x86_64.rpm
- mysql-community-common-5.7.23-1.el7.x86_64.rpm
- mysql-community-libs-5.7.23-1.el7.x86_64.rpm
- mysql-community-libs-compat-5.7.23-1.el7.x86_64.rpm (*解決與XtraBackup安裝時,my.cnf沖突問題)
- mysql-community-server-5.7.23-1.el7.x86_64.rpm
一口氣把他們全都安上,省的報依賴錯誤
rpm -ivh mysql-community-client-5.7.23-1.el7.x86_64.rpm mysql-community-common-5.7.23-1.el7.x86_64.rpm mysql-community-libs-5.7.23-1.el7.x86_64.rpm mysql-community-libs-compat-5.7.23-1.el7.x86_64.rpm mysql-community-server-5.7.23-1.el7.x86_64.rpm
初始化MySQL
先修改 /var/lib/mysql/ 文件夾的權限,因為是用root權限安裝的,需要修改為mysql的權限。
chown -R mysql.mysql /var/lib/mysql/
初始化MySQL
mysqld --initialize
從mysqld.log中獲取初始密碼,得到紅色部分的密碼
[root@localhost srv]# cat /var/log/mysqld.log | grep ‘y password‘ 2018-08-23T05:54:39.866279Z 1 [Note] A temporary password is generated for root@localhost: (WRwAWtoj14+
登錄mysql,修改密碼
[root@localhost srv]# mysql -uroot -p‘(WRwAWtoj14+‘ 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 2 Server version: 5.7.23 Copyright (c) 2000, 2018, 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> alter user root@localhost identified by ‘root‘; Query OK, 0 rows affected (0.01 sec) mysql> exit Bye
至此,MySQL安裝完畢
安裝XtraBackup
按照官網的安裝示例安裝即可:https://www.percona.com/doc/percona-xtrabackup/2.4/installation/yum_repo.html
1、安裝Percona yum 倉庫
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm
2、安裝XtraBackup 24
yum install percona-xtrabackup-24 -y
會以依賴安裝(就是因為依賴總是離線安不上,才用的yum):
作為依賴被安裝: libev.x86_64 0:4.15-7.el7 perl-DBD-MySQL.x86_64 0:4.023-6.el7 perl-Digest.noarch 0:1.17-245.el7
perl-Digest-MD5.x86_64 0:2.52-3.el7 rsync.x86_64 0:3.1.2-4.el7
至此,兩個軟件安裝完畢
上面安裝中的一些坑(已經幫助跳過去了):
1、MySQL無法啟動,cli下報如下錯誤
[root@localhost srv]# service mysqld start Redirecting to /bin/systemctl start mysqld.service Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
/var/log/mysqld.log中報如下錯誤
2018-08-23T06:08:24.018182Z 0 [ERROR] InnoDB: The innodb_system data file ‘ibdata1‘ must be writable 2018-08-23T06:08:24.018188Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 2018-08-23T06:08:24.620670Z 0 [ERROR] Plugin ‘InnoDB‘ init function returned error. 2018-08-23T06:08:24.620698Z 0 [ERROR] Plugin ‘InnoDB‘ registration as a STORAGE ENGINE failed. 2018-08-23T06:08:24.620703Z 0 [ERROR] Failed to initialize builtin plugins. 2018-08-23T06:08:24.620706Z 0 [ERROR] Aborting
解決方法看上面的MySQL初始化部分
2、XtraBackup安裝沖突
file /etc/my.cnf from install of Percona-Server-shared-56-5.6.41-rel84.1.el7.x86_64 conflicts with file from package mysql-community-server-5.7.23-1.el7.x86_64
先安裝 mysql-community-libs-compat-5.7.23-1.el7.x86_64.rpm 即可
CentOS7 下 MySQL 5.7.23 & XtraBackup 24 做數據備份——安裝軟件