初始化数据库

https://www.xuxueli.com/xxl-job/#2.1%20%E5%88%9D%E5%A7%8B%E5%8C%96%E2%80%9C%E8%B0%83%E5%BA%A6%E6%95%B0%E6%8D%AE%E5%BA%93%E2%80%9D

请下载项目源码并解压,获取 “调度数据库初始化SQL脚本” 并执行即可。

https://github.com/xuxueli/xxl-job/releases

“调度数据库初始化SQL脚本” 位置为:

/xxl-job/doc/db/tables_xxl_job.sql

调度中心支持集群部署,集群情况下各节点务必连接同一个mysql实例;

K8s 部署

在服务器根目录下,创建 xxl-job-admin.yaml 文件,文件内容为:

---
kind: ConfigMap
apiVersion: v1
metadata:
  name: xxl-job-cm
  annotations:
    kubesphere.io/creator: admin
data:
  db.password: AuQ43hnPioZX#JW
  db.url: >-
    jdbc:mysql://192.168.3.30:3306/xxl_job?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai
  db.username: xxl_job
---
apiVersion: v1
kind: Service
metadata:
  name: xxl-job-admin-svc
  namespace: dw-prod
  annotations:
    kubesphere.io/alias-name: XXL-JOB 调度中心服务
    kubesphere.io/description: XXL-JOB 调度中心服务
spec:
  ports:
    - name: tcp-8080
      port: 8080
      protocol: TCP
      targetPort: 8080
  selector:
    app: xxl-job-admin
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: xxl-job-admin-deploy
  namespace: dw-prod
  annotations:
    kubesphere.io/alias-name: XXL-JOB 调度中心服务
    kubesphere.io/description: XXL-JOB 调度中心服务
  labels:
    app: xxl-job-admin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: xxl-job-admin
  template:
    metadata:
      labels:
        app: xxl-job-admin
    spec:
      containers:
        - name: xxl-job-admin
          image: 'xuxueli/xxl-job-admin:2.3.1'
          ports:
            - name: http-8080
              containerPort: 8080
              protocol: TCP
          env:
            - name: SPRING_DATASOURCE_URL
              valueFrom:
                configMapKeyRef:
                  name: xxl-job-cm
                  key: db.url
            - name: SPRING_DATASOURCE_USERNAME
              valueFrom:
                configMapKeyRef:
                  name: xxl-job-cm
                  key: db.username
            - name: SPRING_DATASOURCE_PASSWORD
              valueFrom:
                configMapKeyRef:
                  name: xxl-job-cm
                  key: db.password
          imagePullPolicy: Always

使用 kubectl 执行如下命令部署 xxl-job-admin 服务 :

kubectl create -f xxl-job-admin.yaml --namespace=你的命名空间

kubectl create -f xxl-job-admin.yaml --namespace=dw-prod

作者:Jeebiz  创建时间:2023-01-11 11:52
最后编辑:Jeebiz  更新时间:2023-04-17 00:21