第四篇 本地开发环境搭建

开发步骤

本地环境搭建,分为以下几个步骤:

  1. 准备基础软件安装
  2. 克隆远程dolphinscheduler仓库的代码到本地(如何代码已克隆完成,可以跳过这一步)
  3. 修改dolphinscheduler yaml配置文件
  4. 创建本地dolphinscheduler 数据库,并初始化表和数据
  5. 配置vm option参数 ,启动master、worker、api服务
  6. 编译前端npm install、npm run start

前置条件

在搭建 DolphinScheduler 开发环境之前请确保你已经安装一下软件

  • Git: 版本控制系统
  • JDK: 后端开发
  • Maven: Java包管理系统
  • Node: 前端开发

克隆代码库

通过你 git 管理工具下载 git 代码,下面以 git-core 为例

mkdir dolphinscheduler
cd dolphinscheduler
git clone https://github.com/apache/dolphinscheduler.git
切换分支
#查看当前分支
git branch -l
#进行切换分支(2.0.5-release版本)
git checkout 2.0.5-release
准备zookeeper
下载zookeeper

这里使用最新版本的zookeeper,下载地址如下:

https://dlcdn.apache.org/zookeeper/zookeeper-3.8.0/apache-zookeeper-3.8.0-bin.tar.gz

将下载后的压缩包进行解压。

启动zookeeper

进入 zookeeper 的安装目录,将 zoo_sample.cfg 配置文件复制到 conf/zoo.cfg,并将 conf/zoo.cfg 中 dataDir 中的值改成 dataDir=./tmp/zookeeper

# 启动 zookeeper
./bin/zkServer.sh start

数据库

DolphinScheduler 的元数据存储在关系型数据库中,目前支持的关系型数据库包括 MySQL 以及 PostgreSQL。下面以MySQL为例,启动数据库并创建新 database 作为 DolphinScheduler 元数据库,这里以数据库名 dolphinscheduler 为例

创建完新数据库后,将 dolphinscheduler/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql 下的 sql 文件直接在 MySQL 中运行,完成数据库初始化

启动后端

下面步骤将引导如何启动 DolphinScheduler 后端服务

必要的准备工作
  • 打开项目:使用开发工具打开项目,这里以 Intellij IDEA 为例,打开后需要一段时间,让 Intellij IDEA 完成以依赖的下载

  • 插件的配置(仅 2.0 及以后的版本需要):

    • 注册中心插件配置, 以Zookeeper 为例 (registry.properties) dolphinscheduler-service/src/main/resources/registry.properties
     registry.plugin.name=zookeeper
     registry.servers=127.0.0.1:2181
    
  • 必要的修改

    • 如果使用 MySQL 作为元数据库,需要先修改 dolphinscheduler/pom.xml,将 mysql-connector-java 依赖的 scope 改为 compile,使用 PostgreSQL 则不需要
    • 修改数据库配置,修改 dolphinscheduler-dao/src/main/resources/application-mysql.yaml 文件中的数据库配置

    本样例以 MySQL 为例,其中数据库名为 dolphinscheduler,账户名密码均为 dolphinscheduler

     spring:
       datasource:
         driver-class-name: com.mysql.jdbc.Driver
         url: jdbc:mysql://127.0.0.1:3306/dolphinscheduler?useUnicode=true&characterEncoding=UTF-8
         username: ds_user
         password: dolphinscheduler
    
  • 修改日志级别:为以下配置增加一行内容 <appender-ref ref="STDOUT"/> 使日志能在命令行中显示

    dolphinscheduler-server/src/main/resources/logback-worker.xml

    dolphinscheduler-server/src/main/resources/logback-master.xml

    dolphinscheduler-api/src/main/resources/logback-api.xml

    修改后的结果如下:

    <root level="INFO">
    +  <appender-ref ref="STDOUT"/>
      <appender-ref ref="APILOGFILE"/>
      <appender-ref ref="SKYWALKING-LOG"/>
    </root>
    
启动服务

我们需要启动三个服务,包括 MasterServer,WorkerServer,ApiApplicationServer

  • MasterServer:在 Intellij IDEA 中执行 org.apache.dolphinscheduler.server.master.MasterServer 中的 main 方法,并配置 VM Options -Dlogging.config=classpath:logback-master.xml -Ddruid.mysql.usePingMethod=false -Dspring.profiles.active=mysql
  • WorkerServer:在 Intellij IDEA 中执行 org.apache.dolphinscheduler.server.worker.WorkerServer 中的 main 方法,并配置 VM Options -Dlogging.config=classpath:logback-worker.xml -Ddruid.mysql.usePingMethod=false -Dspring.profiles.active=mysql
  • ApiApplicationServer:在 Intellij IDEA 中执行 org.apache.dolphinscheduler.api.ApiApplicationServer 中的 main 方法,并配置 VM Options -Dlogging.config=classpath:logback-api.xml -Dspring.profiles.active=api,mysql。启动完成可以浏览 Open API 文档,地址为 http://localhost:12345/dolphinscheduler/doc.html

VM Options -Dspring.profiles.active=mysqlmysql 表示指定的配置文件

启动前端

由于默认的npm源是国外的地址可能会很慢,所以这里要换成国内的npm源,操作如下:

#查看npm源地址
npm config get registry
#使用淘宝镜像
#第一种方式:临时使用
npm --registry https://registry.npm.taobao.org install express
#第二种方式:持久使用
npm config set registry https://registry.npm.taobao.org
#第三种方式:通过cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
#第四种方式:使用官方镜像
npm config set registry https://registry.npmjs.org/

安装前端依赖并运行前端组件

cd dolphinscheduler-ui
npm install
npm run start

截止目前,前后端已成功运行起来,浏览器访问http://localhost:8888,并使用默认账户密码 admin/dolphinscheduler123 即可完成登录

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值