|
|
|
|
# 后端部署文档
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 基础软件安装
|
|
|
|
|
|
|
|
|
|
* [Mysql](https://blog.csdn.net/u011886447/article/details/79796802) (5.5+) : 必装
|
|
|
|
|
* [JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html) (1.8+) : 必装
|
|
|
|
|
* [ZooKeeper](https://www.jianshu.com/p/de90172ea680)(3.4.6) :必装
|
|
|
|
|
* [Hadoop](https://blog.csdn.net/Evankaka/article/details/51612437)(2.7.3) :选装, 如果需要使用到资源上传功能,MapReduce任务提交则需要配置Hadoop(上传的资源文件目前保存在Hdfs上)
|
|
|
|
|
* [Hive](https://staroon.pro/2017/12/09/HiveInstall/)(1.2.1) : 选装,hive任务提交需要安装
|
|
|
|
|
* Spark(1.x,2.x) : 选装,Spark任务提交需要安装
|
|
|
|
|
* PostgreSQL(8.2.15+) : 选装,PostgreSQL PostgreSQL存储过程需要安装
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
注意:EasyScheduler本身不依赖Hadoop、Hive、Spark、PostgreSQL,仅是会调用他们的Client,用于对应任务的运行。
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 项目编译
|
|
|
|
|
|
|
|
|
|
* 执行编译命令:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
mvn -U clean package assembly:assembly -Dmaven.test.skip=true
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* 查看目录
|
|
|
|
|
|
|
|
|
|
正常编译完后,会在当前目录生成 target/escheduler-{version}/
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
bin
|
|
|
|
|
conf
|
|
|
|
|
lib
|
|
|
|
|
script
|
|
|
|
|
sql
|
|
|
|
|
install.sh
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- 说明
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
bin : 基础服务启动脚本
|
|
|
|
|
conf : 项目配置文件
|
|
|
|
|
lib : 项目依赖jar包,包括各个模块jar和第三方jar
|
|
|
|
|
script : 集群启动、停止和服务监控启停脚本
|
|
|
|
|
sql : 项目依赖sql文件
|
|
|
|
|
install.sh : 一键部署脚本
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 数据库初始化
|
|
|
|
|
|
|
|
|
|
* 创建database和账号
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
mysql -h {host} -u {user} -p{password}
|
|
|
|
|
mysql> CREATE DATABASE escheduler DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
|
|
|
|
|
mysql> GRANT ALL PRIVILEGES ON escheduler.* TO '{user}'@'%' IDENTIFIED BY '{password}';
|
|
|
|
|
mysql> GRANT ALL PRIVILEGES ON escheduler.* TO '{user}'@'localhost' IDENTIFIED BY '{password}';
|
|
|
|
|
mysql> flush privileges;
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* 创建表和导入基础数据
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
说明:在 target/escheduler-{version}/sql/escheduler.sql和quartz.sql
|
|
|
|
|
|
|
|
|
|
mysql -h {host} -u {user} -p{password} -D {db} < escheduler.sql
|
|
|
|
|
|
|
|
|
|
mysql -h {host} -u {user} -p{password} -D {db} < quartz.sql
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 创建部署用户
|
|
|
|
|
|
|
|
|
|
因为escheduler worker都是以 sudo -u {linux-user} 方式来执行作业,所以部署用户需要有 sudo 权限,而且是免密的。
|
|
|
|
|
|
|
|
|
|
```部署账号
|
|
|
|
|
vi /etc/sudoers
|
|
|
|
|
|
|
|
|
|
# 部署用户是 escheduler 账号
|
|
|
|
|
escheduler ALL=(ALL) NOPASSWD: NOPASSWD: ALL
|
|
|
|
|
|
|
|
|
|
# 并且需要注释掉 Default requiretty 一行
|
|
|
|
|
#Default requiretty
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 伪分布式部署
|
|
|
|
|
|
|
|
|
|
### 2,根据实际需求来创建HDFS根路径
|
|
|
|
|
|
|
|
|
|
根据 **common/common.properties** 中 **hdf.startup.states** 的配置来判断是否启动HDFS,如果启动,则需要创建HDFS根路径,并将 **owner** 修改为**部署用户**,否则忽略此步骤
|
|
|
|
|
|
|
|
|
|
### 3,项目编译
|
|
|
|
|
|
|
|
|
|
如上进行 **项目编译**
|
|
|
|
|
|
|
|
|
|
### 4,修改配置文件
|
|
|
|
|
|
|
|
|
|
根据 **配置文件说明** 修改配置文件和 **环境变量** 文件
|
|
|
|
|
|
|
|
|
|
### 5,创建目录并将环境变量文件复制到指定目录
|
|
|
|
|
|
|
|
|
|
- 创建 **common/common.properties** 下的data.basedir.path、data.download.basedir.path和process.exec.basepath路径
|
|
|
|
|
|
|
|
|
|
- 将**.escheduler_env.sh** 和 **escheduler_env.py** 两个环境变量文件复制到 **common/common.properties**配置的**escheduler.env.path** 和 **escheduler.env.py** 的目录下,并将 **owner** 修改为**部署用户**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 分布式部署
|
|
|
|
|
|
|
|
|
|
### 1,创建部署用户
|
|
|
|
|
|
|
|
|
|
- 在需要部署调度的机器上如上 **创建部署用户**
|
|
|
|
|
- [将 **主机器** 和各个其它机器SSH打通](https://blog.csdn.net/thinkmore1314/article/details/22489203)
|
|
|
|
|
|
|
|
|
|
### 2,根据实际需求来创建HDFS根路径
|
|
|
|
|
|
|
|
|
|
根据 **common/common.properties** 中 **hdfs.startup.state** 的配置来判断是否启动HDFS,如果启动,则需要创建HDFS根路径,并将 **owner** 修改为**部署用户**,否则忽略此步骤
|
|
|
|
|
|
|
|
|
|
### 3,项目编译
|
|
|
|
|
|
|
|
|
|
如上进行 **项目编译**
|
|
|
|
|
|
|
|
|
|
### 4,将环境变量文件复制到指定目录
|
|
|
|
|
|
|
|
|
|
将**.escheduler_env.sh** 和 **escheduler_env.py** 两个环境变量文件复制到 **common/common.properties**配置的**escheduler.env.path** 和 **escheduler.env.py** 的目录下,并将 **owner** 修改为**部署用户**
|
|
|
|
|
|
|
|
|
|
### 5,修改 install.sh
|
|
|
|
|
|
|
|
|
|
修改 install.sh 中变量的值,替换成自身业务所需的值
|
|
|
|
|
|
|
|
|
|
### 6,一键部署
|
|
|
|
|
|
|
|
|
|
- 安装 pip install kazoo
|
|
|
|
|
- 安装目录如下:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
bin
|
|
|
|
|
conf
|
|
|
|
|
escheduler-1.0.0-SNAPSHOT.tar.gz
|
|
|
|
|
install.sh
|
|
|
|
|
lib
|
|
|
|
|
monitor_server.py
|
|
|
|
|
script
|
|
|
|
|
sql
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- 使用部署用户 sh install.sh 一键部署
|
|
|
|
|
|
|
|
|
|
- 注意:scp_hosts.sh 里 `tar -zxvf $workDir/../escheduler-1.0.0.tar.gz -C $installPath` 中的版本号(1.0.0)需要执行前手动替换成对应的版本号
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 7,启停服务
|
|
|
|
|
|
|
|
|
|
* 启停Master
|
|
|
|
|
|
|
|
|
|
```启动master
|
|
|
|
|
sh ./bin/escheduler-daemon.sh start master-server
|
|
|
|
|
sh ./bin/escheduler-daemon.sh stop master-server
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* 启停Worker
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
sh ./bin/escheduler-daemon.sh start worker-server
|
|
|
|
|
sh ./bin/escheduler-daemon.sh stop worker-server
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
* 启停Api
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
sh ./bin/escheduler-daemon.sh start api-server
|
|
|
|
|
sh ./bin/escheduler-daemon.sh stop api-server
|
|
|
|
|
```
|
|
|
|
|
* 启停Logger
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
sh ./bin/escheduler-daemon.sh start logger-server
|
|
|
|
|
sh ./bin/escheduler-daemon.sh stop logger-server
|
|
|
|
|
```
|
|
|
|
|
* 启停Alert
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
sh ./bin/escheduler-daemon.sh start alert-server
|
|
|
|
|
sh ./bin/escheduler-daemon.sh stop alert-server
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 服务监控
|
|
|
|
|
|
|
|
|
|
monitor_server.py 脚本是监听,master和worker服务挂掉重启的脚本
|
|
|
|
|
|
|
|
|
|
注意:在全部服务都启动之后启动
|
|
|
|
|
|
|
|
|
|
nohup python -u monitor_server.py > nohup.out 2>&1 &
|
|
|
|
|
|
|
|
|
|
## 日志查看
|
|
|
|
|
日志统一存放于指定文件夹内
|
|
|
|
|
|
|
|
|
|
```日志路径
|
|
|
|
|
logs/
|
|
|
|
|
├── escheduler-alert-server.log
|
|
|
|
|
├── escheduler-master-server.log
|
|
|
|
|
|—— escheduler-worker-server.log
|
|
|
|
|
|—— escheduler-api-server.log
|
|
|
|
|
|—— escheduler-logger-server.log
|
|
|
|
|
```
|