部署 DolphinScheduler
环境准备
配置用户及免密登录
创建用户
useradd dolphinscheduler
添加密码
echo "dolphinscheduler" | passwd --stdin dolphinscheduler
添加 sudo 权限
sed -i '$adolphinscheduler ALL=(ALL) NOPASSWD: NOPASSWD: ALL' /etc/sudoers
sed -i 's/Defaults requirett/#Defaults requirett/g' /etc/sudoers修改目录权限
chown -R dolphinscheduler:dolphinscheduler /opt
配置SSH免密登陆
切换到 dolphinscheduler 用户
su dolphinscheduler
生成密钥
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
将公钥添加到 authorized_keys
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
修改 authorized_keys 权限
chmod 600 ~/.ssh/authorized_keys
创建目录
mkdir -p /opt/bigdata # 用于存放大数据组件
mkdir -p /opt/software # 用于存放安装包
mkdir -p /opt/zkdata # 用于存放 zookeeper 数据
安装 JDK
上传 JDK 到
/opt/software
目录下解压到
/opt/bigdata
目录下tar -zxvf /opt/software/jdk-8u381-linux-x64.tar.gz -C /opt/bigdata
创建软链接
ln -s /opt/bigdata/jdk1.8.0_381 /opt/bigdata/jdk
配置环境变量
sudo vim /etc/profile.d/bigdata.sh
export JAVA_HOME=/opt/bigdata/jdk
export PATH=$JAVA_HOME/bin:$PATH使环境变量生效
source /etc/profile.d/bigdata.sh
安装 zookeeper
下载 zookeeper 并解压到
/opt/bigdata
目录下wget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.2/apache-zookeeper-3.8.2-bin.tar.gz -O /opt/software/apache-zookeeper-3.8.2-bin.tar.gz
tar -zxvf /opt/software/apache-zookeeper-3.8.2-bin.tar.gz -C /opt/bigdata
创建软链接
ln -s /opt/bigdata/apache-zookeeper-3.8.2-bin /opt/bigdata/zookeeper
修改配置文件
mv /opt/bigdata/zookeeper/conf/zoo_sample.cfg /opt/bigdata/zookeeper/conf/zoo.cfg
vim /opt/bigdata/zookeeper/conf/zoo.cfgdataDir=/opt/zkdata
启动 zookeeper
/opt/bigdata/zookeeper/bin/zkServer.sh start
安装部署
安装包准备
下载安装包并解压到当前目录
infoDolphinScheduler 的安装包解压到下载目录即可,其提供的一键部署脚本会自动将安装包拷贝到指定的安装目录。
wget https://dlcdn.apache.org/dolphinscheduler/3.1.7/apache-dolphinscheduler-3.1.7-bin.tar.gz -O /opt/software/apache-dolphinscheduler-3.1.7-bin.tar.gz
tar -zxvf /opt/software/apache-dolphinscheduler-3.1.7-bin.tar.gz -C /opt/software
上传 mysql 驱动
note由于 Apache License 2.0 的限制,DolphinScheduler 的安装包中不包含 mysql 驱动,需要自行上传。
我这里首先下载 mysql 驱动到
/opt/software
目录,然后拷贝到所需驱动的各个服务的 libs 目录下。wget https://downloads.mysql.com/archives/get/p/3/file/mysql-connector-java-8.0.16.tar.gz -O /opt/software/mysql-connector-java-8.0.16.tar.gz
tar -zxvf /opt/software/mysql-connector-java-8.0.16.tar.gz -C /opt/software
cp /opt/software/mysql-connector-java-8.0.16/mysql-connector-java-8.0.16.jar /opt/software/apache-dolphinscheduler-3.1.7-bin/alert-server/libs
cp /opt/software/mysql-connector-java-8.0.16/mysql-connector-java-8.0.16.jar /opt/software/apache-dolphinscheduler-3.1.7-bin/api-server/libs
cp /opt/software/mysql-connector-java-8.0.16/mysql-connector-java-8.0.16.jar /opt/software/apache-dolphinscheduler-3.1.7-bin/master-server/libs
cp /opt/software/mysql-connector-java-8.0.16/mysql-connector-java-8.0.16.jar /opt/software/apache-dolphinscheduler-3.1.7-bin/worker-server/libs
cp /opt/software/mysql-connector-java-8.0.16/mysql-connector-java-8.0.16.jar /opt/software/apache-dolphinscheduler-3.1.7-bin/tools/libscaution- 官方文档说明,若使用 mysql 作为元数据库,则添加的驱动版本必须为 8.0.16。
- 官方文档中只提及了前四个服务,但实际上 tools 也需要 mysql 驱动,否则在初始化元数据库时会报缺少驱动。部署时这里卡了很久,后来才发现 tools 下也有 libs 目录。
初始化元数据库
此处使用 mysql 作为元数据库,mysql 的安装和配置请参考 mysql 安装。
创建元数据库
mysql -uroot -p
mysql> CREATE DATABASE dolphinscheduler DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
# 修改 {user} 和 {password} 为你希望的用户名和密码
mysql> CREATE USER 'homelabscheduler'@'%' IDENTIFIED BY 'yourpassword';
mysql> GRANT ALL PRIVILEGES ON dolphinscheduler.* TO 'homelabscheduler'@'%';
mysql> CREATE USER 'homelabscheduler'@'localhost' IDENTIFIED BY 'yourpassword';
mysql> GRANT ALL PRIVILEGES ON dolphinscheduler.* TO 'homelabscheduler'@'localhost';
mysql> FLUSH PRIVILEGES;
修改 dolphinscheduler_env.sh 配置文件
vim /opt/software/apache-dolphinscheduler-3.1.7-bin/bin/env/dolphinscheduler_env.sh
export JAVA_HOME=${JAVA_HOME:-/opt/bigdata/jdk}
...
export DATABASE=${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={user}
export SPRING_DATASOURCE_PASSWORD={password}caution在 SPRING_DATASOURCE_URL 中,需要补充
&allowPublicKeyRetrieval=true
,否则初始化过程会报错,这一点在官方模板中没有写到。初始化数据库
bash /opt/software/apache-dolphinscheduler-3.1.7-bin/tools/bin/upgrade-schema.sh
部署 DolphinScheduler
修改 install_env.sh 配置文件
vim /opt/software/apache-dolphinscheduler-3.1.7-bin/bin/env/install_env.sh
ips="localhost"
sshPort="22"
masters="localhost"
workers="localhost:default"
alertServer="localhost"
apiServers="localhost"
installPath="/opt/bigdata/dolphinscheduler"
deployUser="dolphinscheduler" # 这里填写之前创建的用户修改 dolphinscheduler_env.sh 配置文件
info如后续调度任务中使用到以下组件,则需要在此处配置对应的环境变量。
export HADOOP_HOME=${HADOOP_HOME:-/opt/soft/hadoop}
export HADOOP_CONF_DIR=${HADOOP_CONF_DIR:-/opt/soft/hadoop/etc/hadoop}
export SPARK_HOME1=${SPARK_HOME1:-/opt/soft/spark1}
export SPARK_HOME2=${SPARK_HOME2:-/opt/soft/spark2}
export PYTHON_HOME=${PYTHON_HOME:-/opt/soft/python}
export HIVE_HOME=${HIVE_HOME:-/opt/soft/hive}
export FLINK_HOME=${FLINK_HOME:-/opt/soft/flink}
export DATAX_HOME=${DATAX_HOME:-/opt/soft/datax}
export PATH=$HADOOP_HOME/bin:$SPARK_HOME1/bin:$SPARK_HOME2/bin:$PYTHON_HOME/bin:$JAVA_HOME/bin:$HIVE_HOME/bin:$FLINK_HOME/bin:$DATAX_HOME/bin:$PATH一键部署
首先确保当前用户为 dolphinscheduler 用户,且 zookeeper 已启动。
bash /opt/software/apache-dolphinscheduler-3.1.7-bin/bin/install.sh
启停命令
# 停止全部
bash /opt/software/apache-dolphinscheduler-3.1.7-bin/bin/stop-all.sh
# 启动全部
bash /opt/software/apache-dolphinscheduler-3.1.7-bin/bin/start-all.sh开放 12345 端口或关闭防火墙
开放 12345 端口
sudo firewall-cmd --zone=public --add-port=12345/tcp --permanent
sudo firewall-cmd --reload关闭防火墙
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service
Web UI 访问
访问地址:http://localhost:12345/dolphinscheduler/ui
note默认的用户名和密码为:admin / dolphinscheduler123
caution访问地址中的
/dolphinscheduler/ui
不能省略,否则无法进入登录页面。