二进制部署MySQL5.7

这个文档用于基础解释,后面通过ansible的自动化对MySQL单实例进行安装部署。

1、解压文件

  1. # tar zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz -C /usr/local

2、重命名文件名称

  1. # cd /usr/local
  2. # mv mysql-5.7.22-linux-glibc2.12-x86_64/ mysql/

3、新建mysql用户

  1. # groupadd mysql
  2. # useradd -g mysql mysql

4、设置用户操作系统资源的限制

  1. # vi /etc/security/limits.conf
  2. mysql soft nproc 65536
  3. mysql hard nproc 65536
  4. mysql soft nofile 65536
  5. mysql hard nofile 65536
  • 验证limit是否生效
  1. su - mysql
  2. ulimit -a

5、创建MySQL数据目录及赋予相应权限

  1. #cd /data/
  2. #mkdir -p /data/mysqldata/{3306/{data,tmp,binlog,innodb_ts,innodb_log},backup,scripts}
  3. #chown -R mysql:mysql mysqldata

6、配置my.cnf

  1. #su - mysql
  2. [client]
  3. port = 3306
  4. socket = /data/mysqldata/3306/mysql.sock
  5. # The MySQL server
  6. [mysqld]
  7. port = 3306
  8. user = mysql
  9. socket = /data/mysqldata/3306/mysql.sock
  10. pid-file = /data/mysqldata/3306/mysql.pid
  11. basedir = /usr/local/mysql
  12. datadir = /data/mysqldata/3306/data
  13. tmpdir = /data/mysqldata/3306/tmp
  14. open_files_limit = 60000
  15. explicit_defaults_for_timestamp
  16. server-id = 1203306
  17. lower_case_table_names = 1
  18. character-set-server = utf8
  19. federated
  20. #sql_mode=STRICT_TRANS_TABLES
  21. max_connections = 1000
  22. max_connect_errors = 100000
  23. interactive_timeout = 86400
  24. wait_timeout = 86400
  25. sync_binlog=0
  26. back_log=100
  27. default-storage-engine = InnoDB
  28. log_slave_updates = 1
  29. #*********** buffer **********************
  30. net_buffer_length = 8K
  31. sort_buffer_size = 2M
  32. join_buffer_size = 4M
  33. read_buffer_size = 2M
  34. read_rnd_buffer_size = 16M
  35. query_cache_size = 128M
  36. query_cache_limit = 2M
  37. query_cache_min_res_unit = 2k
  38. thread_cache_size = 300
  39. table_open_cache = 1024
  40. tmp_table_size = 256M
  41. #*********** Logs related settings ***********
  42. log-bin = /data/mysqldata/3306/binlog/mysql-bin
  43. binlog_format= mixed
  44. binlog_cache_size=32m
  45. max_binlog_cache_size=64m
  46. max_binlog_size=512m
  47. long_query_time = 1
  48. log_output = FILE
  49. log-error = /data/mysqldata/3306/mysql-error.log
  50. slow_query_log = 1
  51. slow_query_log_file = /data/mysqldata/3306/slow_statement.log
  52. #log_queries_not_using_indexes
  53. general_log = 0
  54. general_log_file = /data/mysqldata/3306/general_statement.log
  55. expire-logs-days = 14
  56. #binlog_expire_logs_seconds = 1728000
  57. relay-log = /data/mysqldata/3306/binlog/relay-bin
  58. relay-log-index = /data/mysqldata/3306/binlog/relay-bin.index
  59. #****** MySQL Replication New Feature*********
  60. master-info-repository=TABLE
  61. relay-log-info-repository=TABLE
  62. relay-log-recovery
  63. #*********** INNODB Specific options ***********
  64. innodb_buffer_pool_size = 2048M
  65. transaction-isolation=READ-COMMITTED
  66. innodb_buffer_pool_instances = 4
  67. innodb_file_per_table = 1
  68. innodb_data_home_dir = /data/mysqldata/3306/innodb_ts
  69. innodb_data_file_path = ibdata1:2048M:autoextend
  70. innodb_temp_data_file_path = ibtmp1:2048M:autoextend
  71. innodb_thread_concurrency = 8
  72. innodb_log_buffer_size = 16M
  73. innodb_log_file_size = 128M
  74. innodb_log_files_in_group = 3
  75. innodb_log_group_home_dir = /data/mysqldata/3306/innodb_log
  76. innodb_flush_log_at_trx_commit = 2
  77. innodb_max_dirty_pages_pct = 70
  78. innodb_flush_method=O_DIRECT
  79. [mysql]
  80. no-auto-rehash
  81. default-character-set=gbk
  82. prompt = (\u@\h) [\d]>\_

7、初始化数据库mysql

  1. $/usr/local/mysql/bin/mysqld --defaults-file=/data/mysqldata/3306/my.cnf --initialize-insecure --user=mysql

备注: --initialize 生成一个随机密码

--initialize-insecure不生成随机密码

8、启动mysql服务

  1. $/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf --user=mysql &

9、配置mysql环境变量

  1. [mysql@MHA-Manager ~]$ vi .bash_profile
  2. ...相关配置文件...
  3. PATH=$PATH:/usr/local/mysql/bin
  4. ...相关配置文件...
  5. [mysql@MHA-Manager ~]$ source .bash_profile
  6. [mysql@MHA-Manager ~]$ echo $PATH
  7. [mysql@MHA-Manager ~]$ mysql
  8. Welcome to the MySQL monitor. Commands end with ; or \g.
  9. Your MySQL connection id is 2
  10. Server version: 5.7.22-log MySQL Community Server (GPL)
  11. Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  12. Oracle is a registered trademark of Oracle Corporation and/or its
  13. affiliates. Other names may be trademarks of their respective
  14. owners.
  15. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  16. (root@localhost) [(none)]>

自动化运维(1)之二进制部署MySQL5.7的更多相关文章

  1. 自动化运维工具Ansible详细部署 (转载)

    自动化运维工具Ansible详细部署 标签:ansible 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://sofar.blog. ...

  2. 自动化运维工具Ansible详细部署 - 人生理想在于坚持不懈 - 51CTO技术博客

    自动化运维工具Ansible详细部署 - 人生理想在于坚持不懈 - 51CTO技术博客 自动化运维工具Ansible详细部署

  3. 自动化运维工具SaltStack详细部署【转】

    ==========================================================================================一.基础介绍==== ...

  4. 自动化运维工具Ansible详细部署

    本文来源:http://sofar.blog.51cto.com/353572/1579894/ 前言 一个由 Python 编写的强大的配置管理解决方案.尽管市面上已经有很多可供选择的配置管理解决方 ...

  5. 自动化运维工具Ansible的部署步骤详解

    本文来源于http://sofar.blog.51cto.com/353572/1579894,主要是看到这样一篇好文章,想留下来供各位同僚一起分享. 一.基础介绍 ================= ...

  6. 自动化运维工具SaltStack详细部署

    ==========================================================================================一.基础介绍==== ...

  7. 自动化运维工具 SaltStack 搭建

    原文地址:https://www.ibm.com/developerworks/cn/opensource/os-devops-saltstack-in-cloud/index.html#N10072 ...

  8. 部署MySQL自动化运维工具inception+archer

    ***************************************************************************部署MySQL自动化运维工具inception+a ...

  9. 基于Linux平台的自动化运维Devops-----之自动化系统部署

    一.自动化运维的背景网站业务上线,需要运维人员在短时间内完成几百台服务器部署,包括系统安装.系统初始化.软件的安装与配置.性能的监控......所谓运维自动化,即在最少的人工干预下,利用脚本与第三方工 ...

随机推荐

  1. Ural 1018 Binary Apple Tree

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1018 Dynamic Programming. 首先要根据input建立树形结构,然后在 ...

  2. Java流程控制语句

    流程控制语句 内容: if... if...else if...else if...else switch...case for while do...while 分支结构if 接下来要学习的if条件 ...

  3. centos 7下 django 1.11 + nginx 1.12 + uwsgi 2.0

    之前写过一个博客关于如何安装django的,见下网址, http://www.cnblogs.com/qinhan/p/8732626.html 还有一个网址如何安装nginx的 http://www ...

  4. HPS基本概念及其设计

    DE1-SOC开发版上的FPGA在一个基于ARM的用户定制系统(SOC)中集成了分立处理器(HPS).FPGA和数字信号处理(DSP)功能.HPS是基于ARM cortex-A9双核处理器,具有丰富的 ...

  5. tomcat的调优管理

    1 记性调整存设定. A: 方法如下: 1. linux 下编辑tomcat安装目录下的bin目录下的catalina.sh文件,windows下为catalina.bat vi  catalina. ...

  6. Nginx+Tomcat反向代理利用certbot实现https

    一.利用Let's Encrypt 免费生成HTTPS证书 1.下载安装certbot(Let's Encrypt ) 2.利用certbot生成证书 3.配置nginx的https证书 安装cerb ...

  7. three.js 一幅图片多个精灵

    https://blog.csdn.net/zhulx_sz/article/details/79105359 核心代码 // 把一幅外部图片中包含的5种精灵存入一个精灵材质数组 var sprite ...

  8. IDEA搭建SSM实现登录、注册,数据增删改查功能

     本博文的源代码:百度云盘/java/java实例/SSM实例/SSM实现登录注册,增删改查/IDEA搭建SSM实现登录,注册,增删改查功能.zip 搭建空的Maven项目 使用Intellij id ...

  9. HttpClient和HttpURLConnection的使用和区别(下)

    转自来自点击打开链接 接着上一篇,我们继续来分析HttpURLConnection的使用,以及两者的共同点和区别. 目录 用法 HttpURLConnection 区别 引用资料 用法 HttpURL ...

  10. jsp-9大内置对象简介

    产生背景 JSP引擎在调用JSP对应的jspServlet时,会传递或创建9个与web开发相关的对象供jspServlet使用.JSP技术的设计者为便于开发人员在编写JSP页面时获得这些web对象的引 ...