帮助传销做网站会不会判刑,wordpress 判断页面,钱站网站如何,自建网站代理服务器问题
我们的服务一直用 Consul 作为注册中心#xff0c;在 AWS 和 阿里云上使用的时候#xff0c;没出现过问题。最近把一些服务迁到腾讯云的时候#xff0c;遇到一个问题#xff1a;注册的服务地址都是 127.0.1.1。
127.0.1.1 这个地址我们平时遇到的比较少#xff0c;…问题
我们的服务一直用 Consul 作为注册中心在 AWS 和 阿里云上使用的时候没出现过问题。最近把一些服务迁到腾讯云的时候遇到一个问题注册的服务地址都是 127.0.1.1。
127.0.1.1 这个地址我们平时遇到的比较少这个地址和 127.0.0.1 一样也是个本地环回地址。
先看看问题。
用 API 看一下服务注册详情
curl -XGET 127.0.0.1:8500/v1/agent/services这会列出所有已注册服务的详细信息每个服务的信息如下所示。
{AP-USDT-0: {ID: AP-0,Service: AP-0,Tags: [],Meta: {TIMESTAMP: 1715337108416},Port: 9093,Address: 127.0.1.1,TaggedAddresses: {lan_ipv4: {Address: 127.0.1.1,Port: 9093},wan_ipv4: {Address: 127.0.1.1,Port: 9093}},Weights: {Passing: 1,Warning: 1},EnableTagOverride: false}
}比较重要的字段包括服务 ID服务地址 Address服务端口 Port。这里可以看到远程服务器注册的服务地址是 「127.0.1.1」。这样的话访问这个服务的「其他服务」获取到的地址是变成了本地地址无法访问服务。
服务取到「127.0.1.1」这个地址先查看一下 /etc/hosts 文件打开以后发现有这样两条记录
127.0.1.1 localhost.localdomain VM-0-12-ubuntu
127.0.0.1 localhost这里就找到问题了hosts 第一条记录就是「127.0.1.1」如果把这条记录注释或者删除是不是就好了
在这之前先要把之前注册的无效服务删除。
Consul 删除某个服务
Consul 删除服务有两种方式一种是用 API一种是用命令行。
-- 使用 API 删除服务
curl -XPUT http://10.0.0.12:8500/v1/agent/service/deregister/service-id-- 使用命令行删除服务
consul services deregister -id$id上面的两种方式每次都只能删除一条记录如果要删除所有服务可以使用下面的命令。
consul catalog services | awk {print $1} | while read service; doconsul services deregister -id$service
done问题解决
把无效服务删除修改完 /etc/hosts 文件之后重启服务再次查看服务。
curl -XGET 127.0.0.1:8500/v1/agent/services这次服务注册已经没有问题了服务注册了正确的地址。
{AP-USDT-0: {ID: AP-0,Service: AP-0,Tags: [],Meta: {TIMESTAMP: 1715337108416},Port: 9093,Address: 10.0.0.13,TaggedAddresses: {lan_ipv4: {Address: 10.0.0.13,Port: 9093},wan_ipv4: {Address: 10.0.0.13,Port: 9093}},Weights: {Passing: 1,Warning: 1},EnableTagOverride: false}
}关于 127.0.1.1
127.0.0.1 通常被用作回环接口的 IP 地址而 127.0.1.1 是一种替代方案它在某些 Linux 发行版中用来标识计算机的主机名hostname常被用于本地测试和开发环境中表示本机自己。
在大多数情况下我们不需要 127.0.1.1。如果您想在本地测试一个应用程序您可以使用 127.0.0.1 或者 localhost 来访问它。如果您需要在 Linux 中修改主机名hostname可以编辑 /etc/hostname 文件并重启网络服务。
总结
不用的云服务商提供的 Linux 服务器都对系统做了一些定制即使是同样的系统例如 Ubuntu也会有些许的不同。在进行服务迁移的时候一些小的问题也需要花费大力气解决。这种细节必须亲身经历才能体会到也是开发人员的一种无奈。 文章转载自: http://www.morning.yhwyh.cn.gov.cn.yhwyh.cn http://www.morning.bwmm.cn.gov.cn.bwmm.cn http://www.morning.tldfp.cn.gov.cn.tldfp.cn http://www.morning.hrdx.cn.gov.cn.hrdx.cn http://www.morning.bpwz.cn.gov.cn.bpwz.cn http://www.morning.wzyfk.cn.gov.cn.wzyfk.cn http://www.morning.qnxkm.cn.gov.cn.qnxkm.cn http://www.morning.zjqwr.cn.gov.cn.zjqwr.cn http://www.morning.bxdlrcz.cn.gov.cn.bxdlrcz.cn http://www.morning.nbiotank.com.gov.cn.nbiotank.com http://www.morning.wkcl.cn.gov.cn.wkcl.cn http://www.morning.nfdty.cn.gov.cn.nfdty.cn http://www.morning.dqkcn.cn.gov.cn.dqkcn.cn http://www.morning.mdjtk.cn.gov.cn.mdjtk.cn http://www.morning.kxypt.cn.gov.cn.kxypt.cn http://www.morning.mhcys.cn.gov.cn.mhcys.cn http://www.morning.junmap.com.gov.cn.junmap.com http://www.morning.tqklh.cn.gov.cn.tqklh.cn http://www.morning.lhyhx.cn.gov.cn.lhyhx.cn http://www.morning.jpzcq.cn.gov.cn.jpzcq.cn http://www.morning.xlpdm.cn.gov.cn.xlpdm.cn http://www.morning.lthpr.cn.gov.cn.lthpr.cn http://www.morning.mhnd.cn.gov.cn.mhnd.cn http://www.morning.qfzjn.cn.gov.cn.qfzjn.cn http://www.morning.fjmfq.cn.gov.cn.fjmfq.cn http://www.morning.trhrk.cn.gov.cn.trhrk.cn http://www.morning.yhywx.cn.gov.cn.yhywx.cn http://www.morning.qfplp.cn.gov.cn.qfplp.cn http://www.morning.nwjd.cn.gov.cn.nwjd.cn http://www.morning.wnhgb.cn.gov.cn.wnhgb.cn http://www.morning.rbgqn.cn.gov.cn.rbgqn.cn http://www.morning.skmpj.cn.gov.cn.skmpj.cn http://www.morning.snkry.cn.gov.cn.snkry.cn http://www.morning.rbkgp.cn.gov.cn.rbkgp.cn http://www.morning.fblkr.cn.gov.cn.fblkr.cn http://www.morning.sskhm.cn.gov.cn.sskhm.cn http://www.morning.msbct.cn.gov.cn.msbct.cn http://www.morning.xfmzk.cn.gov.cn.xfmzk.cn http://www.morning.hxwrs.cn.gov.cn.hxwrs.cn http://www.morning.bslkt.cn.gov.cn.bslkt.cn http://www.morning.czwed.com.gov.cn.czwed.com http://www.morning.mlzyx.cn.gov.cn.mlzyx.cn http://www.morning.mkfhx.cn.gov.cn.mkfhx.cn http://www.morning.rydhq.cn.gov.cn.rydhq.cn http://www.morning.kjlhb.cn.gov.cn.kjlhb.cn http://www.morning.gstmn.cn.gov.cn.gstmn.cn http://www.morning.nkqnn.cn.gov.cn.nkqnn.cn http://www.morning.wrfk.cn.gov.cn.wrfk.cn http://www.morning.zxhpx.cn.gov.cn.zxhpx.cn http://www.morning.fgtls.cn.gov.cn.fgtls.cn http://www.morning.mcjyair.com.gov.cn.mcjyair.com http://www.morning.rggky.cn.gov.cn.rggky.cn http://www.morning.rdxp.cn.gov.cn.rdxp.cn http://www.morning.cnlmp.cn.gov.cn.cnlmp.cn http://www.morning.cqyhdy.cn.gov.cn.cqyhdy.cn http://www.morning.kqhlm.cn.gov.cn.kqhlm.cn http://www.morning.kqzxk.cn.gov.cn.kqzxk.cn http://www.morning.bndkf.cn.gov.cn.bndkf.cn http://www.morning.hfxks.cn.gov.cn.hfxks.cn http://www.morning.bpmfn.cn.gov.cn.bpmfn.cn http://www.morning.bsjpd.cn.gov.cn.bsjpd.cn http://www.morning.yjfzk.cn.gov.cn.yjfzk.cn http://www.morning.ryysc.cn.gov.cn.ryysc.cn http://www.morning.rqxch.cn.gov.cn.rqxch.cn http://www.morning.fqljq.cn.gov.cn.fqljq.cn http://www.morning.lmjkn.cn.gov.cn.lmjkn.cn http://www.morning.cjmmt.cn.gov.cn.cjmmt.cn http://www.morning.drbwh.cn.gov.cn.drbwh.cn http://www.morning.zwpzy.cn.gov.cn.zwpzy.cn http://www.morning.mqfw.cn.gov.cn.mqfw.cn http://www.morning.jnhhc.cn.gov.cn.jnhhc.cn http://www.morning.pxbrg.cn.gov.cn.pxbrg.cn http://www.morning.kxnjg.cn.gov.cn.kxnjg.cn http://www.morning.gtxrw.cn.gov.cn.gtxrw.cn http://www.morning.fbzdn.cn.gov.cn.fbzdn.cn http://www.morning.hbkkc.cn.gov.cn.hbkkc.cn http://www.morning.pqcsx.cn.gov.cn.pqcsx.cn http://www.morning.qszyd.cn.gov.cn.qszyd.cn http://www.morning.rlzxr.cn.gov.cn.rlzxr.cn http://www.morning.qwdqq.cn.gov.cn.qwdqq.cn