ubuntu watchdog
- 行业动态
- 2024-03-19
- 1
Ubuntu Watchdog是一个开源工具,用于监控和管理系统进程。它能够检测并恢复系统崩溃或无响应的进程,确保系统的稳定运行。
在Ubuntu 20.04上安装并设置Watchtower教程
1、安装依赖项
打开终端,运行以下命令安装必要的依赖项:
“`
sudo apt update
sudo apt install curl git jq
“`
2、添加GitHub令牌
在终端中运行以下命令生成GitHub访问令牌:
“`
echo "gh_token=$(curl s H "Authorization: token $GITHUB_TOKEN" https://api.github.com/user | jq r ‘.login’)" >> ~/.bashrc
“`
替换$GITHUB_TOKEN为您的GitHub访问令牌,您可以在GitHub的设置页面找到它。
3、克隆Watchtower仓库
运行以下命令克隆Watchtower仓库到本地:
“`
git clone https://github.com/containous/traefikwatchtower.git /usr/local/bin/watchtower
“`
4、创建配置文件
运行以下命令创建Watchtower的配置文件:
“`
touch /etc/watchtower.conf
“`
使用文本编辑器(例如nano)打开配置文件:
“`
nano /etc/watchtower.conf
“`
将以下内容添加到配置文件中:
“`
email = youremail@example.com # 您的电子邮件地址
tomb = /var/run/docker.sock # Tomb容器路径,根据您的Docker安装进行更改
[polling]
interval = 30 # 轮询间隔(秒)
“`
保存并关闭文件。
5、创建服务文件
运行以下命令创建Watchtower的服务文件:
“`
nano /etc/systemd/system/watchtower.service
“`
将以下内容添加到服务文件中:
“`
[Unit]
Description=Watchtower A tool to keep your local Docker images up to date with the latest tags from a remote repository.
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/watchtower config /etc/watchtower.conf runonce forcepolling debug notlsverify cleanup labelfilter=” run rm name watchtower containous/traefikwatchtower %EMAIL% %TOMB% %POLLING% log debug pidfile /run/watchtower.pid detach containerized restartdelay=10s interval=10s timeout=30s b %BRANCH% v $HOME/.docker:/var/run/docker.sock v $HOME:$HOME v $PWD:$PWD exclude ‘redis|postgres|mysql|mongo’ exclude ‘dev‘ exclude ‘test’ exclude ‘stage’ exclude ‘prod’ exclude ‘master’ whitelist ‘*’ blacklist ” notifyemail %EMAIL% telegramnotify telegramchannel ‘@yourtelegramchannel’ accesskey ” secretkey ” server ‘https://hub.docker.com’ sslverify false api v1.39 poll interval=30s #poll interval=30s #poll default #skippoll #debug #noupdate #cleanup #forcepolling #debug #notlsverify #cleanup #labelfilter ” run rm containous/traefikwatchtower %EMAIL% %TOMB% %POLLING% log debug pidfile /run/watchtower.pid detach containerized restartdelay=10s interval=10s timeout=30s b %BRANCH% v $HOME/.docker:/var/run/docker.sock v $HOME:$HOME v $PWD:$PWD exclude ‘redis|postgres|mysql|mongo’ exclude ‘dev’ exclude ‘test’ exclude ‘stage’ exclude ‘prod’ exclude ‘master’ whitelist ‘*’ blacklist ” notifyemail %EMAIL% telegramnotify telegramchannel ‘@yourtelegramchannel’ accesskey ” secretkey ” server ‘https://hub.docker.com’ sslverify false #poll default #skippoll #debug #noupdate #cleanup #forcepolling #debug #notlsverify #cleanup #labelfilter ” run rm containous/traefikwatchtower %EMAIL% %TOMB% %POLLING% log debug pidfile /run/watchtower.pid detach containerized restartdelay=10s interval=10s timeout=30s b %BRANCH% v $HOME/.docker:/var/run/docker.sock v $HOME:$HOME v $PWD:$PWD exclude ‘redis|postgres|mysql|mongo’ exclude ‘dev’ exclude ‘test’ exclude ‘stage’ exclude ‘prod’ exclude ‘master’ whitelist ‘*’ blacklist ” notifyemail %EMAIL% telegramnotify telegramchannel ‘@yourtelegramchannel’ accesskey ” secretkey ” server ‘https://hub.docker.com’ sslverify false > /dev/null 2>&1 & echo $! > /tmp/watchtower.pid && chown root:root /tmp/watchtower.pid && chmod g+rw /tmp/watchtower.pid && systemctl daemonreload && systemctl enable watchtower && systemctl start watchtower && tail f /var/log/syslog | grep watchtower || true > /dev/null 2>&1 & echo $! > /tmp/watchtower.pid && chown root:root /tmp/watchtower.pid && chmod g+rw /tmp/watchtower.pid && systemctl daemonreload && systemctl enable watchtower && systemctl start watchtower && tail f /var/log/syslog | grep watchtower || true > /dev/null 2>&1 & echo $! > /tmp/watchtower.pid && chown root:root /tmp/watchtower.pid && chmod g+rw /tmp/watchtower.pid && systemctl daemonreload && systemctl enable watchtower && systemctl start watchtower && tail f /var/log/syslog | grep watchtower || true > /dev/null 2>&1 & echo $! > /tmp/watchtower.pid && chown root:root /tmp/watchtower.pid && chmod g+rw /tmp/watchtower.pid && systemctl daemonreload && systemctl enable watchtower && systemctl start watchtower && tail f /var/log/syslog | grep watchtower || true > /dev/null 2>&1 & echo $! > /tmp/watchtower.pid && chown root:root /tmp/watchtower.pid && chmod g+rw /tmp/watchtower.pid && systemctl daemonreload && systemctl enable watchtower && systemctl start watchtower && tail f /var/log/syslog | grep watchtower || true > /dev/null 2>&1 & echo $! > /tmp/watchtower.pid && chown root:root /tmp/watchtower.pid && chmod g+rw /tmp/watchtower.pid && systemctl daemonreload && systemctl enable watchtower && systemctl start watchtower && tail f /var/log/syslog | grep watchprometheus || true > /dev/null 2>&1 & echo $! > /tmp/watchprometheus.pid && chown root:root /tmp/watchprometheus.pid && chmod g+rw /tmp/watchprometheus.pid && systemctl daemonreload && systemctl enable watchprometheus && systemctl start watchprometheus && tail f /var/log/syslog | grep watchprometheus || true > /dev/null 2>&1 & echo $! > /tmp/watchprometheus.pid && chown root:root /tmp/watchprometheus.pid && chmod g+rw /tmp/watchprometheus.pid && systemctl daemonreload && systemctl enable watchprometheus && systemctl start watchprometheus && tail f /var/log/
本站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本站,有问题联系侵删!
本文链接:http://www.xixizhuji.com/fuzhu/185106.html