【阿里之RocketMQ的安装】

一、安装

[root@master opt]# ls

alibaba-rocketmq-3.2.6.tar.gz  grafana-2.5.0.linux-x64.tar.gz  httpd-2.2.23.tar.gz             memcached-1.4.25.tar.gz         nagios-3.4.3.tar.gz           php-5.4.10.tar.gz

cacti-0.8.8b.tar.gz            hadoop                          libevent-1.4.14b-stable         mongodb                         nagios-plugins-1.4.13         tomcat

flume1.6                       hadoop_data                     libevent-1.4.14b-stable.tar.gz  mongodb-linux-x86_64-1.6.3.tgz  nagios-plugins-1.4.13.tar.gz

grafana-2.5.0                  httpd-2.2.23                    memcached                       nagios                          php-5.4.10

[root@master opt]# tar -zxvf alibaba-rocketmq-3.2.6.tar.gz 

[root@master opt]# cd alibaba-rocketmq

[root@master alibaba-rocketmq]# ls

benchmark  bin  conf  issues  lib  LICENSE.txt  test  wiki

[root@master alibaba-rocketmq]# cd bin/

[root@master bin]# ls

mqadmin      mqadmin.xml  mqbroker.exe        mqbroker.numanode1  mqbroker.numanode3  mqfiltersrv      mqfiltersrv.xml  mqnamesrv.exe  mqshutdown  play.sh    runbroker.sh  startfsrv.sh

mqadmin.exe  mqbroker     mqbroker.numanode0  mqbroker.numanode2  mqbroker.xml        mqfiltersrv.exe  mqnamesrv        mqnamesrv.xml  os.sh       README.md  runserver.sh  tools.sh

[root@master bin]# cd ../conf/

[root@master conf]# ls

2m-2s-async  2m-2s-sync  2m-noslave  logback_broker.xml  logback_filtersrv.xml  logback_namesrv.xml  logback_tools.xml

[root@master conf]# 

[root@master bin]# ls

mqadmin      mqadmin.xml  mqbroker.exe        mqbroker.numanode1  mqbroker.numanode3  mqfiltersrv      mqfiltersrv.xml  mqnamesrv.exe  mqshutdown  play.sh    runbroker.sh  startfsrv.sh

mqadmin.exe  mqbroker     mqbroker.numanode0  mqbroker.numanode2  mqbroker.xml        mqfiltersrv.exe  mqnamesrv        mqnamesrv.xml  os.sh       README.md  runserver.sh  tools.sh

[root@master bin]# sh play.sh 

Start Name Server and Broker Successfully, 192.168.1.107:9876

[root@master bin]# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0C:29:03:CF:7F  

          inet addr:192.168.1.103  Bcast:192.168.1.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fe03:cf7f/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:8900 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1625 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:12509126 (11.9 MiB)  TX bytes:154496 (150.8 KiB)

          Base address:0x2000 Memory:c9020000-c9040000 

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:39 errors:0 dropped:0 overruns:0 frame:0

          TX packets:39 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:3572 (3.4 KiB)  TX bytes:3572 (3.4 KiB)



 

[root@master bin]# hostname -i

192.168.1.107

[root@master bin]# sh mqadmin

The most commonly used mqadmin commands are:

   updateTopic          Update or create topic

   deleteTopic          Delete topic from broker and NameServer.

   updateSubGroup       Update or create subscription group

   deleteSubGroup       Delete subscription group from broker.

   updateBrokerConfig   Update broker's config

   topicRoute           Examine topic route info

   topicStatus          Examine topic Status info

   brokerStatus         Fetch broker runtime status data

   queryMsgById         Query Message by Id

   queryMsgByKey        Query Message by Key

   queryMsgByOffset     Query Message by offset

   printMsg             Print Message Detail

   producerConnection   Query producer's socket connection and client version

   consumerConnection   Query consumer's socket connection, client version and subscription

   consumerProgress     Query consumers's progress, speed

   consumerStatus       Query consumer's internal data structure

   cloneGroupOffset     clone offset from other group.

   clusterList          List all of clusters

   topicList            Fetch all topic list from name server

   updateKvConfig       Create or update KV config.

   deleteKvConfig       Delete KV config.

   wipeWritePerm        Wipe write perm of broker in all name server

   resetOffsetByTime    Reset consumer offset by timestamp(without client restart).

   updateOrderConf      Create or update or delete order conf

   cleanExpiredCQ       Clean expired ConsumeQueue on broker.

   startMonitoring      Start Monitoring

   checkMsg             Check Message Store

   statsAll             Topic and Consumer tps stats

   syncDocs             Synchronize wiki and issue to github.com

See 'mqadmin help <command>' for more information on a specific command.

[root@master bin]# 



 

二、Send & Receive Messages

Before sending/receiving messages, we need to tell clients where name servers are located. RocketMQ provides multiple ways to achieve this. For simplicity, we use environment variable NAMESRV_ADDR

生产消息窗口

export NAMESRV_ADDR=localhost:9876

Now we are ready to send/receive messages.

sh tools.sh com.alibaba.rocketmq.example.quickstart.Producer

You will see a few hundred messages are sent to brokers.

消息消息窗口

export NAMESRV_ADDR=localhost:9876

To consume messages you just sent in the previous step,

sh tools.sh com.alibaba.rocketmq.example.quickstart.Consumer



 

猜你喜欢

转载自gaojingsong.iteye.com/blog/2330461