搭建一套小的集群 实现手动的代码上线

lb 192.168.111.21 web01 192.168.111.22 web02 192.168.111.23 所有机器都安装nginx;yum install nginx -y 在这里插入图片描述

1.配置负载均衡

[root@lb01 ~]# cat /etc/nginx/conf.d/proxy_html.quyunlong.com.conf
upstream html {
    server 192.168.111.22:80;
    server 192.168.111.23:80;
}

server {
    listen 80;
    server_name html.quyunlong.com;

    location / {
        proxy_pass http://html;
        proxy_set_header Host $http_host;
    }
}

[root@lb01 ~]# nginx -t 
[root@lb01 ~]# systemctl restart nginx

2.配置后端webserver(所有的web集群)

[root@web01 ~]# vim /etc/nginx/conf.d/html.quyunlong.com.conf
server {
    listen 80;
    server_name html.quyunlong.com;
    root /code/web;

    location / {
        index index.html;
    }
}
[root@web01 ~]# mkdir /code/web -p 
[root@web01 ~]# echo "web01..." > /code/web/index.html    #便于区分web01和web02各一个
[root@web01 ~]# nginx -t
[root@web01 ~]# systemctl restart nginx

测试浏览器访问域名http://html.quyunlong.com/ 在这里插入图片描述

3.克隆代码

[root@jenkins ~]# git clone git@gitlab.quyunlong.com:new-group/monitor.git

4.将代码scp至web集群

[root@jenkins ~]# for i in 22 23 ;do scp -r monitor/* root@192.168.111.${i}:/code/web/ ;done

再次访问网站成功展示业务信息 在这里插入图片描述