经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 数据库/运维 » Linux/Shell » 查看文章
tengine 基于权重负载均衡的简单配置
来源:cnblogs  作者:id_iot  时间:2019/5/9 8:42:36  对本文有异议

环境如下:

资源服务器_1:192.168.10.10  centos 7  tengine 2.3.0  

资源服务器_2:192.168.10.129  centos 7  tengine  2.3.0  

代理服务器:192.168.10.130  centos 7  tengine  2.3.0 

一、安装tengine

1、下载tengine

  1. [root@localhost opt]# wget http://tengine.taobao.org/download/tengine-2.3.0.tar.gz

2、编译安装

  1. [root@localhost opt]# tar -zxvf tengine-2.3.0.tar.gz
  2. [root@localhost opt]# cd tengine-2.3.0
  3. [root@localhost tengine-2.3.0]# ./configure --prefix=/opt/tnginx
  4. [root@localhost tengine-2.3.0]# make && make install

 3、将nginx脚本添加到环境变量中。

  1. [root@localhost tengine-2.3.0]# echo $PATH # 查看当前环境变量 

 

  1. 将/opt/tnginx/sbin路径保存到我们的环境变量中。这里我们直接保存到全局环境中。
  1. [root@localhost sbin]# vim /etc/profile

  1. [root@localhost sbin]# source /etc/profile 使配置立即生效

这样我们就可以在任何地方使用nginx来管理我们的nginx服务了。

  1. [root@localhost sbin]# nginx -t 检测配置文件语法是否正确
  2. [root@localhost sbin]# nginx -s reload 重载配置文件
  3. [root@localhost sbin]# nginx -s stop 停止nginx服务
  4. [root@localhost sbin]# nginx 开启nginx服务

好了到此我们的nginx算是初步配置完成,其它两台主机的安装就不再赘述了。为了区别不同的资源服务器我们简单的调整下HTML文件。

4、调整192.168.10.10资源服务器中的HTML文件

  1. [root@localhost sbin]# cd /opt/tnginx/html/ 进入到tnginxHTML目录
  2. [root@localhost html]# vim index.html

我们只需要将图片放到我们当前的html目录下即可,看起来像下面这样。

  1. [root@localhost html]# nginx 开启nginx服务

访问http://192.168.10.10查看我们的小猫咪

4、调整192.168.10.129资源服务器中的HTML文件。

访问http://192.168.10.129查看我们的小滚滚

 好了资源服务器就设置到这里,下面我们去设置代理服务器。

5、设置192.168.10.130代理服务器

  1. [root@localhost ~]# vim /opt/tnginx230/conf/nginx.conf 打开nginx配置文件

在http代码块内server的上面我们添加一个负载均衡池,并将请求交给负载均衡池处理。

  1. [root@localhost ~]# nginx -t 检查配置文件的语法是否正确

 如果像下面图片这样说明你的配置文件没有问题。

  1. [root@localhost ~]# nginx -s reload 重载配置文件

6、在浏览器上访问192.168.10.130代理服务器

 

 也许你会发现有时多次刷新页面权重低的图片加载不出来,具体原因暂时不清楚,等知道了后回来补上。

 

原文链接:http://www.cnblogs.com/caesar-id/p/10835107.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号