# Dolphinscheduler 安装教程
## 请参考官方文档
- [请参考官方文档部署][install]
- [数据源配置及初始化数据库][datasource]

## 注意事项
### 集群部署中 添加密码步骤
```shell
# centos
echo "dolphinscheduler" | passwd --stdin dolphinscheduler
# ubuntu
echo dolphinscheduler:dolphinscheduler | chpasswd &> /dev/null
```

### 建议使用 `dolphinscheduler` 用户操作
配置完用户和免密全选后，后续操作建议都在 `dolphinscheduler` 用户中执行

### 配置 env `./bin/env/dolphinscheduler_env.sh`
```shell
# JAVA_HOME, will use it to start DolphinScheduler server
export JAVA_HOME=${JAVA_HOME:-/opt/soft/java}

# Database related configuration, set database type, username and password
export DATABASE=${DATABASE:-postgresql}
export SPRING_PROFILES_ACTIVE=${DATABASE}
export SPRING_DATASOURCE_URL="jdbc:postgresql://127.0.0.1:5432/dolphinscheduler"
export SPRING_DATASOURCE_USERNAME={user}
export SPRING_DATASOURCE_PASSWORD={password}

# DolphinScheduler server related configuration
export SPRING_CACHE_TYPE=${SPRING_CACHE_TYPE:-none}
export SPRING_JACKSON_TIME_ZONE=${SPRING_JACKSON_TIME_ZONE:-UTC}

# Registry center configuration, determines the type and link of the registry center
export REGISTRY_TYPE=${REGISTRY_TYPE:-zookeeper}
export REGISTRY_ZOOKEEPER_CONNECT_STRING=${REGISTRY_ZOOKEEPER_CONNECT_STRING:-localhost:2181}

# Tasks related configurations, need to change the configuration if you use the related tasks.
export HADOOP_HOME=${HADOOP_HOME:-/opt/soft/hadoop}
export HADOOP_CONF_DIR=${HADOOP_CONF_DIR:-/opt/soft/hadoop/etc/hadoop}
export SPARK_HOME=${SPARK_HOME:-/opt/soft/spark}
export PYTHON_LAUNCHER=${PYTHON_LAUNCHER:-/opt/soft/python}
export HIVE_HOME=${HIVE_HOME:-/opt/soft/hive}
export FLINK_HOME=${FLINK_HOME:-/opt/soft/flink}
export DATAX_LAUNCHER=${DATAX_LAUNCHER:-/opt/soft/datax/bin/python3}

export PATH=$HADOOP_HOME/bin:$SPARK_HOME/bin:$PYTHON_LAUNCHER:$JAVA_HOME/bin:$HIVE_HOME/bin:$FLINK_HOME/bin:$DATAX_LAUNCHER:$PATH
```

### 启停服务
- 本教程编写时 脚本中存在 installPath 变量，执行脚本时需要 export 该变量为安装路径
- 本教程编写时 start-all.sh 脚本无法直接执行，建议直接使用下面的命令。失败原因没花时间找
- 进入安装目录
```shell
export installPath=$(pwd)
# 启停 Master
bash ./bin/dolphinscheduler-daemon.sh stop master-server
bash ./bin/dolphinscheduler-daemon.sh start master-server

# 启停 Worker
bash ./bin/dolphinscheduler-daemon.sh start worker-server
bash ./bin/dolphinscheduler-daemon.sh stop worker-server

# 启停 Api
bash ./bin/dolphinscheduler-daemon.sh start api-server
bash ./bin/dolphinscheduler-daemon.sh stop api-server

# 启停 Alert
bash ./bin/dolphinscheduler-daemon.sh start alert-server
bash ./bin/dolphinscheduler-daemon.sh stop alert-server
```

## 参考文档
- [官方伪集群教程][install]

[install]: https://dolphinscheduler.apache.org/zh-cn/docs/3.2.2/guide/installation/pseudo-cluster
[datasource]: https://github.com/apache/dolphinscheduler/blob/3.2.2-release/docs/docs/zh/guide/howto/datasource-setting.md
