1.下载agent-zip包,地址:https://github.com/nezhahq/agent/releases?page=5 V0最后一个版本是v0.20.5,不要下载错了,找清楚适合自己的包,下载到本地解压缩备用;
2.新建目录
3.上传并赋予执行权限
将本地下载好的运行文件上传到/opt/nezha/agent中
4.创建服务文件,在 /etc/systemd/system/ 目录下创建 nezha-agent.service 文件
5.编辑service文件,添加域名,端口,通讯密钥,并禁止面板机对受控机直接运行命令。
6.设置开机自动重启
2.新建目录
mkdir /opt/nezha
mkdir /opt/nezha/agent
3.上传并赋予执行权限
将本地下载好的运行文件上传到/opt/nezha/agent中
chmod +x /opt/nezha/nezha-agent
4.创建服务文件,在 /etc/systemd/system/ 目录下创建 nezha-agent.service 文件
sudo nano /etc/systemd/system/nezha-agent.service
5.编辑service文件,添加域名,端口,通讯密钥,并禁止面板机对受控机直接运行命令。
[Unit]
Description=哪吒探针监控端
ConditionFileIsExecutable=/opt/nezha/agent/nezha-agent[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/opt/nezha/agent/nezha-agent "-s" "面板域名:端口" "-p" "通讯密钥" --disable-command-execute --disable-command-executeWorkingDirectory=/rootRestart=alwaysRestartSec=120
WantedBy=multi-user.target
6.设置开机自动重启
sudo systemctl daemon-reload
sudo systemctl start nezha-agent
sudo systemctl enable nezha-agent
sudo systemctl status nezha-agent