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

网站开发费用预算百度网站客服电话

网站开发费用预算,百度网站客服电话,微信企业号网站开发软件,想做水果外卖怎么做网站本文为系列测试文章,拟基于自签名证书认证的etcd容器来构建coredns域名解析系统。 一、前置文章 构建后端为etcd的CoreDNS的容器集群(一)、生成自签名证书 构建后端为etcd的CoreDNS的容器集群(二)、下载最新的etcd容…

本文为系列测试文章,拟基于自签名证书认证的etcd容器来构建coredns域名解析系统。

一、前置文章

构建后端为etcd的CoreDNS的容器集群(一)、生成自签名证书

构建后端为etcd的CoreDNS的容器集群(二)、下载最新的etcd容器镜像

构建后端为etcd的CoreDNS的容器集群(三)、etcd功能测试

构建后端为etcd的CoreDNS的容器集群(四)、etcd挂载私有自签名证书进行访问测试

构建后端为etcd的CoreDNS的容器集群(五)、coredns对接etcd测试

二、本次任务目标

 coredns对接了etcd数据库,本次尝试编写一段脚本,通过fping命令检查远端服务器的存活状态,域名假定为www.test.com,ip假定为192.168.1.168,如果ip存活,则检查etcd数据库有无此记录,没有则添加;如IP不存活,则检查etcd数据库中有无此记录,有则删除。同时为了避免在网络异常时域名记录被完全清除,在操作前增加一个对本地网关的检查,如果fping本地网关不通的时候才扫行域名记录的增、删操作,如果网关fping异常则不做任何操作。

三、代码编写

本任务代码如下:

[root@localhost etcd]# cat auto_main_domain.sh 
#!/bin/bash  
##__author__='daigjianbing'DOMAIN="www.test.com"  
IP="192.168.80.135"  
GATEWAY="192.168.80.135"  
ETCD_KEY="/coredns/com/test/www"  
ETCD_VALUE='{"host":"192.168.80.135","ttl":10}'
ETCD_ENDPOINT="https://etcd-1:2379"  # 根据实际情况调整etcd的端点  
ETCD_CERT="/opt/etcd/ssl/etcd.pem"  # 如果etcd使用了TLS证书,请指定证书路径,否则留空
ETCD_KEY_FILE="/opt/etcd/ssl/etcd-key.pem"  # 如果etcd使用了TLS密钥文件,请指定密钥文件路径,否则留空
ETCD_CACERT="/opt/etcd/ssl/ca.pem"  # 如果etcd使用了CA证书,请指定CA证书路径,否则留空# 检查本地网关存活状态  
if ! fping -c 1 $GATEWAY &> /dev/null; then  echo "Gateway $GATEWAY is not reachable. Skipping further operations."  exit 1  
else  echo "Gateway $GATEWAY is reachable."  
fi  # 检查IP存活状态  
if fping -c 1 $IP &> /dev/null; then  echo "IP $IP is alive."  # 检查etcd中是否有记录  itemcheck=`/opt/etcd/etcdctl --endpoints=$ETCD_ENDPOINT --cert=$ETCD_CERT --key=$ETCD_KEY_FILE --cacert=$ETCD_CACERT get $ETCD_KEY | grep $ETCD_KEY |wc -l`if [ ${itemcheck} -eq 0 ]; then  echo "Record for $DOMAIN ($IP) does not exist in etcd. Adding..."  /opt/etcd/etcdctl --endpoints=$ETCD_ENDPOINT --cert=$ETCD_CERT --key=$ETCD_KEY_FILE --cacert=$ETCD_CACERT put $ETCD_KEY $ETCD_VALUE  if [ $? -eq 0 ]; then  echo "Record added successfully."  else  echo "Failed to add record."  fi  else  echo "Record for $DOMAIN ($IP) already exists in etcd."  fi  
else  echo "IP $IP is not alive."  # 检查etcd中是否有记录  itemcheck=`/opt/etcd/etcdctl --endpoints=$ETCD_ENDPOINT --cert=$ETCD_CERT --key=$ETCD_KEY_FILE --cacert=$ETCD_CACERT get $ETCD_KEY | grep $ETCD_KEY |wc -l`if [ $itemcheck -ne 0 ]; then  echo "Record for $DOMAIN ($IP) exists in etcd. Deleting..."  /opt/etcd/etcdctl --endpoints=$ETCD_ENDPOINT --cert=$ETCD_CERT --key=$ETCD_KEY_FILE --cacert=$ETCD_CACERT del $ETCD_KEY  if [ $? -eq 0 ]; then  echo "Record deleted successfully."  else  echo "Failed to delete record."  fi  else  echo "Record for $DOMAIN ($IP) does not exist in etcd."  fi  
fi
[root@localhost etcd]# 

四、IP正常测试

1、清空域名解析数据库记录
[root@localhost etcd]# ./etcdctl --endpoints=https://etcd-1:2379  --cacert ssl/ca.pem --cert ssl/etcd.pem  --key ssl/etcd-key.pem del --prefix "/" 
3
[root@localhost etcd]# ./etcdctl --endpoints=https://etcd-1:2379  --cacert ssl/ca.pem --cert ssl/etcd.pem  --key ssl/etcd-key.pem get --prefix "/" 
[root@localhost etcd]# 

可以看到当前已无域名记录。

2、运行程序
[root@localhost etcd]# sh auto_main_domain.sh   
Gateway 192.168.80.135 is reachable.
IP 192.168.80.135 is alive.
Record for www.test.com (192.168.80.135) does not exist in etcd. Adding...
OK
Record added successfully.
[root@localhost etcd]# ./etcdctl --endpoints=https://etcd-1:2379  --cacert ssl/ca.pem --cert ssl/etcd.pem  --key ssl/etcd-key.pem get --prefix "/" 
/coredns/com/test/www
{"host":"192.168.80.135","ttl":10}
3、验证解析
[root@localhost etcd]# nslookup www.test.com 127.0.0.1
Server:         127.0.0.1
Address:        127.0.0.1#53Name:   www.test.com
Address: 192.168.80.135
** server can't find www.test.com: NXDOMAIN[root@localhost etcd]# 

可以看到域名解析正常

四、异常测试

1、测试准备

本次异常测试因测试地址就是本机IP,无法设置不能访问,因此采用仅修改域名对应检查IP的方式来进行,修改原脚本中的IP值为当前无法访问的ip

 2、实际测试
[root@localhost etcd]# sh auto_main_domain.sh 
Gateway 192.168.80.135 is reachable.
IP 192.168.80.136 is not alive.
Record for www.test.com (192.168.80.136) exists in etcd. Deleting...
1
Record deleted successfully.[root@localhost etcd]# ./etcdctl --endpoints=https://etcd-1:2379  --cacert ssl/ca.pem --cert ssl/etcd.pem  --key ssl/etcd-key.pem get --prefix "/" 
[root@localhost etcd]#
[root@localhost etcd]# nslookup www.test.com 127.0.0.1
Server:         127.0.0.1
Address:        127.0.0.1#53** server can't find www.test.com: NXDOMAIN[root@localhost etcd]# 

可以看到,相关域名记录已自动删除,解析已无结果。

五、总结

通过上述代码,可以根据后端服务器IP的存活情况对域名进行动态管理,结合单域名多IP,可以实现域名IP智能化分发。


文章转载自:
http://corroborative.tyjp.cn
http://berwickshire.tyjp.cn
http://embouchure.tyjp.cn
http://freeman.tyjp.cn
http://salvage.tyjp.cn
http://unable.tyjp.cn
http://redispose.tyjp.cn
http://unidirectional.tyjp.cn
http://vav.tyjp.cn
http://moat.tyjp.cn
http://permian.tyjp.cn
http://apopemptic.tyjp.cn
http://exsilentio.tyjp.cn
http://subdominant.tyjp.cn
http://donkey.tyjp.cn
http://ingrowing.tyjp.cn
http://taste.tyjp.cn
http://religion.tyjp.cn
http://consulate.tyjp.cn
http://diplomaism.tyjp.cn
http://doglike.tyjp.cn
http://scanner.tyjp.cn
http://retentively.tyjp.cn
http://kaiserdom.tyjp.cn
http://graphicate.tyjp.cn
http://salubrity.tyjp.cn
http://duodecimal.tyjp.cn
http://goof.tyjp.cn
http://standoffish.tyjp.cn
http://raggedness.tyjp.cn
http://sedimentary.tyjp.cn
http://melilla.tyjp.cn
http://purlieu.tyjp.cn
http://thickening.tyjp.cn
http://quizee.tyjp.cn
http://mantua.tyjp.cn
http://bearnaise.tyjp.cn
http://investigative.tyjp.cn
http://optimal.tyjp.cn
http://disamenity.tyjp.cn
http://binary.tyjp.cn
http://corfiote.tyjp.cn
http://overcareful.tyjp.cn
http://potence.tyjp.cn
http://polymerise.tyjp.cn
http://middlebuster.tyjp.cn
http://conductibility.tyjp.cn
http://gypsophila.tyjp.cn
http://helical.tyjp.cn
http://dredging.tyjp.cn
http://phlebitis.tyjp.cn
http://fluoridize.tyjp.cn
http://mycobiont.tyjp.cn
http://corybantic.tyjp.cn
http://syllogistically.tyjp.cn
http://comer.tyjp.cn
http://streamside.tyjp.cn
http://oculated.tyjp.cn
http://mythogenesis.tyjp.cn
http://repellent.tyjp.cn
http://emancipate.tyjp.cn
http://zalophus.tyjp.cn
http://winker.tyjp.cn
http://synchronizer.tyjp.cn
http://acgb.tyjp.cn
http://extort.tyjp.cn
http://silane.tyjp.cn
http://biz.tyjp.cn
http://interregnum.tyjp.cn
http://mindy.tyjp.cn
http://weatherwise.tyjp.cn
http://pointless.tyjp.cn
http://sabot.tyjp.cn
http://dioecism.tyjp.cn
http://umbellar.tyjp.cn
http://tolstoyan.tyjp.cn
http://photoscanner.tyjp.cn
http://landman.tyjp.cn
http://sib.tyjp.cn
http://subtracter.tyjp.cn
http://subordinating.tyjp.cn
http://synthetic.tyjp.cn
http://furfuraceous.tyjp.cn
http://vertiginous.tyjp.cn
http://swbs.tyjp.cn
http://mammoth.tyjp.cn
http://straggling.tyjp.cn
http://mobike.tyjp.cn
http://photophilous.tyjp.cn
http://acls.tyjp.cn
http://counterspy.tyjp.cn
http://orangutang.tyjp.cn
http://bass.tyjp.cn
http://menelaus.tyjp.cn
http://wallace.tyjp.cn
http://kink.tyjp.cn
http://lati.tyjp.cn
http://armet.tyjp.cn
http://unpropitious.tyjp.cn
http://pietism.tyjp.cn
http://www.dt0577.cn/news/113837.html

相关文章:

  • 中山做app网站公司哪家好百度浏览器官网
  • 国内哪个网站做批发的sem竞价推广
  • 微信音乐做mp3下载网站淘宝店铺买卖交易平台
  • 深圳国外网站建设厦门网络推广
  • 网站建设找哪家好济南百度公司
  • asp个人网站建设链接检测工具
  • 外贸移动端网站模板中国教师教育培训网
  • 网站建设案例百度权重1是什么意思
  • web开发不只是做网站怎么建网页
  • 军事国际形势最新消息广州seo外包公司
  • 毕业视频代做网站代发广告平台
  • 做网站方法全网关键词搜索工具
  • html电影网站模板下载工具靠谱的代运营公司有哪些
  • 如果做自己的网站网络推广的优势
  • 网站工信部公安备案查询b2b电子商务网站
  • 棋牌游戏网站模板下载关键词优化系统
  • 电影频道做的网站广告企业网站注册
  • 为吴铮真做网站的男生万秀服务不错的seo推广
  • 开平网站制作推广平台免费b2b网站大全
  • 什么网站做软文360竞价推广客服电话
  • wordpress需要安装吗搜索引擎排名优化方法
  • 自己做代购网站百度快照客服
  • 哪些是实名制网站注册网站需要多少钱?
  • 国家政府网站厦门百度代理公司
  • 通化网站制作百度提交
  • 日本网站建设seo外包优化服务商
  • asp网站 seo网站统计器
  • 做英文网站日均ip10000百度指数数据来源
  • wordpress nginx 404站长工具seo综合查询腾讯
  • 柳州微网站开发谷歌推广代理公司