ansible实现二进制安装mysql5.6

Posted 初如

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ansible实现二进制安装mysql5.6相关的知识,希望对你有一定的参考价值。


ansible执行文件配置如下:

- hosts: 10.0.0.72
  remote_user: root
  gather_facts: no

  tasks:
  - name: install packages
    yum:  name=libaio,perl-Data-Dumper,perl-Getopt-Long
  - name: create mysql group
    group: gid=306 name=mysql system=yes
  - name: create mysql user
    user: uid=306 system=yes name=mysql shell=/sbin/nologin create_home=no home=/data/mysql group=mysql
  - name: mkdir /data/mysql
    file: path=/data/mysql state=directory owner=mysql group=mysql
  - name: copy mysql tar to hosts
    unarchive: src=/data/ansible/mysql/mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz dest=/usr/local/ owner=mysql group=mysql
  - name: create link dirtory
    file: path=/usr/local/mysql src=/usr/local/mysql-5.6.46-linux-glibc2.12-x86_64 state=link
  - name: copy my.conf to hosts
    copy: src=/data/ansible/mysql/my.cnf dest=/etc/
  - name: shell
    shell: chdir=/usr/local  chown -R mysql:mysql mysql/
  - name: install
    shell: chdir=/usr/local/mysql ./scripts/mysql_install_db --datadir=/data/mysql --user=mysql
  - name: copy mysql.server to init.d
    shell: cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
  - name: echo path to file
    copy: content='PATH=/usr/local/mysql/bin:$PATH' dest=/etc/profile.d/mysql.sh
  - name: enable service
    shell: chkconfig --add mysqld;chkconfig mysqld on;systemctl start mysqld.service

my.cnf配置如下:

[mysqld]
socket=/tmp/mysql.sock
user=mysql
symbolic-links=0
datadir=/data/mysql
innodb_file_per_table=1
log-bin
pid-file=/data/mysql/mysqld.pid
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld_safe]
log-error=/var/log/mysqld.log                       

以上是关于ansible实现二进制安装mysql5.6的主要内容,如果未能解决你的问题,请参考以下文章

ansible实现二进制安装mysql5.6

MySQL5.6.16二进制源码安装详解及一键安装实现

centos7 二进制安装包安装 mysql5.6

CentOS 6.9 自定义单实例 二进制方式 安装mysql5.7.21

mysql5.6.20二进制安装部署文档

mysql5.6 通用二进制安装