Refer to the official documents themselves, encountered the pit, as the notes ( personal use of a centos6.5 )
First, start
- Set RocketMQ
- Messaging system: your local machine to send and receive messages
Second, prepare conditions
- 64-bit operating systems: Linux / Unix / Mac
- (Note that the environment variable added to the / etc / profile system environment variables) 64 JDK version 1.8+
- (Note that the environment variable added to the / etc / profile system environment variables) Version 3.2.x maven
- Use git get rocketmq on github, you can also go to the official website to download and upload directly to the linux server
- 4g or more hard disk space Broker Support Services
Third, download and install version
- 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 - 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 - 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)
- Start service command: sh mqnamesrv
Fourth, start the service
- 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…
- Use the jobs command to check into the background of service
Fifth, start Broker Services
- Before you start using the command: vim runbroker.sh (the default settings too)
- Set JAVA_OPT = "$ {JAVA_OPT} -server -Xms128m -Xmx256m -Xmn256m
- 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 ...
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
- Train link: http: //rocketmq.apache.org/docs/simple-example/
PS: The last wrote, the key is to learn to refer to the official documentation to practice.