一键编译安装

onekey_install_lnmp.sh

#!/bin/bash


# onekey distribute keys
/bin/bash /server/scripts/distribute_keys.sh /server/scripts/ip_cluster


# install ansible on management server
/bin/bash /server/scripts/ansible_server_install.sh > /dev/null 2>&1
if [ $? -eq 0 ]; then
    echo "ansible_server_install succeed"
else
    echo "ansible_server_install fail"
fi


# 配置及分发hosts文件
cat > /etc/hosts << EOF
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.1.15  lb01
172.16.1.16  lb02
172.16.1.17  web01
172.16.1.18  web02
172.16.1.31  nfs01
172.16.1.41  backup
172.16.1.51  db01
EOF

ansible all --private-key ~/.ssh/id_cluster -m copy -a "src=/etc/hosts dest=/etc/hosts"


# --- 分发软件包 --- #

# 分发nginx软件包
ansible lb_server,web_server --private-key ~/.ssh/id_cluster -m copy -a "src=/server/tools/nginx-1.16.0.tar.gz dest=/server/tools/"


# 分发编译php所依赖软件包
ansible web_server --private-key ~/.ssh/id_cluster -m copy -a "src=/server/tools/libiconv-1.16.tar.gz dest=/server/tools/"


# 分发php源代码
ansible web_server --private-key ~/.ssh/id_cluster -m copy -a "src=/server/tools/php-7.3.5.tar.gz dest=/server/tools/"


# 分发mysql软件
ansible db_server --private-key ~/.ssh/id_cluster -m copy -a "src=/server/tools/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz dest=/server/tools/"


# 分发网站程序源码
ansible web_server --private-key ~/.ssh/id_cluster -m copy -a "src=/server/tools/wordpress-5.3.2.tar.gz dest=/server/tools/"



# --- 分发脚本 --- #

# 分发nginx安装脚本
ansible lb_server,web_server --private-key ~/.ssh/id_cluster -m copy -a "src=/server/scripts/onekey_install_nginx_compile.sh dest=/server/scripts/"

# 分发php安装脚本
ansible web_server --private-key ~/.ssh/id_cluster -m copy -a "src=/server/scripts/onekey_install_php_compile.sh dest=/server/scripts/"

# 分发MySQL安装脚本
ansible db_server --private-key ~/.ssh/id_cluster -m copy -a "src=/server/scripts/onekey_install_mysql_binary.sh dest=/server/scripts/"
ansible db_server --private-key ~/.ssh/id_cluster -m copy -a "src=/server/scripts/chpwd_mysql.sh dest=/server/scripts/"



# --- 执行安装 --- #

# 安装Nginx
ansible lb_server,web_server --private-key ~/.ssh/id_cluster -m script -a "/server/scripts/onekey_install_nginx_compile.sh"

# 安装PHP
ansible web_server --private-key ~/.ssh/id_cluster -m script -a "/server/scripts/onekey_install_php_compile.sh"

# 安装MySQL
ansible db_server --private-key ~/.ssh/id_cluster -m script -a "/server/scripts/onekey_install_mysql_binary.sh"
ansible db_server --private-key ~/.ssh/id_cluster -m script -a "/server/scripts/chpwd_mysql.sh"

distribute_keys.sh

ip_cluster

ansible_server_install.sh

onekey_install_nginx_compile.sh

onekey_install_php_compile.sh

onekey_install_mysql_binary.sh

chpwd_mysql.sh

Last updated