使用playbook安装nginx和mysql

使用playbook安装nginx和mysql

nginx

- hosts: dbserver
  remote_user: root
  tasks:
    - name: add user nginx
      user: name=nginx shell=/sbin/nologin create_home=no
    - name: resolve dependent packages
      yum: name=pcre-devel,gcc,gcc-c++,openssl-devel,zlib-devel
    - name: unarchive tar file
      unarchive: src=/root/nginx-1.15.4.tar.gz dest=/usr/src
    - name: install nginx 
      shell: ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module && make && make install
      args:
        chdir: /usr/src/nginx-1.15.4
    - name: make soft link
      file: src=/usr/local/nginx/sbin/nginx dest=/usr/sbin/nginx state=link
    - name: start nginx
      shell: nginx


mysql

- hosts: dbserver
  remote_user: root
  tasks: 
    - name: resolve dependency
      yum: name=gcc,gcc-c++,ncurses-devel,cmake,bison
    - name: add user
      user: name=mysql create_home=no shell=/sbin/nologin
    - name: unarchive mysql
      unarchive: src=/root/mysql-5.5.22.tar.gz dest=/usr/src
    - name: install mysql
      shell: cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_INNOBASE_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc && make && make install
      args:
        chdir: /usr/src/mysql-5.5.22
    - name: soft link of libmysqlclient
      file: src=/usr/local/mysql/lib/libmysqlclient.so.18 dest=/usr/lib/libmysqlclient.so.18 state=link
    - name: soft link of command
      file: src=/usr/local/mysql/bin/mysql dest=/usr/bin/mysql state=link
    - name: mysqldump link
      file: src=/usr/local/mysql/bin/mysqldump dest=/usr/bin/mysqldump state=link
    - name: copy my.cnf
      copy: src=/usr/src/mysql-5.5.22/support-files/my-large.cnf dest=/etc/my.cnf remote_src=yes
    - name: copy mysql script
      copy: src=/usr/src/mysql-5.5.22/support-files/mysql.server dest=/etc/init.d/mysqld remote_src=yes
    - name: set user and group for mysql dir
      file: path=/usr/local/mysql owner=mysql group=mysql recurse=yes
    - name: give executable privileges
      file: path=/etc/init.d/mysqld mode=0755
    - name: initialize mysql process
      shell: /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --defaults-file=/etc/my.cnf
    - name: start mysql server
      shell: /etc/init.d/mysqld start


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/101884.html原文链接:https://javaforall.net

(0)
上一篇 2021年5月31日 下午7:00
下一篇 2021年5月31日 下午8:00


相关推荐

  • xshell连接虚拟机步骤_安装虚拟机后如何使用

    xshell连接虚拟机步骤_安装虚拟机后如何使用Xshell连接虚拟机1、打开虚拟机终端,输入下面命令,找到ens33对应的IP地址,如图ifconfig2、打开Xshell,打开文件–>新建3、填写名称,主机这里填入刚才的IP,点击连接4、输入登录的用户名,点击确定5、输入密码,点击确定6、连接成功,可以开始使用…

    2026年2月19日
    5
  • PyCharm和Python区别(关系)是什么呢?

    PyCharm和Python区别(关系)是什么呢?1 PyCharm 和 Python 的下载地址和安装方式完全不同 2 Python 是一种计算机程序设计语言 是一种面向对象的动态类型语言 最初被设计用于编写自动化脚本 shell 随着版本的不断更新和语言新功能的添加 越来越多被用于独立的 大型项目的开发 3 PyCharm 是 Python 的专用 IDE 地位类似于 Java 的 IDEEclipse 功能齐全的集成开发环境同时提供收费版和免费版 即专业版和社区版 PyCharm 是安装最快的 IDE 且安装后的配置也非常简单 因此 PyChar

    2026年3月27日
    2
  • AI编程-cursor无限使用, 还有谁不会🎁🎁🎁??

    AI编程-cursor无限使用, 还有谁不会🎁🎁🎁??

    2026年3月16日
    2
  • BufferedWriter[通俗易懂]

    BufferedWriter[通俗易懂]  带有默认缓冲的字符输出流。使用:  构造:BufferedWriterbf=newBufferedWriter(“outFilePath”);  写入:write(“thing”);  换行:newLine();  刷新缓冲区,会将内容写进目标文件:flush();  关闭该流的操作:close();importjava.io.BufferedWrit…

    2022年5月1日
    47
  • 分布式Session共享解决方案「建议收藏」

    Session是服务器用来保存用户操作的一系列会话信息,由Web容器进行管理。单机情况下,不存在Session共享的情况,分布式情况下,如果不进行Session共享会出现请求落到不同机器要重复登录的情况,一般来说解决Session共享有以下几种方案。1、session复制session复制是早期的企业级的使用比较多的一种服务器集群session管理机制。应用服务器开启web容器的sessi…

    2022年4月4日
    41
  • 腾讯元宝,重大更新!

    腾讯元宝,重大更新!

    2026年3月13日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号