美文网首页
centOS7离线安装rocketMq

centOS7离线安装rocketMq

作者: 莫须有的呓语 | 来源:发表于2020-08-11 10:49 被阅读0次

    所需文件,可以用迅雷下
    https://mirror.bit.edu.cn/apache/rocketmq/4.7.0/rocketmq-all-4.7.0-bin-release.zip

    1.前置条件

    如果没有安装zip,unzip,jdk,参考这篇centOS7离线安装ZIP与JDK1.8

    2.上传到指定位置

    /usr/local/software

    指定位置.png

    3.解压

    [root@ohMyGod software]# unzip rocketmq-all-4.7.0-bin-release.zip
    

    4.移到/usr/local/下,并改名rocketmq

    [root@ohMyGod software]# mv rocketmq-all-4.7.0-bin-release /usr/local/rocketmq
    

    5.修改配置文件

    修改runserver.sh

    cd /usr/local/rocketmq/
    vim bin/runserver.sh
    
    修改配置文件.png

    改为1g或者128m(因为我的服务器很小,也可以改更小)

    修改后.png

    同理修改runbroker.sh

    vim bin/runbroker.sh
    

    其中

    JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"
    

    调整为 1G:

    JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn1g"
    
    修改后.png

    6.启动服务

    顺序为 mqnamesrv,

    mkdir /user/local/rocketmq/log
    cd /user/local/rocketmq/
    nohup sh bin/mqnamesrv>/usr/local/rocketmq/log/namesrv.log 2>&1 &
    nohup sh bin/mqbroker -n localhost:9876 autoCreateTopicEnable=true >/usr/local/rocketmq/log/broker.log 2>&1 &
    (开启自动创建topic)
    

    7.停止服务

    # 停止 Broker
    sh bin/mqshutdown broker
    # 停止 NameServer  
    sh bin/mqshutdown namesrv
    

    8.开机自启

    (1)管理脚本

    #!/usr/bin/env bash
     
    #
    # rocketmq - this script starts and stops the rocketmq daemon
    #
    # chkconfig: 2345 85 15
     
    ROCKETMQ_HOME=/usr/local/rocketmq
    ROCKETMQ_BIN=${ROCKETMQ_HOME}/bin
    ADDR=`127.0.0.1`:9876
    LOG_DIR=${ROCKETMQ_HOME}/log
    NAMESERVER_LOG=${LOG_DIR}/namesrv.log
    BROKER_LOG=${LOG_DIR}/broker.log
     
    start() {
    if [ ! -d ${LOG_DIR} ];then
    mkdir ${LOG_DIR}
    fi
    cd ${ROCKETMQ_HOME}
    export JAVA_HOME=/usr/local/java/jdk1.8.0_202
    nohup sh bin/mqnamesrv > ${NAMESERVER_LOG} 2>&1 &
    echo -n "The Name Server boot success..."
    export JAVA_HOME=/usr/local/java/jdk1.8.0_202
    nohup sh bin/mqbroker -n localhost:${ADDR} autoCreateTopicEnable=true > ${BROKER_LOG} 2>&1 &
    echo -n "The broker[%s, ${ADDR}] boot success..."
    }
    stop() {
    cd ${ROCKETMQ_HOME}
    sh bin/mqshutdown broker
    sleep 1
    sh bin/mqshutdown namesrv
    }
    restart() {
    stop
    sleep 5
    start
    }
     
     
    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    restart
    ;;
    *)
    echo $"Usage: $0 {start|stop|restart}"
    exit 2
    esac
    

    (2)授权,移动,加入开机自启

    chmod a+x rocketmq.sh
    
    sudo mv rocketmq.sh /etc/rc.d/init.d/rocketmq
    
    chkconfig --add rocketmq
    

    (3)服务操作

    启动:service rocketmq start
    关闭:service rocketmq stop
    重启:service rocketmq restart
    

    可能需要开放的端口为

    rocke有9876
    非vip通道端口:10911
    vip通道端口:10909
    10909是VIP通道对应的端口,在JAVA中的消费者对象或者是生产者对象中关闭VIP通道即可无需开放10909端口
    

    参考自:
    https://www.cnblogs.com/markLogZhu/p/12536664.html
    http://www.shixinke.com/mq/rocketmq-installation-and-management

    相关文章

      网友评论

          本文标题:centOS7离线安装rocketMq

          本文链接:https://www.haomeiwen.com/subject/gjejdktx.html