DolphinScheduler3.0部署手册
1 前言
1.1 参考资料
DolphinScheduler官网:https://dolphinscheduler.apache.org/zh-cn/index.html
1.2架构说明
本手册目的是在一台服务器上部署伪集群,系统配置如下:
系统 | CPU | 内存 | 硬盘 |
---|---|---|---|
CentOS7.9 | 8 | 16G | 300G |
1.3 软件准备
注意: DolphinScheduler 本身不依赖 Hadoop、Hive、Spark,但如果你运行的任务需要依赖他们,就需要有对应的环境支持,否则在配置中可以注释掉,软件清单及下载方式如下:
JDK:1.8 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html
MySQL:8 下载地址:https://dev.mysql.com/downloads/mysql/
Zookeeper:3.7 下载地址:https://zookeeper.apache.org/releases.html#download
DolphinScheduler:3.0 下载地址:https://dolphinscheduler.apache.org/zh-cn/download/download.html
由于MySQL数据源的JDBC驱动和Apache LICENSE V2不兼容,需要提前下载mysql-connector-java-8.0.16.jar驱动,下载地址:
https://repo1.maven.org/maven2/mysql/mysql-connector-java/
1.4 软件部署顺序
JDK--》MySQL--》Zookeeper--》DolphinScheduler
2 JDK部署
[root@localhost data]# tar -zxvf jdk-8u341-linux-x64.tar.gz -C /usr/local/
[root@localhost data]# vim /etc/profile
#jdk
export JAVA_HOME=/usr/local/jdk1.8.0_341/
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
添加后保存退出
[root@localhost data]# source /etc/profile
3 数据库安装
3.1删除系统自带的数据库
(没有就不用管)
[root@localhost data]# rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@localhost data]# yum remove mariadb-libs-5.5.68-1.el7.x86_64 -y
3.2安装MySQL
[root@localhost data]# tar -xvf mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz
[root@localhost data]# mv mysql-8.0.30-linux-glibc2.12-x86_64 /usr/local/mysql
[root@localhost data]# groupadd mysql
[root@localhost data]# useradd -r -g mysql -s /sbin/nologin mysql
[root@localhost data]# mkdir /data/mysql -p
[root@localhost data]# mkdir /usr/local/mysql/etc -p
[root@localhost data]# mkdir /var/run/mysql/
[root@localhost data]# chown -R mysql:mysql /usr/local/mysql/
[root@localhost data]# chown -R mysql:mysql /data/mysql
[root@localhost data]# chown -R mysql:mysql /var/run/mysql/
3.3编辑配置
[root@localhost data]# vim /usr/local/mysql/etc/my.cnf
[client]
port=3306
socket=/var/run/mysql/mysql.sock
[mysqld]
user=mysql
port=3306
bind-address=0.0.0.0
datadir=/data/mysql
basedir=/usr/local/mysql
socket=/var/run/mysql/mysql.sock
pid-file=/var/run/mysql/mysql.pid
default-storage-engine=INNODB
character_set_server=utf8mb4
lower_case_table_names=1
table_open_cache=128
max_connections=1200
max_connect_errors=1000
innodb_file_per_table=1
innodb_buffer_pool_size=1G
max_allowed_packet=64M
transaction_isolation=READ-COMMITTED
innodb_flush_method=O_DIRECT
innodb_lock_wait_timeout=1800
innodb_flush_log_at_trx_commit=0
sync_binlog=0
symbolic-links=0
explicit_defaults_for_timestamp=true
server-id=1
log-error=/data/mysql/mysql.err
log-bin=mysql-bin
expire_logs_days = 7
binlog_format=mixed
slow_query_log=1
long_query_time=10
slow_query_log_file=/data/mysql/mysql-slow.log
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
skip-name-resolve
[mysql]
default-character-set=utf8mb4
[mysql.server]
default-character-set=utf8mb4
3.4初始化数据
[root@localhost data]# cd /usr/local/mysql/bin
[root@localhost bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --lower-case-table-names=1
[root@localhost bin]# tailf /data/mysql/mysql.err
[root@localhost bin]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost bin]# /etc/init.d/mysqld start
[root@localhost bin]# vim /etc/profile
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
[root@localhost bin]# source /etc/profile
3.5登录MySQL修改权限
[root@localhost bin]# mysql -uroot -p
mysql> alter user 'root'@'localhost' identified by 'Mypasswd123!';
mysql> use mysql;
mysql> create user 'root'@'%' identified by 'Mypasswd123!';
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
mysql> select host, user, authentication_string, plugin from user;
4 Zookeeper安装
4.1安装
[root@localhost ~]# cd /data/
[root@localhost data]# tar -zxvf apache-zookeeper-3.7.1-bin.tar.gz
[root@localhost data]# mv apache-zookeeper-3.7.1-bin zookeeper
4.2修改配置
[root@localhost data]# cd zookeeper/conf/
[root@localhost conf]# cp -a zoo_sample.cfg zoo.cfg
并将 conf/zoo.cfg 中 dataDir 中的值改成 dataDir=./tmp/zookeeper,不然启动会报错
4.3启动
[root@localhost conf]# cd ..
[root@localhost zookeeper]# ./bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /data/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@localhost zookeeper]# netstat -nplt|grep 2181
tcp6 0 0 :::2181 :::* LISTEN 2736/java
5 DolphinScheduler安装
5.1 准备启动环境
解压二进制包
[root@localhost zookeeper]# cd /data/
[root@localhost data]# tar -zxvf apache-dolphinscheduler-3.0.0-bin.tar.gz
创建用户
[root@localhost data]# useradd dolphinscheduler
添加密码
[root@localhost data]# echo "DolphinScheduler@2022" | passwd --stdin dolphinscheduler
更改用户 dolphinscheduler 的密码 。
passwd:所有的身份验证令牌已经成功更新。
修改目录权限,使得部署用户对二进制包解压后的 apache-dolphinscheduler-*-bin 目录有操作权限
[root@localhost data]# chown -R dolphinscheduler:dolphinscheduler apache-dolphinscheduler-3.0.0-bin
配置 sudo 免密(因为任务执行服务是以 sudo -u {linux-user} 切换不同 linux 用户的方式来实现多租户运行作业,所以部署用户需要有 sudo 权限,而且是免密的)
[root@localhost data]# sed -i '$adolphinscheduler ALL=(ALL) NOPASSWD: NOPASSWD: ALL' /etc/sudoers
[root@localhost data]# sed -i 's/Defaults requirett/#Defaults requirett/g' /etc/sudoers
5.2 配置机器SSH免密登陆
[root@localhost data]# su dolphinscheduler
[dolphinscheduler@localhost data]$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
[dolphinscheduler@localhost data]$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[dolphinscheduler@localhost data]$ chmod 600 ~/.ssh/authorized_keys
[dolphinscheduler@localhost data]$ ssh dolphinscheduler@localhost
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is SHA256:vl+WY6uESNw7u0uhjurbKEtePiKOIEAvfS66t1WHamo.
ECDSA key fingerprint is MD5:89:96:ed:68:86:0d:a6:cb:8c:28:0a:e5:5e:44:ae:17.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
Last login: Tue Oct 11 10:57:07 2022
[dolphinscheduler@localhost ~]$ exit
登出
Connection to localhost closed.
[dolphinscheduler@localhost data]$ exit
exit
[root@localhost data]#
5.3 修改相关配置
完成基础环境的准备后,需要根据你的机器环境修改配置文件。配置文件可以在目录 bin/env 中找到,他们分别是install_env.sh 和 dolphinscheduler_env.sh。
配置install_env.sh
[root@localhost data]# cd /data/apache-dolphinscheduler-3.0.0-bin/
[root@localhost apache-dolphinscheduler-3.0.0-bin]# vim bin/env/install_env.sh
#sshPort请按照实际端口填写
ips="localhost"
sshPort="22"
masters="localhost"
workers="localhost:default"
alertServer="localhost"
apiServers="localhost"
# DolphinScheduler installation path, it will auto-create if not exists
installPath=~/dolphinscheduler
# Deploy user, use the user you create in section **Configure machine SSH password-free login**
deployUser="dolphinscheduler"
zkRoot=${zkRoot:-"/dolphinscheduler"}
配置dolphinscheduler_env.sh
[root@localhost apache-dolphinscheduler-3.0.0-bin]# vim bin/env/dolphinscheduler_env.sh
# JAVA_HOME, will use it to start DolphinScheduler server
export JAVA_HOME="/usr/local/jdk1.8.0_341"
# Database related configuration, set database type, username and password
export DATABASE="mysql"
export SPRING_PROFILES_ACTIVE=${DATABASE}
export SPRING_DATASOURCE_URL="jdbc:mysql://127.0.0.1:3306/dolphinscheduler?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true"
export SPRING_DATASOURCE_USERNAME=dolphinscheduler
export SPRING_DATASOURCE_PASSWORD=DolphinScheduler@2022
# DolphinScheduler server related configuration
export SPRING_CACHE_TYPE="none"
export SPRING_JACKSON_TIME_ZONE="Asia/Shanghai"
export MASTER_FETCH_COMMAND_NUM="10"
# Registry center configuration, determines the type and link of the registry center
export REGISTRY_TYPE="zookeeper"
export REGISTRY_ZOOKEEPER_CONNECT_STRING="localhost:2181"
5.4 添加MySQL驱动
mysql-connector-java驱动移动到DolphinScheduler的每个模块的 libs 目录下,并将权限改成dolphinscheduler 用户的,不然无效。其中包括:
api-server/libs
alert-server/libs
master-server/libs
worker-server/libs
tools/libs
6 系统初始化
6.1 数据库初始化
登录MySQL添加dolphinscheduler用户并赋权
mysql> CREATE DATABASE dolphinscheduler DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
Query OK, 1 row affected, 2 warnings (0.02 sec)
mysql> CREATE USER 'dolphinscheduler'@'%' IDENTIFIED BY 'DolphinScheduler@2022';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON dolphinscheduler.* TO 'dolphinscheduler'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE USER 'dolphinscheduler'@'localhost' IDENTIFIED BY 'DolphinScheduler@2022';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON dolphinscheduler.* TO 'dolphinscheduler'@'localhost';
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
初始化数据库(可切换到dolphinscheduler用户操作)
[root@localhost apache-dolphinscheduler-3.0.0-bin]# bash tools/bin/upgrade-schema.sh
6.2 系统部署启动
(可跳过)可以先启动单机模式测试配置文件的可用性
启动单机模式
[root@localhost apache-dolphinscheduler-3.0.0-bin]# bash ./bin/dolphinscheduler-daemon.sh start standalone-server
关闭
[root@localhost apache-dolphinscheduler-3.0.0-bin]# bash ./bin/dolphinscheduler-daemon.sh stop standalone-server
切换到dolphinscheduler用户进行部署
[root@localhost apache-dolphinscheduler-3.0.0-bin]# su dolphinscheduler
一键部署(安装后会出现未启动情况,启动一下就好)
[dolphinscheduler@localhost apache-dolphinscheduler-3.0.0-bin]$ bash ./bin/install.sh
切换到家目录(工作目录进行操作比较好,前面的是安装目录)
[root@localhost apache-dolphinscheduler-3.0.0-bin]# cd /home/dolphinscheduler/dolphinscheduler/
启停动Master/Worker/Api/Alert
bash ./bin/dolphinscheduler-daemon.sh start master-server
bash ./bin/dolphinscheduler-daemon.sh start worker-server
bash ./bin/dolphinscheduler-daemon.sh start api-server
bash ./bin/dolphinscheduler-daemon.sh start alert-server
停止 Master/Worker/Api/Alert
bash ./bin/dolphinscheduler-daemon.sh stop master-server
bash ./bin/dolphinscheduler-daemon.sh stop worker-server
bash ./bin/dolphinscheduler-daemon.sh stop api-server
bash ./bin/dolphinscheduler-daemon.sh stop alert-server
服务启动后分别进行健康检查
[dolphinscheduler@localhost dolphinscheduler]$ curl --request GET 'http://localhost:12345/dolphinscheduler/actuator/health'
{"status":"UP","components":{"db":{"status":"UP","details":{"database":"MySQL","validationQuery":"select 1","result":1}}}}
[dolphinscheduler@localhost dolphinscheduler]$ curl --request GET 'http://localhost:5679/actuator/health'
{"status":"UP","components":{"db":{"status":"UP","details":{"database":"MySQL","validationQuery":"select 1","result":1}}}}
[dolphinscheduler@localhost dolphinscheduler]$ curl --request GET 'http://localhost:1235/actuator/health'
{"status":"UP","components":{"db":{"status":"UP","details":{"database":"MySQL","validationQuery":"select 1","result":1}}}}
[dolphinscheduler@localhost dolphinscheduler]$ curl --request GET 'http://localhost:50053/actuator/health'
{"status":"UP","components":{"db":{"status":"UP","details":{"database":"MySQL","validationQuery":"select 1","result":1}}}}
浏览器访问地址 http://localhost:12345/dolphinscheduler/ui 即可登录系统UI。默认的用户名和密码是 admin/dolphinscheduler123
6.3 设置开机自启
由于Ubuntu不再inited管理系统,改用 systemd,没有/etc/rc.local文件,所以需要自己配置rc.local,在/usr/lib/systemd/system/rc-local.service文件中添加下面内容:
vim /usr/lib/systemd/system/rc-local.service
[Install]
WantedBy=multi-user.target
Alias=rc-local.service
重新加载文件
systemctl daemon-reload
编辑/etc/rc.local文件
#!/bin/bash -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.
export JAVA_HOME=/usr/local/jdk1.8.0_341
su - dolphinscheduler -c "bash /home/dolphinscheduler/dolphinscheduler/bin/dolphinscheduler-daemon.sh start master-server"
su - dolphinscheduler -c "bash /home/dolphinscheduler/dolphinscheduler/bin/dolphinscheduler-daemon.sh start alert-server"
su - dolphinscheduler -c "bash /home/dolphinscheduler/dolphinscheduler/bin/dolphinscheduler-daemon.sh start api-server"
su - dolphinscheduler -c "bash /home/dolphinscheduler/dolphinscheduler/bin/dolphinscheduler-daemon.sh start worker-server"
##zookeeper
/data/zookeeper/bin/zkServer.sh start
exit 0
修改权限
chmod 755 /etc/rc.local
重启rc服务,并设置开机自启
systemctl restart rc-local.service
systemctl enable rc-local
7 问题处理
7.1 数据库公钥问题
报错:
Public Key Retrieval is not allowed
方案:
添加allowPublicKeyRetrieval=true
export SPRING_DATASOURCE_URL="jdbc:mysql://localhost:3306/dolphinscheduler?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true"
7.2 未找到表
Install时报错
Caused by: java.sql.SQLSyntaxErrorException: Table 'dolphinscheduler.t_ds_plugin_define' doesn't exist
原因:
没有初始化数据库
方案:
[root@localhost apache-dolphinscheduler-3.0.0-bin]# bash tools/bin/upgrade-schema.sh
7.3 任务出现权限问题
报错:
任务调度是出现权限问题,无法进行操作
方案:
任务需要时用可以su的用户作为租户,最好是使用安装的dolphinscheduler租户。
7.4 驱动问题
报错:
Cannot load driver class: com.mysql.cj.jdbc.Driver
原因:
未识别mysql驱动
方案:
添加mysql驱动