填坑惟品會分佈式調度Saturn

惟品會分佈式調度Saturn的開發文檔見:https://vipshop.github.io/Saturn/#/zh-cn/3.0/quickstartjava

這裏面說要安裝node.js 8.7.0+跟npm 5.4.2+node

但其實node.js 8.7.0就已經包含了npm 5.4.2,首先下載node.js 8.7.0python

wget https://nodejs.org/dist/v8.7.0/node-v8.7.0-linux-x64.tar.gzlinux

解壓tar -xzvf node-v8.7.0-linux-x64.tar.gzgit

mv node-v8.7.0-linux-x64 /usr/local/node-8.7github

cd /usr/local/node-8.7/spring

創建軟連接docker

ln -s /usr/local/node-8.7/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npmapache

ln -s /usr/local/node-8.7/bin/node /usr/local/bin/nodenpm

修改vim /etc/profile

PATH=/usr/local/node-8.7/bin:$PATH

export PATH

保存退出,source /etc/profile

[root@host2 node-8.7]# node -v
v8.7.0
[root@host2 node-8.7]# npm -v
5.4.2

這樣咱們能夠看到node跟npm就裝好了。

由於我是從docker啓動的,而這裏須要有一個docker-compose,這裏咱們須要來安裝docker-compose.

要安裝docker-compose須要先安裝pip.

yum -y install epel-release

yum -y install python-pip

升級pip

pip install --upgrade pip

查看pip版本號

[root@host2 node-8.7]# pip -V   (這裏是大寫的V)
pip 18.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)

這個時候用pip來安裝docker-compose是確定會報錯的

pip install docker-compose

ipapython 4.5.0 requires pyldap>=2.4.15, which is not installed.
ipapython 4.5.0 has requirement dnspython>=1.15, but you'll have dnspython 1.12.0 which is incompatible.

Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

根據提示咱們來安裝pyldap也同樣會報錯

pip install pyldap

Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

ipapython 4.5.0 has requirement dnspython>=1.15, but you'll have dnspython 1.12.0 which is incompatible.

Cannot uninstall 'python-ldap'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

根據提示dnspython版本不對,要進行升級

pip install --ignore-installed dnspython

安裝yum install python-devel

安裝yum install openldap-devel

升級pip install --ignore-installed python-ldap

安裝pip install pyldap

如今能夠安裝docker-compose了

pip install docker-compose --ignore-installed requests

[root@host2 node-8.7]# docker-compose -version
docker-compose version 1.23.1, build b02f130

修改saturn-docker目錄下的quickstart-docker.sh

vim quickstart-docker.sh

把docker-compose up改爲從後臺啓動

nohup docker-compose up &

保存退出。

固然咱們還要安裝docker(若是你沒裝的話)

yum install docker

修改quickstart-docker.sh爲可執行文件

chmod 755 quickstart-docker.sh

運行該文件

./quickstart-docker.sh

咱們在瀏覽器就能夠看到管理界面了(端口號9088)

查看docker進程能夠看到他啓了什麼

[root@host1 saturn-docker]# docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                                            NAMES
d200d64a2b02        saturn/demo-init        "/saturn-executor/..."   27 hours ago        Up 25 hours                                                          demo-init
0a92685fb26c        saturn/saturn-console   "java -DSATURN_CON..."   27 hours ago        Up 25 hours         0.0.0.0:2181->2181/tcp, 0.0.0.0:9088->9088/tcp   saturn_console
08f66a0247e9        saturn/saturn-db        "docker-entrypoint..."   27 hours ago        Up 25 hours         33060/tcp, 0.0.0.0:3308->3306/tcp                saturn_db

Java開發Job填坑

新建一個maven項目(非springboot項目)

pom

<dependencies>
    <dependency>
        <groupId>com.vip.saturn</groupId>
        <artifactId>saturn-job-api</artifactId>
        <!-- 修改爲指定版本 -->
        <version>3.1.0</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>com.vip.saturn</groupId>
            <artifactId>saturn-plugin</artifactId>
            <!-- 版本與saturn-job-api一致 -->
            <version>3.1.0</version>
        </plugin>
    </plugins>
</build>

java類

package com.guanjian;


import com.vip.saturn.job.AbstractSaturnJavaJob;
import com.vip.saturn.job.SaturnJobExecutionContext;
import com.vip.saturn.job.SaturnJobReturn;

/**
 * Created by Administrator on 2018/11/5.
 */
public class DemoJob extends AbstractSaturnJavaJob {
    @Override
    public SaturnJobReturn handleJavaJob(String s, Integer integer, String s1, SaturnJobExecutionContext saturnJobExecutionContext) throws InterruptedException {
        return new SaturnJobReturn("我是分片" + integer + "處理結果");
    }
}

Windows開發環境下修改C:\Windows\System32\drivers\etc\hosts

添加192.168.5.129 console的映射(很重要,IP地址爲你安裝的服務器,教程上沒有說)

在linux系統下一樣要在/etc/hosts下添加該映射

而後刷新網卡service network restart

添加maven參數

saturn:run -Dnamespace=saturn-it.vip.com -DexecutorName=exec01 -DVIP_SATURN_CONSOLE_URI=http://192.168.5.129:9088

依據教程我就很少說了,能夠運行起來

打包:(在Windows CMD命令行下)

E:\saturntest>mvn saturn:zip
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.guanjian:saturntest >-----------------------
[INFO] Building saturntest 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> saturn-plugin:3.1.0:zip (default-cli) > package @ saturntest >>>
Downloading from central: https://repo.maven.apache.org/maven2/com/vip/saturn/saturn-job-api/3.1.0/saturn-job-api-3.1.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/com/vip/saturn/saturn-job-api/3.1.0/saturn-job-api-3.1.0.pom (463 B at 241 B/s)
Downloading from central: https://repo.maven.apache.org/maven2/com/vip/saturn/saturn-job-api/3.1.0/saturn-job-api-3.1.0.jar
Downloaded from central: https://repo.maven.apache.org/maven2/com/vip/saturn/saturn-job-api/3.1.0/saturn-job-api-3.1.0.jar (16 kB at 16 kB/s)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ saturntest ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ saturntest ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ saturntest ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory E:\saturntest\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ saturntest ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ saturntest ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ saturntest ---
[INFO] Building jar: E:\saturntest\target\saturntest-1.0-SNAPSHOT.jar
[INFO]
[INFO] <<< saturn-plugin:3.1.0:zip (default-cli) < package @ saturntest <<<
[INFO]
[INFO]
[INFO] --- saturn-plugin:3.1.0:zip (default-cli) @ saturntest ---

[INFO] Packing the saturn job into a zip file: version:3.1.0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 43.362 s
[INFO] Finished at: 2018-11-06T15:41:16+08:00
[INFO] ------------------------------------------------------------------------

此時咱們能夠看到

在target目錄下多了一個zip包。剩下的坑還有待發現(待續)

相關文章
相關標籤/搜索