虚机搭建RocketMQ服务
准备工作
新建虚拟机:VMware 、Linux镜像(链接:https://pan.baidu.com/s/1Evyuyq8tuPI40X_0wt_S5Q 提取码:uy2v)
(1):使用仅主机模式网络、IP设置(保证物理机虚拟网卡可用、虚机IP设置与物理机物理网卡在同一网段,如果虚机需要上网,将物理机使用的网卡,设置为共享即可)
(2):关于分配资源,根据自己物理机的情况来看
(3):虚机跑起来(Server模式)以后,Xshell连接访问(便于工作)
软件环境
RocketMQ服务搭建之前,虚机中应该已经有的应用:
1:JDK
我的习惯是先卸载掉OpenJDK,再安装商用JDK(Oracle JDK)
1.1查看已经有的JDK
[aaa@qq.com dev]# java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-b12)
OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)
1.2检测JDK安装包
[aaa@qq.com dev]# rpm -qa|grep java
java-1.8.0-openjdk-headless-1.8.0.131-11.b12.el7.x86_64
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64
tzdata-java-2017b-1.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
1.3卸载openjdk
[aaa@qq.com dev]# yum remove *openjdk*
[aaa@qq.com dev]# rpm -qa|grep java
javapackages-tools-3.4.1-11.el7.noarch
tzdata-java-2017b-1.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
1.4安装自己的JDK
准备好jdk的包,rz到虚机,自己的目录底下:
[aaa@qq.com dev]# ll
total 181168
-rw-r--r--. 1 root root 185515842 Sep 27 02:44 jdk-8u144-linux-x64.tar.gz
解压第一步:
[aaa@qq.com dev]# tar -zxvf jdk-8u144-linux-x64.tar.gz -C /home/jdk
[aaa@qq.com dev]# ll /home/jdk
total 0
drwxr-xr-x. 8 10 143 255 Jul 22 2017 jdk1.8.0_144
配置环境变量:
[aaa@qq.com dev]# vim /etc/profile
export JAVA_HOME=/home/jdk/jdk1.8.0_144
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
[aaa@qq.com dev]# source /etc/profile
[aaa@qq.com dev]# java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
2:maven安装(用户构建RocketMQ)
压缩包上传虚机、解压、配置环境变量,过程同JDK一样
export JAVA_HOME=/home/jdk/jdk1.8.0_144
export JRE_HOME=${JAVA_HOME}/jre
export MAVEN_HOME=/home/maven/apache-maven-3.6.3
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:${MAVEN_HOME}/bin:$PATH
[aaa@qq.com dev]# source /etc/profile
[aaa@qq.com dev]# mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/maven/apache-maven-3.6.3
Java version: 1.8.0_144, vendor: Oracle Corporation, runtime: /home/jdk/jdk1.8.0_144/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-693.el7.x86_64", arch: "amd64", family: "unix"
本地仓库配置
[aaa@qq.com dev]# vim /home/maven/apache-maven-3.6.3/conf/settings.xml
<localRepository>/home/maven/repository</localRepository>
阿里的私服配上
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
插曲
Redhat 无法yum
[aaa@qq.com dev]# yum repolist all
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
repolist: 0
卸载、换成国内的
[aaa@qq.com dev]# rpm -qa |grep yum
yum-3.4.3-154.el7.noarch
yum-langpacks-0.4.2-7.el7.noarch
yum-rhn-plugin-2.0.1-9.el7.noarch
yum-utils-1.1.31-42.el7.noarch
PackageKit-yum-1.1.5-1.el7.x86_64
yum-metadata-parser-1.1.4-10.el7.x86_64
[aaa@qq.com dev]# rpm -qa|grep yum|xargs rpm -e --nodeps
warning: /etc/yum/pluginconf.d/langpacks.conf saved as /etc/yum/pluginconf.d/langpacks.conf.rpmsave
[aaa@qq.com dev]# rpm -qa |grep yum
[aaa@qq.com dev]#
[aaa@qq.com ~]# wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/yum-3.4.3-163.el7.centos.noarch.rpm
[aaa@qq.com ~]# wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
[aaa@qq.com ~]# wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
[aaa@qq.com ~]# wget http://mirrors.163.com/centos/7.7.1908/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
根据自己的虚机系统版本,找可用的yum源
下载好以后:
[aaa@qq.com ~]# ll |grep rpm
-rw-r--r--. 1 root root 39800 Jul 4 2014 python-iniparse-0.4-9.el7.noarch.rpm
-rw-r--r--. 1 root root 1297332 Aug 23 2019 yum-3.4.3-163.el7.centos.noarch.rpm
-rw-r--r--. 1 root root 28348 Jul 4 2014 yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
-rw-r--r--. 1 root root 34744 Aug 23 2019 yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
最重要的是yum开头的而几个
修改配置文件:
[aaa@qq.com ~]# vim /etc/yum.repos.d/rhel-debuginfo.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.163.com/centos/7.7.1908/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/7.7.1908/os/x86_64/RPM-GPG-KEY-CentOS-7
# released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.163.com/centos/7.7.1908/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/7.7.1908/os/x86_64/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.163.com/centos/7.7.1908/extras//$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/7.7.1908/os/x86_64/RPM-GPG-KEY-CentOS-7
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.163.com/centos/7.7.1908/centosplus//$basearch/
gpgcheck=1
enabled=0
更新yum
[aaa@qq.com dev]# yum makecache
Apache RocketMQ推荐unzip解压,所以必须先install zip unzip
[aaa@qq.com dev]# yum install zip unzip
安装我需要的uzip和zip
[aaa@qq.com dev]# yum install zip unzip
[aaa@qq.com dev]# yum list|grep zip.x86
gzip.x86_64 1.5-9.el7 @anaconda/7.4
unzip.x86_64 6.0-20.el7 @base
zip.x86_64 3.0-11.el7 @anaconda/7.4
3:RocketMQ安装
3.1下载解压第一步(我选择从Apache上取,当然也可以从github clone源码,那就必须再装git喽):
[aaa@qq.com dev]# unzip rocketmq-all-4.3.0-source-release.zip
3.2 构建
[aaa@qq.com rocketmq-all-4.3.0]# pwd
/home/rocketmq/rocketmq-all-4.3.0
[aaa@qq.com rocketmq-all-4.3.0]# mvn -Prelease-all -DskipTests clean install -U
构建成功的样子(大概5min)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Apache RocketMQ 4.3.0 4.3.0:
[INFO]
[INFO] Apache RocketMQ 4.3.0 .............................. SUCCESS [01:40 min]
[INFO] rocketmq-logging 4.3.0 ............................. SUCCESS [ 9.163 s]
[INFO] rocketmq-remoting 4.3.0 ............................ SUCCESS [ 4.294 s]
[INFO] rocketmq-common 4.3.0 .............................. SUCCESS [ 4.116 s]
[INFO] rocketmq-client 4.3.0 .............................. SUCCESS [ 7.341 s]
[INFO] rocketmq-store 4.3.0 ............................... SUCCESS [ 5.031 s]
[INFO] rocketmq-srvutil 4.3.0 ............................. SUCCESS [ 2.223 s]
[INFO] rocketmq-filter 4.3.0 .............................. SUCCESS [ 1.924 s]
[INFO] rocketmq-broker 4.3.0 .............................. SUCCESS [ 5.308 s]
[INFO] rocketmq-tools 4.3.0 ............................... SUCCESS [ 3.220 s]
[INFO] rocketmq-namesrv 4.3.0 ............................. SUCCESS [ 1.334 s]
[INFO] rocketmq-logappender 4.3.0 ......................... SUCCESS [ 2.167 s]
[INFO] rocketmq-openmessaging 4.3.0 ....................... SUCCESS [ 2.094 s]
[INFO] rocketmq-example 4.3.0 ............................. SUCCESS [ 1.339 s]
[INFO] rocketmq-test 4.3.0 ................................ SUCCESS [ 5.980 s]
[INFO] rocketmq-distribution 4.3.0 ........................ SUCCESS [01:22 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:00 min
[INFO] Finished at: 2020-03-22T17:25:27+08:00
[INFO] ------------------------------------------------------------------------
修改日志的默认路径
[aaa@qq.com apache-rocketmq]# vim conf/logback_namesrv.xml
:%s/${user.home}/\/home\/rocketmq/g
我将namesrv和broker默认的日志地址都改了
测试
启动namesrv
[aaa@qq.com apache-rocketmq]# nohup sh bin/mqnamesrv &
[aaa@qq.com dev]# tail -f /home/rocketmq/logs/rocketmqlogs/namesrv.log
2020-03-22 18:20:23 INFO main - tls.client.certPath = null
2020-03-22 18:20:23 INFO main - tls.client.authServer = false
2020-03-22 18:20:23 INFO main - tls.client.trustCertPath = null
2020-03-22 18:20:24 INFO main - Using OpenSSL provider
2020-03-22 18:20:24 INFO main - SSLContext created for server
2020-03-22 18:20:24 INFO NettyEventExecutor - NettyEventExecutor service started
2020-03-22 18:20:24 INFO main - The Name Server boot success. serializeType=JSON
2020-03-22 18:20:24 INFO FileWatchService - FileWatchService service started
2020-03-22 18:21:24 INFO NSScheduledThread1 - --------------------------------------------------------
2020-03-22 18:21:24 INFO NSScheduledThread1 - configTable SIZE: 0
看到"The Name Server boot success. serializeType=JSON",说明启动成功了!
启动broker
[aaa@qq.com apache-rocketmq] nohup sh bin/mqbroker -n localhost:9876 &
发现并没有日志生成,nohup的异常日志中有输出:
[aaa@qq.com apache-rocketmq]# cat nohup.out
Java HotSpot(TM) 64-Bit Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release
Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
The Name Server boot success. serializeType=JSON
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000005c0000000, 8589934592, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 8589934592 bytes for committing reserved memory.
# An error report file with more information is saved as:
启动配置的JVM可能太大了,那就给参数调小,在哪调整呢?
[aaa@qq.com apache-rocketmq]# ll ./bin/ |grep run*
-rwxr-xr-x. 1 root root 819 Jul 26 2018 runbroker
-rwxr-xr-x. 1 root root 2206 Jul 26 2018 runbroker.cmd
-rwxr-xr-x. 1 root root 2869 Jul 26 2018 runbroker.sh
-rwxr-xr-x. 1 root root 1816 Jul 26 2018 runserver.cmd
-rwxr-xr-x. 1 root root 2443 Jul 26 2018 runserver.sh
runserver.sh
#===========================================================================================
# JVM Configuration
#===========================================================================================
#JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn125m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:-UseParNewGC"
JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/rmq_srv_gc.log -XX:+PrintGCDetails"
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"
JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"
#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
runbroker.sh
#===========================================================================================
# JVM Configuration
#===========================================================================================
#JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn125m"
JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:SurvivorRatio=8"
JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:/dev/shm/mq_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=15g"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking"
JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"
#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
保存修改,再次启动namesrv
[aaa@qq.com apache-rocketmq]# nohup sh bin/mqnamesrv &
再次看到启动成功的标志:
2020-03-22 18:44:30 INFO main - The Name Server boot success. serializeType=JSON
broker
[aaa@qq.com apache-rocketmq]# nohup sh bin/mqbroker -n localhost:9876 &
[aaa@qq.com rocketmqlogs]# tail -f /home/rocketmq/logs/rocketmqlogs/broker.log
2020-03-22 18:45:02 WARN main - Load default transaction message hook service: TransactionalMessageServiceImpl
2020-03-22 18:45:02 WARN main - Load default discard message hook service: DefaultTransactionalMessageCheckListener
2020-03-22 18:45:02 INFO PullRequestHoldService - PullRequestHoldService service started
2020-03-22 18:45:02 INFO FileWatchService - FileWatchService service started
2020-03-22 18:45:03 INFO brokerOutApi_thread_1 - register broker to name server localhost:9876 OK
2020-03-22 18:45:03 INFO main - Start transaction service!
2020-03-22 18:45:03 INFO main - The broker[rocketmq, 192.168.23.168:10911] boot success. serializeType=JSON and name server is localhost:9876
2020-03-22 18:45:12 INFO BrokerControllerScheduledThread1 - dispatch behind commit log 0 bytes
2020-03-22 18:45:12 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 0 bytes
2020-03-22 18:45:13 INFO brokerOutApi_thread_2 - register broker to name server localhost:9876 OK
2020-03-22 18:45:43 INFO brokerOutApi_thread_3 - register broker to name server localhost:9876 OK
2020-03-22 18:46:03 INFO TransactionalMessageCheckService - create new topic TopicConfig [topicName=RMQ_SYS_TRANS_HALF_TOPIC, readQueueNums=1, writeQueueNums=1, perm=RW-, topicFilterType=SINGLE_TAG, topicSysFlag=0, order=false]
2020-03-22 18:46:03 INFO brokerOutApi_thread_4 - register broker to name server localhost:9876 OK
2020-03-22 18:46:12 INFO BrokerControllerScheduledThread1 - dispatch behind commit log 0 bytes
2020-03-22 18:46:12 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 0 bytes
2020-03-22 18:46:13 INFO brokerOutApi_thread_1 - register broker to name server localhost:9876 OK
2020-03-22 18:46:43 INFO brokerOutApi_thread_2 - register broker to name server localhost:9876 OK
2020-03-22 18:47:12 INFO BrokerControllerScheduledThread1 - dispatch behind commit log 0 bytes
2020-03-22 18:47:12 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 0 bytes
2020-03-22 18:47:13 INFO brokerOutApi_thread_3 - register broker to name server localhost:9876 OK
OK,broker也启动成功了!
终于可以RocketMQ 的HelloWorld
进入指定目录:
[aaa@qq.com apache-rocketmq]# pwd
/home/rocketmq/rocketmq-all-4.3.0/distribution/target/apache-rocketmq
生产者和消费者在同一个terminal 窗口执行,否则看不到效果呢!
Producer demo:
[aaa@qq.com apache-rocketmq]# export NAMESRV_ADDR=localhost:9876
[aaa@qq.com apache-rocketmq]# sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
19:00:11.944 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
SendResult [sendStatus=SEND_OK, msgId=C0A817A8D37C7D4991AD7039701F0000, offsetMsgId=C0A817A800002A9F000000000002BEB2, messageQueue=MessageQueue [topic=TopicTest, brokerName=rocketmq, queueId=0], queueOffset=250]
SendResult [sendStatus=SEND_OK, msgId=C0A817A8D37C7D4991AD7039703E0001, offsetMsgId=C0A817A800002A9F000000000002BF64, messageQueue=MessageQueue [topic=TopicTest, brokerName=rocketmq, queueId=1], queueOffset=250]
SendResult [sendStatus=SEND_OK, msgId=C0A817A8D37C7D4991AD703970420002, offsetMsgId=C0A817A800002A9F000000000002C016, messageQueue=MessageQueue [topic=TopicTest, brokerName=rocketmq, queueId=2], queueOffset=250]
SendResult [sendStatus=SEND_OK, msgId=C0A817A8D37C7D4991AD7039704D0003, offsetMsgId=C0A817A800002A9F000000000002C0C8, messageQueue=MessageQueue [topic=TopicTest, brokerName=rocketmq, queueId=3], queueOffset=250]
……………………………………………………………………………………………………………
Consumer demo:
[aaa@qq.com apache-rocketmq]# sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
19:00:24.804 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework
Consumer Started.
ConsumeMessageThread_1 Receive New Messages: [MessageExt [queueId=1, storeSize=178, queueOffset=250, sysFlag=0, bornTimestamp=1584874812478, bornHost=/192.168.23.168:35028, storeTimestamp=1584874812480, storeHost=/192.168.23.168:10911, msgId=C0A817A800002A9F000000000002BF64, commitLogOffset=180068, bodyCRC=1401636825, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='TopicTest', flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=500, CONSUME_START_TIME=1584874825406, UNIQ_KEY=C0A817A8D37C7D4991AD7039703E0001, WAIT=true, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 49], transactionId='null'}]]
ConsumeMessageThread_2 Receive New Messages: [MessageExt [queueId=1, storeSize=178, queueOffset=251, sysFlag=0, bornTimestamp=1584874812508, bornHost=/192.168.23.168:35028, storeTimestamp=1584874812511, storeHost=/192.168.23.168:10911, msgId=C0A817A800002A9F000000000002C22C, commitLogOffset=180780, bodyCRC=1424393152, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='TopicTest', flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=500, CONSUME_START_TIME=1584874825419, UNIQ_KEY=C0A817A8D37C7D4991AD7039705C0005, WAIT=true, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 53], transactionId='null'}]]
ConsumeMessageThread_3 Receive New Messages: [MessageExt [queueId=1, storeSize=178, queueOffset=252, sysFlag=0, bornTimestamp=1584874812528, bornHost=/192.168.23.168:35028, storeTimestamp=1584874812529, storeHost=/192.168.23.168:10911, msgId=C0A817A800002A9F000000000002C4F4, commitLogOffset=181492, bodyCRC=1565577195, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='TopicTest', flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=500, CONSUME_START_TIME=1584874825431, UNIQ_KEY=C0A817A8D37C7D4991AD703970700009, WAIT=true, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 57], transactionId='null'}]]
ConsumeMessageThread_4 Receive New Messages: [MessageExt [queueId=1, storeSize=179, queueOffset=253, sysFlag=0, bornTimestamp=1584874812560, bornHost=/192.168.23.168:35028, storeTimestamp=1584874812561, storeHost=/192.168.23.168:10911, msgId=C0A817A800002A9F000000000002C7BF, commitLogOffset=182207, bodyCRC=311324588, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='TopicTest', flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=500, CONSUME_START_TIME=1584874825444, UNIQ_KEY=C0A817A8D37C7D4991AD70397090000D, WAIT=true, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 49, 51], transactionId='null'}]]
……………………………………………………………………………………………………………
这就算完成了RocketMQ服务的搭建,还有怎么停下服务呢?
关掉broker:
[aaa@qq.com distribution]# sh bin/mqshutdown broker
The mqbroker(53673) is running...
Send shutdown request to mqbroker(53673) OK
[aaa@qq.com distribution]# pwd
/home/rocketmq/rocketmq-all-4.3.0/distribution
关掉namesrv:
[aaa@qq.com distribution]# sh bin/mqshutdown namesrv
The mqnamesrv(53647) is running...
Send shutdown request to mqnamesrv(53647) OK
[aaa@qq.com distribution]# ps -ef|grep java
root 54571 53817 0 19:26 pts/0 00:00:00 grep --color=auto java
能起能停,才能收放自如。接下来,就可以写代码喽!!!!!!!!!!!!!!!!!!!!
具体的使用,后续应该会有续章
上一篇: SNS社会网络分析
下一篇: 社交网站的强关系与弱关系 sns