Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autorun dev #44

Open
wants to merge 48 commits into
base: autorun-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
c0ebf8a
Update JobXProcess.java
Aug 9, 2018
fb782a7
exec big fix!
wolfboys Aug 26, 2018
158d63d
Delete build.sh
Aug 27, 2018
c1095dc
Delete build.bat
Aug 27, 2018
3bc7804
Delete agent.sh
Aug 27, 2018
1016657
Delete server.bat
Aug 27, 2018
5668761
Delete server.sh
Aug 27, 2018
d96a0e2
Delete pom.xml
Aug 27, 2018
a88b331
Delete executor.c
Aug 27, 2018
58c725b
Create deployment
Aug 27, 2018
b13bc61
fix bug
wolfboys Aug 27, 2018
ea81d60
fix bug
wolfboys Aug 27, 2018
93de4f4
fix bug
wolfboys Aug 27, 2018
8870c01
fix bug
wolfboys Aug 27, 2018
f7ee080
fix bug
wolfboys Aug 27, 2018
aaf8b0d
Update README.md
Aug 27, 2018
92e9511
Update README.md
Aug 27, 2018
59940f2
fix bug
wolfboys Aug 28, 2018
b9b302d
fix bug
wolfboys Aug 30, 2018
ad02f05
fix bug
wolfboys Aug 30, 2018
475142f
fix bug
wolfboys Aug 30, 2018
1ad9cee
fix bug
wolfboys Aug 30, 2018
e114984
exec bug fix!
wolfboys Aug 30, 2018
3ba82d9
exec bug fix!
wolfboys Aug 31, 2018
0b1e3b7
fixbug
wolfboys Aug 31, 2018
933299c
fix bug
wolfboys Aug 31, 2018
478e98f
fix bug
wolfboys Aug 31, 2018
4da793c
fix bug
wolfboys Aug 31, 2018
3ad66cd
fix bug
wolfboys Aug 31, 2018
59b2793
fix bug
wolfboys Aug 31, 2018
1fc607c
fix bug
wolfboys Aug 31, 2018
2bfdb3e
fix bug
wolfboys Aug 31, 2018
7a69217
fix bug
wolfboys Aug 31, 2018
f3f61b0
fix bug
wolfboys Sep 5, 2018
2bbec9e
fix bug
wolfboys Sep 6, 2018
65303d2
fix bug
wolfboys Sep 6, 2018
9e8338d
fix bug
wolfboys Sep 11, 2018
dee9565
fix bug(job add error)
wolfboys Nov 28, 2018
f835176
Update server.sh
wolfboys Dec 3, 2018
c4cc3d8
Delete conf.properties
wolfboys Dec 3, 2018
4d08bd6
Update agent.sh
wolfboys Dec 3, 2018
7268607
Update build.sh
wolfboys Dec 3, 2018
0be297e
kill bug fix
pankbgos Dec 20, 2018
f1e2290
Merge pull request #33 from pankbgos/master
wolfboys Dec 20, 2018
6f3f0d6
timeout bug fix
pankbgos Dec 25, 2018
de9d55d
Merge pull request #34 from pankbgos/master
Jan 4, 2019
c00dd89
Refactor the RPC engineering structure
error0702 Jan 6, 2020
d01ecb9
maven revision add
error0702 Jan 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
222 changes: 40 additions & 182 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,188 +103,53 @@ Browser IE10+

## 安装说明

jobx分为两个jobx-server端和jobx-agent端,jobx-server端即为一个web可视化的中央管理调度平台,jobx-agent为要管理的任务的机器
agent和server都依赖zookeeper,安装部署jobx之前必须先安装和启动zookeeper,server和agent必须连接同一个zookeeper,server端依赖redis
jobx分为两个jobx-server端和jobx-agent端,jobx-server端即为一个web可视化的中央管理调度平台,
jobx-agent为要管理的任务的机器,agent和server都依赖zookeeper,安装部署jobx之前必须先安装和启动zookeeper
server和agent必须连接同一个zookeeper,server端依赖redis

## 编译步骤:

```
1)下载源码:
> git clone https://github.com/jobxhub/jobx.git

2):修改server端的配置信息
1:创建数据,数据库名字可以是jobx或者其他
2:进入jobx-server/src/main/resources 修改config.properties里的jdbc连接信息

#jdbc
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://${mysql_host}:3306/jobx?useUnicode=true&characterEncoding=UTF-8
jdbc.username=${user}
jdbc.password=${password}

#redis
redis.host=${redis.host}
redis.password=${redis.password}
redis.port=${redis.port}

#zookeeper
jobx.registry=zookeeper://${zookeeper_host}:2181?bakup=${zookeeper_host1}:2181,${zookeeper_host2}:2181

3):修改agent端配置信息
cd JobX/jobx-agent/src/conf/conf

#zookepper注册中心
jobx.registry=zookeeper://127.0.0.1:2181
2):编译:
进入deployment
> cd deployment
#修改配置信息
jobx.password=jobx
jobx.port=1577
jobx.registry=zookeeper://${zookeeper_host}:2181?bakup=${zookeeper_host1}:2181,${zookeeper_host2}:2181

4):进入源码目录执行编译:
*nix平台执行 sh build.sh
window平台双击 build.bat
编译完成的文件在build/dist下
#jobx.host=
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/jobx
jdbc.username=root
jdbc.password=${password}

5):启动agent
1)自动化部署
*nix平台: 执行 sh agent.sh
window平台: 需要进入jobx-agent/target下,解包jobx-agent-${version}.tar.gz到指定的位置,进入bin,执行startup.bat
jobx.cluster=false
jobx.cached=memcached

2) 手动部署agent步骤
redis.host=${redis.host}
redis.password=${redis.password}
redis.port=6379

memcached.servers=${memcached.servers}
memcached.protocol=BINARY

*nix平台执行 sh build.sh
window平台双击 build.bat

将jobx-agent-${version}.tar.gz包拷贝到要管理任务的目标服务器,解包,会看到以下目录
---bin/
| startup.sh #agent的启动脚本,调用的是jobx.sh来完成
| shutdown.sh #agent停止脚本,调用的是jobx.sh来完成
| jobx.sh #agent控制启动|停止的脚本
| monitor.sh #实时监控获取数据需要的脚本,由系统调度
| kill.sh #kill任务时需要的脚本,由系统调度
---conf/
conf.properties #agent配置文件
| log4j.properties #log4j配置文件
---lib/
| *.jar #agent运行需要的jar文件
---temp/
| *.sh #用于存放项目生成的零时文件的目录
---logs
| jobx.out #项目启动会产生的Log文件

> tar -xzvf jobx-agent-${version}.tar.gz
1)修改conf/conf.properties里的配置信息
#zookepper注册中心
jobx.registry=zookeeper://${zookeeper_host}:2181
#agent Ip,确保server可以通过此ip访问到该agent(主要实现agent自动注册)
jobx.host=127.0.0.1
2)启动jobx-agent 进入jobx-agent/bin
> cd jobx-agent/bin
> sh startup.sh
这里可以接受两个参数,分别是服务启动的端口和密码(默认端口是:1577,默认密码:jobx)以及agent自动注册的url和密码
如要指定参数启动命令如下:
> sh startup.sh -P10001 -p123456
参数说明:
-P (大写的p)为agent启动的端口,选填,如果不输入默认启动端口是1577
-p (小写的p)为当前agent的连接密码,选填,如果不输入默认连接该机器的密码是jobx
以下两个参数为agent自动注册需要的两个参数(选填)
该脚本启动之后agent就自动注册到server端了
更多详细的启动信息请查看logs/jobx.out

3)停止jobx-agent 进入jobx-agent/bin 执行:
> cd jobx-agent/bin
> sh shutdown.sh


6):启动server
3):启动
1) agent
*nix平台: 执行 sh agent.sh
window平台: 需要进入jobx-agent/target下,解包jobx-agent-${version}.tar.gz 双击bin/startup.bat

1) 自动化部署
*nix平台执行 server.sh
window平台执行server.bat即可完成启动

2) 手动发布 tomcat或者其他web服务器
tomcat发布项目步骤:
找到build/dist/jobx-server.war
tomcat部署有两种部署方式
1):直接部署到webapps下:
1:下载tomcat8或者以上版本(http://tomcat.apache.org)
2:解压tomcat,删除webapps目录下的全部文件
> rm -rf ${tomcat_home}/webapps/*
3:在webapps下新建ROOT文件夹
> mkdir ${tomcat_home}/webapps/ROOT
4:将war解包到ROOT下并删除war文件(注意解包完毕一定要删除war包)
> mv server.war ${tomcat_home}/webapps/ROOT
> cd ${tomcat_home}/webapps/ROOT
> jar -xvf server.war
> rm -rf server.war
5:更改jdbc和zookeeper配置信息
> vi ${tomcat_home}/webapps/ROOT/WEB-INF/classes/config.properties
6:完成启动
2):通过配置server.xml外部指向
1:将war包解压到指定的路径,如 /data/www/jobx,并删除war包
2:更改jdbc配置文件
vi /data/www/jobx/WEB-INF/classes/config.properties
3:进入tomcat的conf中修改server.xml配置文件
下面附上我的完整的server.xml配置:

<?xml version='1.0' encoding='utf-8'?>
<Server port="7000" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

<Service name="Catalina">

<!--项目的访问端口-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
maxThreads="550"
minSpareThreads="25"
maxSpareThreads="75"
minProcessors="100"
maxProcessors="300"
acceptCount="100"
enableLookups="false"
disableUploadTimeout="true"
compression="on"
compressionMinSize="2048"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain"
redirectPort="7970"
URIEncoding="UTF-8"/>
<Connector port="3007" protocol="AJP/1.3" redirectPort="2007" />

<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host name="localhost"
appBase="/data/www/jobx"
unpackWARs="true"
autoDeploy="false"
xmlValidation="false"
xmlNamespaceAware="false"
URIEncoding="UTF-8">

<Context path="/"
docBase="/data/www/jobx"
debug="0"
reloadable="true"/>
</Host>

</Engine>
</Service>

</Server>

配置里Host里的appBase和Context的docBase即为外部解压的项目的路径
推荐第二种外部部署的方式

启动tomcat,打开浏览器以$ip:$port的方式访问,如: http://192.168.0.188:8080

不论哪种方式部署,第一次会自动创建表,默认初始用户名jobx,密码jobx,第一次登陆会提示修改密码.

3):进入到jobx的管理端,如果agent也启动了,应该可以直接在server的执行器页面看到agent,则添加任务即可...
2) server
*nix平台: 执行 sh server.sh 8080
window平台 双击 server.bat

3) 进入到jobx的管理端,如果agent也启动了,应该可以直接在server的执行器页面看到agent,则添加任务即可...

```

Expand All @@ -293,12 +158,10 @@ Browser IE10+
1):如果自行编译项目的,有可能agent端的脚本执行失败,这时请更改agent/bin下所有的脚本的字符集
a) vim *.sh
b) :set ff=unix 保存退出即可

2):如果脚本字符编码已经是unix,还是启动失败,请尝试给启动脚本添加权限 chmod 777 bin/*

3):如果agent已经成功启动server还是连接不上,请检查agent端口是否开放(如很多云服务器得开放端口才能访问)
2):如果agent已经成功启动server还是连接不上,请检查agent端口是否开放(如很多云服务器得开放端口才能访问)

4):如果server端用nginx做反向代理,配置如下:
3):如果server端用nginx做反向代理,配置如下:


upstream jobx {
Expand Down Expand Up @@ -346,14 +209,9 @@ server {
## 常见问题:
```
1)创建作业运行身份无法选择?
由于考虑到权限的问题,当前登录的用户不能随便指定任务的执行身份,需要超级管理员权限的用户(jobx)登录,在设置页面统一设置运行身份,多个运行身份用","分割,然后超级管理员在编辑用户
为该用户指定可以执行的身份(可选择多个),这样用户在创建任务的时候就可以选择指定身份去执行了

2) executor.so:cannot execute binary file
需要授权agent/bin下面的所有文件777权限
> chmod 777 jobx-agent/bin/*
如果授权完还提示这个错,则需要进入源码目录(JobX/jobx-executor/src/main/c/executor.c),手动gcc编译下executor.c文件,然后将编译完的文件命名成executor.so,放到jobx-agent/bin下
并且授777权限
由于考虑到权限的问题,当前登录的用户不能随便指定任务的执行身份,需要超级管理员权限的用户(jobx)登录,在设置页面统一设置运行身份,
多个运行身份用","分割,然后超级管理员在编辑用户,为该用户指定可以执行的身份(可选择多个)
这样用户在创建任务的时候就可以选择指定身份去执行了

```

Expand Down
22 changes: 9 additions & 13 deletions agent.sh → deployment/agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,34 @@ done
PRGDIR=`dirname "$PRG"`

WORKDIR=`cd "$PRGDIR" >/dev/null; pwd`;
WORKBASE=`cd "$PRGDIR"/../ >/dev/null; pwd`;

# Get standard environment variables
###############################################################################################
APP_ARTIFACT=jobx-agent
APP_VERSION="1.2.0-RELEASE";
APP_TAR_NAME=${APP_ARTIFACT}-${APP_VERSION}.tar.gz
MAVEN_TARGET_TAR="${WORKDIR}"/${APP_ARTIFACT}/target/${APP_TAR_NAME}
DIST_PATH=${WORKDIR}/dist/
MAVEN_TARGET_TAR="${WORKBASE}"/${APP_ARTIFACT}/target/${APP_TAR_NAME}
DEPLOY_PATH=${WORKDIR}/jobx-agent
CONFIG_TEMPLATE=${WORKDIR}/conf.properties
CONFIG_PATH=${DEPLOY_PATH}/conf/conf.properties
###############################################################################################

[ ! -d "${DIST_PATH}" ] && mkdir -p "${DIST_PATH}"

DEPLOY_PATH=${WORKDIR}/dist/jobx-agent

#先检查dist下是否有war包
if [ ! -f "${DIST_PATH}/${APP_TAR_NAME}" ] ; then
if [ ! -f "${WORKDIR}/${APP_TAR_NAME}" ] ; then
#dist下没有tar包则检查agent的target下是否有tar包.
if [ ! -f "${MAVEN_TARGET_TAR}" ] ; then
echo_r "[JobX] please build project first!"
exit 0;
else
cp ${MAVEN_TARGET_TAR} ${DIST_PATH};
cp ${MAVEN_TARGET_TAR} ${WORKDIR};
fi
fi

[ -d "${DEPLOY_PATH}" ] && rm -rf ${DEPLOY_PATH}/* || mkdir -p ${DEPLOY_PATH}

tar -xzvf ${DIST_PATH}/${APP_TAR_NAME} -C ${DEPLOY_PATH}/../ >/dev/null 2>&1 && chmod +x ${DEPLOY_PATH}/bin/* >/dev/null 2>&1

#untar..
tar -xzvf ${WORKDIR}/${APP_TAR_NAME} && chmod +x ${DEPLOY_PATH}/bin/* >/dev/null 2>&1
EXECUTABLE=${DEPLOY_PATH}/bin/startup.sh

# Check that target executable exists
if $os400; then
# -x will Only work on the os400 if the files are:
Expand All @@ -104,5 +101,4 @@ else
exit 1
fi
fi

exec "$EXECUTABLE" "$@"
35 changes: 17 additions & 18 deletions build.bat → deployment/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
@REM In debug mode we need a real JDK (JAVA_HOME)

echo\
echo _______
echo /\ _________ ______ _____ / /
echo (()) ______ / ________ / ___ \/ /
echo \/ ___ _ / _ __ \_ __ \ ___ /
echo / /_/ / / /_/ / /_/ / __ . \
echo _______
echo /\ _________ ______ _____ / /
echo (()) ______ / ________ / ___ \/ /
echo \/ ___ _ / _ __ \_ __ \ ___ /
echo / /_/ / / /_/ / /_/ / __ . \
echo \____/ \____/ /_.___/ __ / \_\__
echo _____ /
echo _____ /
echo\

if ""%1"" == ""debug"" goto needJavaHome
Expand Down Expand Up @@ -106,14 +106,14 @@ setlocal
@REM Guess JOBX_HOME if not defined

set "WORK_DIR=%~dp0"
set "JOBX_HOME=%WORK_DIR%"
set "JOBX_BASE=%JOBX_HOME%"
set "JOBX_HOME=%WORK_DIR%\..\"

@REM #################################################################################################
set JOBX_VERSION=1.2.0-RELEASE
set DIST_HOME=%JOBX_HOME%\dist
set JOBX_AGENT=%JOBX_HOME%\jobx-agent\target\jobx-agent-%JOBX_VERSION%.tar.gz
set JOBX_SERVER=%JOBX_HOME%\jobx-server\target\jobx-server-%JOBX_VERSION%.war
set JOBX_AGENT_TAR=%WORK_DIR%\jobx-agent-%JOBX_VERSION%.tar.gz
set JOBX_SERVER_WAR=%WORK_DIR%\jobx-server-%JOBX_VERSION%.war
set "EXECUTABLE=%JOBX_HOME%\.mvn\mvnw.cmd"
@REM #################################################################################################

Expand All @@ -123,21 +123,20 @@ echo This file is needed to run this program
goto exit

:okExec
call "%EXECUTABLE%" "clean" "install" "-Dmaven.test.skip=true"
if %errorlevel%==0 goto toDist
call "%EXECUTABLE%" "-f" "%JOBX_HOME%\pom.xml" "clean" "install" "-Dmaven.test.skip=true"
if %errorlevel%==0 goto toCopy
goto exit

:toDist
if exist "%DIST_HOME%" rd /s /q %DIST_HOME%
if not exist "%DIST_HOME%" mkdir %DIST_HOME%
copy %JOBX_AGENT% %DIST_HOME%
copy %JOBX_SERVER% %DIST_HOME%
echo [JobX] build jobx @Version %JOBX_VERSION% successfully! please goto %DIST_HOME%
:toCopy
if exist "%JOBX_AGENT_TAR%" rd /s /q %JOBX_AGENT_TAR%
if exist "%JOBX_SERVER_WAR%" rd /s /q %JOBX_SERVER_WAR%
copy %JOBX_AGENT% %WORK_DIR%
copy %JOBX_SERVER% %WORK_DIR%
echo [JobX] build jobx @Version %JOBX_VERSION% successfully! please goto %WORK_DIR%
pause

:exit
exit /b 1

:end
exit /b 0

Loading