In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to install RocketMQ in Centos, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Installation
The official address is: https://rocketmq.apache.org/docs/quick-start/ is installed as follows:
/ / download the latest rocketmqwget http://apache-mirror.8birdsvideo.com/rocketmq/4.4.0/rocketmq-all-4.4.0-bin-release.zip// decompression unzip rocketmq-all-4.4.0-bin-release.zip// to change to the mq directory cd rocketmq-all-4.4.0-bin-release//name server launch nohup. / bin/mqnamesrv-n 111.231.XX.XX:9876 & / /-c conf/broker.conf autoCreateTopicEnable=true parameter needs to be taken with Otherwise, topic needs to manually create nohup sh bin/mqbroker-n 111.231.XX.XX:9876-c conf/broker.conf autoCreateTopicEnable=true &
Configure, switch to the bin directory of mq
Cd rocketmq-all-4.4.0-bin-release/bin
By default, the minimum memory of rocketmq is 4G. If there is not enough memory in the machine, find runserver.sh and runbroker.sh and edit them as follows:
JAVA_OPT= "${JAVA_OPT}-server-Xms256m-Xmx256m-Xmn125m-XX:MetaspaceSize=128m-XX:MaxMetaspaceSize=320m"
Running
Run the official demo and find the following error:
22249 [NettyClientSelector_1] INFO RocketmqRemoting-closeChannel: close the connection to remote address [] result: trueorg.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException: sendDefaultImpl call timeout at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl (DefaultMQProducerImpl.java:640) at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send (DefaultMQProducerImpl.java:1310) at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send (DefaultMQProducerImpl.java: 1256) at org.apache.rocketmq.client.producer.DefaultMQProducer.send (DefaultMQProducer.java:339) at org.apache.rocketmq.example.simple.Producer.main (Producer.java:40)
Run the following command to view the broker configuration and write to the remote ip address:
/ / View broker configuration sh. / bin/mqbroker-M ip / close brokersh bin/mqshutdown broker// to write native remote ip to the configuration file echo 'brokerIP1=111.231.XX.XX' > conf/broker.properties / / restart brokernohup sh bin/mqbroker-n 111.231.XX.XX:9876-c conf/broker.conf autoCreateTopicEnable=true & administrative console installation
Git address: https://github.com/apache/rocketmq-externals/tree/master/rocketmq-console
Git clone git@github.com:apache/rocketmq-externals.gitcd rocketmq-external/rocketmq-console/mvn clean package-Dmaven.test.skip=true
When you have finished packing, run the following command
Java-jar rocketmq-console-ng-1.0.1.jar-server.port=12181-rocketmq.config.namesrvAddr=111.231.XX.XX:9876
Open the http://localhost:12181 access console, like the following
The following exception occurs when querying on the Procuder page:
Java.lang.RuntimeException: org.apache.rocketmq.client.exception.MQBrokerException: CODE: 1 DESC: the producer group [] not existFor more information, please visit the url, http://rocketmq.apache.org/docs/faq/ at com.google.common.base.Throwables.propagate (Throwables.java:160) at org.apache.rocketmq.console.service.impl.ProducerServiceImpl.getProducerConnection (ProducerServiceImpl.java:38) at org.apache.rocketmq.console.controller.ProducerController.producerConnection (ProducerController.java:39)
Please leave out the sentence producer.shutdown () in the code and add it in the production environment.
/ / producer.shutdown (); code sample (official) producer package org.apache.rocketmq.example.simple;import org.apache.rocketmq.client.exception.MQClientException;import org.apache.rocketmq.client.producer.DefaultMQProducer;import org.apache.rocketmq.client.producer.SendResult;import org.apache.rocketmq.common.message.Message;import org.apache.rocketmq.remoting.common.RemotingHelper;public class Producer {public static void main (String [] args) throws MQClientException, InterruptedException {DefaultMQProducer producer = new DefaultMQProducer ("ProducerGroupName") Producer.setNamesrvAddr ("111.231.XX.XX:9876"); producer.start (); for (int I = 0; I < 10 Try {{Message msg = new Message ("TopicTest", "TagA", "OrderID188", "Hello world" .getBytes (RemotingHelper.DEFAULT_CHARSET)); SendResult sendResult = producer.send (msg) System.out.printf ("% s% n", sendResult);}} catch (Exception e) {e.printStackTrace ();} / / producer.shutdown ();}} Consumer package org.apache.rocketmq.example.simple;import java.util.List;import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer Import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;import org.apache.rocketmq.client.exception.MQClientException;import org.apache.rocketmq.common.consumer.ConsumeFromWhere;import org.apache.rocketmq.common.message.MessageExt;public class PushConsumer {public static void main (String [] args) throws InterruptedException, MQClientException {DefaultMQPushConsumer consumer = new DefaultMQPushConsumer ("CID_JODIE_1") Consumer.subscribe ("TopicTest", "*"); consumer.setConsumeFromWhere (ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); / / wrong time format 2017 / 0422 / 221800 / / consumer.setConsumeTimestamp ("20181109221800"); consumer.setNamesrvAddr ("111.231.XX.XX:9876") Consumer.registerMessageListener (new MessageListenerConcurrently () {@ Override public ConsumeConcurrentlyStatus consumeMessage (List msgs, ConsumeConcurrentlyContext context) {System.out.printf ("% s Receive New Messages:% s% n", Thread.currentThread () .getName (), msgs); return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;}}); consumer.start () System.out.printf ("Consumer Started.%n");}} these are all the contents of the article "how to install RocketMQ in Centos". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.