模拟公司真实环境架构搭建

模拟公司真实环境架构搭建

现要求公司的整体架构达到高可用

实验环境:

client(Ansible):192.168.1.1/192.168.2.2、网关192.168.2.1

透明代理:192.168.1.4(192.168.2.1)

Varnish反向代理:192.168.1.5、网关192.168.1.4

负载均衡+keepalived:192.168.1.6/192.168.1.7

LNMP:192.168.1.8/192.168.1.9

Iscsi共享存储:192.168.1.10

高可用架构结业.png

Ansible自动化批量部署LNMP

nginx剧本

需要单独在主控端,写一个nginx启动脚本和php测试页面,用来传文件,nginx用copy,php用模板,用copy也行

[root@localhost ~]# vim nginx.yml 
- hosts: dbserver
  remote_user: root
  tasks:
    - name: install nginx
      unarchive: src=/root/nginx-1.11.1.tar.gz dest=/usr/src
    - name: yum install pcre* openssl*
      yum: name=pcre-devel,openssl-devel,gcc,gcc-c++,zlib-devel
    - name: make install nginx
# 以下表示进行shell操作时,先进入/usr/src/nginx-1.11.1目录
      shell: ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-pcre && make && make install
      args:
        chdir: /usr/src/nginx-1.11.1
    - name: lnfile
      file: src=/usr/local/nginx/sbin/nginx dest=/usr/local/sbin/nginx state=link
    - name: create nginx user
      user: name=nginx create_home=no shell=/sbin/nologin state=present
    - name: nginx start script
      copy: src=/root/nginx dest=/etc/init.d/nginx
    - name: xp
      file: path=/etc/init.d/nginx mode=0755
    - name: add system service
      shell: chkconfig --add nginx
    - name: open system auto started
      shell: systemctl enable nginx
    - name: start nginx
      service: name=nginx state=started

[root@localhost ~]# ansible-playbook nginx.yml 

Only one搭建LNMP

LNMP

LNMP是Linux+Nginx+Mysql+PHP的组合方式

使用LNMP的主要原因还是因为Nginx体积小,方便后期对于网络的环境变换(灵活)、切换和方便调试,比较符合轻量级, 相比 Apache,Nginx 使用更少的资源,支持更多的并发连接,体现更高的效率,也可作为负载均衡及反向代理服务器,做到动静分离

Only one也就是LNMP全部都安装在一台Linux服务器




正在载入...
PoweredHexo
HostedAliyun
DNSAliyun
ThemeVolantis
UV
PV
BY-NC-SA 4.0