- 请自行从 https://api.github.com/repos/nezhahq/agent/releases/latest 上下载nezha-agent到本地,注意无后缀,这是个二进制文件
- 在服务器上创建 "/opt/nezha/agent" 目录,将nezha-agent放入
- 将以下代码替换成自己的服务器地址与密钥
[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
- 在 "/etc/systemd/system/" 目录新建一个nezha-agent.service文件,将替换完成的代码保存进其中
- 确认以上工作全部完成以后,在终端运行以下命令
systemctl daemon-reload systemctl enable nezha-agent systemctl restart nezha-agent
6.还可以直接下载二进制
chmod +x nazha-agent
./nezha-agent -s IP:port -p secret
有需求做个自启