1. 程式人生 > >Centos下 sitewhere2.0 部署

Centos下 sitewhere2.0 部署

前期準備 (需要安裝git、jdk1.8,在此略過)

1、安裝Docker CE

刪除老版本,如果有或者不確定的話; sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine 使用repository安裝 先設定 sudo yum install -y yum-utils device-mapper-persistent-data lvm2 sudo yum-config-manager –add-repo

https://download.docker.com/linux/centos/docker-ce.repo 安裝DOCKER CE sudo yum install docker-ce 啟動 systemctl start docker 測試,如果需要的話 sudo docker run hello-world

配置監聽Docker守護程式 監聽TCP 2375 vi /lib/systemd/system/docker.service 增加加黑部分 ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock

重啟服務 sudo systemctl daemon-reload sudo systemctl restart docker 測試一下成功與否 curl

http://localhost:2375/version {“Platform”:{“Name”:""},“Components”:[{“Name”:“Engine”,“Version”:“18.06.1-ce”,“Details”:{“ApiVersion”:“1.38”,“Arch”:“amd64”,“BuildTime”:“2018-08-21T17:25:29.000000000+00:00”,“Experimental”:“false”,“GitCommit”:“e68fc7a”,“GoVersion”:“go1.10.3”,“KernelVersion”:“3.10.0-123.el7.x86_64”,“MinAPIVersion”:“1.12”,“Os”:“linux”}}],“Version”:“18.06.1-ce”,“ApiVersion”:“1.38”,“MinAPIVersion”:“1.12”,“GitCommit”:“e68fc7a”,“GoVersion”:“go1.10.3”,“Os”:“linux”,“Arch”:“amd64”,“KernelVersion”:“3.10.0-123.el7.x86_64”,“BuildTime”:“2018-08-21T17:25:29.000000000+00:00”}

2、安裝Docker Compose

下載 sudo curl -L “https://github.com/docker/compose/releases/download/1.22.0/docker-compose-(unames)(uname -s)-(uname -m)” -o /usr/local/bin/docker-compose 修改許可權 sudo chmod +x /usr/local/bin/docker-compose 測試安裝成功否 docker-compose --version docker-compose version 1.22.0, build f46880fe

3、啟用Swarm mode

docker swarm init

4、構建

GRADLE_HOME=/usr/local/gradle-4.10.2 export PATH=GRADLEHOME/bin:{GRADLE_HOME}/bin:{PATH}

過載/etc/profile這個檔案 source /etc/profile 測試 gradle -version 生成gradlew cd /usr/local/gradle-4.10.2 gradle wrapper ln -s gradlew ./bin/gradlew

下載sitewhere git clone https://github.com/sitewhere/sitewhere.git cd sitewhere git checkout --force sitewhere-2.0.rc2 執行Gradle構建指令碼前先編輯gradle.properties,根據自己設定修改 dockerProtocol=tcp dockerHostname=localhost (在本機所以不用ip或域名) dockerPort=2375 dockerRepository=docker.io registryUrl=https://index.docker.io/v1/ registryUsername=使用者名稱 registryPassword=密碼 registryEmail=郵箱

開始構建映象 gradlew clean dockerImage 如果遇到Could not find tools.jar. Please check that /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre contains a valid JDK installation cd / find -name tools.jar 找下看有沒 好吧,可能是閹割過的卸了重新安裝 yum -y remove java-1.8.0-openjdk* yum -y install java-1.8.0-openjdk*

沒問題的話完工 docker images 應該可以看到構建映象清單 REPOSITORY TAG IMAGE ID CREATED SIZE sitewhere/service-web-rest 2.0.rc2 d4b81db1b475 About a minute ago 158MB sitewhere/service-user-management 2.0.rc2 197fe55f3148 About a minute ago 133MB sitewhere/service-tenant-management 2.0.rc2 72e3202d597b About a minute ago 132MB sitewhere/service-streaming-media 2.0.rc2 66e2bf65e2df About a minute ago 136MB sitewhere/service-schedule-management 2.0.rc2 8c14b495a4cb 2 minutes ago 134MB sitewhere/service-rule-processing 2.0.rc2 740e19f15d91 2 minutes ago 135MB sitewhere/service-outbound-connectors 2.0.rc2 31316561deb9 2 minutes ago 143MB sitewhere/service-label-generation 2.0.rc2 3a6501e0c1fb 2 minutes ago 135MB sitewhere/service-instance-management 2.0.rc2 4ea4a4330778 3 minutes ago 131MB sitewhere/service-inbound-processing 2.0.rc2 9916102afc79 3 minutes ago 136MB sitewhere/service-event-sources 2.0.rc2 9c0ed2e0709e 3 minutes ago 147MB sitewhere/service-event-search 2.0.rc2 c87f85ca42cc 4 minutes ago 133MB sitewhere/service-event-management 2.0.rc2 2ef01c3a7de5 4 minutes ago 140MB sitewhere/service-device-state 2.0.rc2 dc0c8f14f856 5 minutes ago 137MB sitewhere/service-device-registration 2.0.rc2 d7967388db5f 5 minutes ago 135MB sitewhere/service-device-management 2.0.rc2 2d794b9b7762 5 minutes ago 137MB sitewhere/service-command-delivery 2.0.rc2 108601dc07dd 5 minutes ago 137MB sitewhere/service-batch-operations 2.0.rc2 7880c7832013 5 minutes ago 136MB sitewhere/service-asset-management 2.0.rc2 f37a4fa00eb7 6 minutes ago 137MB openjdk 8-jre-alpine 0fe3f0d1ee48 2 weeks ago 83MB

5、部署

下載 git clone https://github.com/sitewhere/sitewhere-recipes.git 先構建啟動基礎服務映象 cd sitewhere-recipes/docker-compose/infrastructure_defaul docker-compose up 再啟用預設微服務 cd sitewhere-recipes/docker-compose/default docker-compose up

全部做完沒報錯的話,下載sitewhere-admin-ui 輸入使用者名稱admin密碼password ,IP地址然後登入