将中小企业架构通过Ansible的方式实现
galaxy | tower-->Redhat
环境配置
- 准备roles目录
[root@manager ~]# mkdir /opt/roles/{tasks,handlers,temples,files} -p
- 准备清单文件
[root@manager roles]# cat /opt/roles/hosts
[nfsservers]
172.16.1.31
[backupservers]
172.16.1.41
[lbservers]
172.16.1.5
172.16.1.6
[webservers]
172.16.1.7
172.16.1.8
[dbservers]
172.16.1.51
3.准备ansible配置文件
[root@manager roles]# cat /opt/roles/ansible.cfg
[defaults]
inventory = ./hosts
host_key_checking = False
forks = 100
4.测试主机连通性
[root@manager roles]# ansible all --list-hosts
hosts (7):
172.16.1.41
172.16.1.7
172.16.1.8
172.16.1.5
172.16.1.6
172.16.1.51
172.16.1.31
5.基础环境
- 防火墙 firewalld selinux 关闭
- yum源 base epel nginx php
- 安装软件
- 用户创建 www
- SSH配置
- 内核参数
- 文件描述符
- rsync备份脚本
6.基础模块 ( 通用性 | 独立 )
后端: NFS Redis MySQL
web: Nginx PHP Tomcat
代理: Nginx_Proxy Keepalived
扩展: zabbix-agent filebeat
7.业务引入 wordpress
- 1.nginx+php环境ok
- 2.nginx虚拟主机配置文件
- 3.上传代码-->mysql--redis
- 4.引入负载均衡接入
技术解决
1.wordpress:
1.先安装一次,将安好的代码打包,将sql文件导出
2.在引入的时, sql文件需要导入到mysql中.
2.Tomcat + Redis --->
1.先配置好Tomcat+Redis
2.将整体Tomcat打包
3.安装Tomcat基础环境时就分发过去
3.NFS挂载问题?
4.mysql主从配置?
mysql_replication Manage MySQL replication
5.rsync备份服务端?
问题:
环境清零
负载均衡
systemctl stop nginx keepalived
systemctl disable nginx keepalived
rm -rf /etc/nginx/conf.d/*
> /etc/keepalived/keepalived.conf
web
systemctl stop nginx php-fpm
systemctl disable nginx php-fpm
rm -rf /etc/nginx/conf.d/*
rm -rf /soft
rm -rf /code
umount -lf 172.16.1.31:/roles_data
nfs
rm -rf /data
> /etc/exports
systemctl stop nfs
systemctl disable nfs
mysql
systemctl stop redis mariadb
systemctl disable mariadb
rm -rf /var/lib/mysql/*
网友评论