cronsun 集群部署

cronsun:
是一个分布式任务系统,单个节点和 Linux 机器上的 crontab 近似.是为了解决多台 Linux  机器上 crontab 任务管理不方便的问题,同时提供任务高可用的支持(当某个节点死机的时候可以自动调度到正常的节点执行).支持界面管理机器上的任务,支持任务失败邮件提醒,安装简单,使用方便,是替换 crontab 一个不错的选择.


环境:
VM centos7(192.168.153.131 192.168.153.132 192.168.153.133)  docker-compose docker quay.io/coreos/etcd  etcdctl version: 3.3.7 API version: 2


资源:
etcd:
docker search etcd   quay.io/coreos/etcd
mongodb
docker search mongo   docker.io/mongo:3.4
cronsun
https://github.com/shunfei/cronsun/releases


etcd 


0x01. 分别(192.168.153.131 192.168.153.132 192.168.153.133) 获取etcd镜像  docker pull quay.io/coreos/etcd


0x02. 192.168.153.131


docker run --restart always -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \
--name etcd quay.io/coreos/etcd \
etcd \
--name etcd0 \
--advertise-client-urls http://192.168.153.131:2379,http://192.168.153.131:4001 \
--listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
--initial-advertise-peer-urls http://192.168.153.131:2380 \
--listen-peer-urls http://0.0.0.0:2380 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster etcd0=http://192.168.153.131:2380,etcd1=http://192.168.153.132:2380,etcd2=http://192.168.153.133:2380 \
--initial-cluster-state new


0x03. 192.168.153.132


docker run --restart always -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \
--name etcd quay.io/coreos/etcd \
etcd \
--name etcd1 \
--advertise-client-urls http://192.168.153.132:2379,http://192.168.153.132:4001 \
--listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
--initial-advertise-peer-urls http://192.168.153.132:2380 \
--listen-peer-urls http://0.0.0.0:2380 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster etcd0=http://192.168.153.131:2380,etcd1=http://192.168.153.132:2380,etcd2=http://192.168.153.133:2380 \
--initial-cluster-state new


0x04. 192.168.153.133


docker run --restart always -d -v /usr/share/ca-certificates/:/etc/ssl/certs -p 4001:4001 -p 2380:2380 -p 2379:2379 \
--name etcd quay.io/coreos/etcd \
etcd \
-name etcd2 \
--advertise-client-urls http://192.168.153.133:2379,http://192.168.153.133:4001 \
--listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 \
--initial-advertise-peer-urls http://192.168.153.133:2380 \
--listen-peer-urls http://0.0.0.0:2380 \
--initial-cluster-token etcd-cluster-1 \
--initial-cluster etcd0=http://192.168.153.131:2380,etcd1=http://192.168.153.132:2380,etcd2=http://192.168.153.133:2380 \
--initial-cluster-state new




mongdb


0x01. 获取mongo镜像  docker pull docker.io/mongo


0x02. 编写docker-compose 文件 docker-compose.yml


version: '2'
services:
  master:
    ports:
      - "27017:27017"
    image: mongo:3.4
    volumes:
      - /home/workspace/tmp/docker/data/mongodb3.4/rs1:/data/db:z
    command: mongod --dbpath /data/db --replSet newset --oplogSize 128
  slave:
    ports:
      - "27018:27017"
    image: mongo:3.4
    volumes:
      - /home/workspace/tmp/docker/data/mongodb3.4/rs2:/data/db:z
    command: mongod --dbpath /data/db --replSet newset --oplogSize 128
  myarbiter:
    ports:
      - "27019:27017"
    image: mongo:3.4
    volumes:
      - /home/workspace/tmp/docker/data/mongodb3.4/rs3:/data/db:z
    command: mongod --dbpath /data/db --replSet newset --smallfiles --oplogSize 128




0x03. 到docker-compose.yml 文件所在目录执行 docker-compose up


0x04. 确定主从和裁决关系 docker-compose exec master mongo  rs.initiate() rs.add('slave:27017') rs.add('myarbiter:27017',true) use test db.test.insert({msg: 'this is from primary', ts: new Date()})


0x05. 确定主从和裁决关系 docker-compose exec slave mongo rs.slaveOk() use test db.test.find()


0x06. 确定主从和裁决关系 rs.slaveOk() use test db.test.find()


#不确立主从关系 cronsun 项目无法启动


cronsun


0x01. 下载cronsun https://github.com/shunfei/cronsun/releases/download/v0.3.2/cronsun-v0.3.2-linux-amd64.zip -o cronsun-v0.3.2-linux-amd64.zip
0x02. conf 目录下的配置文件:db.json 和 etcd.json,分别修改 MongoDB 和 etcd 的实际地址
0x03. 启动 web:./cronweb -conf conf/base.json  启动 node:./cronnode -conf conf/base.json 
0x04. 访问前台:http://x.x.x.x:7079/ui/


参考文献:
https://www.cnblogs.com/zhangeamon/p/6139964.html
https://blog.csdn.net/zone_/article/details/79238349
https://zhangge.net/5129.html
阅读更多

扫码向博主提问

写回

非学,无以致疑;非问,无以广识
去开通我的Chat快问
想对作者说点什么?
相关热词

博主推荐

换一批

没有更多推荐了,返回首页