Docker部署PPGO(定时任务系统)

Docker部署PPGO(定时任务系统)

Scroll Down

PPGO定时任务系统简介

PPGo_Job定时任务管理系统是一款可视化的任务管理系统,支持多人多角色多权限,支持一任务多服务器同时执行,系统基于golang开发,后端采用beego框架,前端使用layui
任务类型:
1、PHP,Python,Shell,Java,Go等常见编程语言的定时任务管理
2、支持各类unix服务器的各种命令等
3、不仅支持定时任务的管理,也支持常驻任务的管理或者监控
4、支持一个任务多个执行器同时执行或者轮询执行

安装PPGO

[ppgo安装包](链接:https://pan.baidu.com/s/112LMeFF-pc9kALiwLl8Jsw 提取码:lwsd)

上传ppgo.tar.gz并解压

[root@v1 ~]# cd /opt
[root@v1 opt]# rz   #上传ppgo.tar.gz文件
[root@v1 opt]# tar xf ppgo.tar.gz
[root@v1 opt]# ls
 ppgo  ppgo.tar.gz
[root@v1 opt]# cd ppgo
[root@v1 opt]#  ls
conf  docker-compose.yml  PPGo_Job  ppgo_job2.sql  static  views

配置数据库

这里使用已创建的mysql5.7,如没有ppgo_job库需创建该库

[root@v1 ~]# mysql -uroot -p123456 -Dppgo_job < /root/ppgo_job2.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost ~]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 300
Server version: 5.7.29 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| itop               |
| mysql              |
| performance_schema |
| ppgo_job           |
| sys                |
+--------------------+
6 rows in set (0.00 sec)

mysql> use ppgo_job
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+----------------------+
| Tables_in_ppgo_job   |
+----------------------+
| pp_notify_tpl        |
| pp_task              |
| pp_task_ban          |
| pp_task_group        |
| pp_task_log          |
| pp_task_server       |
| pp_task_server_group |
| pp_uc_admin          |
| pp_uc_auth           |
| pp_uc_role           |
| pp_uc_role_auth      |
+----------------------+
11 rows in set (0.00 sec)

mysql> \q
Bye

ppgo配置文件

[root@v1 conf]# pwd
/opt/ppgo/conf
[root@v1 conf]# ls
app.conf
[root@v1 conf]# cat app.conf
AppName = PPGo_Job2
HTTPPort = 8080
RunMode = prod
SessionOn = true
version= V2.8
# 允许同时运行的任务数
jobs.pool = 1000

# 站点名称
site.name = 定时任务管理器

#通知方式 0=邮件,1=信息,2=钉钉,3=微信
notify.type = 0

# 数据库配置
db.host = 192.168.200.100
db.user = root
db.password = "123456"
db.port = 3306
db.name = ppgo_job
db.prefix = pp_
db.timezone = Asia/Shanghai

# 邮件通知配置
email.host = smtp.exmail.qq.com
email.port = 465
email.from = ******
email.user = ******
email.password = "******"
email.pool = 10

# 短信通知方式配置
msg.url = http://xx.com/api/tools/send_sms
msg.pool = 10

# 钉钉通知配置
dingtalk.url = "https://oapi.dingtalk.com/robot/send?access_token=%s"
dingtalk.pool = 10

# 微信通知方式配置
wechat.url = http://xx.com/api/tools/send_wechat
wechat.pool = 10

docker-compose && Dockerfile

[root@k8s-op-nfs ppgo]# cat docker-compose.yml
version: '3.7'
services:
  web:
    build:
      context: .
      dockerfile: .docker/web_new/Dockerfile
    volumes:
      - /etc/localtime:/etc/localtime
    ports:
      - "8080:8080" # http
      # - "443:443" # https
    # file with environment declarations for the container
    env_file:
      - .docker/web/.env
    # Link to containers in another service
    command: ["./wait-for-it.sh", "192.168.200.100:3306", "--", "./PPGo_Job"]
[root@k8s-op-nfs ppgo]# cat .docker/web_new/Dockerfile
FROM registry.cn-hangzhou.aliyuncs.com/jimu/ppgo:base
COPY conf/ ./conf/
COPY static ./static
COPY views ./views
ADD PPGo_Job .
CMD ["./PPGo_Job"]    

运行PPGO

[root@v1 ppgo]# docker-compose up -d
Creating network "ppgo_default" with the default driver
Building web
Step 1/6 : FROM registry.cn-hangzhou.aliyuncs.com/jimu/ppgo:base
base: Pulling from jimu/ppgo
c87736221ed0: Pull complete
5187536719e4: Pull complete
f8e7029892b7: Pull complete
Digest: sha256:00f559634877e9ceca381647cd2fbdd8978bf3d79d5837ce0ef24817c7055383
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/jimu/ppgo:base
 ---> 706be5156705
Step 2/6 : COPY conf/ ./conf/
 ---> d3f3ffb6a857
Step 3/6 : COPY static ./static
 ---> 431bb4c5ca8a
Step 4/6 : COPY views ./views
 ---> 14449b75e5e3
Step 5/6 : ADD PPGo_Job .
 ---> c01794938faf
Step 6/6 : CMD ["./PPGo_Job"]
 ---> Running in d727b2bfe637
Removing intermediate container d727b2bfe637
 ---> f549166cf2ad

Successfully built f549166cf2ad
Successfully tagged ppgo_web:latest
WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating ppgo_web_1 ... done
[root@v1 ppgo]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                             NAMES
ea637aa92397        ppgo_web            "./wait-for-it.sh 19…"   2 minutes ago       Up 2 minutes        443/tcp, 0.0.0.0:8080->8080/tcp   ppgo_web_1

访问PPGO web界面

URL:http://IP:8080
用户名:admin 密码:123456
ppgo1.png

PPGO工作方式

PPGO_agent zip包地址:链接:https://pan.baidu.com/s/1YF1WRkySynNDbFqS_f1A0A
提取码:j303
1、任务调度管理层:
简称master,包含任务调度,系统页面,出错通知和日志管理等功能。master是系统老板,负责分配别人干活,验收,出错通报等等…
2、执行层:
简称actuator,或者叫执行器。具体包含四种执行器:agent执行器(推荐)、本地执行器、ssh执行器以及telnet执行器(windows),actuator就是员工,负责接收老板指令,完成情况及时汇报。
2-1本地执行器:
相对于master来说的,和master部署在一起,也就是说,仅部署master也是可以执行本地服务器的定时任务
2-2ssh执行器:
自从有了ssh执行器,master可以通过ssh的方式连接其他服务器,管理和执行其他服务器的定时任务
2-3telnet执行器:
ssh执行器受限于linux系统,windows系统就不好使了,所以master使用telnet的方式连接其他windows服务器执行任务
2-4 agnet执行器:
V2.8新增功能,与其他三个不同的是,agent需要单独部署到目标服务器或者容器上,自动注册到master执行资源中,支持linux、mac和windows。因其部署简单,自动注册,资源占用少,通信可靠,强烈推荐使用