【mysql使用系列】Percona Server8.0安装和初步使用

本文参考资料

https://blog.csdn.net/vkingnew/article/details/85220187
https://www.mayi888.com/archives/59253
https://www.percona.com/doc/percona-server/LATEST/installation/yum_repo.html
https://blog.csdn.net/myNameIssls/article/details/84031426

安装过程

参考 https://jxdw.github.io/2017/06/21/mysql5-7-install/ ,安装软件。

安装需要的软件

wget https://repo.percona.com/release/7Server/RPMS/x86_64/jemalloc-3.6.0-1.el7.x86_64.rpm
rpm -ivh jemalloc-3.6.0-1.el7.x86_64.rpm

删除废弃的软件包

rpm -e --nodeps  mariadb-libs

按照需要的软件:

yum -y install net-tools libaio perl openssl openssl-devel perl-Data-Dumper  perl-JSON
wget https://www.percona.com/downloads/Percona-Server-8.0/Percona-Server-8.0.13-3/binary/redhat/7/x86_64/Percona-Server-8.0.13-3-ra920dd6-el7-x86_64-bundle.tar

解压,查看软件包列表:

ll percona*.rpm

安装过程:

rpm -ivh percona-*.rpm

创建目录

mkdir -p /data/mysql/{log,binlogs,run,data}
touch /data/mysql/run/mysqld.pid
chown -R mysql:mysql /data/mysql

初始化

mysqld --initialize-insecure --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data

配置文件/etc/my.cnf

# Percona Server template configuration
#
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password
port = 3306
#basedir = /data/mysql这里注释掉,如果不注释掉,percona会报错:
datadir = /data/mysql/data
socket = /data/mysql/mysql.sock
log-error = /data/mysql/log/mysqld.log
pid-file = /data/mysql/run/mysqld.pid
log-bin = /data/mysql/binlogs/mysql-bin
slow_query_log = 1
slow_query_log_file = /data/mysql/log/mysql_slow_query.log
long_query_time = 5
symbolic-links=0
character_set_server=utf8mb4
collation_server=utf8mb4_unicode_ci
skip-character-set-client-handshake
innodb_undo_log_truncate=off
#允许时间字段为"0000-00-00 00:00:00"
sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
#打开函数功能
log_bin_trust_function_creators=1
# general
table_open_cache = 200000
table_open_cache_instances=64
back_log=3500
max_connections=110000
# files
innodb_file_per_table
innodb_log_file_size=1G
innodb_log_files_in_group=2
innodb_open_files=4000
# buffers
innodb_buffer_pool_size= 2G
innodb_buffer_pool_instances=8
innodb_log_buffer_size=256M
# tune
innodb_doublewrite= 1
innodb_thread_concurrency=0
innodb_flush_log_at_trx_commit= 0
innodb_flush_method=O_DIRECT_NO_FSYNC
innodb_max_dirty_pages_pct=90
innodb_max_dirty_pages_pct_lwm=10
innodb_lru_scan_depth=2048
innodb_page_cleaners=4
join_buffer_size=256K
sort_buffer_size=256K
innodb_use_native_aio=1
innodb_stats_persistent = 1
innodb_spin_wait_delay=96
innodb_adaptive_flushing = 1
innodb_flush_neighbors = 0
innodb_read_io_threads = 16
innodb_write_io_threads = 16
innodb_io_capacity=1500
innodb_io_capacity_max=2500
innodb_purge_threads=4
innodb_adaptive_hash_index=0
max_prepared_stmt_count=1000000
innodb_monitor_enable = ‘%’
performance_schema = ON

启动

systemctl start mysqld.service
systemctl status mysqld.service

初始化密码和权限

mysql -h 127.0.0.1 -u root
alter user 'root'@'localhost' identified with mysql_native_password by '123456'; --查询了资料,percona 8.0的密码插件已变成caching_sha2_password
UPDATE user SET Host = '%' WHERE User = 'root';
flush privileges;

体验