当前位置:   article > 正文

二进制安装Percona mysql5.7_percona server依赖

percona server依赖

前言

快速安装Percona mysql5.7,二进制安装基本适用于所有系统,包括Centos、Debian、Ubuntu。
安装路径、数据、配置文件、日志都在一个目录(/data/app/mysql5.7)下,方便管理,以后迁移都方便。二进制安装包采用minimal,只有80M,解压完才370M,很小,安装很快。

0、环境

系统版本: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

1、下载并解压Percona mysql

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
  • 1
  • 2
  • 3

2、创建用户和相关目录

useradd mysql -M -s /sbin/nologin
mkdir -p /data/app/mysql5.7/{data,logs,binlog,run}
  • 1
  • 2

3、新建my.cnf配置文件

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103

4、设置环境变量

cat >> /etc/profile <<"EOF" 
# mysql5.7
export MysqlHome="/data/app/mysql5.7"
export PATH=${MysqlHome}/bin:$PATH
EOF
source /etc/profile

mysql -V
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

5、授权

chown -R mysql.mysql /data/app/mysql5.7
  • 1

6、安装依赖

debian、ubuntu:

apt-get install numactl libaio-dev  -y
  • 1

centos

yum  install numactl libaio-dev  -y
  • 1

7、初始化

mysqld --defaults-file=/data/app/mysql5.7/my.cnf  --initialize  --user=mysql
  • 1

8、启动mysql

链接启动文件:

ln -s /data/app/mysql5.7/support-files/mysql.server  /etc/init.d/mysql
  • 1

修改启动文件:

# vi /etc/init.d/mysql
# 修改basedir和datadir
basedir="/data/app/mysql5.7"
datadir="/data/app/mysql5.7/data"
  • 1
  • 2
  • 3
  • 4

启动并设置开机自启:
debian、ubuntu:

systemctl daemon-reload
systemctl start mysql
systemctl status mysql
systemctl enable mysql
  • 1
  • 2
  • 3
  • 4

centos:

/etc/init.d/mysql start
/etc/init.d/mysql status
chkconfig mysql  on
  • 1
  • 2
  • 3

9、获取初始密码和设置密码

在日志文件中获取初始密码:

## 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
  • 1
  • 2
  • 3

设置密码:

# 登录:
mysql -uroot -p'AyR5/hXdNQme'
# 设置密码为Abc.123456 (自己的密码)
mysql> SET PASSWORD FOR root@'localhost' = 'Abc.123456';
mysql> flush privileges;
mysql> exit
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

安利一波我的个人博客:倔强的阿木木

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/877145
推荐阅读
相关标签
  

闽ICP备14008679号