TOC

preface

This article uses version 4.3.0 as the standard to deploy a Single RocketMQ instance under Linux, requiring a JAVA environment to be configured.

Apache RocketMQ was donated by Alibaba to the Apache Foundation in November 2016 and successfully graduated as an Apache Top Level project in September 2017.

Download the package

Directly use the general download already compiled binary file is good, after downloading

> unzip rocketmq - all - 4.3.0 - bin - release. Zip

> CD rocketmq - all - 4.3.0 - bin - release /

Start the name server

> nohup sh bin/mqnamesrv &

Tail The log to see if has been launched successfully > tail -f ~ / logs/rocketmqlogs/namesrv log The Name Server boot success…

Start the Broker

> nohup sh bin/mqbroker -n localhost:9876 &

Tail it log see if has been launched successfully > tail -f ~ / logs/rocketmqlogs/broker log The broker [172.30.30.233% s: 10911] The boot success…

Sending and receiving messages

For a simple test, before sending/receiving a message we need to set the NAMESRV_ADDR environment variable > export NAMESRV_ADDR=localhost:9876

Send a message, Test cases in the way is to use a for loop sent 1000 messages > sh bin/view sh org. Apache. Rocketmq. Example. The quickstart. Producer SendResult [sendStatus = SEND_OK, msgId =…

Receives the message > sh bin/view sh org. Apache. Rocketmq. Example. The quickstart. Consumer SendResult [sendStatus = SEND_OK, msgId =…

Close the service

> sh bin/mqshutdown broker

The mqbroker (36695) is running...

Send shutdown request to mqbroker(36695) OK

> sh bin/mqshutdown namesrv

The mqnamesrv (36664) is running...

Send shutdown request to mqnamesrv(36664) OK

At this point, we’ve completed a simple deployment and sending and receiving of messages, but this is just sending and receiving messages on the Intranet.

FAQ

How to modify the startup memory of name Server and Broker?

The default STARTUP JVM for Name Server and Broker is 4G memory, and the startup fails if there is not enough memory.

The name Server and broker startup memory parameters need to be modified. CMD name Server: runServer. sh: runServer. sh: runServer.cmd: RunServer.cmd: runServer.cmd: runServer.cmd: runServer.cmd: runServer.cmd

How do YOU configure extranet access?

1. The broker does not allow automatic creation of topics. 2. 2. The broker is not properly connected to the Name server. 3

  • For case 1, in startupbrokerWhen you addautoCreateTopicEnable=trueParameters are good.

  • In case 2, the name server may not exist or there may be a port conflict. For details, see the log error cause.
  • In case 3, it’s usually ports, If the local sending and receiving of messages is normal on the server but fails when sending messages with the client SDK, you can first check whether the local ping of port 9876 and port 10911 of the server are normal. If they are normal, you can close the VIP channel and try again. The JAVA client is like the following

    Producers close VIP channels: producer.setVipChannelEnabled(false);

    Consumers close VIP channels: consumer.setVipChannelEnabled(false);

    The reason why it is ok to close the VIP channel is that the VIP channel occupies a port, port 10909, and the server port 10909 is not open to the public, so it failed.

The configuration file

This is my broker.properties configuration file

brokerClusterName = DefaultCluster brokerName = broker-a brokerId = 0 deleteWhen = 04 fileReservedTime = 48 brokerRole = ASYNC_MASTER flushDiskType = ASYNC_FLUSH brokerIP1=172.17.59.146 brokerIP2=172.17.59.146 namesrvAddr=172.17.59.146:5776  autoCreateTopicEnable=trueCopy the code

Since I am not using the default port 9876, THERE is also a name Server configuration file,namesrv.conf

listenPort=5776
Copy the code

You can also download my broker.properties and namesrv.conf directly

When you start the Name Server and broker with your own configuration file, you add a parameter named file path -c

So far, a simple example of a Single Apache RocketMQ machine has been deployed, and it’s time to enjoy your message queuing journey!