zoukankan      html  css  js  c++  java
  • RocketMq安装

    参考文档:

    http://rocketmq.apache.org/docs/quick-start/

    https://www.jianshu.com/p/824066d70da8

    http://blog.51cto.com/yushiwh/2118625

    https://www.cnblogs.com/quchunhui/p/7284752.html

    nameserver默认使用9876端口,broker默认端口10911,vip通道端口号为10909,同时该broker会使用10910[mqadmin连接使用],10912端口[slave连接使用],在阿里云部署时需要开放这几个端口。

    一、下载安装包

    源码安装:https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.2.0/rocketmq-all-4.2.0-source-release.zip

    Binary安装:https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.2.0/rocketmq-all-4.2.0-bin-release.zip

    二、安装

    RocketMq需要安装jdk1.8。源码安装的话还需要maven和git,参考官方文档安装即可。

    Binary安装直接下载安装包到/opt目录下,unzip命令解压 unzip rocketmq-all-4.2.0-bin-release.zip -d  rocketmq-all-4.2.0

    三、启动

    解压之后cd到bin目录下,首先根据服务器配置来修改 runserver.sh 和 runbroker.sh 两个文件的jvm配置。

    cd到rocketmq安装目录,创建logs文件夹,

    启动namesrv

    nohup sh bin/mqnamesrv > /opt/rocketmq-all-4.2.0/logs/mqnamesrv.log 2>&1 &

    tailf /logs/mqnamesrv.log,出现 The Name Server boot success. serializeType=JSON表示启动namesrv成功

    启动broker

    nohup sh bin/mqbroker -n localhost:9876 autoCreateTopicEnable=true >/opt/rocketmq-all-4.2.0/logs/broker.log 2>&1 &

    (autoCreateTopicEnable=true 表示自动创建topic)

    tailf  /logs/broker.log

    执行jps

    namesrv和broker启动成功!

     

    关闭服务器:

    sh bin/mqshutdown broker //停止 broker
    sh bin/mqshutdown namesrv //停止 nameserver

     

    四、测试

    发送消息:

    export NAMESRV_ADDR=localhost:9876
    sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer

    接收消息:

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

    五、添加开机自启动

    切换到rocketMq的bin目录下,

    1、拷贝play.sh到Start.sh,并修改Start.sh内容如下:

    #!/bin/sh
     
    # Licensed to the Apache Software Foundation (ASF) under one or more
    # contributor license agreements.  See the NOTICE file distributed with
    # this work for additional information regarding copyright ownership.
    # The ASF licenses this file to You under the Apache License, Version 2.0
    # (the "License"); you may not use this file except in compliance with
    # the License.  You may obtain a copy of the License at
    #
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
     
    #
    # Name Server
    #
    #nohup sh mqnamesrv > ns.log 2>&1 &
    nohup  sh /opt/rocketmq-all-4.2.0/bin/mqnamesrv >/opt/rocketmq-all-4.2.0/logs/mqnamesrv.log 2>&1 &
     
    #
    # Service Addr
    #
    ADDR=`hostname -i`:9876
     
    #
    # Broker
    #
    #nohup sh mqbroker -n ${ADDR} > bk.log 2>&1 &
    nohup sh  /opt/rocketmq-all-4.2.0/bin/mqbroker -n localhost:9876 autoCreateTopicEnable=true  >/opt/rocketmq-all-4.2.0/logs/broker.log 2>&1 &
    #sh broker.sh
     
    echo "Start Name Server and Broker Successfully, ${ADDR}"

    2.修改rc.local文件,vim  /etc/rc.local

    #!/bin/bash
    # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
    #
    # It is highly advisable to create own systemd services or udev rules
    # to run scripts during boot instead of using this file.
    #
    # In contrast to previous versions due to parallel execution during boot
    # this script will NOT be run after all other services.
    #
    # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
    # that this script will be executed during boot.
     
    touch /var/lock/subsys/local
    source /etc/profile
    su -c 'cd && /opt/rocketmq-all-4.2.0/bin/Start.sh'

    3.查看Start.sh 和rc.local的权限,看是否可执行,如果不是的话添加可执行权限

    chomd +x  /opt/rocketmq-all-4.2.0/bin/Start.sh

    4.重启服务器,使用jps查看是否已经启动,如果没有检查下脚本是否正确

     

  • 相关阅读:
    C#捕获摄像头进行拍照和录像资料总结
    MySQL:日期函数、时间函数总结(MySQL 5.X)
    apache 虚拟主机详细配置:http.conf配置详解
    [转载文章]6个重要的.NET概念:栈,堆,值类型,引用类型,装箱,拆箱
    GetType和typeof的区别
    [转]C#读写xml文件
    DateTime 格式化
    jquery sortable 插件参数详解
    [转]一个人脸检测器
    why SOA
  • 原文地址:https://www.cnblogs.com/yinwutuan/p/9257041.html
Copyright © 2011-2022 走看看