当前位置:   article > 正文

Mysql-Percona mysql5.7简单安装_percona 5.7安装

percona 5.7安装

来源:https://www.cnblogs.com/dingkailinux/p/8881327.html
 

Mysql-Percona mysql5.7简单安装

一、什么是Percona

单从mysql的角度来讲,可以把Percona理解为mysql的一个分支,因为mysql的源码是开源的,Percona就是在源码基础上对mysql做了一些改进,逐渐发展成了一条分支。其他分支还有mariadb等,都是mysql的分支,作为基础使用者,了解这么多就可以了,后续想深入了解,去看书吧。

二、Mysql5.7安装准备

1.基础信息:

(1)可参考官方文档【https://www.percona.com/doc/percona-server/5.7/installation/yum_repo.html】

(2)环境信息

系统:Centos7.3

Mysql:Percona的Mysql5.7

2.安装方式:

这里选择yum安装,原因是没有特殊需求,yum安装比较快

三、部署Mysql5.7

1.关闭selinux及firewalld防火墙

如果不关闭,启动会受到影响!!!别问我为什么知道!!!

  1. # sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/sysconfig/selinux
  2. # setenforce 0  #关闭Selinux(强烈建议关闭)
  3. # systemctl stop firewalld
  4. # systemctl disable firewalld  #关闭firewalld防火墙

2.安装yum源

# yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm

3.安装Percona-server57(mysql5.7)

# yum -y install Percona-Server-server-57

4.创建mysql相关目录

  1. # mkdir -p /opt/mysql/{mysql_data,mysql_log}  #创建mysql的数据目录和日志目录
  2. # chown -R mysql:mysql /opt/mysql         #更改属主属组为mysql
  3. # usermod -d /opt/mysql mysql           #将mysql用户的家目录改成工作目录(个人觉得应该修改)

4.修改配置文件

(1)清理不必要的原生配置文件

  1. # cd /etc/
  2. # rm -rf my.cnf my.cnf.d percona-server.cnf percona-server.conf.d  #我觉得这么一堆配置文件,不好维护,所以全部干掉

(2)建立mysql配置文件

  1. cat <<EOF>>/etc/my.cnf
  2. # Generated by Percona Configuration Wizard (http://tools.percona.com/) version REL5-20120208
  3. [client]
  4. port = 3306
  5. socket = /tmp/mysql.sock
  6. [mysql]
  7. # CLIENT #
  8. port = 3306
  9. socket = /tmp/mysql.sock
  10. default-character-set = utf8
  11. prompt="\u@\h:\p \R:\m:\s [\d]>"
  12. [mysqld]
  13. # GENERAL #
  14. user = mysql
  15. default-storage-engine = InnoDB
  16. character_set_server = utf8
  17. socket = /tmp/mysql.sock
  18. pid-file = /opt/mysql/mysql_log/mysqld.pid
  19. log_timestamps = SYSTEM
  20. server-id = 1001
  21. # MyISAM #
  22. key-buffer-size = 32M
  23. myisam-recover-options = FORCE,BACKUP
  24. # SAFETY #
  25. max-allowed-packet = 32M
  26. max-connect-errors = 1000000
  27. sql-mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
  28. innodb = FORCE
  29. # DATA STORAGE #
  30. datadir = /opt/mysql/mysql_data/
  31. # BINARY LOGGING #
  32. log-bin = /opt/mysql/mysql_log/mysql-bin
  33. expire-logs-days = 15
  34. sync-binlog = 1
  35. binlog_format = ROW
  36. log_bin_trust_function_creators = ON
  37. binlog_rows_query_log_events = ON
  38. # REPLICATION #
  39. gtid_mode = ON
  40. enforce_gtid_consistency = ON
  41. log_slave_updates = ON
  42. relay-log = /opt/mysql/mysql_log/relay-bin
  43. relay_log_info_repository = TABLE
  44. relay_log_recovery = ON
  45. sync-relay-log = 10000
  46. sync-relay-log-info = 10000
  47. master_info_repository = TABLE
  48. sync-master-info = 10000
  49. binlog_group_commit_sync_delay = 0
  50. binlog_group_commit_sync_no_delay_count = 0
  51. transaction_write_set_extraction = 'XXHASH64'
  52. binlog_transaction_dependency_tracking = WRITESET
  53. # SLAVE #
  54. slave-parallel-type = LOGICAL_CLOCK
  55. slave-parallel-workers = 8
  56. #read-only = 1
  57. #super_read_only = 1
  58. slave-net-timeout = 60
  59. #skip-slave-start = 1
  60. slave_pending_jobs_size_max = 64M
  61. # CACHES AND LIMITS #
  62. tmp-table-size = 32M
  63. max-heap-table-size = 32M
  64. query-cache-type = 0
  65. query-cache-size = 0
  66. max-connections = 8000
  67. thread-cache-size = 50
  68. open-files-limit = 65535
  69. table-definition-cache = 4096
  70. table-open-cache = 4096
  71. optimizer_switch = 'condition_fanout_filter=off,derived_merge=off'
  72. # INNODB #
  73. innodb-flush-method = O_DIRECT
  74. innodb-log-files-in-group = 4
  75. innodb-log-file-size = 512M
  76. innodb-flush-log-at-trx-commit = 1
  77. innodb-file-per-table = 1
  78. innodb_log_buffer_size = 8M
  79. innodb-buffer-pool-size = 16G
  80. # LOGGING #
  81. log-error = /opt/mysql/mysql_log/mysql-error.log
  82. log_error_verbosity = 1
  83. slow-query-log = 1
  84. slow-query-log-file = /opt/mysql/mysql_log/mysql-slow.log
  85. max_slowlog_size = 1G
  86. log_queries_not_using_indexes = OFF
  87. EOF
  88. 注:这个配置文件仅供参考,可以根据自己需求进行更改,Percona的在线生成配置文件工具【http://tools.percona.com/】

(3)修改/etc/systemd/system/mysql.service

  1. # vim /etc/systemd/system/mysql.service
  2. 修改以下行

  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  #重新加载配置

4.启动mysql

  1. # systemctl enable mysqld
  2. # systemctl start mysqld

5.mysql简单初始化

(1)登录及修改初始密码

 

  1. # grep -i 'password' /opt/mysql/mysql_log/mysql-error.log   #获取mysql初始密码
  2. 2018-04-19T04:07:12.534522Z 1 [Note] A temporary password is generated for root@localhost: er+Pezm/r31i
  3. # mysql -u root -p'er+Pezm/r31i'  #登录mysql
  4. # SET PASSWORD FOR root@'localhost' = 'MFdb@2018!'; #更改root密码

 

 

6.简单排错

如果启动时报错,可以使用以下方式排错

(1) 查看当前实例使用的配置文件是否是你定义的

  1. # mysqld --verbose --help |grep -A 1 'Default options'
  2. Default options are read from the following files in the given order:
  3. /etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf

(2)查看输出日志

# cat /opt/mysql_log/mysql-error.log

(3)查看系统日志

  1. # systemctl status mysqld  #这个看systemd的报错,个人觉得没什么卵用
  2. # journalctl -b    #这个看系统输出的日志,信息量很大,比较有用
  3. # journalctl -xe    #这个也是系统输出的日志,信息简略,有一些用
本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号