当前位置: 首页 > news >正文

用凡科可以做视频网站吗何鹏seo

用凡科可以做视频网站吗,何鹏seo,创办网站,网络直播营销的方式5. Nginx 负载均衡配置案例(附有详细截图说明) 文章目录 5. Nginx 负载均衡配置案例(附有详细截图说明)1. Nginx 负载均衡 配置实例3. 注意事项和避免的坑4. 文档: Nginx 的 upstream 配置技巧5. 最后: 1. Nginx 负载均衡 配置实例 需求说明/图解 windows 浏览器输…

5. Nginx 负载均衡配置案例(附有详细截图说明++)

文章目录

  • 5. Nginx 负载均衡配置案例(附有详细截图说明++)
  • 1. Nginx 负载均衡 配置实例
  • 3. 注意事项和避免的坑
  • 4. 文档: Nginx 的 upstream 配置技巧
  • 5. 最后:


1. Nginx 负载均衡 配置实例

需求说明/图解

windows 浏览器输入: http://www.rainbowseacrm.com/search/look.html

在这里插入图片描述

负载均衡配置-思路分析/图解

在这里插入图片描述

负载均衡配置规则:

  • 负载均衡就是将负载分摊到不同的服务单元,既保证服务的可用性,又保证响应足够快。

  • Linux 下有:Nginx、LVS、Haproxy 等等服务可以提供负载均衡服务,Nginx 提供了如下几种分配方式(策略):

    1. 轮询**(默认)** :每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器 down 掉,能自动剔 除
    2. weight(根据权重的大小,比例进行负载均衡)

    weight 代表权,重默认为 1,权重越高被分配的客户端越多。

    指定轮询几率,weight 和访问比率成正比,用于后端服务器性能不均的情况。 例如

    upstream rsservers{
    server 192.168.12.134:8080 weight=1;
    server 192.168.12.134:8081 weight=2;
    }
    
    1. ip_hash : 每个请求按访问 IP 的 hash 结果分配,这样每个访客固定访问一个后端服务器,可以解决 session 的问题。例如:
    upstream rsservers{
    ip_hash;
    server 192.168.12.134:8081;
    server 192.168.12.134:8080;
    }
    
    1. fair(第三方):按后端服务器的响应时间来分配请求,响应时间短的优先分配
upstream rsservers{
server 192.168.12.134:8080;
server 192.168.12.134:8081;
fair;
}

 # 2. Nginx 负载均衡实现具体步骤如下
  1. 修改 C:\Windows\System32\drivers\etc\hosts 配置虚拟主机名,配置相关域名的映射

在这里插入图片描述

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost127.0.0.1 account.wondershare.com
# 配置 eureka 主机 和 ip 的映射
127.0.0.1 eureka9001.com
127.0.0.1 eureka9002.com
192.168.76.157 www.rainbowsea.com
192.168.76.159 www.rainbowseamall.com
192.168.76.160 www.rainbowseacrm.com
  1. 修改 安装目录conf\nginx.conf 配置,反向代理路径映射

这里我的 nginx.conf 路径是在 /usr/local/nginx/conf 路径下。
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

 upstream rsservers {36         server 192.168.76.160:8080;37         server 192.168.76.160:8081;38 39     }40 41     server {42         listen       80;43         server_name 192.168.76.160;44        #server_name  localhost;45         #charset koi8-r;46 47         #access_log  logs/host.access.log  main;48 49         location / {50             root   html;51             proxy_pass http://rsservers;52             index  index.html index.htm;53         }54 

查看 nginx.conf 是否存在配置错误:

[root@localhost nginx]# ./sbin/nginx -t
[root@localhost nginx]# /usr/local/nginx/sbin/nginx -t

在这里插入图片描述

重启 Nginx ,加载我们修改后的配置:

[root@localhost nginx]# ./sbin/nginx -s reload
[root@localhost nginx]# ps -aux | grep nginx

在这里插入图片描述

在这里插入图片描述

  1. 在 Linux 的 Tomcat8080 创建 webapps\search\look.html

在这里插入图片描述

在这里插入图片描述

这里我先进入到 Tomcat 的 webapps 目录下,创建 look.html 文件,进行一个访问映射。

在这里插入图片描述

<h1>tomcat 8080 search.... </h1>
  1. 在 Linux 下重新安装一份 Tomcat, 并将端口修改成 8081
[root@localhost opt]# cp -r ./tomcat/ ./tomcat8081

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

修改 tomcat 的 conf\server.xml , 注意要修改如下位置,否则该 Tomcat 是不能正常工作。

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

细节说明:不同版本的 tomcat 修改的端口还不一样, 小伙伴们灵活处理即可。

  1. 在 Linux 的 Tomcat8081 创建 webapps\search\look.html

在这里插入图片描述

在这里插入图片描述

<h1>tomcat 8081 search.... </h1>
  1. linux 防火墙打开 80 端口, 保证外网可以访问
[root@localhost product]# firewall-cmd --add-port=80/tcp --permanent # 防火墙开放 10000 端口
[root@localhost product]# firewall-cmd --reload # 重启防火墙
[root@localhost product]# firewall-cmd --list-all # 查看防火墙信息

在这里插入图片描述

  1. 启动 Linux 下两个 Tomcat
[root@localhost bin]# ./startup.sh

在这里插入图片描述

[root@localhost bin]# netstat -an | more

在这里插入图片描述

在这里插入图片描述

打开 Linux 当中的浏览器: 访问

  • http://localhost:8080/
  • http://localhost:8081/

在这里插入图片描述

在这里插入图片描述

查看启动的端口, 确保有 8080 和 8081 端口在监听(提示: 如果 tomcat 没有监听 对应端口, 说明启动失败了, 可以尝试先执行 shutdown.sh 再执行 startup.sh 解决)

在这里插入图片描述

  1. 测试是否可以在 Linux 下可以正常访问到两个页面
  • Tomcat 8080 访问/search/look.html 成功 ;http://localhost:8080/search/look.html

在这里插入图片描述

  • Tomcat 8081 访问/search/look.html 成功 ;http://localhost:8081/search/look.html

在这里插入图片描述

  1. 启动 或者 重新加载 Nginx
[root@localhost nginx]# ./sbin/nginx
[root@localhost nginx]# ps -aux | grep nginx

在这里插入图片描述

  1. windows 浏览器输入(保证浏览器不是无痕上网): http://www.rainbowseacrm.com/search/look.html

http://www.rainbowseacrm.com/search/look.html

在这里插入图片描述

3. 注意事项和避免的坑

  1. nginx.conf 的 upstream 不能带下划线, 否则会失败, 但是语法检测不到

在这里插入图片描述

带下划线,报错信息,如下:
在这里插入图片描述

  1. 如果你的浏览器是无痕上网, 负载均衡可能失效, 因为 Nginx 无法采集到相关信息, 就遇到这个情况, 改用其它浏览器即可(比如 chrome)

  2. 如果某 tomcat 没有监听对应端口说明启动失败了,可以尝试先执行,shutdown.sh再执行 startup.sh 解决

4. 文档: Nginx 的 upstream 配置技巧

基本介绍:

Nginx 是一个反向代理软件,大部分的网站都采用 Nginx 作为网站/平台的 服务器软件。Nginx 除了可以直接作为 web 服务器使用外,更多的情况是 通过反向代理将请求转发给上游服务器。

配置上游服务器可以使用 upstream 进行设置,通过 upstream 可以实现服 务的负载均衡规则,可以提高服务器的高可用性。

地址:https://zhuanlan.zhihu.com/p/409693332

  • 如果停掉 1 个 Tomcat, 会怎样?
  • 如果停掉 1 个 Tomcat, 然后又恢复,会怎样?
  • 如何给不同的服务,分配权重 weight

5. 最后:

“在这个最后的篇章中,我要表达我对每一位读者的感激之情。你们的关注和回复是我创作的动力源泉,我从你们身上吸取了无尽的灵感与勇气。我会将你们的鼓励留在心底,继续在其他的领域奋斗。感谢你们,我们总会在某个时刻再次相遇。”

在这里插入图片描述

http://www.hkea.cn/news/372033/

相关文章:

  • 深圳网站开发电话惠州网络营销
  • 中宁网站建设公司商城全网推广运营公司
  • 网站文章列表如何排版郑州seo技术培训班
  • 小型b2c网站百度开户渠道商哪里找
  • 武进区住房和城乡建设局网站爱站网能不能挖掘关键词
  • APP手机端电子商务网站建设营销成功的案例
  • 公司网站引导页百度搜索关键词排名优化技术
  • 网站开发与维护学什么网站建设seo优化培训
  • 常州网站开发百度网盘电脑版官网
  • wordpress安全权限关键词优化公司哪家好
  • 银川做网站服务google play下载安卓
  • 科技型中小企业服务网安徽搜索引擎优化seo
  • 网站建设专家排名邯郸seo营销
  • 做网站一个月20g流量够吗安全又舒适的避孕方法有哪些
  • 扫二维码直接进网站怎么做怎么提交网址让百度收录
  • 柳州建设局网站广告买卖网
  • 做外贸一般上哪些网站google play谷歌商店
  • 泉州手机网站制作如何做企业产品推广
  • 徐州手机网站设计汕头网站建设优化
  • 有没有专业收费做网站优化的百度百科优化排名
  • 常州网站建设哪家便宜江西seo推广软件
  • 如何用pageadmin做网站品牌宣传策略有哪些
  • 网站免费优化软件需要优化的地方
  • 24小时学会网站建设下载厦门百度竞价开户
  • 怎样学做网站网站权重等级
  • 做网站好还是做淘宝好北京seo推广
  • 郑州门户网站建设哪家好网站首页不收录
  • 网站制作营销型哪些网站可以发广告
  • 最新政府网站建设理念广州头条新闻最新
  • 济宁网站建设神华线上推广的三种方式