定时任务管理工具cronsun部署

官方文档:https://github.com/shunfei/cronsun/wiki
几种常用的工具对比https://blog.csdn.net/ra681t58cjxsgckj31/article/details/78851749
cronsun依赖mongo和etcd,因为etcd的docker镜像(elcolio/etcd)已经3年没有更新了,所以mongo通过docker部署,etcd在宿主机安装。

安装mongo

#运行mongo容器
docker run --name cronsun-mongodb -p 892:27017 -v /data/docker/cronsun_mongo/configdb:/data/configdb/ -v /data/docker/cronsun_mongo/db/:/data/db/  --restart always -d mongo

#通过admin进入mongo命令
docker exec -it  cronsun-mongodb  mongo admin

#添加admin用户并设置密码
db.createUser({ user: 'admin', pwd: 'password', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });

 

安装etcd

wget https://github.com/etcd-io/etcd/releases/download/v3.3.13/etcd-v3.3.13-linux-amd64.tar.gz

tar -xvf etcd-v3.3.13-linux-amd64.tar.gz

cd etcd-v3.3.13-linux-amd64

nohup ./etcd --advertise-client-urls=http://0.0.0.0:891 --listen-client-urls=http://0.0.0.0:891 --data-dir=/data/etcd/data   >/dev/null 2>&1 &

#添加用户密码
./etcdctl --endpoints http://127.0.0.1:891 user add root

#开启认证
./etcdctl --endpoints http://127.0.0.1:891 auth enable

 

 

其他etcd常用命令

顺序步骤命令
1 添加root用户 etcdctl --endpoints http://: user add root
2 开启认证 etcdctl --endpoints http://: auth enable
3 添加非root用户 etcdctl --endpoints http://: –username root: user add
4 添加角色 etcdctl --endpoints http://: –username root: role add
5 给角色授权(只读、只写、可读写) etcdctl --endpoints http://: –username root: role grant --readwrite --path
6 给用户分配角色(即分配了角色对应的权限) etcdctl --endpoints http://: –username root: user grant --roles

启动cronsun

下载解压

wget https://github.com/shunfei/cronsun/releases/download/v0.3.5/cronsun-v0.3.5-linux-amd64.zip

unzip cronsun-v0.3.5-linux-amd64.zip

cd cronsun-v0.3.5-linux-amd64

 

修改conf中对应的配置文件,主要是etcd和db两个
启动

nohup ./cronweb -conf conf/base.json > /dev/null 2>&1 &
nohup ./cronnode -conf conf/base.json > /dev/null 2>&1 &

 

如果要添加新的节点只需拷贝该文件夹,修改etcd和db中对应的配置,执行cronnode即可。

posted @ 2020-10-15 10:04  技术颜良  阅读(641)  评论(0编辑  收藏  举报