赞
踩
CentOS7安装Percona Server for MySQL 5.7
简介
CentOS7 安装和配置
安装Percona Server
简介
由于公司产品要支持MySQL,之前试过MySQL5.7社区版和MySQL Cluster 7.6在性能上都不理想,只好再试试Perona Server。以下记录一下安装的过程。
CentOS7 安装和配置
使用deadline
使用xfs文件系统
修改vm.swappiness参数,降低swap使用率
调整vm.dirty_background_ratly、vm.dirty_ratil内核参数
调整net.ipv4.tcp_tw_recycle、net.ipv4.tcp+tw_reuse设置为1
安装Percona Server
删除旧数据库
rpm -qa | grep mysql
rpm -qa | grep mariad
rpm -e mysql
rpm -e --nodeps mysql
yum remove mariadb-libs-5.5.41-2.el7_0.x86_64
1
2
3
4
5
6
安装其他依赖包
yum -y install perl-Module-Install.noarch
yum -y install libaio libaio-devel
1
2
通过yum安装
# 配置yum安装源
yum install https://www.percona.com/downloads/percona-release/redhat/1.0-13/percona-release-1.0-13.noarch.rpm
# 安装percona
yum install Percona-Server-server-57
1
2
3
4
5
通过rpm安装
若yum在线安装不了,可以通过rpm离线安装
# 下载Percona Server
wget https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-5.7.27-30/binary/redhat/7/x86_64/Percona-Server-5.7.27-30-r8916819-el7-x86_64-bundle.tar
# 解压Percona Server # 建议解压到/usr/local/mysql
tar xvf Percona-Server-5.7.27-30-r8916819-el7-x86_64-bundle.tar
# 安装Percona Server
rpm -ivh Percona-Server-shared-compat-57-5.7.27-30.1.el7.x86_64.rpm
rpm -ivh Percona-Server-shared-57-5.7.27-30.1.el7.x86_64.rpm
rpm -ivh Percona-Server-client-57-5.7.27-30.1.el7.x86_64.rpm
rpm -ivh Percona-Server-server-57-5.7.27-30.1.el7.x86_64.rpm
1
2
3
4
5
6
7
8
9
10
11
配置
# 配置用户组
groupadd mysql
useradd -r -g mysql mysql
#初始化mysql
mysqld --initialize --user=mysql --/var/lib/mysql
1
2
3
4
5
6
# my.cnf配置 # 默认路径/etc/percona-server.conf.d/mysqld.cnf
# Percona Server template configuration
[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 leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# 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
port=3306
character-set-server=utf8mb4
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#GENERAL
default-storage-engine=INNODB
#INNODB
innodb_buffer_pool_size=16G
innodb_file_per_table=1
#innodb_data_file_path= ibdata1:256M:autoextend
innodb_log_file_size=256M
innodb_log_files_in_group=2
#innodb_open_fiels=2048
innodb_thread_concurrency = 0
#OTHER
skip-name-resolve
back_log = 600
max_connections = 100
max_connect_errors = 600
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 16M
binlog_cache_size = 1M
tmp_table_size = 2G
max_heap_table_size = 2G
join_buffer_size=8M
sort_buffer_size=8M
read_buffer_size=8M
read_rnd_buffer_size=8M
secure_file_priv=
thread_cache_size = 64
query_cache_type=0
query_cache_size=0
key_buffer_size=512M
table_definition_cache=512
explicit_defaults_for_timestamp = true
[mysql]
socket=/var/lib/mysql/mysql.sock
default-character-set=utf8mb4
# 修改目录权限
chown -R mysql:mysql /var/lib/mysql
# 启动Percona Server
service mysqld start
登录
cat /var/log/mysqld.log | grep "temporary password" ## 找到root的初始密码。
mysql -u root -p
# 修改密码
set password = password('123456');
#配置权限 (第3方工具可以连接)由此可以看出,只能以localhost的主机方式访问。
解决方法:
mysql> Grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
(%表示是所有的外部机器,如果指定某一台机,就将%改为相应的机器名;‘root’则是指要使用的用户名,)
mysql> flush privileges; (运行此句才生效,或者重启MySQL)
Query OK, 0 rows affected (0.03 sec)
总结
安装mysql的数据库必要步骤有:
安装依赖包
安装mysql数据库
初始化服务(mysqld --initialize)
修改配置文件,配置datadir目录权限和用户
启动服务,链接数据库
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。