赞
踩
快速安装Percona mysql5.7,二进制安装基本适用于所有系统,包括Centos、Debian、Ubuntu。
安装路径、数据、配置文件、日志都在一个目录(/data/app/mysql5.7)下,方便管理,以后迁移都方便。二进制安装包采用minimal,只有80M,解压完才370M,很小,安装很快。
系统版本:debian10(其他版本也适用,我会说明的)
mysql版本:Percona-Server-5.7.39
目录说明 | 路径 |
---|---|
数据目录 | /data/app/mysql5.7/data |
日志目录 | /data/app/mysql5.7/logs |
binlog目录 | /data/app/mysql5.7/binlog |
pid目录 | /data/app/mysql5.7/run |
配置文件 | /data/app/mysql5.7/my.cnf |
wget https://downloads.percona.com/downloads/Percona-Server-5.7/Percona-Server-5.7.39-42/binary/tarball/Percona-Server-5.7.39-42-Linux.x86_64.glibc2.17-minimal.tar.gz
tar xf Percona-Server-5.7.39-42-Linux.x86_64.glibc2.17-minimal.tar.gz -C /data/app/
mv /data/app/Percona-Server-5.7.39-42-Linux.x86_64.glibc2.17-minimal /data/app/mysql5.7
useradd mysql -M -s /sbin/nologin
mkdir -p /data/app/mysql5.7/{data,logs,binlog,run}
cat > /data/app/mysql5.7/my.cnf <<EOF
# Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208
[client]
port = 3306
socket = /tmp/mysql.sock
[mysql]
# CLIENT #
port = 3306
socket = /tmp/mysql.sock
pid-file = /data/app/mysql5.7/run/mysqld.pid
default-character-set = utf8
prompt="u@h:p R:m:s [d]>"
[mysqld]
# GENERAL #
port = 3306
user = mysql
default-storage-engine = InnoDB
character_set_server = utf8
socket = /tmp/mysql.sock
log_timestamps = SYSTEM
server-id = 1001
# MyISAM #
key-buffer-size = 32M
myisam-recover-options = FORCE,BACKUP
# SAFETY #
max-allowed-packet = 100M
max-connect-errors = 1000000
sql-mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
innodb = FORCE
# DATA STORAGE #
datadir = /data/app/mysql5.7/data
# BINARY LOGGING #
log-bin = /data/app/mysql5.7/binlog/mysql-bin
expire-logs-days = 15
sync-binlog = 1
binlog_format = ROW
log_bin_trust_function_creators = ON
binlog_rows_query_log_events = ON
# REPLICATION #
gtid_mode = ON
enforce_gtid_consistency = ON
log_slave_updates = ON
relay-log = /data/app/mysql5.7/binlog/relay-bin
relay_log_info_repository = TABLE
relay_log_recovery = ON
sync-relay-log = 10000
sync-relay-log-info = 10000
master_info_repository = TABLE
sync-master-info = 10000
binlog_group_commit_sync_delay = 0
binlog_group_commit_sync_no_delay_count = 0
transaction_write_set_extraction = 'XXHASH64'
binlog_transaction_dependency_tracking = WRITESET
# SLAVE #
slave-parallel-type = LOGICAL_CLOCK
slave-parallel-workers = 8
#read-only = 1
#super_read_only = 1
slave-net-timeout = 60
#skip-slave-start = 1
slave_pending_jobs_size_max = 64M
# CACHES AND LIMITS #
tmp-table-size = 32M
max-heap-table-size = 32M
query-cache-type = 0
query-cache-size = 0
max-connections = 8000
thread-cache-size = 50
open-files-limit = 65535
table-definition-cache = 4096
table-open-cache = 4096
optimizer_switch = 'condition_fanout_filter=off,derived_merge=off'
wait_timeout = 10
# INNODB #
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 4
innodb-log-file-size = 512M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1
innodb_log_buffer_size = 8M
innodb-buffer-pool-size = 1G
# LOGGING #
log-error = /data/app/mysql5.7/logs/mysql.log
log_error_verbosity = 1
slow-query-log = 1
slow-query-log-file = /data/app/mysql5.7/logs/mysql-slow.log
max_slowlog_size = 1G
log_queries_not_using_indexes = OFF
# lc-messages
lc-messages-dir=/data/app/mysql5.7/share
EOF
cat >> /etc/profile <<"EOF"
# mysql5.7
export MysqlHome="/data/app/mysql5.7"
export PATH=${MysqlHome}/bin:$PATH
EOF
source /etc/profile
mysql -V
chown -R mysql.mysql /data/app/mysql5.7
debian、ubuntu:
apt-get install numactl libaio-dev -y
centos
yum install numactl libaio-dev -y
mysqld --defaults-file=/data/app/mysql5.7/my.cnf --initialize --user=mysql
链接启动文件:
ln -s /data/app/mysql5.7/support-files/mysql.server /etc/init.d/mysql
修改启动文件:
# vi /etc/init.d/mysql
# 修改basedir和datadir
basedir="/data/app/mysql5.7"
datadir="/data/app/mysql5.7/data"
启动并设置开机自启:
debian、ubuntu:
systemctl daemon-reload
systemctl start mysql
systemctl status mysql
systemctl enable mysql
centos:
/etc/init.d/mysql start
/etc/init.d/mysql status
chkconfig mysql on
在日志文件中获取初始密码:
## xxxxxxxxxx为初始密码
grep password /data/app/mysql5.7/logs/mysql.log
2022-10-21T17:24:27.138216+08:00 1 [Note] A temporary password is generated for root@localhost: xxxxxxxxxx
设置密码:
# 登录:
mysql -uroot -p'AyR5/hXdNQme'
# 设置密码为Abc.123456 (自己的密码)
mysql> SET PASSWORD FOR root@'localhost' = 'Abc.123456';
mysql> flush privileges;
mysql> exit
安利一波我的个人博客:倔强的阿木木
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。