[哪吒面板] 解决国内鸡无法下载/安装哪吒面板代理端核心问题(非原创)
前言
哪吒面板不用多介绍,99%MJJ的选择但是当我们遇到给国内鸡安装探针的时候,麻烦就来了,基本表现如下
1. DNS错误导致无法连接GIthub,没办法下载核心
2. 可以成功解析GIthub域名但是下载太慢,或卡死
针对以上情况,哪吒面板wiki也给出了解决方案,但是总会出现各种各样的问题。
如果你的被控服务器位于中国大陆,可以使用镜像:
curl -L https://cdn.jsdelivr.net/gh/naiba/nezha@master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo CN=true ./nezha.sh
有时候,这个域名也会抽风。(笔者就遇到过几次,很难受)
了解哪吒面板代理端文件分布
以下内容来自nezha.sh NZ_BASE_PATH="/opt/nezha" NZ_AGENT_PATH="${NZ_BASE_PATH}/agent" NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service" 1. "/opt/nezha" 为面板核心的存放目录,包括Dashboard 和 Agent 2. "/opt/nezha/agent" 结合上文,此目录就为代理端核心文件的存放位置 3. "/etc/systemd/system/nezha-agent.service" 对Liunx系统比较熟悉的小伙伴就会知道这个文件决定的哪吒代理端的开机启动
了解了以上内容我们就可以很轻易的不依赖外部的网络来部署哪吒探针代理端了
操作步骤
1. 请自行从 https://api.github.com/repos/nezhahq/agent/releases/latest 上下载nezha-agent到本地,注意无后缀,这是个二进制文件
2. 在服务器上创建 “/opt/nezha/agent” 目录,将nezha-agent放入
3. 将以下代码替换成自己的服务器地址与密钥
[Unit] Description=Nezha Agent After=syslog.target #After=network.target #After=nezha-dashboard.service [Service] # Modify these two values and uncomment them if you have # repos with lots of files and get an HTTP error 500 because # of that ### #LimitMEMLOCK=infinity #LimitNOFILE=65535 Type=simple User=root Group=root WorkingDirectory=/opt/nezha/agent/ ExecStart=/opt/nezha/agent/nezha-agent -s IP地址:5555 -p 密钥 Restart=always #Environment=DEBUG=true # Some distributions may not support these hardening directives. If you cannot start the service due # to an unknown option, comment out the ones not supported by your version of systemd. #ProtectSystem=full #PrivateDevices=yes #PrivateTmp=yes #NoNewPrivileges=true [Install] WantedBy=multi-user.target
4. 在 “/etc/systemd/system/” 目录新建一个nezha-agent.service文件,将替换完成的代码保存进其中
5. 确认以上工作全部完成以后,在终端运行以下命令
systemctl daemon-reload systemctl enable nezha-agent systemctl restart nezha-agent