一、cronsun介紹
1)cronsun產生的背景
大量的 crontab 任務散布在各台服務器,帶來了很高的維護成本
任務沒有按時執行,甚至失敗了很久才發現,需要重試或排查
crontab 分散在很多集群上,需要一台一台去看日志分析,頭都大了
crontab 存在單點問題,對於不能重復執行的定時任務很傷腦筋
因此,我們非常需要一個集中管理定時任務系統
2)github官網
https://github.com/shunfei/cronsun
3)架構圖
cronsun的重要組件:
cronsun架構圖
二、環境准備
1.1)單節點安裝etcd服務
下載安裝包,下載地址:https://github.com/etcd-io/etcd/releases wget https://github.com/etcd-io/etcd/releases/download/v3.3.13/etcd-v3.3.13-linux-amd64.tar.gz 解壓文件 tar -zxvf etcd-v3.3.13-linux-amd64.tar.gz cd etcd-v3.3.13-linux-amd64 目錄下有兩個可執行文件etcd 和 etcdctl cp etcd /usr/bin/ cp etcdctl /usr/bin/ 配置服務 # vim /usr/lib/systemd/system/etcd.service (添加以下內容) [Unit] Description=Etcd Server After=network.target [Service] Type=simple WorkingDirectory=/var/lib/etcd/ EnvironmentFile=-/etc/etcd/etcd.conf ExecStart=/usr/bin/etcd [Install] WantedBy=multi-user.target 創建工作文件夾 mkdir -p /var/lib/etcd mkdir -p /etc/etcd vim /etc/etcd/etcd.conf (添加以下內容) #[member] ETCD_NAME=default ETCD_DATA_DIR="/var/lib/etcd/default.etcd" ETCD_LISTEN_CLIENT_URLS="http://127.0.0.1:2379" ETCD_ADVERTISE_CLIENT_URLS="http://127.0.0.1:2379"
1.2)啟動服務。
systemctl daemon-reload systemctl enable etcd.service systemctl start etcd.service 測試服務狀態: etcdctl cluster-health [root@node01 ~]# etcdctl cluster-health member 8e9e05c52164694d is healthy: got healthy result from http://127.0.0.1:2379 cluster is healthy
2)單節點mongodb的安裝
https://www.cnblogs.com/linu/articles/10135432.html
三、部署 cronsun 任務管理器
1)下載並安裝
1 下載 cronsun:https://github.com/shunfei/cronsun/releases (選擇最新版本即可) https://github.com/shunfei/cronsun/releases/download/v0.3.5/cronsun-v0.3.5-linux-amd64.zip 2 解壓后修改 conf 目錄下的配置文件:db.json 和 etcd.json,分別修改 MongoDB 和 etcd 的實際地址。 由於是單節點安裝。所以不需要進行修改 3 啟動 web:./cronweb -conf conf/base.json (若要后台運行則使用 nohup) nohup /usr/local/cronsun-v0.3.5/cronweb -conf /usr/local/cronsun-v0.3.5/conf/base.json & 4 啟動 node:./cronnode -conf conf/base.json (若要后台運行則使用 nohup) nohup /usr/local/cronsun-v0.3.5/cronnode -conf /usr/local/cronsun-v0.3.5/conf/base.json & 5 訪問前台:http://x.x.x.x:7079/ui/ 默認用戶密碼: admin@admin.com / admin
2)訪問 web界面
四、任務管理的基本使用
1) 查看所以節點,進行分組
2)添加任務