Fork me on GitHub

【Linus安装RocketMq】

  一、准备

     下载MQ所需tar包

wget https://github.com/apache/rocketmq/archive/rocketmq-all-4.2.0.tar.gz

  二、安装MQ步骤

     ①创建目录/usr/local/rocketmq 将下载好的tar包 解压在该目录中 tar –zxvf rocketmq-all-4.2.0.tar.gz

     ②在目录/usr/loacl/rocketmq/usr/local/rocketmq-all-4.2.0 目录中执行命令

         mvn -Prelease-all -DskipTests clean install –U   如下图表示编译成功

       image

     ③配置系统环境变量 vi /etc/profile  并且执行source /etc/profile

#RocketMq
ROCKETMQ=/usr/local/rocketmq/rocketmq-rocketmq-all-4.2.0

PATH=$PATH:$ROCKETMQ/bin

export JAVA_HOME JRE_HOME CLASS_PATH PATH MAVEN_HOME

     ④创建mq日志文件夹 /usr/local/logs/rocketmqlogs

     ⑤进入/usr/local/rocketmq/rocketmq-rocketmq-all-4.2.0/distribution/target/apache-rocketmq/bin目录

        启动namesrv   参考命令模块

        启动broker   参考命令模块

      ⑥检查是否启动成功

        ps –ef | grep rocketmq

        image

        查看日志  /usr/local/logs/rocketmqlogs/namesrv.log

        image

        查看日志  /usr/local/logs/rocketmqlogs/broker.log

        image

      ⑦消息收发验证

        export NAMESRV_ADDR = localhost:9876

        在/usr/local/rocketmq/rocketmq-rocketmq-all-4.2.0/distribution/target/apache-rocketmq/bin目录中执行

        sh tools.sh org.apache.rocketmq.example.quickstart.Producer

        image

        sh tools.sh org.apache.rocketmq.example.quickstart.Consumer

        image


  三、命令

#启动namesrv
nohup sh mqnamesrv > /usr/local/logs/rocketmqlogs/namesrv.log 2>&1 &
#启动broker
nohup sh mqbroker -n localhost:9876 autoCreateTopicEnable=true > /usr/local/logs/rocketmqlogs/broker.log 2>&1 &
#停止 nameserver
sh bin/mqshutdown namesrv
#停止broker
sh bin/mqshutdown broker
#查看集群情况
./mqadmin clusterList -n 127.0.0.1:9876
#查看 broker 状态
./mqadmin brokerStatus -n 127.0.0.1:9876 -b 172.20.1.138:10911 (注意换成你的 broker 地址)
#查看 topic 列表
./mqadmin topicList -n 127.0.0.1:9876
#查看 topic 状态
./mqadmin topicStatus -n 127.0.0.1:9876 -t MyTopic (换成你想查询的 topic)
#查看 topic 路由
./mqadmin topicRoute -n 127.0.0.1:9876 -t MyTopic

四、安装MQAdmin 可视化工具

     ①首先确定有maven和git环境 如果没有参考其他部署文章

        mvn –version

        git –-version

     ②创建目录/usr/local/rocketmq/rocketmq-project

     ③在rocketmq-project目录执行

        git init

        git clone https://github.com/apache/rocketmq-externals.git 

        下载完毕目录会有rocketmq-externals工程

     ④进入/usr/local/rocketmq/rocketmq-project/rocketmq-externals/rocketmq-console目录执行

        mvn clean package -Dmaven.test.skip=true

        打包完成后会在target目录生成rocketmq-console-ng-1.0.0.jar

     ⑤进入target目录执行jar包

 nohup java -jar rocketmq-console-ng-1.0.0.jar --server.port=12581 --rocketmq.config.namesrvAddr=10.89.0.64:9876;10.89.0.65:9876  >/usr/local/logs/rocketmqlogs/rocket_console.log >&1 &

     ⑥查看日志 /usr/local/logs/rocketmqlogs/rocket_console.log


五、问题

    1.mq目录中mvn编译错误问题

       因第一次mvn编译要下载好多插件,有可能会下载超时,多试几次就好了

     2.启动namesrv和broker时内存问题

     进入文件夹/usr/local/rocketmq/rocketmq-rocketmq-all-4.2.0/distribution/target/apache-rocketmq/bin

     修改文件runserver.sh和runbroker.sh,重新启动

JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx128m -Xmn128m -XX:PermSize=128m -XX:MaxPermSize=128m"

posted @ 2018-11-30 13:58  mankeu  阅读(183)  评论(0编辑  收藏  举报