rocketmq

rocketmq

安装rocketmq

下载链接:https://archive.apache.org/dist/rocketmq/4.9.3/rocketmq-all-4.9.3-bin-release.zip

1. 解压;

2. 修改启动参数:

  • 启动脚本中设置的 JVM 内存参数很大,如果服务器内存不够的话可以按这一步调小一点。这里只是测试所以设置很小,生产环境可以默认或者更大一点。修改 Name Server 堆内存大小(比如 -Xms512m -Xmx512m -Xmn256m)。
vim rocketmq-4.9.3/bin/runserver.sh

img

img

  • 修改 Broker 堆内存大小(比如 -Xms512m -Xmx512m)

    vim rocketmq-4.9.3/bin/runbroker.sh
    

    img

  • 修改 tools.sh 指定 Name Server 地址 export NAMESRV_ADDR=localhost:9876(这个不用指定,为开启外网访问做准备),设置堆内存大小 (比如 -Xms512m -Xmx512m)

    vim rocketmq-4.9.3/bin/tools.sh
    

    rocketmq_第1张图片

3. 开启外网

相关问题

修改配置

# vim rocketmq/conf/borker.conf

# 修改配置
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH

namesrvAddr=外网IP:9876
brokerIP1=外网IP

允许访问端口

服务器或防火墙可能对端口有限制,需要开启9876,10909,10911这三个端口。

4. 启动/停止

  • 启动

    # 后台方式启动 Name Server
    nohup sh bin/mqnamesrv &
    
    # 后台启动 Broker
    nohup sh bin/mqbroker -n localhost:9876 -c conf/broker.conf autoCreateTopicEnable=true &
    -n:指定要连接的NameServer地址
    -c:指定配置文件
    autoCreateTopicEnable=true 自动创建Topic,生产建议关闭
    

    停止一定要删除~目录下的store文件夹

    tip:将/root/store目录下所有文件删除(find / -name store)

  • 停止

    # 停止 Broker
    sh /opt/soft/rocketmq-4.9.1/bin/mqshutdown broker
    tip:将/root/store目录下所有文件删除(find / -name store)
    
    # 停止 Name Server
    sh /opt/soft/rocketmq-4.9.1/bin/mqshutdown namesrv
    

    tip:将/root/store目录下所有文件删除(find / -name store)

  • 查看日志

    tail -f -n 100 nohup.out
    
  • 查看端口情况

    ss -lnt
    

5. 测试

  • 发送消息

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

    消息发送成功时输出:SendResult [sendStatus=SEND_OK, msgId= …

  • 接收消息

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

    消息接收成功时输出:ConsumeMessageThread_%d Receive New Messages: [MessageExt…

  • 禁用服务器

    sh bin/mqshutdown broker
    sh bin/mqshutdown namesrv
    

安装rocketmq-console

1. 下载后解压,需要build成jar包:

现在在github上面已经改名为rocketmq-dashboard.tar.gz

tar xf rocketmq-dashboard-1.0.0.tar.gz
cd rocketmq-dashboard-rocketmq-dashboard-1.0.0
#修改配置为需要登录
sed -i s/rocketmq.config.loginRequired=fasle/rocketmq.config.loginRequired=true/g src/main/resources/application.properties

2. 修改配置文件:

  • 修改 application.properties 内容如下(每次修改完记得重新编译打包):

    server.address=0.0.0.0
    # =============修改端口为9876=============
    server.port=9876
     
    ### SSL setting
    #server.ssl.key-store=classpath:rmqcngkeystore.jks
    #server.ssl.key-store-password=rocketmq
    #server.ssl.keyStoreType=PKCS12
    #server.ssl.keyAlias=rmqcngkey
     
    #spring.application.index=true
    spring.application.name=rocketmq-console
    spring.http.encoding.charset=UTF-8
    spring.http.encoding.enabled=true
    spring.http.encoding.force=true
    logging.level.root=INFO
    logging.config=classpath:logback.xml
    #if this value is empty,use env value rocketmq.config.namesrvAddr  NAMESRV_ADDR | now, you can set it in ops page.default localhost:9876
    # =============修改namesrv地址,如果是多个请以分号;分隔(此处修改成你自己安装的rocket namesrv地址ip即可)=============
    rocketmq.config.namesrvAddr=xx.xx.xxx:9876
    
    #if you use rocketmq version < 3.5.8, rocketmq.config.isVIPChannel should be false.default true
    rocketmq.config.isVIPChannel=
    #rocketmq-console's data path:dashboard/monitor
    rocketmq.config.dataPath=/tmp/rocketmq-console/data
    #set it false if you don't want use dashboard.default true
    rocketmq.config.enableDashBoardCollect=true
    #set the message track trace topic if you don't want use the default one
    rocketmq.config.msgTrackTopicName=
    rocketmq.config.ticketKey=ticket
     
    #Must create userInfo file: ${rocketmq.config.dataPath}/users.properties if the login is required
    # =============开启控制台账户密码登录(为true表示开启,为false表示关闭)=============
    rocketmq.config.loginRequired=true
     
    #set the accessKey and secretKey if you used acl
    #rocketmq.config.accessKey=
    #rocketmq.config.secretKey=
    
    
  • 修改 users.properties 内容如下(每次修改完记得重新编译打包):

    # This file supports hot change, any change will be auto-reloaded without Console restarting.
    # Format: a user per line, username=password[,N] #N is optional, 0 (Normal User); 1 (Admin)
     
    # Define Admin
    # =============用户名和密码规则「用户名=密码,权限」,这里的权限为1表示管理员,为0表示普通用户=============
    # 例如:admin=admin123,1
    这是用户名=这是密码,1
     
     
    # Define Users
    # =============屏蔽下边两个账户=============
    #user1=user1
    #user2=user2
    

    3. 打包上传,并运行

    nuhup java -jar rocketmq-dashboard-1.0.0.jar &
    

这是密码,1

Define Users

=屏蔽下边两个账户=

#user1=user1
#user2=user2


### 3. 打包上传,并运行

```linux
nuhup java -jar rocketmq-dashboard-1.0.0.jar &

你可能感兴趣的:(rocketmq,linux)