RPM安装 percona-xtrabackup-80-8.0.35-30.1.el7.x86_64.rpm
官网: https://www.percona.com/
下载地址: https://www.percona.com/downloads
wget https://downloads.percona.com/downloads/percona-distribution-mysql-ps/percona-distribution-mysql-ps-8.0.36/binary/redhat/7/x86_64/percona-xtrabackup-80-8.0.35-30.1.el7.x86_64.rpm
yum install -y percona-xtrabackup-80-8.0.35-30.1.el7.x86_64.rpm
#报错:
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be installed
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: perl-DBD-MySQL-4.023-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: perl-DBD-MySQL-4.023-6.el7.x86_64
--> Finished Dependency Resolution
Error: Package: perl-DBD-MySQL-4.023-6.el7.x86_64 (base)
Requires: libmysqlclient.so.18()(64bit)
Error: Package: perl-DBD-MySQL-4.023-6.el7.x86_64 (base)
Requires: libmysqlclient.so.18(libmysqlclient_18)(64bit)
You could try using --skip-broken to work around the problem
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
mysql-community-server-8.0.36-1.el7.x86_64 has missing requires of mysql-community-icu-data-files = ('0', '8.0.36', '1.el7')
安装依赖
rpm -ivh mysql-community-libs-compat-8.0.36-1.el7.x86_64.rpm
# 安装完继续执行即可完成安装
yum install -y percona-xtrabackup-80-8.0.35-30.1.el7.x86_64.rpm
yum 安装 xtrabackup 8
1.安装libev依赖
yum install libev
2.安装zstd依赖
yum install epel-release -y
yum install zstd -y
3.安装Percona yum存储库
yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm -y
4.启用存储库
percona-release enable-only tools
5.安装xtrabackup
yum install percona-xtrabackup-80
至此,xtrabackup安装完成
番外:安装 Mysql
查看mysql版本 mysql --help| grep Distrib
环境:
mysql 主:10.128.0.3
mysql 从:10.128.0.4
两台服务器都装上 mysql8
# 创建下载目录
mkdir -p /opt/mysql
cd /opt/mysql
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.36-1.el7.x86_64.rpm-bundle.tar
tar xf mysql-8.0.36-1.el7.x86_64.rpm-bundle.tar
# 卸载 mariadb 组件
yum remove mariadb-libs -y
# 安装
rpm -ivh mysql-community-common-8.0.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.36-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.36-1.el7.x86_64.rpm
# 无法安装可强制安装
rpm -ivh mysql-community-server-8.0.36-1.el7.x86_64.rpm --nodeps --force
# 根据报错安装配置依赖
yum install -y numactl
# 初始化
mkdir -p /var/lib/mysql/{log,data}
chown -R mysql.mysql /var/lib/mysql
mysqld --initialize --lower-case-table-names=1
# 修改my.cnf
配置文件在下方,若不修改配置文件,启动会报错,因为上方默认开启参数 lower-case-table-names
# 启动
systemctl start mysqld
# 查看初始密码
cat /var/log/mysqld.log | grep password
2024-01-23T14:03:00.144612Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost:
>6kWYu_Ldwtf
也有密码在配置文件设定的日志位置:/var/lib/mysql/log/error.log 里
防止报错,可以提前创建目录以及设定属组
mkdir -p /var/lib/mysql/{data,log}
chown -R mysql.mysql /var/lib/mysql
# 设置sock软连接
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
# 登入mysql,更改默认密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'line=2.71828c++';
# 配置mysql密码文件
echo 'line=2.71828c++' >> /root/mysql
# 登入mysql
mysql -uroot -p`cat /root/mysql`
配置主从
# 在主节点创建一个用户mysql-slave,用于从节点mysql-slave链接主节点时使用。
CREATE USER 'mysql-slave'@'10.128.0.%' IDENTIFIED WITH mysql_native_password BY '71inE828@l@@';
GRANT REPLICATION SLAVE ON *.* TO 'mysql-slave'@'10.128.0.%';
# 刷新授权表信息
flush privileges;
# 获取主节点当前binary log文件名和位置(position)
mysql> SHOW MASTER STATUS;
+-------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------+----------+--------------+------------------+-------------------+
| node01-bin.000056 | 610 | | | |
+-------------------+----------+--------------+------------------+-------------------+
# 在从(Slave)节点上设置主节点参数
CHANGE MASTER TO
MASTER_HOST='10.128.0.3',
MASTER_USER='mysql-slave',
MASTER_PASSWORD='71inE828@l@@',
MASTER_LOG_FILE='node01-bin.000056',
MASTER_LOG_POS=610;
my.cnf
[mysqld]
datadir=/var/lib/mysql/data
basedir=/var/lib/mysql
plugin_dir=/usr/lib64/mysql/plugin
tmpdir=/tmp
#sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
tmp_table_size=128M
socket=/var/lib/mysql/mysql.sock
log-bin=/var/lib/mysql/log/node01-bin
binlog_cache_size = 16M
max_binlog_size = 1G
binlog_checksum=NONE
binlog_expire_logs_seconds = 604800
log_timestamps=SYSTEM
server-id=1
innodb_file_per_table=ON
host_cache_size=0
skip_name_resolve=ON
skip-external-locking
default_storage_engine = InnoDB
max_allowed_packet = 512M
max_connections = 4300
open_files_limit = 10000
slow_query_log = 1
slow_query_log_file = /var/lib/mysql/log/slow.log
lower_case_table_names = 1
long_query_time = 1
user = mysql
default-storage-engine = InnoDB
transaction_isolation = REPEATABLE-READ #READ-COMMITTED
back_log = 5120 #50
max_connect_errors = 5120 #10
table_open_cache = 2845
max_heap_table_size = 128M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 512
#query_cache_size = 32M
#query_cache_limit = 2M
#query_cache_type = 2
ft_min_word_len = 4
###innodb_file_format=Barracuda
###innodb_page_size=4K
innodb_flush_neighbors=0
innodb_buffer_pool_size = 2048M #innodb_buffer_pool_size = 80G
###innodb_data_file_path = ibdata1:256M;ibdata2:256M:autoextend
innodb_write_io_threads = 2 # innodb_write_io_threads = 16
innodb_read_io_threads = 2 # innodb_read_io_threads = 8
innodb_io_capacity = 2000 # innodb_io_capacity = 6000
innodb_io_capacity_max = 4000 # innodb_io_capacity_max = 8000
#innodb_force_recovery=1
innodb_thread_concurrency = 48
innodb_flush_log_at_trx_commit = 2 #1
#innodb_fast_shutdown
innodb_log_buffer_size = 16M #8M
#innodb_log_file_size = 1G
#innodb_log_files_in_group = 2
innodb_max_dirty_pages_pct = 75
innodb_flush_method=O_DIRECT
innodb_lock_wait_timeout = 30
thread_stack = 256K
log-error=/var/lib/mysql/log/error.log
pid-file=/var/lib/mysql/mysqld.pid
character-set-server=utf8mb4
collation-server = utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
sql_mode="NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES"
[mysql]
default-character-set=utf8mb4
[client]
default-character-set=utf8mb4
socket=/var/lib/mysql/mysql.sock