opensuse下安装mysql5.7(glibc2.12)+xtrabackup(glibc2.17)

环境:
Os:opensuse leap 16
mysql:5.7.44
xtrabackup:2.4.29

1.下载安装介质
mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz


2.创建mysql用户和用户组
系统默认已经创建了mysql用户组和用户
#groupadd mysql
#useradd -g mysql mysql
#passwd mysql

 

3.下载解压安装
[root@localhost soft]# tar -xvf mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
[root@localhost soft]# mv mysql-5.7.44-linux-glibc2.12-x86_64 /opt/mysql57

 

4.在mysql主目录下建立相应的目录
data目录存放数据文件,conf目录存放配置文件
[root@localhost mysql5733]#cd /opt/mysql57
[root@localhost mysql5733]#mkdir data ##数据文件目录
[root@localhost mysql5733]#mkdir conf ## 配置文件目录
[root@localhost mysql5733]#mkdir -p mysqllog/relaylog ##主从环境relaylog
[root@localhost mysql5733]#mkdir -p mysqllog/logfile ##错误日志文件
[root@localhost mysql5733]#mkdir -p mysqllog/binlog ##binlog文件
[root@localhost mysql5733]#mkdir -p secure_file ##secure_file_priv参数指定路

 

5.修改系统配置
5.1 修改 /etc/selinux/config
vi /etc/security/limits.conf
SELINUX=disabled

 

5.2 修改 /etc/security/limits.conf
zypper install pam
vi /etc/security/limits.conf
添加如下内容
* hard nofile 65535
* soft nofile 65535

修改权限
chmod 644 /etc/security/limits.conf
chown root:root /etc/security/limits.conf

退出后重新登录
localhost:~ # ulimit -n
65535

 

6.准备配置文件
vi /opt/mysql57/conf/my.cnf

[mysqld]
port=13306
server-id=1
basedir=/opt/mysql57
datadir=/opt/mysql57/data
socket=/opt/mysql57/mysql.sock
max_connections = 1000
character_set_server=utf8mb4
collation-server=utf8mb4_general_ci
init_connect='SET collation_connection = utf8mb4_general_ci'
init_connect='SET NAMES utf8mb4'
interactive_timeout=86400
wait_timeout=86400

skip-external-locking
key_buffer_size= 128M
max_allowed_packet=32M
query_cache_size=32M
read_buffer_size=2M
sort_buffer_size=1M
join_buffer_size= 128M

innodb_file_per_table= 1
innodb_open_files= 5000
innodb_buffer_pool_size= 4G
innodb_write_io_threads= 16
innodb_read_io_threads= 16
innodb_thread_concurrency = 0
innodb_purge_threads= 1
innodb_flush_log_at_trx_commit= 2
innodb_log_buffer_size=16M
innodb_log_file_size=512M
innodb_log_files_in_group= 5
innodb_max_dirty_pages_pct= 90
innodb_lock_wait_timeout= 120
bulk_insert_buffer_size= 64M
log_bin_trust_function_creators=1
event_scheduler=1
max_binlog_size=100M
binlog_format=row
log-bin=/opt/mysql57/mysqllog/binlog/binlog.bin
slow_query_log=on
slow_query_log_file=/opt/mysql57/mysqllog/logfile/slow-query.log
long_query_time=1

log_queries_not_using_indexes=on
log-error=/opt/mysql57/mysqllog/logfile/mysql-err.log
binlog_cache_size=4MB
skip-host-cache
skip-name-resolve
expire_logs_days=15
skip-slave-start
relay-log-index=/opt/mysql57/mysqllog/relaylog/slave-relay-bin.index
relay-log=/opt/mysql57/mysqllog/relaylog/relaylog-binlog
replicate-ignore-db=information_schema,performance_schema,sys
slave_net_timeout=60
##language=/opt/mysql57/share/english
early-plugin-load=""
explicit_defaults_for_timestamp=true
log_slave_updates=1
gtid_mode=ON
enforce_gtid_consistency = ON
lower_case_table_names=1
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

##secure_file_priv参数
secure_file_priv=/opt/mysql57/secure_file

 

7.修改mysql目录权限
[root@localhost opt]# chown -R mysql:mysql /opt/mysql57

 

8.初始化数据库
localhost:/opt/mysql57 # cd /opt/mysql57/bin
localhost:/opt/mysql57/bin # ./mysqld --initialize --user=mysql --basedir=/opt/mysql57 --datadir=/opt/mysql57/data --lc_messages_dir=/opt/mysql57/share --lc_messages=en_US

这里没有输出,日志生成在如下文件,初始化密码也在该文件

localhost:/var/log/mysql # more /var/log/mysql/mysqld.log
2026-06-23T06:25:01.643800Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details)
.
2026-06-23T06:25:01.919070Z 0 [Warning] InnoDB: New log files created, LSN=45790
2026-06-23T06:25:01.972678Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2026-06-23T06:25:02.046238Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 441f0043-6ecc-11
f1-ba1b-0800271e5749.
2026-06-23T06:25:02.048419Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2026-06-23T06:25:03.692062Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2026-06-23T06:25:03.692078Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2026-06-23T06:25:03.695002Z 0 [Warning] CA certificate ca.pem is self signed.
2026-06-23T06:25:04.254035Z 1 [Note] A temporary password is generated for root@localhost: 8kCvYT/70639

 

9.生成错误日志文件
产生错误日志文件
[root@localhost mha]#echo>/opt/mysql57/mysqllog/logfile/mysql-err.log
[root@localhost opt]#chown -R mysql:mysql /opt/mysql57

 

10.启动
localhost:/opt/mysql57/bin #cd /opt/mysql57/bin
localhost:/opt/mysql57/bin #./mysqld_safe --defaults-file=/opt/mysql57/conf/my.cnf --user=mysql &

 

11.登陆mysql并修改密码

cd /opt/mysql57/bin
localhost:/opt/mysql57/bin # ./mysql -h localhost -uroot -P13306 -p -S /opt/mysql57/mysql.sock
./mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

解决办法:
建立软连接
ln -s /usr/lib64/libncurses.so.6.5 /usr/lib64/libncurses.so.5

继续报错:

localhost:/opt/mysql57/bin # ./mysql -h localhost -uroot -P13306 -p -S /opt/mysql57/mysql.sock
./mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

 

解决办法:
建立软连接
ln -s /usr/lib64/libtinfo.so.6.5 /usr/lib64/libtinfo.so.5

 

再次登录就可以了

localhost:/opt/mysql57/bin # ./mysql -h localhost -uroot -P13306 -p -S /opt/mysql57/mysql.sock
mysql>  set password=password('mysql');

 

12.重启
root账号下操作
/opt/mysql57/bin/mysqladmin -h localhost -uroot -P13306 -p -S /opt/mysql57/mysql.sock shutdown
/opt/mysql57/bin/mysqld_safe --defaults-file=/opt/mysql57/conf/my.cnf --user=mysql &

 

################################xtrabackup安装部署##############################
1.介质准备
percona-xtrabackup-2.4.29-Linux-x86_64.glibc2.17.tar.gz

 

2.解压安装
localhost:/soft # tar -xvf percona-xtrabackup-2.4.29-Linux-x86_64.glibc2.17.tar.gz
localhost:/soft # mv percona-xtrabackup-2.4.29-Linux-x86_64.glibc2.17 /opt/xtrabackup-2.4.29

 

3.备份
/opt/xtrabackup-2.4.29/bin/innobackupex --defaults-file=/opt/mysql57/conf/my.cnf --user=root --password=mysql -P13306 --socket=/opt/mysql57/mysql.sock /opt/xtrabackup_file

 

posted @ 2026-06-23 15:13  slnngk  阅读(3)  评论(0)    收藏  举报