Salt之CentOS7.5使用RPM包安装MySQL5.7.22

Posted minseo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Salt之CentOS7.5使用RPM包安装MySQL5.7.22相关的知识,希望对你有一定的参考价值。

  手动安装参考CentOS7.5使用RPM包安装MySQL5.7.22

  目录结构为

技术图片

  install.sls文件

#按顺序分别安装commin libs client server
#避免冲突安装common前需要卸载mysql-libs
mysql-common-install:
  file.managed:
    - name: /opt/mysql-community-common-5.7.22-1.el7.x86_64.rpm
    - source: salt://mysql/files/mysql-community-common-5.7.22-1.el7.x86_64.rpm
    - mode: 644
    - user: root
    - group: root
  cmd.run:
    - name: cd /opt && yum -y remove mysql-libs && rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm

mysql-libs-install:
  file.managed:
    - name: /opt/mysql-community-libs-5.7.22-1.el7.x86_64.rpm
    - source: salt://mysql/files/mysql-community-libs-5.7.22-1.el7.x86_64.rpm
    - mode: 644
    - user: root
    - group: root
  cmd.run:
    - name: cd /opt && rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm

mysql-client-install:
  file.managed:
    - name: /opt/mysql-community-client-5.7.22-1.el7.x86_64.rpm
    - source: salt://mysql/files/mysql-community-client-5.7.22-1.el7.x86_64.rpm
    - mode: 644
    - user: root
    - group: root
  cmd.run:
    - name: cd /opt && rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm

mysql-server-install:
  file.managed:
    - name: /opt/mysql-community-server-5.7.22-1.el7.x86_64.rpm
    - source: salt://mysql/files/mysql-community-server-5.7.22-1.el7.x86_64.rpm
    - mode: 644
    - user: root
    - group: root
  cmd.run:
    - name: cd /opt && rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm && systemctl start mysqld && systemctl enable mysqld
#依赖配置文件及bin-log配置
  require:
    - file: mysql-config
    - file: /var/lib/mysql/mysql-bin-log/

#my.cnf配置文件
mysql-config:
  file.managed:
    - name: /etc/my.cnf
    - source: salt://mysql/files/my.cnf
    - mode: 644
    - user: root
    - group: root

#创建bin-log文件夹默认无该文件夹,不创建会导致mysql无法启动
/var/lib/mysql/mysql-bin-log/:
  file.directory:
    - mode: 755
    - user: mysql
    - group: mysql
    - makedirs: True

  配置文件my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[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
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
#修改密码复制度要求只验证密码长度不验证密码复制度
validate_password_policy=LOW

#bin-log日志设置
log-bin=/var/lib/mysql/mysql-bin-log/mysql-bin
binlog_cache_size = 4M
max_binlog_cache_size = 256M
max_binlog_size = 32M
binlog_format = row
expire_logs_days = 7
server-id = 1

  安装命令

salt ‘salt-test‘ state.sls mysql.install saltenv=prod

  

以上是关于Salt之CentOS7.5使用RPM包安装MySQL5.7.22的主要内容,如果未能解决你的问题,请参考以下文章

Centos7.5-软件包的管理与安装

saltstack学习-简单部署之rhel5安装salt(不能联网)

CentOS7.5安装teamviwer13

CentOS7.5 yum 安装与配置MySQL5.7.24

CentOS7.5 安装MySQL8 tar

现代Java服务端开发核心技术之CentOS7.5安装MySQL5.7