RocketMQ stand-alone installation

First, the environmental information

  • centos7
  • jdk 8
  • rocketmq 4.7.0

Second, the installation

Enter the software installation package directory

cd /home/software/

Download RocketMQ of Binary version of the installation package, you can also upload your own compilation

wget https://mirror.bit.edu.cn/apache/rocketmq/4.7.0/rocketmq-all-4.7.0-bin-release.zip   

Unzip the file and rename the directory

unzip rocketmq-all-4.7.0-bin-release.zip
# 重命名目录名
mv rocketmq-all-4.7.0-bin-release rocketmq

Moving the directory / usr / local directory

mv rocketmq /usr/local

Check the directory that contains content

cd /usr/local/rocketmq 
ll
drwxr-xr-x 2 root root  4096 Mar  5 19:44 benchmark
drwxr-xr-x 3 root root  4096 Mar  4 09:59 bin
drwxr-xr-x 6 root root  4096 Mar  4 09:59 conf
drwxr-xr-x 2 root root  4096 Mar  5 19:44 lib
-rw-r--r-- 1 root root 17336 Mar  4 09:59 LICENSE
-rw-r--r-- 1 root root  1338 Mar  4 09:59 NOTICE
-rw-r--r-- 1 root root  4948 Mar  4 09:59 README.md
  • LICENSE, NOTICE, README.md contain some versions of declarations and claims information;

  • benchmark contains run the benchmark program shell scripts;

  • bin directory contains various use RocketMQ the shell and cmd script, such as start NameServer script mqnamesrv , startup Broker script mqbroker the like;

  • conf directory to store configuration files, including three ways broker configuration file, the logback log configuration files;
  • lib directory contains RocketMQ each module jar packages and other dependent jar package.

Third, start the service

3.1 boot sequence

First start NameServer , then start Broker

3.2 Starting NameServer

nohup sh bin/mqnamesrv &

By JPS View Java process Command

[root@VM_0_15_centos rocketmq]# jps
12833 Jps

I found NameServer does not start, we look to see the cause of the error log:

tail -n 30 nohup.out

Message as follows:

# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2147483648 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /usr/local/rocketmq/hs_err_pid12459.log

You can see because of insufficient memory can not start because RocketMQ default configuration environment needs to function properly need more than 4G of memory, our server only 2G it will fail to start, we have to adjust its configuration under:

vim bin/runserver.sh

You can see the default memory is 4G

JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"

We have to adjust to 1G

JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"

Similarly Broker will also have this problem, we have come together configuration

vim bin/runbroker.sh
JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"

Adjusted to 1G:

JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn1g"

Restart NameServer :

nohup sh bin/mqnamesrv &

View process:

[root@VM_0_15_centos bin]# jps
1781 NamesrvStartup
1800 Jps

We can see already started

3.3 Starting Broker

nohup ./bin/mqbroker -n monchickey:9876 &

View process:

[root@localhost rocketmq]# jps
1844 Jps
1781 NamesrvStartup
1837 BrokerStartup

We can see Broker also started.

3.4 Production and consumption of test start message

Set the environment variable: Location Server

export NAMESRV_ADDR=localhost:9876       

Production news:

sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
SendResult [sendStatus=SEND_OK, msgId=C0A8892F09D44DC639966908745C0000, offsetMsgId=C0A8892F00002A9F00000000000249FA, messageQueue=MessageQueue [topic=TopicTest, brokerName=localhost, queueId=1], queueOffset=209]
SendResult [sendStatus=SEND_OK, msgId=C0A8892F09D44DC63996690874790001, offsetMsgId=C0A8892F00002A9F0000000000024AAC, messageQueue=MessageQueue [topic=TopicTest, brokerName=localhost, queueId=2], queueOffset=209]

Consumer news:

sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
ConsumeMessageThread_1 Receive New Messages: [MessageExt [brokerName=localhost, queueId=3, storeSize=180, queueOffset=32, sysFlag=0, bornTimestamp=1584753866001, bornHost=/192.168.137.47:46826, storeTimestamp=1584753866003, storeHost=/192.168.137.47:10911, msgId=C0A8892F00002A9F0000000000005AFA, commitLogOffset=23290, bodyCRC=724156045, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='TopicTest', flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=208, CONSUME_START_TIME=1584754056909, UNIQ_KEY=C0A8892F08E74DC639966903F1100082, WAIT=true, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 49, 51, 48], transactionId='null'}]] 

3.5 Stop Services

# 停止 Broker
sh bin/mqshutdown broker
# 停止 NameServer  
sh bin/mqshutdown namesrv

Guess you like

Origin www.cnblogs.com/markLogZhu/p/12536664.html