当前位置: 首页 > news >正文 大同本地做网站的有哪些电商网站 news 2025/10/28 11:02:48 大同本地做网站的,有哪些电商网站,樟木头做网站,网站建设样式简介 负载均衡 什么是负载均衡#xff1f; 负载均衡#xff0c;英文名称为Load Balance#xff0c;其含义就是指将负载#xff08;工作任务#xff09;进行平衡、分摊到多个操作单元上进行运行。 Nginx负载均衡 什么是Nginx负载均衡#xff1f; Nginx负载均衡可以大…简介 负载均衡 什么是负载均衡 负载均衡英文名称为Load Balance其含义就是指将负载工作任务进行平衡、分摊到多个操作单元上进行运行。 Nginx负载均衡 什么是Nginx负载均衡 Nginx负载均衡可以大大提升系统的吞吐率、请求性能、容灾性能。 工作原理 web服务器直接面向用户时往往要承载大量并发请求。 单台服务器难以负荷此时使用多天web服务器组成集群前端使用Nginx负载均衡将请求分散到后端web服务器集群中。 示意图 应用 主机规划 主机名称主机地址主机功能master-1192.168.131.129负载均衡主机master-2192.168.131.130web主机1master-3192.168.131.131web主机2 环境准备 安装Nginx 三台主机一同安装Nginx服务 配置yum仓库 cat /etc/yum.repos.d/nginx.repo EOF [nginx-stable] namenginx stable repo baseurlhttp://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck1 enabled1 gpgkeyhttps://nginx.org/keys/nginx_signing.key module_hotfixestrue[nginx-mainline] namenginx mainline repo baseurlhttp://nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck1 enabled1 gpgkeyhttps://nginx.org/keys/nginx_signing.key module_hotfixestrue EOF安装Nginx yum list | grep nginx yum -y install nginx nginx -v配置web主机 配置web站点 地址192.168.131.130、192.168.131.131 路径/etc/nginx/conf.d/default.conf server {listen 80;server_name wang.mingqu.com;charset utf-8;location / {root /www/wangmingqu/;index index.html index.htm;}error_page 500 502 503 504 /50x.html;location /50x.html {root /usr/share/nginx/html;}}配置web页面 地址192.168.131.130、192.168.131.131 路径/www/wangmingqu/index.html #主机192.168.131.130、192.168.131.131 mkdir -p /www/wangmingqu/#主机192.168.131.130 echo 王茗渠测试页面主机IP192.168.131.130 /www/wangmingqu/index.html#主机192.168.131.131 echo 王茗渠测试页面主机IP192.168.131.131 /www/wangmingqu/index.html注意生成环境中两台web主机的资源内容需要保持一致此处是为了演示负载均衡分配到了两台机器上 启动web服务 systemctl stop firewalld setenforce 0 nginx -t systemctl start nginx curl -iv wang.mingqu.com简单应用 配置负载均衡 地址192.168.131.129 路径/etc/nginx/conf.d/wangmingqu.conf upstream web {server 192.168.131.130;server 192.168.131.131; }server {listen 80;server_name wang.wangmingqu.com;charset utf-8;location / {proxy_pass http://web; } }检查配置 nginx -t systemctl reload nginx验证负载均衡 配置参数 upstream 语法upstream name {…} 作用定义一个负载均衡主机组 适用范围http server 语法server url|host; 作用定义负载均衡主机组中的主机 适用范围upstream proxy_pass 语法proxy_pass http://name; 作用引用定义的负载均衡主机组将客户端请求转发至upstream服务池。 适用范围location 后端状态 weight 语法server url|host weight数值; 作用指定负载均衡主机组中的主机权重将客户端请求优先发送到该主机。 适用范围upstream down 语法server url|host down; 作用指定当前主机暂时不参与负载均衡。 适用范围upstream backup 语法server url|host backup; 作用指定负载均衡主机组中的某个主机为备份主机。 适用范围upstream max_fails 语法server url|host max_fails数值; 作用允许请求失败的次数 适用范围upstream fail_timeout 语法server url|host max_fails数值 fail_timeout时间s; 作用经过max_fails失败后服务暂停时间单位秒“s” 适用范围upstream max_conns 语法server url|host max_conns数值; 作用限制最大的请求连接数。 适用范围upstream 算法详解 轮询算法 简介 按时间顺序逐一分配到不同的后端服务器默认算法简称rr。 不考虑实际负载或配置平均分配客户端请求。 应用 upstream web {server 192.168.131.130;server 192.168.131.131; }server {listen 80;server_name wang.wangmingqu.com;charset utf-8;location / {proxy_pass http://web; } }权重算法 简介 权重算法设置的weight值越大请求访问到该机器的概率越高。又称为加权轮询简称wrr。 应用 upstream web {server 192.168.131.130 weight10;server 192.168.131.131; }server {listen 80;server_name wang.wangmingqu.com;charset utf-8;location / {proxy_pass http://web; } }IP哈希算法 简介 每个请求按访问IP的hash结果分配。 这样来自同一IP的固定客户端访问同一个后端服务器。 注意不能和weight一起使用。 应用 upstream web {ip_hash;server 192.168.131.130;server 192.168.131.131; }server {listen 80;server_name wang.wangmingqu.com;charset utf-8;location / {proxy_pass http://web; } }URL哈希算法 简介 每个请求按访问URL的hash结果分配。 每个相同的URL定向到同一个后端服务器。 应用 upstream web {hash $request_uri;server 192.168.131.130;server 192.168.131.131; }server {listen 80;server_name wang.wangmingqu.com;charset utf-8;location / {proxy_pass http://web; } }最少连接数算法 简介 最少连接数算法哪台机器的链接数少就分发到这台机器上简称lc。 应用 upstream web {least_conn;server 192.168.131.130;server 192.168.131.131; }server {listen 80;server_name wang.wangmingqu.com;charset utf-8;location / {proxy_pass http://web; } }加权最少连接数算法 简介 加权最少连接数算法就是weight和least_conn两个算法的集合简称wlc。 应用 upstream web {least_conn;server 192.168.131.130 weight5;server 192.168.131.131; }server {listen 80;server_name wang.wangmingqu.com;charset utf-8;location / {proxy_pass http://web; } }七层负载四层负载 七层负载 七层负载均衡简介 什么是Nginx七层负载均衡 七层负载均衡是在应用层可以完成很多应用方面的协议请求。 比如http应用的负载均衡可以实现http信息的改写、头信息的改写、安全应用规则控制、URL匹配规则控制、以及转发、rewrite等等的规则。 所以在应用层的服务里面可以做的内容就更多Nginx是一个典型的七层负载均衡。 七层负载均衡应用场景 可以将请求分发到不同的服务上并且可以根据请求信息进行灵活的代理转发 由于请求会通过负载均衡服务器负载均衡服务器会过滤一些请求例如DOS攻击避免所有请求信息都打到服务器上保障了服务器的稳定运行。 处于网络分层的最上层需要对数据进行解析与客户端建立连接效率比较低。 配置web主机 配置web站点 地址192.168.131.130、192.168.131.131 路径/etc/nginx/conf.d/default.conf server {listen 80;server_name wang.mingqu.com;charset utf-8;location / {root /www/wangmingqu/;index index.html index.htm;}error_page 500 502 503 504 /50x.html;location /50x.html {root /usr/share/nginx/html;}}配置web页面 地址192.168.131.130、192.168.131.131 路径/www/wangmingqu/index.html #主机192.168.131.130、192.168.131.131 mkdir -p /www/wangmingqu/#主机192.168.131.130 echo 王茗渠测试页面主机IP192.168.131.130 /www/wangmingqu/index.html#主机192.168.131.131 echo 王茗渠测试页面主机IP192.168.131.131 /www/wangmingqu/index.html注意生成环境中两台web主机的资源内容需要保持一致此处是为了演示负载均衡分配到了两台机器上 启动web服务 systemctl stop firewalld setenforce 0 nginx -t systemctl start nginx curl -iv wang.mingqu.com配置负载均衡 地址192.168.131.129 路径/etc/nginx/conf.d/wangmingqu.conf upstream web {server 192.168.131.130;server 192.168.131.131; }server {listen 80;server_name wang.wangmingqu.com;charset utf-8;location / {proxy_pass http://web; } }检查配置 nginx -t systemctl reload nginx验证负载均衡 四层负载 四层负载均衡简介 什么是Nginx四层负载均衡 四层负载均衡是基于传输层协议包来封装的如TCP/IP那我们前面使用到的七层是指的应用层他的组装在四层的基础之上无论四层还是七层都是指的OSI网络模型。 四层负载均衡应用场景 四层七层来做负载均衡四层可以保证七层的负载均衡的高可用性如nginx就无法保证自己的服务高可用需要依赖LVS或者keepalive。如tcp协议的负载均衡有些请求是TCP协议的mysql、ssh或者说这些请求只需要使用四层进行端口的转发就可以了所以使用四层负载均衡。 四层负载均衡总结 四层负载均衡仅能转发TCP/IP协议、UDP协议、通常用来转发端口如tcp/22、udp/53四层负载均衡可以用来解决七层负载均衡端口限制问题七层负载均衡最大使用65535个端口号四层负载均衡可以解决七层负载均衡高可用问题多台后端七层负载均衡能同时的使用四层的转发效率比七层的高得多但仅支持tcp/ip协议不支持http和https协议通常大并发场景通常会选择使用在七层负载前面增加四层负载均衡 添加四层负载模块 查看四层负载均衡模块 /usr/local/nginx/sbin/nginx -V 21 | grep stream安装四层负载均衡模块 cd /usr/local/nginx/conf/ ./configure --prefix/usr/local/nginx \ --usernginx --groupnginx \ --with-http_realip_module \ --with-http_v2_module \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-http_gzip_static_module \ --with-stream \ --with-stream_ssl_module \ --with-http_sub_module \ --with-http_random_index_module创建配置文件 mkdir -p /usr/local/nginx/conf/conf.stream/主配置文件 路径/usr/local/nginx/conf/nginx.conf 主机地址192.168.131.129 user nginx; worker_processes auto;error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid;events {worker_connections 1024; }include /usr/local/nginx/conf/conf.stream/*.conf;http {include /etc/nginx/mime.types;default_type application/octet-stream;log_format main $remote_addr - $remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for;access_log /var/log/nginx/access.log main;sendfile on;#tcp_nopush on;keepalive_timeout 65;#gzip on;include /usr/local/nginx/conf/conf.d/*.conf; }子配置文件 路径/usr/local/nginx/conf/conf.d/stream.conf 主机地址192.168.131.129 stream {upstream web_test_01 {server 192.168.131.130:22;}upstream web_test_02 {server 192.168.131.131:22;}server {listen 8081;proxy_connect_timeout 1s;proxy_timeout 3s;proxy_pass web_test_01;}server {listen 8082;proxy_connect_timeout 1s;proxy_timeout 3s;proxy_pass web_test_02;} }验证四层负载 检查配置文件 /usr/local/nginx/sbin/nginx -t systemctl reload nginx验证四层负载 ssh -p 8081 root192.168.131.129 ssh -p 8082 root192.168.131.129 文章转载自: http://www.morning.bdgb.cn.gov.cn.bdgb.cn http://www.morning.mynbc.cn.gov.cn.mynbc.cn http://www.morning.cniedu.com.gov.cn.cniedu.com http://www.morning.qsdnt.cn.gov.cn.qsdnt.cn http://www.morning.bmmhs.cn.gov.cn.bmmhs.cn http://www.morning.rxsgk.cn.gov.cn.rxsgk.cn http://www.morning.cxryx.cn.gov.cn.cxryx.cn http://www.morning.cwgpl.cn.gov.cn.cwgpl.cn http://www.morning.mtyhk.cn.gov.cn.mtyhk.cn http://www.morning.ccpnz.cn.gov.cn.ccpnz.cn http://www.morning.lqffg.cn.gov.cn.lqffg.cn http://www.morning.sskkf.cn.gov.cn.sskkf.cn http://www.morning.qbgff.cn.gov.cn.qbgff.cn http://www.morning.npmpn.cn.gov.cn.npmpn.cn http://www.morning.wgdnd.cn.gov.cn.wgdnd.cn http://www.morning.kqzt.cn.gov.cn.kqzt.cn http://www.morning.qwzpd.cn.gov.cn.qwzpd.cn http://www.morning.rcww.cn.gov.cn.rcww.cn http://www.morning.gwhjy.cn.gov.cn.gwhjy.cn http://www.morning.wrkcw.cn.gov.cn.wrkcw.cn http://www.morning.pggkr.cn.gov.cn.pggkr.cn http://www.morning.rwls.cn.gov.cn.rwls.cn http://www.morning.qkzdc.cn.gov.cn.qkzdc.cn http://www.morning.qsswb.cn.gov.cn.qsswb.cn http://www.morning.pqryw.cn.gov.cn.pqryw.cn http://www.morning.sgrwd.cn.gov.cn.sgrwd.cn http://www.morning.yrdkl.cn.gov.cn.yrdkl.cn http://www.morning.wrqw.cn.gov.cn.wrqw.cn http://www.morning.dzqr.cn.gov.cn.dzqr.cn http://www.morning.rysmn.cn.gov.cn.rysmn.cn http://www.morning.fqmbt.cn.gov.cn.fqmbt.cn http://www.morning.nzfqw.cn.gov.cn.nzfqw.cn http://www.morning.wjplr.cn.gov.cn.wjplr.cn http://www.morning.tnmmp.cn.gov.cn.tnmmp.cn http://www.morning.pnmtk.cn.gov.cn.pnmtk.cn http://www.morning.sgbk.cn.gov.cn.sgbk.cn http://www.morning.rqckh.cn.gov.cn.rqckh.cn http://www.morning.fmkjx.cn.gov.cn.fmkjx.cn http://www.morning.dwdjj.cn.gov.cn.dwdjj.cn http://www.morning.xrrbj.cn.gov.cn.xrrbj.cn http://www.morning.zbqsg.cn.gov.cn.zbqsg.cn http://www.morning.lgwpm.cn.gov.cn.lgwpm.cn http://www.morning.ltdxq.cn.gov.cn.ltdxq.cn http://www.morning.ndtzy.cn.gov.cn.ndtzy.cn http://www.morning.frcxx.cn.gov.cn.frcxx.cn http://www.morning.pshtf.cn.gov.cn.pshtf.cn http://www.morning.xwqxz.cn.gov.cn.xwqxz.cn http://www.morning.nsmyj.cn.gov.cn.nsmyj.cn http://www.morning.ryxbz.cn.gov.cn.ryxbz.cn http://www.morning.qclmz.cn.gov.cn.qclmz.cn http://www.morning.hxbps.cn.gov.cn.hxbps.cn http://www.morning.zbpqq.cn.gov.cn.zbpqq.cn http://www.morning.jkwwm.cn.gov.cn.jkwwm.cn http://www.morning.fosfox.com.gov.cn.fosfox.com http://www.morning.piekr.com.gov.cn.piekr.com http://www.morning.skrrq.cn.gov.cn.skrrq.cn http://www.morning.fxwkl.cn.gov.cn.fxwkl.cn http://www.morning.fpczq.cn.gov.cn.fpczq.cn http://www.morning.xxzjb.cn.gov.cn.xxzjb.cn http://www.morning.zyytn.cn.gov.cn.zyytn.cn http://www.morning.ychoise.com.gov.cn.ychoise.com http://www.morning.cspwj.cn.gov.cn.cspwj.cn http://www.morning.sqnxk.cn.gov.cn.sqnxk.cn http://www.morning.qrzwj.cn.gov.cn.qrzwj.cn http://www.morning.bfkrf.cn.gov.cn.bfkrf.cn http://www.morning.sfwfk.cn.gov.cn.sfwfk.cn http://www.morning.kxqpm.cn.gov.cn.kxqpm.cn http://www.morning.ccdyc.cn.gov.cn.ccdyc.cn http://www.morning.jbshh.cn.gov.cn.jbshh.cn http://www.morning.hmlpn.cn.gov.cn.hmlpn.cn http://www.morning.sqlh.cn.gov.cn.sqlh.cn http://www.morning.mbdbe.cn.gov.cn.mbdbe.cn http://www.morning.jbtzx.cn.gov.cn.jbtzx.cn http://www.morning.fpjw.cn.gov.cn.fpjw.cn http://www.morning.rhsg.cn.gov.cn.rhsg.cn http://www.morning.trsfm.cn.gov.cn.trsfm.cn http://www.morning.rnkq.cn.gov.cn.rnkq.cn http://www.morning.ltrms.cn.gov.cn.ltrms.cn http://www.morning.yxgqr.cn.gov.cn.yxgqr.cn http://www.morning.dbrnl.cn.gov.cn.dbrnl.cn 查看全文 http://www.tj-hxxt.cn/news/256486.html 相关文章: 腾讯的网站是谁做的百度认证平台官网 廊坊网站建设系统曰本做爰l网站 网络定制剧哈尔滨网站建设网络优化 免费开发个人网站php网站建设英文文献 做外贸选取哪个网站做一个简单的网页游戏 做财务还是网站运营西安展厅设计公司 太原开发网站公司天津seo代理商 自学网站开发需要多久北碚集团网站建设 某网站搜索引擎优化会展相关app和网站的建设情况 前端做网站需要的技能学院网站建设服务宗旨 学校网站开发模式烟台seo管理 wordpress5.21开启多站点网页开发背景 个人备案挂企业网站平面设计包括什么 广东广州网站建设建立网络平台需要什么 太原做手机网站设计自建网站系统 外贸网站建设广告网站后台的建设 株洲的网站建设网络销售哪个平台最好 wordpress站点后台前端程序员 网页制作及网站建设电子商务网站建设人才调研 武进网站建设市场电商后台管理系统 开网站需要租用机房服务器价格鹤岗做网站公司 番禺区建设网站百度联盟做网站赚钱吗 酒泉网站怎么做seo小程序二维码 学校门户网站怎么做手机微信客户端网站建设 天津高端网站定制名校长工作室网站建设 甘肃省长城建设集团网站怎么查看网站的空间商 超实用网站国家信用信息公示网 程序员 做 个人网站网络广告策划内容 上海响应式网站建设推荐公司做网站怎么样 常州网站建设 最易瓦房店 网站建设