访问raw.githubusercontent.com失败问题的处理

1 问题

GitHub上的项目的有些资源是放在raw.githubusercontent.com上的,通常我们在安装某些软件的时候会从该地址下载资源,直接访问的话经常容易失败。

sh 复制代码
# 安装operator
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/deploy/operator.yaml
# 报错内容
The connection to the server raw.githubusercontent.com was refused - did you specify the right host or port?

分析原因:因为神秘力量,域名解析不了,所以访问不了。

解决方法:不用域名登录,直接用ip登录,或者去/etc/hosts里设置下域名解析

2 解决方法

利用修改hosts文件的方法

hosts文件中有用的内容都以一行一行的形式排布,格式为 ip地址 + 空格 + 域名 ,比如 140.82.114.4 github.com ,这样设备在访问 github.com 时就会直接访问 140.82.114.4 这个地址了,而不用向DNS服务器查询。

2.1 查询出raw.githubusercontent.com的ip地址

我们利用查询网查询,查询网的地址为:https://www.ip138.com

查询结果为

2.2 在/etc/hosts里填写如下内容

sh 复制代码
# 把 185.199.109.133 raw.githubusercontent.com 追加到/etc/hosts

echo "185.199.109.133  raw.githubusercontent.com" >> /etc/hosts

3.2 再次执行安装语句,执行成功

sh 复制代码
# 再次执行安装operator
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/deploy/operator.yaml
# 下面为执行成功的信息
namespace/oceanbase-system created
customresourcedefinition.apiextensions.k8s.io/obclusterbackups.oceanbase.oceanbase.com created
customresourcedefinition.apiextensions.k8s.io/obclusterrestores.oceanbase.oceanbase.com created
......

总结

总的来说修改hosts文件来解决一些网站因为DNS原因无法访问或者访问缓慢的情况还是非常方便的。这个方法也可以用于改善 github.comgithub.global.ssl.fastly.net 等网站的访问情况。

相关推荐
OpenTiny社区18 小时前
🎨 看完 GenUI SDK 源码我悟了!
前端·vue.js·github
千寻girling21 小时前
一份不可多得的《微服务》教程
后端·面试·github
霜落长河1 天前
用Gemini提升React代码调试效率的教程
github
Sokach10151 天前
Linux Shell 脚本从零到能用:一个新手的一天学习总结
linux
英勇无比的消炎药1 天前
TinyRobot 源码深度分析:OpenTiny 的 AI 对话组件库
前端·vue.js·github
AlfredZhao2 天前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
逛逛GitHub2 天前
慢慢吃掉你的 Claude Code,在终端里养一只黑洞。
github
jump_jump2 天前
为了重玩金庸群侠传,我研究了一下 Ruffle 怎么复活 Flash
游戏·rust·github
LinXunFeng2 天前
Obsidian - 使用 Share Note 分享笔记并自部署
前端·笔记·github
DayDaydream3 天前
7 天涨了 8000+ Star,Agent Reach 想给 AI 装上互联网眼睛
github