中间件的常用命令汇总

天道酬勤

  • 启动ES:docker run -itd --name es -p 9200:9200 -p 9300:9300 -e “discovery.type=single-node” elasticsearch /bin/bash
  • 启动消息队列:docker run -itd -p 9876:9876 rocketmqinc/rocketmq:4.2.0

Rocketmq

  1. 启动 NameServer:
    1. nohup sh bin/mqnamesrv &; tail -f ~/logs/rocketmqlogs/namesrv.log
  2. 启动 Broker:
    1. nohup sh bin/mqbroker -n localhost:9876 &; tail -f ~/logs/rocketmqlogs/broker.log
  3. 测试发送和接受消息:
    1. 发送消息:
      1. export NAMESRV_ADDR=localhost:9876; sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
    2. 接受消息:
      1. sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
  4. 关闭服务:
    1. sh bin/mqshutdown broker // 停止 broker
    2. sh bin/mqshutdown namesrv // 停止 nameserver
  5. 查看集群情况:
    1. ./mqadmin clusterList -n 127.0.0.1:9876
  6. 查看 broker 状态:
    1. ./mqadmin brokerStatus -n 127.0.0.1:9876 -b 172.20.1.138:10911
  7. 查看 topic 列表:
    1. ./mqadmin topicList -n 127.0.0.1:9876
  8. 查看 topic 状态:
    1. ./mqadmin topicStatus -n 127.0.0.1:9876 -t MyTopic
  9. 查看 topic 路由:
    1. ./mqadmin topicRoute -n 127.0.0.1:9876 -t MyTopic