Ubuntu 20.04 安装 xxl-job 2.3.1 任务调度系统

配置过程需要全程链接外部网络

1.apt install net-tools                    #习惯问题
2.apt install ssh                            #方便远程安装操作
3.apt install vim -y                        #可以选择性安装
4.apt install maven                       #默认会安装 openjdk11  不需要单独配置jdk

 


查看安装后的版本情况
mvn -v

root@ibe-jobs:~# mvn -v
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.17, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-58-generic", arch: "amd64", family: "unix"


更换源、更新升级
备份
cp /etc/apt/sources.list /etc/apt/sources.list.bak

编辑vi /etc/apt/sources.list,更换成国内源                       # 推荐 阿里云 或者 华为 

 

# deb cdrom:[Ubuntu 20.04.5 LTS _Focal Fossa_ - Release amd64 (20220831)]/ focal main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.huaweicloud.com/repository/ubuntu/ focal main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.huaweicloud.com/repository/ubuntu/ focal-updates main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.huaweicloud.com/repository/ubuntu/ focal universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal universe
deb http://mirrors.huaweicloud.com/repository/ubuntu/ focal-updates universe
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
## team, and may not be under a free licence. Please satisfy yourself as to 
## your rights to use the software. Also, please note that software in 
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.huaweicloud.com/repository/ubuntu/ focal multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://mirrors.huaweicloud.com/repository/ubuntu/ focal-updates multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.huaweicloud.com/repository/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://mirrors.huaweicloud.com/repository/ubuntu/ focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://mirrors.huaweicloud.com/repository/ubuntu/ focal-security universe
# deb-src http://security.ubuntu.com/ubuntu focal-security universe
deb http://mirrors.huaweicloud.com/repository/ubuntu/ focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.


/apt/ 文件保存


将mysql 源 copy到 /etc/apt/sources.list.d   

mysql-community.list

# Ubuntu 20.04 LTS
deb https://mirrors.tuna.tsinghua.edu.cn/mysql/apt/ubuntu focal mysql-5.7 mysql-8.0 mysql-tools

# Ubuntu 18.04 LTS
deb https://mirrors.tuna.tsinghua.edu.cn/mysql/apt/ubuntu bionic mysql-5.7 mysql-8.0 mysql-tools

# Ubuntu 16.04 LTS
deb https://mirrors.tuna.tsinghua.edu.cn/mysql/apt/ubuntu xenial mysql-5.6 mysql-5.7 mysql-8.0 mysql-tools

# Ubuntu 14.04 LTS
deb https://mirrors.tuna.tsinghua.edu.cn/mysql/apt/ubuntu trusty mysql-5.6 mysql-5.7 mysql-8.0 mysql-tools

更新源一下:

sudo apt-get update 

更新过程或显示缺失key  安装就行

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29

sudo apt-get update  

apt-cache policy mysql-server


安装 mysql 5.7   

#为什么不安装默认的 mysql 8.0  主要是 jdbc 的驱动问题。

sudo apt install mysql-community-client=5.7.41-1ubuntu18.04
sudo apt install mysql-client=5.7.41-1ubuntu18.04

sudo apt install mysql-community-server=5.7.41-1ubuntu18.04

这里输入 mysql root密码  123456     # 这里的密码需要和后面xxl-job 的密码统一

sudo apt install mysql-server=5.7.41-1ubuntu18.04

安装完毕检查,安装后的软件情况
dpkg -l | grep mysql


root@ibe-jobs:/opt# dpkg -l | grep mysql
ii  libmysqlclient21:amd64                     8.0.30-0ubuntu0.20.04.2             amd64        MySQL database client library
ii  mysql-client                               5.7.41-1ubuntu18.04                 amd64        MySQL Client meta package depending on latest version
ii  mysql-common                               5.8+1.0.5ubuntu2                    all          MySQL database common files, e.g. /etc/mysql/my.cnf
ii  mysql-community-client                     5.7.41-1ubuntu18.04                 amd64        MySQL Client
ii  mysql-community-server                     5.7.41-1ubuntu18.04                 amd64        MySQL Server
ii  mysql-server                               5.7.41-1ubuntu18.04                 amd64        MySQL Server meta package depending on latest version

开始解压安装  xxl-job 
将压缩文件放到/opt 下
cd /opt

tar -zxvf xxl-job-2.3.1.tar.gz 

cd xxl-job-2.3.1/


vi xxl-job-admin/src/main/resources/application.properties

1.web端口,如果有冲突,一定要更换(本文采用默认8080)

server.port=8080

2.修改数据库信息

spring.datasource.url=jdbc:mysql://deptestxx:3306/xxl-job?Unicode=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=123456(修改成MySQL密码)


开始导入 xxl-job 数据库   导入的时候注意数据库文件的实际路径 

mysql -uroot -p123456 < /opt/xxl-job-2.3.1/doc/db/tables_xxl_job.sql


查看 mysql 数据导入情况   xxl-job 一共有8个表 确认是否完全正常

mysql -uroot -p123456

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| xxl_job            |
+--------------------+
5 rows in set (0.00 sec)

mysql> use xxl_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_xxl_job  |
+--------------------+
| xxl_job_group      |
| xxl_job_info       |
| xxl_job_lock       |
| xxl_job_log        |
| xxl_job_log_report |
| xxl_job_logglue    |
| xxl_job_registry   |
| xxl_job_user       |
+--------------------+
8 rows in set (0.00 sec)

mysql> quit;

开始使用maven 打包   过程有点长 20-30分钟 左右

mvn package

启动  xxl-job

# 具体的 xxl-job-admin-2.3.1.jar  需要跟进自己的实际生成文件做调整 


nohup java -jar /opt/xxl-job-2.3.1/xxl-job-admin/target/xxl-job-admin-2.3.1.jar &


nohup java -jar /opt/xxl-job-2.3.1/xxl-job-executor-samples/xxl-job-executor-sample-springboot/target/xxl-job-executor-sample-springboot-2.3.1.jar &


ps aux|grep java


root@ibe-jobs:/opt/xxl-job-2.3.1# ps aux|grep java
root       31456  179  5.2 7483888 427796 pts/1  Sl   10:41   0:21 java -jar /opt/xxl-job-2.3.1/xxl-job-admin/target/xxl-job-admin-2.3.1.jar
root       31596  232  3.8 7134684 310836 pts/1  Sl   10:41   0:13 java -jar /opt/xxl-job-2.3.1/xxl-job-executor-samples/xxl-job-executor-sample-springboot/target/xxl-job-executor-sample-springboot-2.3.1.jar
root       31717  0.0  0.0  17556   656 pts/1    R+   10:41   0:00 grep --color=auto java

查看端口情况

netstat -tunlp
root@ibe-jobs:/opt/xxl-job-2.3.1# netstat -tunlp
激活Internet连接 (仅服务器)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      767/systemd-resolve 
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      804/cupsd           
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      14583/mysqld        
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      919/sshd: /usr/sbin 
tcp6       0      0 :::8081                 :::*                    LISTEN      31596/java          
tcp6       0      0 :::8080                 :::*                    LISTEN      31456/java          
tcp6       0      0 ::1:631                 :::*                    LISTEN      804/cupsd           
tcp6       0      0 :::9999                 :::*                    LISTEN      31596/java          
tcp6       0      0 :::22                   :::*                    LISTEN      919/sshd: /usr/sbin 
udp        0      0 127.0.0.53:53           0.0.0.0:*                           767/systemd-resolve 
udp        0      0 0.0.0.0:631             0.0.0.0:*                           866/cups-browsed    
udp        0      0 0.0.0.0:42131           0.0.0.0:*                           797/avahi-daemon: r 
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           797/avahi-daemon: r 
udp6       0      0 :::56684                :::*                                797/avahi-daemon: r 
udp6       0      0 :::5353                 :::*                                797/avahi-daemon: r 
root@ibe-jobs:/opt/xxl-job-2.3.1# 

确认完全启动之后  打开

http://IP:8080/xxl-job-admin/

默认用户名 密码     admin/123456

Ubuntu 20.04 安装 xxl-job 2.3.1 任务调度系统_第1张图片

 

Ubuntu 20.04 安装 xxl-job 2.3.1 任务调度系统_第2张图片

 

##########################开机自动启动脚本设置###########################################

开机自动启动脚本设置

由于ubuntu20.04LST 没有/etc/rc.local,需要创建一个.sh文件

sudo vi /etc/rc.local

脚本内容为

root@ibe-jobs:/etc/ssh# more /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

#source /etc/profile

nohup java -jar /opt/xxl-job-2.3.1/xxl-job-admin/target/xxl-job-admin-2.3.1.jar &
nohup java -jar /opt/xxl-job-2.3.1/xxl-job-executor-samples/xxl-job-executor-sample-springboot/target/xxl-job-executor-sample-springboot-2.3.1.jar &
exit 0


给脚本赋权限

sudo chmod +x /etc/rc.local

完成脚本编写后需要启动rc.local.service,命令如下

sudo vi /lib/systemd/system/rc-local.service

rc.local.service的内容如下


在文件下面添加如下内容,并且修改ExecStart

[Service]
ExecStart=/etc/rc.local start
[Install]
WantedBy=multi-user.target

执行

systemctl enable rc-local
systemctl start rc-local.service  #启动服务
systemctl status rc-local.service #查看状态


root@ibe-jobs:~# systemctl status rc-local.service 
● rc-local.service - /etc/rc.local Compatibility
     Loaded: loaded (/lib/systemd/system/rc-local.service; enabled; vendor preset: enabled)
    Drop-In: /usr/lib/systemd/system/rc-local.service.d
             └─debian.conf
     Active: active (running) since Sat 2023-01-28 09:58:13 CST; 46min ago
       Docs: man:systemd-rc-local-generator(8)
    Process: 1091 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
      Tasks: 114 (limit: 9408)
     Memory: 773.1M
     CGroup: /system.slice/rc-local.service
             ├─1093 java -jar /opt/xxl-job-2.3.1/xxl-job-admin/target/xxl-job-admin-2.3.1.jar
             └─1094 java -jar /opt/xxl-job-2.3.1/xxl-job-executor-samples/xxl-job-executor-sample-springboot/target/xxl-job-executor-sample-springboot-2.3.1.jar

你可能感兴趣的:(服务器,ubuntu,运维,服务器)