A note under linux study notes RoketMQ

Refer to the official documents themselves, encountered the pit, as the notes ( personal use of a centos6.5 )

First, start

  1. Set RocketMQ
  2. Messaging system: your local machine to send and receive messages

Second, prepare conditions

  1. 64-bit operating systems: Linux / Unix / Mac
  2. (Note that the environment variable added to the / etc / profile system environment variables) 64 JDK version 1.8+
  3. (Note that the environment variable added to the / etc / profile system environment variables) Version 3.2.x maven
  4. Use git get rocketmq on github, you can also go to the official website to download and upload directly to the linux server
  5. 4g or more hard disk space Broker Support Services

Third, download and install version

  1. You can choose to download the 4.6.0 source release (not compiled)
    https://archive.apache.org/dist/rocketmq/4.6.0/rocketmq-all-4.6.0-source-release.zip
  2. You can also download binary release (compiled)
    http://mirrors.tuna.tsinghua.edu.cn/apache/rocketmq/4.6.0/rocketmq-all-4.6.0-bin-release.zip
  3. This presentation is rocketmq-all-4.6.0-source-release.zip version (note)

rocketmq-all-4.6.0-source-release.zip the unzip
CD rocketmq-All-4.6.0 /
mvn -Prelease -DskipTests Clean All the install -U-
CD Distribution / target / rocketmq-4.6.0 / 4.6.0-rocketmq / bin (this is my installation is the directory where the command mqnamesrv)

  1. Start service command: sh mqnamesrv

Fourth, start the service

  1. Enter the service where the bin directory: cd /usr/local/tools/rocketmq-all-4.6.0-source-release/distribution/target/rocketmq-4.6.0/rocketmq-4.6.0/bin

nohup sh mqnamesrv &
tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success…
Here Insert Picture Description

  1. Use the jobs command to check into the background of service

Here Insert Picture Description

Fifth, start Broker Services

  1. Before you start using the command: vim runbroker.sh (the default settings too)
  2. Set JAVA_OPT = "$ {JAVA_OPT} -server -Xms128m -Xmx256m -Xmn256m
  3. Open ports in the firewall system, iptables 9876: vim / etc / sysconfig / iptables

nohup sh mqbroker -n localhost: 9876 & ( provided that it enters the bin directory so used)
tail -f ~ / logs / rocketmqlogs / broker.log
of The Broker [% S, 172.30.30.233:10911] Boot Success ...
Here Insert Picture Description

Sixth, sending and receiving messages

export NAMESRV_ADDR=localhost:9876
sh tools.sh org.apache.rocketmq.example.quickstart.Producer
SendResult [sendStatus=SEND_OK, msgId= …
sh tools.sh org.apache.rocketmq.example.quickstart.Consumer
ConsumeMessageThread_%d Receive New Messages: [MessageExt…

Seven, shut down service

sh mqshutdown broker
The mqbroker(36695) is running…
Send shutdown request to mqbroker(36695) OK

sh mqshutdown namesrv
The mqnamesrv(36664) is running…
Send shutdown request to mqnamesrv(36664) OK

Eight, demo with reference to the official website developed using java

  1. Train link: http: //rocketmq.apache.org/docs/simple-example/

Here Insert Picture Description
PS: The last wrote, the key is to learn to refer to the official documentation to practice.

Published 17 original articles · won praise 3 · views 10000 +

Guess you like

Origin blog.csdn.net/Tolove_dream/article/details/103499697