ansible部署负载均衡

本文介绍了如何利用Ansible部署负载均衡系统,重点是通过Nginx作为负载均衡器,将流量分发到后端运行httpd服务的两台服务器。详细步骤包括前置的httpd和Nginx知识,非交互式文本编辑,以及在非标准端口上运行httpd服务。此外,还展示了如何在Windows主机上使用Ansible进行自动化操作。
摘要由CSDN通过智能技术生成

1、前置知识点

1.1 httpd nginx基本使用、配置文件

1. 主配置文件
1) [root@master ~]# rpm -ql httpd |grep conf
/etc/httpd/conf/httpd.conf
[root@master ~]# rpm -ql nginx |grep conf
/etc/nginx/nginx.conf
/etc/nginx/nginx.conf.default
2.项目部署首页文件位置
[root@master ~]# find / -name index.html
/usr/share/nginx/html/index.html
/var/www/html/index.html

1.2 非交互式编辑文本

1. [root@master ~]# echo hello > index.html
[root@master ~]# cat index.html
hello
2.替换内容
[root@master ~]# sed -i 's/hello/hello world/' index.html
###-i 修改; s是替换
[root@master ~]# cat index.html
hello world
3. 添加新行内容
[root@master ~]# sed -i '1i good luck' index.html
[root@master ~]# cat index.html
good luck
hello world
###1i 在第一行添加内容

1.3 httpd 使用其他非标端口

[root@serverb ~]# vi /etc/httpd/conf/httpd.conf
Listen 81
[root@serverb ~]# systemctl restart httpd

1.4 负载均衡的配置(使用Nginx作为负载均衡器

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一叶知秋xj

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值