• ansible一键完成二进制mysql8.0.19部署脚本(yaml)


    #centos7
    --- - hosts: 10.0.0.27 remote_user: root gather_facts: no tasks: - name: "创建Mysql用户" shell: id mysql &> /dev/null || useradd -r -d /data/mysql -s /sbin/nologin mysql - name: "安装依赖包" yum: name=libaio,perl-Data-Dumper,ncurses-libs - name: "创建mysql的家目录文件夹" file: path=/data/mysql state=directory owner=mysql group=mysql - name: "解压二进制程序" unarchive: src=/data/mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz dest=/usr/local owner=root group=root - name: "将压缩后的文件设置为软链接" file: src=/usr/local/mysql-8.0.19-linux-glibc2.12-x86_64 dest=/usr/local/mysql state=link - name: "环境变量" copy: content='PATH=/usr/local/mysql/bin/:$PATH' dest=/etc/profile.d/mysql.sh - name: "同步环境变量" shell: source /etc/profile.d/mysql.sh - name: "准备MySQL配置文件" copy: content='[mysqld] datadir = /data/mysql socket=/data/mysql/mysql.sock log-error=/data/mysql/mysql.log pid-file=/data/mysql/mysql.pid [client] port=3306 socket=/data/mysql/mysql.sock ' dest=/etc/my.cnf - name: "生成数据库文件" shell: /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/data/mysql - name: "复制服务启动文件" shell: /bin/cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld - name: "启动mysql服务并设置开机启动" shell: chkconfig --add mysqld;chkconfig mysqld on;service mysqld start - name: "修改mysql默认密码" shell: mysqladmin -uroot -p`awk '/A temporary password/{print $NF}' /data/mysql/mysql.log` password 123456
    #centos8
    ---
    - hosts: 10.0.0.58
      remote_user: root
      gather_facts: no
    
      tasks: 
        - name: "创建Mysql用户"
          shell: id mysql &> /dev/null || useradd -r -d /data/mysql -s /sbin/nologin mysql
        - name: "安装依赖包"
          yum: name=libaio,perl-Data-Dumper,ncurses-c++-libs,ncurses-compat-libs
        - name: "创建mysql的家目录文件夹"
          file: path=/data/mysql state=directory owner=mysql group=mysql
        - name: "解压二进制程序"
          unarchive: src=/data/mysql-8.0.19-linux-glibc2.12-x86_64.tar.xz dest=/usr/local owner=root group=root
        - name: "将压缩后的文件设置为软链接"
          file: src=/usr/local/mysql-8.0.19-linux-glibc2.12-x86_64 dest=/usr/local/mysql state=link
        - name: "环境变量"
          copy: content='PATH=/usr/local/mysql/bin/:$PATH' dest=/etc/profile.d/mysql.sh
        - name: "同步环境变量"
          shell: source /etc/profile.d/mysql.sh
        - name: "准备MySQL配置文件"
          copy: content='[mysqld]
    datadir = /data/mysql
    socket=/data/mysql/mysql.sock
    log-error=/data/mysql/mysql.log
    pid-file=/data/mysql/mysql.pid
    
    [client]
    port=3306
    socket=/data/mysql/mysql.sock
    ' dest=/etc/my.cnf
        - name: "生成数据库文件"
          shell: /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/data/mysql
        - name: "复制服务启动文件"
          shell: /bin/cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld 
        - name: "启动mysql服务并设置开机启动"
          shell: chkconfig --add mysqld;chkconfig mysqld on;service mysqld start
        - name: "修改mysql默认密码"
          shell: mysqladmin  -uroot -p`awk '/A temporary password/{print $NF}' /data/mysql/mysql.log` password 123456
  • 相关阅读:
    BeanPostProcessor后置处理器原理以及ApplicationListener原理
    SpringCloud之服务注册与发现Eureka+客户端Feign
    AJPFX关于TreeSet集合的介绍
    AJPFX:关于面向对象的封装
    AJPFX总结Java 类与对象的初始化
    AJPFX关于增强for的概述和使用(foreach)
    AJPFX总结泛型概念和使用
    AJPFX简述可变参数概述和使用
    AJPFX关于JAVA StringBuffer的用法总结
    AJPFX关于Collection 集合的表述
  • 原文地址:https://www.cnblogs.com/nj-duzi/p/13842051.html
Copyright © 2020-2023  润新知