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

构建docker集群环境 #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 23 additions & 0 deletions carrera-prod/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## DDMQ PROD ##

1、创建自定义网络:

* docker network create --subnet=172.18.0.0/16 ddmq-net
* docker network ls

2、将carrera-prod/mysql/ddmq.sql导入宿主机MySQL的carrera_open_source库

* 这里宿主机的MySQL的root账号密码是wawa521
* 需要修改账号和密码,需要修改carrera-console/carrera-console/setting/carrera-console-dev.properties文件,并且重新编译

3、修改启动脚本

* 这里宿主机IP是192.168.11.24,请将carrera-prod/play.sh里面的192.168.11.24改为实际宿主机的IP
* mkdir -p /usr/local/var/rocketmq
* chmod 777 /usr/local/var/rocketmq
* 在docker中设置共享目录 /usr/local/var/rocketmq

4、启动集群

* sh carrera-prod/play.sh

10 changes: 10 additions & 0 deletions carrera-prod/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

(cd ../carrera-common && mvn clean install -DskipTests)
(cd ../carrera-sdk/consumer/java/carrera-consumer-sdk && mvn clean install -DskipTests)
(cd ../carrera-sdk/producer/java/carrera-producer-sdk && mvn clean install -DskipTests)

../carrera-producer/build.sh && cp ../carrera-producer/target/carrera-producer-1.0.0-SNAPSHOT-jar-with-dependencies.jar n01/producer/ && cp ../carrera-producer/target/carrera-producer-1.0.0-SNAPSHOT-jar-with-dependencies.jar n02/producer/ && cp ../carrera-producer/target/carrera-producer-1.0.0-SNAPSHOT-jar-with-dependencies.jar n03/producer/
../carrera-consumer/build.sh && cp ../carrera-consumer/target/carrera-consumer-1.0.0-SNAPSHOT-jar-with-dependencies.jar n01/consumer/ && cp ../carrera-consumer/target/carrera-consumer-1.0.0-SNAPSHOT-jar-with-dependencies.jar n02/consumer/ && cp ../carrera-consumer/target/carrera-consumer-1.0.0-SNAPSHOT-jar-with-dependencies.jar n03/consumer/
../carrera-chronos/build.sh && cp ../carrera-chronos/target/chronos-1.0.0-SNAPSHOT-jar-with-dependencies.jar n01/chronos/ && cp ../carrera-chronos/target/chronos-1.0.0-SNAPSHOT-jar-with-dependencies.jar n02/chronos/
../carrera-console/build.sh && cp ../carrera-console/carrera-console/target/carrera.war n01/console/ && cp ../carrera-console/carrera-console/target/carrera.war n02/console/ && cp ../carrera-console/carrera-console/target/carrera.war n03/console/
9 changes: 9 additions & 0 deletions carrera-prod/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM mysql:5.7

ENV MYSQL_ALLOW_EMPTY_PASSWORD yes
ENV MYSQL_DATABASE=carrera_open_source
ENV MYSQL_ROOT_PASSWORD=wawa521

ADD ddmq.sql /docker-entrypoint-initdb.d

EXPOSE 3306
379 changes: 379 additions & 0 deletions carrera-prod/mysql/ddmq.sql

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions carrera-prod/n01/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM centos:7

## Ports
EXPOSE 9613
EXPOSE 9713
EXPOSE 8080
EXPOSE 2181

# Env
ENV HOME_DIR /root
ENV HOME /root

WORKDIR ${HOME_DIR}

RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo 'Asia/Shanghai' >/etc/timezone

RUN yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel unzip gettext nmap-ncat openssl wget telnet\
&& yum clean all -y

RUN curl http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.24/bin/apache-tomcat-9.0.24.zip -o tomcat.zip \
&& unzip tomcat.zip \
&& mv apache-tomcat-9.0.24 tomcat \
&& rm tomcat.zip \
&& chmod +x tomcat/bin/*.sh

RUN curl http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz -o zookeeper-3.4.10.tar.gz \
&& tar xzvf zookeeper-3.4.10.tar.gz \
&& mv zookeeper-3.4.10 zookeeper \
&& rm zookeeper-3.4.10.tar.gz \
&& cp zookeeper/conf/zoo_sample.cfg zookeeper/conf/zoo.cfg \
&& echo "dataDir=/root/zookeeper/data" >> zookeeper/conf/zoo.cfg \
&& echo "server.1=172.18.0.3:2888:3888" >> zookeeper/conf/zoo.cfg \
&& echo "server.2=172.18.0.4:2888:3888" >> zookeeper/conf/zoo.cfg \
&& echo "server.3=172.18.0.5:2888:3888" >> zookeeper/conf/zoo.cfg \
&& mkdir zookeeper/data \
&& echo '1' > zookeeper/data/myid

RUN mkdir -p \
/root/logs/rocketmqlogs \
/root/chronos-storage/rocksdb \
/root/chronos-storage/seektimestamp \
/root/chronos-storage/rocksdb_backup \
/root/chronos-storage/rocksdb_restore

# copy
COPY console ${HOME_DIR}/console
COPY consumer ${HOME_DIR}/consumer
COPY producer ${HOME_DIR}/producer
COPY chronos ${HOME_DIR}/chronos
COPY broker ${HOME_DIR}/broker
COPY namesvr ${HOME_DIR}/namesvr
COPY start.sh ${HOME_DIR}/start.sh
COPY stop.sh ${HOME_DIR}/stop.sh

# cmd
CMD bash -C '/root/start.sh';'bash'
334 changes: 334 additions & 0 deletions carrera-prod/n01/broker/LICENSE

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions carrera-prod/n01/broker/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Apache RocketMQ
Copyright 2016-2017 The Apache Software Foundation

This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).

------
This product has a bundle netty:
The Netty Project
=================

Please visit the Netty web site for more information:

* http://netty.io/

Copyright 2014 The Netty Project

The Netty Project licenses this file to you under the Apache License,
version 2.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.

Also, please refer to each LICENSE.<component>.txt file, which is located in
the 'license' directory of the distribution file, for the license terms of the
components that this product depends on.

------
This product has a bundle commons-lang, which includes software from the Spring Framework,
under the Apache License 2.0 (see: StringUtils.containsWhitespace())
29 changes: 29 additions & 0 deletions carrera-prod/n01/broker/bin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
### Operating system tuning
Before deploying broker servers, it's highly recommended to run **os.sh**, which is to optimize your operating system for better performance.

## Notice
### os.sh should be executed only once with root permission.
### os.sh parameter settings are for reference purpose only. You can tune them according to your target host configurations.


### Start broker
* Unix platform

`nohup sh mqbroker &`

### Shutdown broker
sh mqshutdown broker

### Start Nameserver
* Unix platform

`nohup sh mqnamesrv &`

### Shutdown Nameserver
sh mqshutdown namesrv

### Update or create Topic
sh mqadmin updateTopic -b 127.0.0.1:10911 -t TopicA

### Update or create subscription group
sh mqadmin updateSubGroup -b 127.0.0.1:10911 -g SubGroupA
42 changes: 42 additions & 0 deletions carrera-prod/n01/broker/bin/cachedog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

export PATH=$PATH:/sbin

while true; do
nr_free_pages=`fgrep -A 10 Normal /proc/zoneinfo |grep nr_free_pages |awk -F ' ' '{print $2}'`
high=`fgrep -A 10 Normal /proc/zoneinfo |grep high |awk -F ' ' '{print $2}'`

NOW_DATE=`date +%D`
NOW_TIME=`date +%T`

if [ ${nr_free_pages} -le ${high} ]; then
sysctl -w vm.drop_caches=3
nr_free_pages_new=`fgrep -A 10 Normal /proc/zoneinfo |grep nr_free_pages |awk -F ' ' '{print $2}'`

printf "%s %s [CLEAN] nr_free_pages < high, clean cache. nr_free_pages=%s ====> nr_free_pages=%s\n" "${NOW_DATE}" "${NOW_TIME}" ${nr_free_pages} ${nr_free_pages_new}

sysctl -w vm.drop_caches=1
echo
echo
echo
else
printf "%s %s [NOTHING] nr_free_pages=%s high=%s\n" "${NOW_DATE}" "${NOW_TIME}" ${nr_free_pages} ${high}
fi

sleep 1
done
20 changes: 20 additions & 0 deletions carrera-prod/n01/broker/bin/cleancache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

export PATH=$PATH:/sbin

sysctl -w vm.drop_caches=3
40 changes: 40 additions & 0 deletions carrera-prod/n01/broker/bin/cleancache.v1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

export PATH=$PATH:/sbin

#
# GB
#
function changeFreeCache()
{
EXTRA=$1
MIN=$2
sysctl -w vm.extra_free_kbytes=${EXTRA}000000
sysctl -w vm.min_free_kbytes=${MIN}000000
}


if [ $# -ne 1 ]
then
echo "Usage: $0 freecache(GB)"
echo "Example: $0 15"
exit
fi

changeFreeCache 3 $1
changeFreeCache 3 1
45 changes: 45 additions & 0 deletions carrera-prod/n01/broker/bin/mqadmin
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if [ -z "$ROCKETMQ_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"

# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done

saveddir=`pwd`

ROCKETMQ_HOME=`dirname "$PRG"`/..

# make it fully qualified
ROCKETMQ_HOME=`cd "$ROCKETMQ_HOME" && pwd`

cd "$saveddir"
fi

export ROCKETMQ_HOME

sh ${ROCKETMQ_HOME}/bin/tools.sh org.apache.rocketmq.tools.command.MQAdminStartup $@
18 changes: 18 additions & 0 deletions carrera-prod/n01/broker/bin/mqadmin.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

if not exist "%ROCKETMQ_HOME%\bin\tools.cmd" echo Please set the ROCKETMQ_HOME variable in your environment! & EXIT /B 1
call "%ROCKETMQ_HOME%\bin\tools.cmd" org.apache.rocketmq.tools.command.MQAdminStartup %*
43 changes: 43 additions & 0 deletions carrera-prod/n01/broker/bin/mqadmin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<java>
<debug>false</debug>

<javahome>${JAVA_HOME}</javahome>

<jvmtype>server</jvmtype>

<mainclass>org.apache.rocketmq.tools.command.MQAdminStartup</mainclass>

<properties>
<java.ext.dirs>${cpd}/../lib</java.ext.dirs>
<rocketmq.home.dir>${cpd}/..</rocketmq.home.dir>
</properties>

<classpaths>
</classpaths>

<options>
<-Xms512m></-Xms512m>
<-Xmx1g></-Xmx1g>
<-XX:NewSize>256M</-XX:NewSize>
<-XX:MaxNewSize>512M</-XX:MaxNewSize>
<-XX:PermSize>128M</-XX:PermSize>
<-XX:MaxPermSize>128M</-XX:MaxPermSize>
</options>
</java>
Loading