SaltStack安装Apache/Mysql/PHP部署Wordpress

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
公共DNS(含HTTPDNS解析),每月1000万次HTTP解析
简介: SaltStack是一个服务器基础架构集中化管理平台,具备配置管理、远程执行、监控等功能,基于Python语言实现,结合轻量级消息队列(ZeroMQ)与Python第三方模块(Pyzmq、PyCrypto、Pyjinjia2、python-msgpack和PyYAML等)构建。SaltStack 采用 C/S模式,server端就是salt的master,client端就是minion,minion与master之间通过ZeroMQ消息队列通信。master监听4505和4506端口,4505对应的是ZMQ的PUB system,用来发送消息,4506对应的是REP system是来接受


salt介绍



SaltStack是一个服务器基础架构集中化管理平台,具备配置管理、远程执行、监控等功能,基于Python语言实现,结合轻量级消息队列(ZeroMQ)与Python第三方模块(Pyzmq、PyCrypto、Pyjinjia2、python-msgpack和PyYAML等)构建。

SaltStack 采用 C/S模式,server端就是salt的master,client端就是minion,minion与master之间通过ZeroMQ消息队列通信。

master监听4505和4506端口,4505对应的是ZMQ的PUB system,用来发送消息,4506对应的是REP system是来接受消息的。


命令执行步骤

具体步骤如下

  • Salt stack的Master与Minion之间通过ZeroMq进行消息传递,使用了ZeroMq的发布-订阅模式,连接方式包括tcp,ipc
  • salt命令,将cmd.run ls命令从salt.client.LocalClient.cmd_cli发布到master,获取一个Jodid,根据jobid获取命令执行结果。
  • master接收到命令后,将要执行的命令发送给客户端minion。
  • minion从消息总线上接收到要处理的命令,交给minion._handle_aes处理
  • minion._handle_aes发起一个本地线程调用cmdmod执行ls命令。线程执行完ls后,调用minion._return_pub方法,将执行结果通过消息总线返回给master
  • master接收到客户端返回的结果,调用master._handle_aes方法,将结果写的文件中
  • salt.client.LocalClient.cmd_cli通过轮询获取Job执行结果,将结果输出到终端。


saltstack安装



测试环境

  • CentOS6.5
  • master:172.20.22.46 (主机名:hadoop1) # 之前配置Spark改的名字
  • slave:172.20.22.159 (主机名:hadoop2)


分为以下几步

关闭selinux

/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled

master安装salt-minion, salt-master

Google

slave安装salt-minion

Google

配置salt-master

参考

#指定master,冒号后有一个空格
master: 192.168.2.22
user: root
#-------以下为可选--------------
# salt运行的用户,影响到salt的执行权限
user: root
#s alt的运行线程,开的线程越多一般处理的速度越快,但一般不要超过CPU的个数
worker_threads: 10
# master的管理端口
publish_port : 4505
# master跟minion的通讯端口,用于文件服务,认证,接受返回结果等
ret_port : 4506
# 如果这个master运行的salt-syndic连接到了一个更高层级的master,那么这个参数需要配置成连接到的这个高层级master的监听端口
syndic_master_port : 4506
# 指定pid文件位置
pidfile: /var/run/salt-master.pid
# saltstack 可以控制的文件系统的开始位置
root_dir: /
# 日志文件地址
log_file: /var/log/salt_master.log
# 分组设置
nodegroups:
  group_all: '*'
# salt state执行时候的根目录
file_roots:
  base:
    - /srv/salt/
# 设置pillar 的根目录
pillar_roots:
  base:
    - /srv/pillar
复制代码

本文主要改动

file_roots:
  base:
    - /srv/salt/base
  dev:
    - /srv/salt/dev
  test:
    - /srv/salt/test
  prod:
    - /srv/salt/prod
复制代码
配置salt-minion

参考

#指定master,冒号后有一个空格
master: 192.168.2.22
id: minion-01
user: root
#-------以下为可选--------------
# minion的识别ID,可以是IP,域名,或是可以通过DNS解析的字符串
id: 192.168.0.100
# salt运行的用户权限
user: root
# master的识别ID,可以是IP,域名,或是可以通过DNS解析的字符串
master : 192.168.0.100
# master通讯端口
master_port: 4506
# 备份模式,minion是本地备份,当进行文件管理时的文件备份模式
backup_mode: minion
# 执行salt-call时候的输出方式
output: nested 
# minion等待master接受认证的时间
acceptance_wait_time: 10
# 失败重连次数,0表示无限次,非零会不断尝试到设置值后停止尝试
acceptance_wait_time_max: 0
# 重新认证延迟时间,可以避免因为master的key改变导致minion需要重新认证的syn风暴
random_reauth_delay: 60
# 日志文件位置
log_file: /var/logs/salt_minion.log
# 文件路径基本位置
file_roots:
  base:
    - /etc/salt/minion/file
# pillar基本位置
pillar_roots:
  base:
    - /data/salt/minion/pillar
复制代码

本文主要改动

master : 172.20.22.46
grains:
  roles:
    - nginx
  env:
    - test
  myname:
    - yzd
复制代码
启动/重启salt

sudo service salt-master start/restart

sudo service salt-minion start/restart

master认证minion的key

Google

检查安装是否完成
[root@hadoop1 Desktop]# salt-run manage.status
down:
up:
    - hadoop1
    - hadoop2
[root@hadoop1 Desktop]# salt '*' grains.item os myname
hadoop1:
    ----------
    myname:
    os:
        CentOS
hadoop2:
    ----------
    myname: # 自定义的grains
        - yzd
    os:
        CentOS
复制代码


部署WordPress



环境要求

摘自官网 We recommend servers running version 7.2 or greater of PHP and MySQL version 5.6 OR MariaDB version 10.0 or greater. We also recommend either Apache or Nginx as the most robust options for running WordPress, but neither is required.

最后的完整文件树

[root@hadoop1 base]# tree
.
├── mysql
│   ├── conf.sls
│   ├── files
│   │   ├── conf.sh
│   │   ├── my.cnf
│   │   ├── mysql-5.5.60.tar.gz
│   │   ├── mysql-5.6.40.tar.gz
│   │   ├── mysqld
│   │   └── mysqllns.sh
│   ├── init.sls
│   └── install.sls
├── top.sls
├── web
│   ├── apache.sls
│   ├── ap.sls
│   └── files
│       ├── apache-conf.d
│       │   ├── mod_dnssd.conf
│       │   ├── php.conf
│       │   ├── README
│       │   └── welcome.conf
│       ├── httpd.conf
│       └── php.ini
└── wordpress
    ├── files
    │   ├── wordpress-latest.tar.gz
    │   └── wordpress-yang.tar.gz
    └── wp-install.sls
7 directories, 21 files
复制代码


安装Apache和Php


流程

  • 安装apache和php依赖
  • 将主机的apache和php配置文件覆盖从机文件
  • 运行apache服务

web/ap.sls:

lamp-install:
  pkg.installed:
    - pkgs:
      - httpd
      - php
      - php-pdo
      - php-mysql
      - php-gd
apache-config:
  file.managed:
    - name: /etc/httpd/conf/httpd.conf #服务实际使用的文件路径
    - source: salt://web/files/httpd.conf #salt的源文件用于分发到minion上面 路径是base目录下面的web 这里也支持http和ftp方式
    - user: root
    - group: root
    - mode: 644
    - require:
      - pkg: lamp-install
php-config:
  file.managed:
    - name: /etc/php.ini
    - source: salt://web/files/php.ini
    - user: root
    - group: root
    - mode: 644
#使用watch在apache配置文件发送变化时,重新加载apache配置
lamp-service:
  service.running:
    - name: httpd
    - enable: True
    - reload: True  #如果不加reload 默认会重启服务
    - watch: #增加
      - file: apache-config #监控上面的apache-config ID 所以说 一个ID在一个状态只能出现一次
apache-conf:
  file.recurse:
    - name: /etc/httpd/conf.d
    - source: salt://web/files/apache-conf.d
复制代码

运行结果:

[root@hadoop1 base]# salt 'hadoop2' state.sls web.ap
hadoop2:
----------
          ID: lamp-install
    Function: pkg.installed
      Result: True
     Comment: 4 targeted packages were installed/updated. The following packages were already installed: httpd
     Started: 09:14:41.225378
    Duration: 64220.577 ms
     Changes:   
              ----------
              libXpm:
                  ----------
                  new:
                      3.5.10-2.el6
                  old:
              php:
                  ----------
                  new:
                      5.3.3-49.el6
                  old:
              php-cli:
                  ----------
                  new:
                      5.3.3-49.el6
                  old:
              php-common:
                  ----------
                  new:
                      5.3.3-49.el6
                  old:
              php-gd:
                  ----------
                  new:
                      5.3.3-49.el6
                  old:
              php-mysql:
                  ----------
                  new:
                      5.3.3-49.el6
                  old:
              php-pdo:
                  ----------
                  new:
                      5.3.3-49.el6
                  old:
----------
          ID: apache-config
    Function: file.managed
        Name: /etc/httpd/conf/httpd.conf
      Result: True
     Comment: File /etc/httpd/conf/httpd.conf is in the correct state
     Started: 09:15:45.451376
    Duration: 14.631 ms
     Changes:   
----------
          ID: php-config
    Function: file.managed
        Name: /etc/php.ini
      Result: True
     Comment: File /etc/php.ini is in the correct state
     Started: 09:15:45.466131
    Duration: 4.601 ms
     Changes:   
----------
          ID: lamp-service
    Function: service.running
        Name: httpd
      Result: True
     Comment: Service httpd has been enabled, and is running
     Started: 09:15:45.477085
    Duration: 477.583 ms
     Changes:   
              ----------
              httpd:
                  True
----------
          ID: apache-conf
    Function: file.recurse
        Name: /etc/httpd/conf.d
      Result: True
     Comment: Recursively updated /etc/httpd/conf.d
     Started: 09:15:45.954926
    Duration: 149.052 ms
     Changes:   
              ----------
              /etc/httpd/conf.d/welcome.conf:
                  ----------
                  diff:
                      ---  
                      +++  
                      @@ -9,3 +9,4 @@
                           ErrorDocument 403 /error/noindex.html
                       </LocationMatch>
Summary
------------
Succeeded: 5 (changed=3)
Failed:    0
------------
Total states run:     5
复制代码


安装Mysql5.6


流程

  • 传输mysql源码包至从机
  • 解压源码包
  • 安装编译所需依赖
  • 源码安装mysql
  • 将主机my.cnf覆盖从机文件
  • 运行conf.sh,使用scripts/mysql_install_db建立数据库
  • 运行mysqllns.sh创建所需要的软连接
  • 将主机mysqld覆盖从机文件
  • 运行mysqld

init.sls

include:
  - mysql.install
  - mysql.conf
复制代码

install.sls

#install source mysql
mysql_source:
  file.managed:
    - name: /home/mysql-5.6.40.tar.gz
    - unless: test -e /home/mysql-5.6.40.tar.gz
    - source: salt://mysql/files/mysql-5.6.40.tar.gz
#tar source mysql
extract_mysql:
  cmd.run:
    - cwd: /home
    - names:
        - tar xf mysql-5.6.40.tar.gz
    - unless: test -d /home/mysql-5.6.40
    - require:
        - file: mysql_source
#useradd for mysql
mysql_user:
  user.present:
    - name: mysql
    - uid: 1024
    - createhome: False
    - gid_from_name: True
    - shell: /sbin/nologin
#mysql pkg.install
mysql_pkg:
  pkg.installed:
    - pkgs:
      - gcc
      - gcc-c++
      - autoconf
      - automake
      - openssl
      - openssl-devel
      - zlib
      - zlib-devel
      - ncurses-devel
      - libtool-ltdl-devel
      - cmake
#mysql source install
mysql_commpile:
  cmd.run:
    - cwd: /home/mysql-5.6.40
    - names:
        - chown root:root /home/mysql-5.6.40 -R
        - cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATTON=utf8_cuicode_ci   -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1  -DENABLED_LOCAL_INFILE=1 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0
        - make
        - make install
    - require:
        - cmd: extract_mysql
        - pkg: mysql_pkg
    - unless: test -d /usr/local/mysql
复制代码

conf.sls

include:
  - mysql.install
# mysql for config
mysql_cnf:
  file.managed:
    - name: /etc/my.cnf
    - user: root
    - mode: 755
    - source: salt://mysql/files/my.cnf
# mysql init
salt://mysql/files/conf.sh:
  cmd.script:
      - env:
          - BATCH: 'yes'
      - require:
          - cmd: mysql_commpile
          - pkg: mysql_pkg 
# mysql lnk
salt://mysql/files/mysqllns.sh:
  cmd.script:
    - env:
      - BATCH: 'yes'
    - require:
      - cmd: mysql_commpile
      - pkg: mysql_pkg
# mysql server
mysql_service:
   file.managed:
     - name: /etc/init.d/mysqld
     - user: root
     - mode: 755
     - source: salt://mysql/files/mysqld
   cmd.run:
     - names:
         - /sbin/chkconfig --add mysqld
         - /sbin/chkconfig --level 35 mysqld on
     - unless: /sbin/chkconfig --list mysqld
   service.running:
     - name: mysqld
     - enable: True
     - reload: True
复制代码

conf.sh:

#!/bin/bash
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
复制代码

mysqllns.sh

#!/bin/bash
ln -sv /usr/local/mysql/bin/mysql /usr/bin 
ln -sv /usr/local/mysql/bin/mysqladmin /usr/bin/
ln -sv /usr/local/mysql/bin/mysqldump /usr/bin/
#mysql competence
/bin/chown -R mysql.mysql /usr/local/mysql/ && /bin/chown -R mysql.mysql /usr/local/mysql/data/
#for wordpress
mkdir /var/lib/mysql
ln -sv /usr/local/mysql/data/mysql.sock /var/lib/mysql/
复制代码

mysqld

#!/bin/sh
# chkconfig: 2345 10 50
# description: mysqld
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/
复制代码

注意: 需要添加下面两行来保证chkconfig设置成功

#!/bin/sh
# chkconfig: 2345 10 50
复制代码


运行结果

由于首次运行编译返回日志过长,为了美观的结果,运行了两次,所以软连接脚本显示失败(文件已存在)

[root@hadoop1 base]# salt 'hadoop2' state.sls mysql.init
hadoop2:
----------
          ID: mysql_source
    Function: file.managed
        Name: /home/mysql-5.6.40.tar.gz
      Result: True
     Comment: unless execution succeeded
     Started: 10:09:23.030270
    Duration: 888.041 ms
     Changes:   
----------
          ID: extract_mysql
    Function: cmd.run
        Name: tar xf mysql-5.6.40.tar.gz
      Result: True
     Comment: unless execution succeeded
     Started: 10:09:23.919593
    Duration: 7.14 ms
     Changes:   
----------
          ID: mysql_user
    Function: user.present
        Name: mysql
      Result: True
     Comment: User mysql is present and up to date
     Started: 10:09:23.927631
    Duration: 2.501 ms
     Changes:   
----------
          ID: mysql_pkg
    Function: pkg.installed
      Result: True
     Comment: All specified packages are already installed.
     Started: 10:09:23.931484
    Duration: 2006.185 ms
     Changes:   
----------
          ID: mysql_commpile
    Function: cmd.run
        Name: cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATTON=utf8_cuicode_ci   -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1  -DENABLED_LOCAL_INFILE=1 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0
      Result: True
     Comment: unless execution succeeded
     Started: 10:09:25.939461
    Duration: 8.829 ms
     Changes:   
----------
          ID: mysql_commpile
    Function: cmd.run
        Name: make
      Result: True
     Comment: unless execution succeeded
     Started: 10:09:25.948913
    Duration: 5.983 ms
     Changes:   
----------
          ID: mysql_commpile
    Function: cmd.run
        Name: make install
      Result: True
     Comment: unless execution succeeded
     Started: 10:09:25.955397
    Duration: 6.567 ms
     Changes:   
----------
          ID: mysql_cnf
    Function: file.managed
        Name: /etc/my.cnf
      Result: True
     Comment: File /etc/my.cnf is in the correct state
     Started: 10:09:25.962408
    Duration: 4.894 ms
     Changes:   
----------
          ID: salt://mysql/files/conf.sh
    Function: cmd.script
      Result: True
     Comment: Command 'salt://mysql/files/conf.sh' run
     Started: 10:09:25.967900
    Duration: 200740.417 ms
     Changes:   
              ----------
              pid:
                  28643
              retcode:
                  0
              stderr:
                  2018-07-24 10:09:26 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
                  2018-07-24 10:09:26 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
                  2018-07-24 10:09:26 0 [Note] /usr/local/mysql//bin/mysqld (mysqld 5.6.40) starting as process 28647 ...
                  2018-07-24 10:11:06 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
                  2018-07-24 10:11:06 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
                  2018-07-24 10:11:06 0 [Note] /usr/local/mysql//bin/mysqld (mysqld 5.6.40) starting as process 28744 ...
              stdout:
                  Installing MySQL system tables...OK
                  Filling help tables...OK
                  To start mysqld at boot time you have to copy
                  support-files/mysql.server to the right place for your system
                  PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
                  To do so, start the server, then issue the following commands:
                    /usr/local/mysql//bin/mysqladmin -u root password 'new-password'
                    /usr/local/mysql//bin/mysqladmin -u root -h 192.168.253.62 password 'new-password'
                  Alternatively you can run:
                    /usr/local/mysql//bin/mysql_secure_installation
                  which will also give you the option of removing the test
                  databases and anonymous user created by default.  This is
                  strongly recommended for production servers.
                  See the manual for more instructions.
                  You can start the MySQL daemon with:
                    cd . ; /usr/local/mysql//bin/mysqld_safe &
                  You can test the MySQL daemon with mysql-test-run.pl
                    cd mysql-test ; perl mysql-test-run.pl
                  Please report any problems at http://bugs.mysql.com/
                  The latest information about MySQL is available on the web at
                    http://www.mysql.com
                  Support MySQL by buying support/licenses at http://shop.mysql.com
                  WARNING: Found existing config file /usr/local/mysql//my.cnf on the system.
                  Because this file might be in use, it was not replaced,
                  but was used in bootstrap (unless you used --defaults-file)
                  and when you later start the server.
                  The new default config file was created as /usr/local/mysql//my-new.cnf,
                  please compare it with your file and take the changes you need.
                  WARNING: Default config file /etc/my.cnf exists on the system
                  This file will be read by default by the MySQL server
                  If you do not want to use this, either remove it, or use the
                  --defaults-file argument to mysqld_safe when starting the server
----------
          ID: salt://mysql/files/mysqllns.sh
    Function: cmd.script
      Result: False
     Comment: Command 'salt://mysql/files/mysqllns.sh' run
     Started: 10:12:46.710451
    Duration: 262.12 ms
     Changes:   
              ----------
              pid:
                  28810
              retcode:
                  1
              stderr:
                  ln: creating symbolic link `/usr/bin/mysql': File exists
                  ln: creating symbolic link `/usr/bin/mysqladmin': File exists
                  ln: creating symbolic link `/usr/bin/mysqldump': File exists
                  mkdir: cannot create directory `/var/lib/mysql': File exists
                  ln: creating symbolic link `/var/lib/mysql/mysql.sock': File exists
              stdout:
----------
          ID: mysql_service
    Function: file.managed
        Name: /etc/init.d/mysqld
      Result: True
     Comment: File /etc/init.d/mysqld is in the correct state
     Started: 10:12:46.972872
    Duration: 4.936 ms
     Changes:   
----------
          ID: mysql_service
    Function: cmd.run
        Name: /sbin/chkconfig --add mysqld
      Result: True
     Comment: unless execution succeeded
     Started: 10:12:46.977924
    Duration: 10.248 ms
     Changes:   
----------
          ID: mysql_service
    Function: cmd.run
        Name: /sbin/chkconfig --level 35 mysqld on
      Result: True
     Comment: unless execution succeeded
     Started: 10:12:46.988419
    Duration: 6.787 ms
     Changes:   
----------
          ID: mysql_service
    Function: service.running
        Name: mysql
      Result: True
     Comment: Service mysql has been enabled, and is in the desired state
     Started: 10:12:46.995438
    Duration: 236.708 ms
     Changes:   
              ----------
              mysql:
                  True
Summary
-------------
Succeeded: 13 (changed=3)
Failed:     1
-------------
Total states run:     14
复制代码


安装wordpress

流程

  • 将wordpress解压至/var/www/html
  • 修改wp-config.php并发送至从机
  • 在数据库新建名为wordpress数据库

wp-install.sls

# copy tar.gz
wordpress_source:
  file.managed:
    - name: /home/wordpress-yang.tar.gz
    - unless: test -e /home/wordpress-yang.tar.gz
    - source: salt://wordpress/files/wordpress-yang.tar.gz
#tar source
extract_wordpress:
  cmd.run:
    - cwd: /home
    - names:
        - tar xf wordpress-yang.tar.gz
        - chown root:root /home/wordpress -R
    - unless: test -d /home/wordpress
    - require:
        - file: wordpress_source
# move to www
move_wordpress:
  cmd.run:
    - cwd: /home
    - names:
      - cp -rf wordpress/* /var/www/html/
      - mysql -uroot -e "create database IF NOT EXISTS wordpress"
    - require:
      - cmd: extract_wordpress
复制代码

运行结果

[root@hadoop1 base]# salt 'hadoop2' state.sls wordpress.wp-install
hadoop2:
----------
          ID: wordpress_source
    Function: file.managed
        Name: /home/wordpress-yang.tar.gz
      Result: True
     Comment: unless execution succeeded
     Started: 10:22:32.580145
    Duration: 1199.729 ms
     Changes:   
----------
          ID: extract_wordpress
    Function: cmd.run
        Name: tar xf wordpress-yang.tar.gz
      Result: True
     Comment: unless execution succeeded
     Started: 10:22:33.780510
    Duration: 9.208 ms
     Changes:   
----------
          ID: extract_wordpress
    Function: cmd.run
        Name: chown root:root /home/wordpress -R
      Result: True
     Comment: unless execution succeeded
     Started: 10:22:33.790282
    Duration: 6.722 ms
     Changes:   
----------
          ID: move_wordpress
    Function: cmd.run
        Name: cp -rf wordpress/* /var/www/html/
      Result: True
     Comment: Command "cp -rf wordpress/* /var/www/html/" run
     Started: 10:22:33.797953
    Duration: 2065.049 ms
     Changes:   
              ----------
              pid:
                  29030
              retcode:
                  0
              stderr:
              stdout:
----------
          ID: move_wordpress
    Function: cmd.run
        Name: mysql -uroot -e "create database IF NOT EXISTS wordpress"
      Result: True
     Comment: Command "mysql -uroot -e "create database IF NOT EXISTS wordpress"" run
     Started: 10:22:35.863419
    Duration: 53.151 ms
     Changes:   
              ----------
              pid:
                  29033
              retcode:
                  0
              stderr:
              stdout:
Summary
------------
Succeeded: 5 (changed=2)
Failed:    0
------------
Total states run:     5
复制代码

总结


成功通过master的saltstack为slave安装lamp环境,并将openstack部署成功。


遇到的问题整理


无法运行state.sls

报错the function "state.highstate" is running as PID xxxx kill掉slave的进程

php admin不显示网页

重启apache sudo service httpd restart


参考



https://www.jianshu.com/p/624b9cf51c64https://blog.csdn.net/chengyuqiang/article/details/78119322https://www.linuxidc.com/Linux/2017-12/149615.htmlhttp://www.cnblogs.com/xiewenming/p/7674806.html

相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
前端开发 关系型数据库 MySQL
PHP与MySQL动态网站开发实战指南####
【10月更文挑战第21天】 本文将深入浅出地探讨如何使用PHP与MySQL构建一个动态网站,从环境搭建到项目部署,全程实战演示。无论你是编程新手还是希望巩固Web开发技能的老手,都能在这篇文章中找到实用的技巧和启发。我们将一起探索如何通过PHP处理用户请求,利用MySQL存储数据,并最终呈现动态内容给用户,打造属于自己的在线平台。 ####
47 0
|
27天前
|
存储 关系型数据库 MySQL
PHP与MySQL动态网站开发:从基础到实践####
本文将深入探讨PHP与MySQL的结合使用,展示如何构建一个动态网站。通过一系列实例和代码片段,我们将逐步了解数据库连接、数据操作、用户输入处理及安全防护等关键技术点。无论您是初学者还是有经验的开发者,都能从中获益匪浅。 ####
|
1月前
|
安全 关系型数据库 MySQL
PHP与MySQL动态网站开发实战指南####
——深入探索LAMP栈下的高效数据交互与处理技巧 ####
|
28天前
|
关系型数据库 MySQL PHP
php实现一个简单的MySQL分页
通过本文的详细步骤和代码示例,我们实现了一个简单的PHP MySQL分页功能。主要步骤包括计算总记录数、设置分页参数、查询当前页的数据以及生成分页链接。这种分页方式适用于大多数Web应用,能够有效提升用户体验和页面响应速度。
26 4
|
1月前
|
关系型数据库 MySQL PHP
PHP与MySQL动态网站开发实战指南####
深入探索PHP与MySQL的协同工作机制,本文旨在通过一系列实战案例,揭示构建高效、稳定且用户友好的动态网站的秘诀。从环境搭建到数据交互,再到最佳实践分享,本文为开发者提供了一条清晰的学习路径,助力其在LAMP(Linux, Apache, MySQL, PHP/Perl/Python)栈上实现技术飞跃。 ####
|
1月前
|
关系型数据库 MySQL PHP
PHP与MySQL的无缝集成:构建动态网站的艺术####
本文将深入探讨PHP与MySQL如何携手合作,为开发者提供一套强大的工具集,以构建高效、动态且用户友好的网站。不同于传统的摘要概述,本文将以一个生动的案例引入,逐步揭示两者结合的魅力所在,最终展示如何通过简单几步实现数据驱动的Web应用开发。 ####
|
29天前
|
SQL 关系型数据库 MySQL
PHP与MySQL的高效协同开发策略####
本文深入探讨了PHP与MySQL在Web开发中的协同工作机制,通过优化配置、最佳实践和高级技巧,展示了如何提升数据库交互性能,确保数据安全,并促进代码可维护性。我们将从环境搭建讲起,逐步深入到查询优化、事务管理、安全防护及性能调优等核心环节,为开发者提供一套实战驱动的解决方案框架。 ####
|
1月前
|
SQL 关系型数据库 MySQL
PHP与MySQL动态网站开发深度探索####
本文旨在为读者提供一份详尽的指南,深入剖析PHP与MySQL在动态网站开发中的应用。通过具体实例与代码解析,揭示如何高效结合这两种技术构建功能强大、响应迅速的Web应用。文章将逐一探讨PHP的基础语法、MySQL数据库管理以及二者交互的关键技巧,旨在帮助开发者提升技能,优化项目开发流程。 ####
|
22天前
|
SQL 关系型数据库 MySQL
PHP与MySQL的高效交互:从基础到实践####
本文深入探讨了PHP与MySQL数据库之间的高效交互技术,涵盖了从基础连接到高级查询优化的全过程。不同于传统的摘要概述,这里我们直接以一段精简代码示例作为引子,展示如何在PHP中实现与MySQL的快速连接与简单查询,随后文章将围绕这一核心,逐步展开详细讲解,旨在为读者提供一个从入门到精通的实战指南。 ```php <?php // 数据库配置信息 $servername = "localhost"; $username = "root"; $password = "password"; $dbname = "test_db"; // 创建连接 $conn = new mysqli($se
24 0
|
29天前
|
关系型数据库 MySQL PHP
PHP与MySQL的深度整合:构建高效动态网站####
在当今这个数据驱动的时代,掌握如何高效地从数据库中检索和操作数据是至关重要的。本文将深入探讨PHP与MySQL的深度整合方法,揭示它们如何协同工作以优化数据处理流程,提升网站性能和用户体验。我们将通过实例分析、技巧分享和最佳实践指导,帮助你构建出既高效又可靠的动态网站。无论你是初学者还是有经验的开发者,都能从中获得宝贵的见解和实用的技能。 ####
22 0

推荐镜像

更多