Mysql-Percona mysql5.7 simple installation
First, what is Percona
From the perspective of a single mysql, Percona can be understood as a branch of mysql, mysql because the source code is open source, Percona is based on the source code for mysql made some improvements, and gradually developed into a branch. There are other branches mariadb branch, are mysql as a basis for the user to learn so much on it, follow want to learn more, see the book.
Two, Mysql5.7 installation preparation
1. Basic information:
(1) refer to the official documentation] [https://www.percona.com/doc/percona-server/5.7/installation/yum_repo.html
(2) Environmental Information
System: Centos7.3
Mysql: Percona of Mysql5.7
2. Installation:
Yum install selected here, because there is no special needs, yum install faster
Third, the deployment Mysql5.7
1. Turn off selinux and firewalld firewall
If you do not shut down, start will be affected! ! ! Do not ask me why I know! ! !
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux
setenforce 0 # close Selinux (strongly recommended closed)
systemctl stop firewalld
systemctl disable firewalld # turn off the firewall firewalld
2. Install the yum source
yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
3. Installation Percona-server57 (mysql5.7)
yum -y install Percona-Server-server-57
4. Create mysql directory relevant
mkdir -p / opt / mysql / {mysql_data, mysql_log} # Create mysql log directory data directory and
chown -R mysql: mysql / opt / mysql # Change owner is a group of mysql
usermod -d / opt / mysql mysql # mysql user's home directory will change the working directory (personally feel should be revised)
4. Modify the configuration file
(1) clean up unnecessary native profile
cd /etc/
rm -rf my.cnf my.cnf.d percona-server.cnf percona-server.conf.d # I feel so a bunch of configuration files, bad maintenance, so get rid of all
(2) establish mysql configuration file
Copy the code
cat <
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
default-character-set = utf8
prompt="\u@\h:\p \R:\m:\s [\d]>"
[mysqld]
GENERAL
user = mysql
default-storage-engine = InnoDB
character_set_server = utf8
socket = /tmp/mysql.sock
pid-file = /opt/mysql/mysql_log/mysqld.pid
log_timestamps = SYSTEM
server-id = 1001
MyISAM
key-buffer-size = 32M
myisam-recover-options = FORCE,BACKUP
SAFETY
max-allowed-packet = 32M
max-connect-errors = 1000000
sql-mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
innodb = FORCE
DATA STORAGE
datadir = /opt/mysql/mysql_data/
BINARY LOGGING
log-bin = /opt/mysql/mysql_log/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 = /opt/mysql/mysql_log/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'
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 = 16G
LOGGING
log-error = /opt/mysql/mysql_log/mysql-error.log
log_error_verbosity = 1
slow-query-log = 1
slow-query-log-file = /opt/mysql/mysql_log/mysql-slow.log
max_slowlog_size = 1G
log_queries_not_using_indexes = OFF
EOF
Note: This configuration file is for reference only and can be changed according to their needs, Percona online tool generates the configuration file] [http://tools.percona.com/
Copy the code
(3) modify the /etc/systemd/system/mysql.service
duplicated code
vim /etc/systemd/system/mysql.service
Modify the following line
sed -i 's#/var/run/mysqld/mysqld.pid#/opt/mysql/mysql_log/mysqld.pid#g' /etc/systemd/system/mysql.service
sed -i 's#/var/run/mysqld/mysqld.pid#/opt/mysql/mysql_log/mysqld.pid#g' /usr/lib/systemd/system/mysqld.service
sed -i 's # LimitNOFILE = 5000 # LimitNOFILE = 100000 # g' /etc/systemd/system/mysql.service
sed -i 's # LimitNOFILE = 5000 # LimitNOFILE = 100000 # g' /usr/lib/systemd/system/mysqld.service
systemctl daemon-reload # reload the configuration
Copy the code
4. Start mysql
systemctl enable mysqld
systemctl start mysqld
5.mysql simple initialization
(1) modify the initial login password and
copy the code
grep -i 'password' /opt/mysql/mysql_log/mysql-error.log # obtain initial password mysql
2018-04-19T04:07:12.534522Z 1 [Note] A temporary password is generated for root@localhost: er+Pezm/r31i
mysql -u root -p'er + Pezm / r31i '# login mysql
SET PASSWORD FOR root @ 'localhost' = 'MFdb @ 2018!'; # Change the root password
Copy the code
6. Simple Troubleshooting
If the error when you start, you can use the following way Troubleshooting
(1) view the current instance profile if you defined
mysqld --verbose --help |grep -A 1 'Default options'
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
(2) to view the output log
cat /opt/mysql_log/mysql-error.log
(3) view the system log