Dolphin Scheduler Docker集群部署實踐


 

0.     說明

使用10.45.154.208環境中的docker部署4個節點的DS集群,各節點角色分布情況如下:

  角色

節點

Master-server

Worker-server

Alert-server

Api-server

zookeeper

ds1

 

 

 

 

 

ds2

 

 

 

 

 

ds3

 

 

 

 

 

ds4

 

 

 

 

 

 

選擇ds1作為主部署機。

1.     准備部署主機

1.1 創建docker容器

docker run -itd --privileged -p 31188:8888 -p 31122:22 -p 31145:12345 --name yj_ds1 docker.io/centos:7 /usr/sbin/init
docker run -itd --privileged -p 32222:22 --name yj_ds2 docker.io/centos:7 /usr/sbin/init
docker run -itd --privileged -p 33022:22 --name yj_ds3 docker.io/centos:7 /usr/sbin/init
docker run -itd --privileged -p 34422:22 --name yj_ds4 docker.io/centos:7 /usr/sbin/init

1.2 設置主機名稱解析

再在各台主機上,編輯/etc/hosts文件:

sudo vi /etc/hosts

內容是一樣的,均為:

172.17.0.8     ds1

172.17.0.9     ds2

172.17.0.11    ds3

172.17.0.10    ds4

 

1.3 創建部署用戶

在所有部署調度的機器上創建部署用戶,並且一定要配置sudo免密。假如我們計划在ds1,ds2,ds3,ds4這4台機器上部署調度,首先需要在每台機器上都創建部署用戶。

# 設置用戶名,請自行修改,后面以dolphinscheduler為例

useradd dolphinscheduler

 

# 設置用戶密碼,請自行修改,后面以dolphinscheduler123為例

echo "dolphinscheduler123" | passwd --stdin dolphinscheduler

 

# 配置sudo免密

echo 'dolphinscheduler  ALL=(ALL)  NOPASSWD: NOPASSWD: ALL' >> /etc/sudoers

注意:

 -  因為是以 sudo -u {linux-user} 切換不同linux用戶的方式來實現多租戶運行作業,所以部署用戶需要有 sudo 權限,而且是免密的。

- 如果/etc目錄下沒有sudoers文件,請使用yum install –y sodo安裝

- 如果發現/etc/sudoers文件中有"Default requiretty"這行,也請注釋掉

 - 如果用到資源上傳的話,還需要在`HDFS或者MinIO`上給該部署用戶分配讀寫的權限

1.4 安裝ssh

在所有部署機上安裝ssh。

yum install –y openssh-server

yum install –y openssh-clients

安裝之后檢查ssh-server的啟動狀態

1.5 配置免密

ds1 dolphinscheduler ssh本機免密鑰。

su dolphinscheduler

 

ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

chmod 600 ~/.ssh/authorized_keys

在ds1上,配置部署用戶dolphinscheduler ssh打通到其他待部署的機器

su dolphinscheduler;

 

for ip in ds2 ds3 ds4;

do

  ssh-copy-id $ip #該操作執行過程中需要手動輸入dolphinscheduler用戶的密碼

done

1.6 同步時間

timedatectl set-local-rtc 1 # 將硬件時鍾調整為與本地時鍾一致, 0 為設置為 UTC 時間

timedatectl set-timezone Asia/Shanghai # 設置系統時區為上海

ntpdate ntp1.aliyun.com  # 同步時間

2.     安裝基礎軟件

2.1    JDK

手動安裝,將JDK1.8下載解壓后,添加環境變量。

添加java命令軟鏈接到/bin/java。

ln -s /opt/soft/jdk1.8.0_221/java /bin/java

2.2 Zookeeper

zoo.cfg配置

# 服務器之間或客戶端與服務器之間維持心跳的時間間隔

# tickTime以毫秒為單位。

 tickTime=2000

# 集群中的follower服務器(F)與leader服務器(L)之間的初始連接心跳數

 initLimit=10

# 集群中的follower服務器與leader服務器之間請求和應答之間能容忍的最多心跳數

 syncLimit=5

# 快照保存目錄

# 不要設置為/tmp,該目錄重新啟動后會被自動清除

 dataDir=/home/hadoop/data/zookeeper/data

# 日志保存目錄

 dataLogDir=/home/hadoop/data/zookeeper/logs

# 客戶端連接端口

 clientPort=2181

# 客戶端最大連接數。

# 根據自己實際情況設置,默認為60個

# maxClientCnxns=60

# 三個接點配置,格式為:

#  server.服務編號=服務地址、LF通信端口、選舉端口

 server.1=ds1:2888:3888

 server.2=ds2:2888:3888

 server.3=ds3:2888:3888

將該ZK分發到ds2、ds3節點:

scp –r zookeeper/ ds2:/opt/soft/

scp –r zookeeper/ ds3:/opt/soft/

寫入節點標記

在三個slave節點上,分別在/home/dolphinscheduler/data/zookeeper/data/myid寫入節點標記:

ds1

1

ds2

2

ds3

 3

啟動Zookeeper

在ds1、ds2、ds3上,分別啟動zkServer。

zkServer.sh start

2.3 Postgresql

  這里數據庫選擇Postgresql,將其安裝在ds1

yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm # 安裝yum源

yum install -y postgresql96-server postgresql96-contrib  # 安裝postgresql 

 

/usr/pgsql-9.6/bin/postgresql96-setup initdb # 初始化數據庫

 

  配置遠程訪問。

vi /var/lib/pgsql/9.6/data/postgresql.conf

找到listen_addresses,按i鍵進入插入編輯模式,如果想對所有IP開放,則將localhost改為*即可,如果想僅對部分IP開放,多個IP之間用,(逗號+空格)隔開。改完之后去掉“listen_address”前面的#。 

 

 

vi /var/lib/pgsql/9.6/data/pg_hba.conf

按i鍵進入插入編輯模式,在IPv4 local connections下方添加允許連接的IP。 如果想允許所有IPv4地址,則加入一行host all all 0.0.0.0/0 md5。IPv6方法類似。

 

 

  啟動服務

systemctl start postgresql-9.6

systemctl enable postgresql-9.6

3.     安裝DS

3.1    初始化數據庫

進入數據庫。

su postgres

psql

創建用戶並配置密碼和權限。

create user ds with password 'ds1234';

create database dolphinscheduler owner ds;

grant all privileges on database dolphinscheduler to ds;

修改conf/application.properties中下面三項

spring.datasource.url=jdbc:postgresql://ds1:5432/dolphinscheduler?characterEncoding=UTF-8

spring.datasource.username=ds

spring.datasource.password=ds1234

執行腳本script/create-dolphinscheduler.sh初始化數據庫。

sh create-dolphinscheduler.sh

3.2    配置install.sh

修改以下配置項。

# for example postgresql or mysql ...

dbtype="postgresql"

 

# db config

# db address and port

dbhost="ds1:5432"

 

# db name

dbname="dolphinscheduler"

 

# db username

username="ds"

 

# db passwprd

# Note: if there are special characters, please use the \ transfer character to transfer

passowrd="ds1234"

 

# conf/config/install_config.conf config

# Note: the installation path is not the same as the current path (pwd)

installPath="/opt/dolphinscheduler_inst"

 

# deployment user

# Note: the deployment user needs to have sudo privileges and permissions to operate hdfs. If hdfs is enabled, the root directory needs to be created by itself

deployUser="dolphinscheduler"

 

# zk cluster

zkQuorum="ds1:2181,ds2:2181,ds3:2181"

 

# install hosts

# Note: install the scheduled hostname list. If it is pseudo-distributed, just write a pseudo-distributed hostname

ips="ds1,ds2,ds3,ds4"

 

# ssh port, default 22

# Note: if ssh port is not default, modify here

sshPort=22

 

# run master machine

# Note: list of hosts hostname for deploying master

masters="ds1,ds2"

 

# run worker machine

# note: list of machine hostnames for deploying workers

workers="ds3,ds4"

 

# run alert machine

# note: list of machine hostnames for deploying alert server

alertServer="ds2"

 

# run api machine

# note: list of machine hostnames for deploying api server

apiServers="ds1"

 

# alert config

# mail protocol

mailProtocol="SMTP"

 

# mail server host

mailServerHost="smtp.163.com"

 

# mail server port

mailServerPort="465"

 

# sender

mailSender="akalayu@163.com"

 

# user

mailUser="akalayu@163.com"

 

# sender password

mailPassword="abcabc123"

 

# TLS mail protocol support

starttlsEnable="false"

 

sslTrust="smtp.163.com"

 

# SSL mail protocol support

# note: The SSL protocol is enabled by default. 

# only one of TLS and SSL can be in the true state.

sslEnable="true"

 

# resource Center upload and select storage method:HDFS,S3,NONE

resUploadStartupType="HDFS"

 

# if resUploadStartupType is HDFS,defaultFS write namenode address,HA you need to put core-site.xml and hdfs-site.xml in the conf directory.

# if S3,write S3 address,HA,for example :s3a://dolphinscheduler,

# Note,s3 be sure to create the root directory /dolphinscheduler

defaultFS="hdfs://10.45.154.209:8020"

 

# if it is a single resourcemanager, you only need to configure one host name. If it is resourcemanager HA, the default configuration is fine.

singleYarnIp="10.45.154.209"

3.3    一鍵部署DS

su dolphinscheduler

sh install.sh

3.4 安裝Nginx

將nginx放到yum repro庫中:

rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

使用yum安裝ngnix:

yum install nginx

在/etc/nginx/conf.d/目錄下添加一個名為dolphinscheduler.conf的配置文件,內容如下:

server {

       listen       8888;

       server_name  ds1;

       #charset koi8-r;

       #access_log  /var/log/nginx/host.access.log  main;

       client_max_body_size 1024M;

       location / {

           root   /opt/dolphinscheduler_inst/ui;

           index  index.html index.html;

       }

       location /dolphinscheduler {

           proxy_pass http://ds1:12345;

           proxy_set_header Host $host;

           proxy_set_header X-Real-IP $remote_addr;

           proxy_set_header x_real_ipP $remote_addr;

           proxy_set_header remote_addr $remote_addr;

           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

           proxy_http_version 1.1;

           proxy_connect_timeout 4s;

           proxy_read_timeout 30s;

           proxy_send_timeout 12s;

           proxy_set_header Upgrade $http_upgrade;

           proxy_set_header Connection "upgrade";

       }

       #error_page  404              /404.html;

       # redirect server error pages to the static page /50x.html

       #

       error_page   500 502 503 504  /50x.html;

       location = /50x.html {

           root   /usr/share/nginx/html;

       }

   }

啟動nginx:

systemctl start nginx.service

 

通過安裝ds1時指定的映射端口訪問DS:

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM