|
|
|
# 后端部署文档
|
|
|
|
|
|
|
|
后端有2种部署方式,分别为自动化部署和编译源码部署
|
|
|
|
|
|
|
|
## 1、准备工作
|
|
|
|
#### 准备一:基础软件安装(必装项请自行安装)
|
|
|
|
|
|
|
|
* [Mysql](http://geek.analysys.cn/topic/124) (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.6+) :选装, 如果需要使用到资源上传功能,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,用于对应任务的运行。
|
|
|
|
```
|
|
|
|
|
|
|
|
#### 准备二:下载安装包
|
|
|
|
目前最新安装包版本是1.0.1,下载地址: [码云下载](https://gitee.com/easyscheduler/EasyScheduler/attach_files/)
|
|
|
|
下载escheduler-backend-1.0.1.tar.gz后,解压后会产生escheduler-backend-1.0.1目录(简称escheduler-backend),进入该escheduler-backend目录
|
|
|
|
|
|
|
|
|
|
|
|
## 2、部署
|
|
|
|
以下两种方式任选其一部署即可,推荐自动化部署
|
|
|
|
|
|
|
|
### 2.1 自动化部署
|
|
|
|
|
|
|
|
我们先来大体了解下escheduler-backend目录下的文件(夹)说明
|
|
|
|
|
|
|
|
```
|
|
|
|
bin : 基础服务启动脚本
|
|
|
|
conf : 项目配置文件
|
|
|
|
lib : 项目依赖jar包,包括各个模块jar和第三方jar
|
|
|
|
script : 集群启动、停止和服务监控启停脚本
|
|
|
|
sql : 项目依赖sql文件
|
|
|
|
install.sh : 一键部署脚本
|
|
|
|
```
|
|
|
|
|
|
|
|
### 2.2 数据库初始化
|
|
|
|
|
|
|
|
* 创建database和账号
|
|
|
|
|
|
|
|
通过以下mysql命令进入mysql命令行服务:
|
|
|
|
|
|
|
|
> mysql -h {host} -u {user} -p{password}
|
|
|
|
|
|
|
|
然后执行以下命令创建database和账号
|
|
|
|
|
|
|
|
```sql
|
|
|
|
CREATE DATABASE escheduler DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
|
|
|
|
GRANT ALL PRIVILEGES ON escheduler.* TO '{user}'@'%' IDENTIFIED BY '{password}';
|
|
|
|
GRANT ALL PRIVILEGES ON escheduler.* TO '{user}'@'localhost' IDENTIFIED BY '{password}';
|
|
|
|
flush privileges;
|
|
|
|
```
|
|
|
|
|
|
|
|
* 创建表和导入基础数据
|
|
|
|
说明:在escheduler-backend/sql/escheduler.sql和quartz.sql
|
|
|
|
|
|
|
|
```sql
|
|
|
|
mysql -h {host} -u {user} -p{password} -D {db} < escheduler.sql
|
|
|
|
|
|
|
|
mysql -h {host} -u {user} -p{password} -D {db} < quartz.sql
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### 2.3 创建部署用户
|
|
|
|
|
|
|
|
- 在所有需要部署调度的机器上创建部署用户,因为worker服务是以 sudo -u {linux-user} 方式来执行作业,所以部署用户需要有 sudo 权限,而且是免密的。
|
|
|
|
|
|
|
|
```部署账号
|
|
|
|
vi /etc/sudoers
|
|
|
|
|
|
|
|
# 例如部署用户是escheduler账号
|
|
|
|
escheduler ALL=(ALL) NOPASSWD: NOPASSWD: ALL
|
|
|
|
|
|
|
|
# 并且需要注释掉 Default requiretty 一行
|
|
|
|
#Default requiretty
|
|
|
|
```
|
|
|
|
|
|
|
|
### 2.4 ssh免密配置
|
|
|
|
在部署机器和其他安装机器上配置ssh免密登录,如果要在部署机上安装调度,需要配置本机免密登录自己
|
|
|
|
|
|
|
|
- [将 **主机器** 和各个其它机器SSH打通](http://geek.analysys.cn/topic/113)
|
|
|
|
|
|
|
|
|
|
|
|
### 2.5. 修改安装目录权限
|
|
|
|
|
|
|
|
- 安装目录如下:
|
|
|
|
|
|
|
|
```
|
|
|
|
bin
|
|
|
|
conf
|
|
|
|
install.sh
|
|
|
|
lib
|
|
|
|
script
|
|
|
|
sql
|
|
|
|
|
|
|
|
```
|
|
|
|
- 修改权限(deployUser修改为对应部署用户)
|
|
|
|
|
|
|
|
`sudo chown -R deployUser:deployUser *`
|
|
|
|
|
|
|
|
### 2.6. 修改环境变量文件
|
|
|
|
|
|
|
|
- 根据业务需求,修改conf/env/目录下的**escheduler_env.py**,** .escheduler_env.sh**两个文件中的环境变量
|
|
|
|
|
|
|
|
### 2.7. 修改部署参数
|
|
|
|
|
|
|
|
- 修改 **install.sh**中的参数,替换成自身业务所需的值
|
|
|
|
|
|
|
|
- 如果使用hdfs相关功能,需要拷贝**hdfs-site.xml**和**core-site.xml**到conf目录下
|
|
|
|
|
|
|
|
|
|
|
|
### 2.8. 一键部署
|
|
|
|
|
|
|
|
- 安装zookeeper工具
|
|
|
|
|
|
|
|
`pip install kazoo`
|
|
|
|
|
|
|
|
- 切换到部署用户,一键部署
|
|
|
|
|
|
|
|
`sh install.sh`
|
|
|
|
|
|
|
|
- jps查看服务是否启动
|
|
|
|
|
|
|
|
```aidl
|
|
|
|
MasterServer ----- master服务
|
|
|
|
WorkerServer ----- worker服务
|
|
|
|
LoggerServer ----- logger服务
|
|
|
|
ApiApplicationServer ----- api服务
|
|
|
|
AlertServer ----- alert服务
|
|
|
|
```
|
|
|
|
|
|
|
|
## 日志查看
|
|
|
|
日志统一存放于指定文件夹内
|
|
|
|
|
|
|
|
```日志路径
|
|
|
|
logs/
|
|
|
|
├── escheduler-alert-server.log
|
|
|
|
├── escheduler-master-server.log
|
|
|
|
|—— escheduler-worker-server.log
|
|
|
|
|—— escheduler-api-server.log
|
|
|
|
|—— escheduler-logger-server.log
|
|
|
|
```
|
|
|
|
|
|
|
|
## 启停服务
|
|
|
|
|
|
|
|
* 一键停止集群所有服务
|
|
|
|
|
|
|
|
` sh ./script/stop_all.sh`
|
|
|
|
|
|
|
|
* 一键开启集群所有服务
|
|
|
|
|
|
|
|
` sh ./script/start_all.sh`
|
|
|
|
|
|
|
|
* 启停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
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
如果不喜欢自动化部署,我们也可以编译源码来部署
|
|
|
|
### 编译源码部署
|
|
|
|
|
|
|
|
将源码包下载后,
|
|
|
|
|
|
|
|
* 执行编译命令:
|
|
|
|
|
|
|
|
```
|
|
|
|
mvn -U clean package assembly:assembly -Dmaven.test.skip=true
|
|
|
|
```
|
|
|
|
|
|
|
|
* 查看目录
|
|
|
|
|
|
|
|
正常编译完后,会在当前目录生成 target/escheduler-{version}/
|
|
|
|
|