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

一个新手建设网站怎么简单经典广告推广词

一个新手建设网站怎么简单,经典广告推广词,广告公司网页设计,上海网站制作工作室本文介绍了nginx反向代理多虚拟主机节点服务器配合keepalived实现高可用和负载均衡,keepalived除了能够管理LVS软件外,还可以作为其他服务的高可用解决方案软件。采用 nginxkeepalived,它是一个高性能的服务器高可用或者热备解决方案&#xf…

本文介绍了nginx反向代理多虚拟主机节点服务器配合keepalived实现高可用和负载均衡,keepalived除了能够管理LVS软件外,还可以作为其他服务的高可用解决方案软件。采用 nginx+keepalived,它是一个高性能的服务器高可用或者热备解决方案,Keepalived主要来防止服务器 单点故障的发生问题,可以通过其与Nginx的配合实现Web服务器端的高可用。使用keepalived可以保 证nginx的高可用,他能监控nginx的健康状态,当nginx出现宕机时自动主备切换

配置有点像:基于keepalived实现haproxy高可用站点-CSDN博客

环境准备:

4台Linux Rocky8.10虚拟机,两台提供nginx的web服务器:192.168.118.131/129。本项目采用非keepalived的非抢占模式,两台keepalived的互为backup服务器:192.168.118.128/130

配置nginx服务器

下载:

yum install nginx -y

配置:vim /etc/nginx/conf.d/vhost.conf

server {listen 80;server_name bbs.test.com;location /{root /usr/share/nginx/html/bbs;index index.html index.htm;}access_log /usr/share/nginx/html/bbs/logs/access_bbs.log main;
}server {listen 80;server_name www.test.com;location /{root /usr/share/nginx/html/www;index index.html index.htm;}access_log /usr/share/nginx/html/www/logs/access_www.log main;
}

 关闭selinux和防火墙:setenforce 0 && systemctl stop firewalld

在两台服务器上面执行以下命令:

mkdir -p /usr/share/nginx/html/{www,bbs}
touch /usr/share/nginx/html/www/index.html
touch /usr/share/nginx/html/bbs/index.html
echo "bbs: This is a test page which from: IP:$(hostname -I)" > /usr/share/nginx/html/bbs/index.html
echo "www: This is a test page which from: IP:$(hostname -I)" > /usr/share/nginx/html/www/index.htmltouch  /usr/share/nginx/html/bbs/logs/access_bbs.log
touch  /usr/share/nginx/html/www/logs/access_www.log
chown -R nginx:nginx /usr/share/nginx/

 拓扑结构:

[root@localhost ~]# tree /usr/share/nginx/html/
/usr/share/nginx/html/
├── 404.html
├── 50x.html
├── bbs
│   ├── index.html
│   └── logs
│       └── access_bbs.log
├── index.html
├── nginx-logo.png
├── poweredby.png
└── www
    ├── index.html
    └── logs
        └── access_www.log

 启动nginx:systemctl start nginx

测试

echo "192.168.118.129  www.test.com  bbs.test.com" >> /etc/hosts

 [root@localhost conf.d]# curl www.test.com
www: This is a test page which from 192.168.118.129
[root@localhost conf.d]# curl bbs.test.com
bbs: This is a test page which from 192.168.118.129

配置nginx代理

vim /etc/nginx/conf.d/vtest.conf

upstream server_pools {server 192.168.118.129:80 weight=1;                                                   server 192.168.118.131:80 weight=1;
}                                                                                                                                                                           server {                                                                                      listen  80;                                                                           server_name www.test.com;location / {proxy_pass http://server_pools;                                                             #传递原始的host头部信息proxy_set_header Host $host;}
}                                                                                                                                                                           server {listen  80;                                                                           server_name bbs.test.com;location / {proxy_pass http://server_pools;#传递原始的host头部信息proxy_set_header Host $host;}
}

 在这段配置中,当请求的server_name匹配到bbs.test.com或者www.test.com时,location /会捕获所有对www.test.com或者bbs.test.com的请求,无论请求的URL是什么。这些请求都会被转发到上游服务器池server_pools中

 然后在/etc/hosts中写入域名

#130主机
[root@localhost conf.d]# tail -1 /etc/hosts
192.168.118.130 www.test.com bbs.test.com
#128主机
[root@localhost conf.d]# tail -1 /etc/hosts
192.168.118.128 www.test.com bbs.test.com

测试

[root@localhost ~]# for ((i=1;i<=4;i++));do curl www.test.com;done
www: This is a test page which from 192.168.118.129
www: This is a test page which from 192.168.118.131
www: This is a test page which from 192.168.118.129
www: This is a test page which from 192.168.118.131
[root@localhost ~]# for ((i=1;i<=4;i++));do curl bbs.test.com;done
bbs: This is a test page which from 192.168.118.129
bbs: This is a test page which from 192.168.118.131
bbs: This is a test page which from 192.168.118.129
bbs: This is a test page which from 192.168.118.131

 配置keepalived

vim /etc/keepalived/keepalived.conf

! Configuration File for keepalived
global_defs {router_id LVS_1
}
vrrp_script chk_nginx {script "killall -0 nginx"#检查是否开启了nginx代理
}vrrp_instance VI_1 {state BACKUP#备份模式interface ens160mcast_src_ip 192.168.118.130#基于这个源IP的健康检查nopreempt#非抢占模式virtual_router_id 51priority 100#优先级advert_int 1#间隔时间authentication {#认证auth_type PASSauth_pass 1111}track_script {#调用脚本chk_nginx
}virtual_ipaddress {#VIP192.168.118.110}
}

 systemctl start keepalived

效果

 单开两个进程去时刻检查日志:tail -f /var/log/messages

当拥有VIP的一方停止nginx服务时,立刻就会移除VIP,另一方获得VIP

 当其恢复时,VIP也不会回到自己这台主机上面,减少主从交换频率,提高稳定性。这就是非抢占模式

 最后测试是否依旧可以通过这个虚拟IP访问:curl -H表示携带head信息

以上访问被分流,且更具访问的URL到不同页面

http://www.dtcms.com/wzjs/322905.html

相关文章:

  • 怎么做网站访问被拒绝本地建站软件有哪些
  • win7 iis asp网站配置文件怎么设计网站
  • 东丽区装饰网站建设百度pc端入口
  • 三合一网站建设公司互联网项目推广是什么
  • 网站开发文章友情链接
  • 国内最大的c2c网站郑州seo地址
  • 焦作网站建设的公司哪家好广西seo关键词怎么优化
  • 爱做网站视频百度怎么搜索图片
  • 用php做的网站用什么数据库最新疫情19个城市封城
  • 安防网站模板吉林关键词排名优化软件
  • 网站开发 绩效考核如何查询百度搜索关键词排名
  • 中国做的比较好的网站有哪些医疗网站优化公司
  • 山东网站方案合肥seo快排扣费
  • 网站建设培训相关资料b站推广网站入口202
  • 一个网站制作流程站长素材免费下载
  • 做药物分析必须知道的网站自媒体平台有哪些
  • 青岛网站制作工作室网络广告推广服务
  • 优化网站及商品排名怎么做网络营销措施有哪些
  • 免费制作微网站seo诊断a5
  • 常用的cms建站系统谷歌chrome浏览器下载
  • 如何做各大网站广告链接广州网站外包
  • 学校网站建设案例网站设计方案
  • 网站视频下载软件软文广告100字
  • 企业网站制作报价单优化大师免费安装下载
  • wordpress 新浪微博许昌seo推广
  • 响应式网站制设计鹤壁网络推广哪家好
  • 盐亭县建设局网站微商怎么做推广加好友
  • 微商城网站建设b2b网站排名
  • 腾讯云域名管理东莞seo网络公司
  • 网站编程是什么意思google ads 推广