解耦异步 prc调用,数据源变动
官网:http://rocketmq.apache.org/ 资源:http://jm.taobao.org/2017/01/12/rocketmq-quick-start-in-10-minutes/ https://www.jianshu.com/p/453c6e7ff81c
前置条件:已经安装jdk8,maven 官网:http://rocketmq.apache.org/docs/quick-start/
下载 wget http://mirror.bit.edu.cn/apache/rocketmq/4.4.0/rocketmq-all-4.4.0-source-release.zip 解压 unzip rocketmq-all-4.4.0-source-release.zip cd rocketmq-all-4.4.0 安装 mvn -Prelease-all -DskipTests clean install -U出现下面表示安装成功 启动Start Name Server
cd distribution/target/apache-rocketmq 非守护进程启动(t1) sh bin/mqnamesrv 守护进程启动(t2) nohup sh bin/mqnamesrv & tail -f ~/logs/rocketmqlogs/namesrv.log启动可能NameServerٖ内存不足,修改 JAVA_OPT
vi /usr/local/rock/rock/distribution/target/apache-rocketmq/bin/runserver.sh 报错信息如下: [root@iZwz94sw188z3yfl7lpmmsZ apache-rocketmq]# sh bin/mqnamesrv Java HotSpot(TM) 64-Bit Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release. Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000006ec800000, 2147483648, 0) failed; error='Cannot allocate memory' (errno=12) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (mmap) failed to map 2147483648 bytes for committing reserved memory. # An error report file with more information is saved as: # /usr/local/software/rocketmq-all- 4.4.0/distribution/target/apache-rocketmq/hs_err_pid8993.log 修改举例 JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn256m - XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"启动Start Broker
broker.conf配置文件 namesrvAddr={你自己的阿里云服务器外网IP或者内网IP}:9876 brokerIP1={你自己的阿里云服务器外网IP} brokerName=james brokerClusterName=DefaultCluster brokerId=0 autoCreateTopicEnable=true autoCreateSubscriptionGroup=true cd distribution/target/apache-rocketmq 非守护进程启动(t1) sh bin/mqbroker -n localhost:9876 #(本机) sh bin/mqbroker -n 192.168.1.188:9876 #(其他机) 守护进程启动(t2) nohup sh bin/mqbroker -n localhost:9876 autoCreateTopicEnable=true & nohup sh bin/mqbroker -n 47.100.207.234:9876 -c conf/broker.conf & tail -f ~/logs/rocketmqlogs/broker.log The broker[%s,192.168.10.100:10911] boot success...Broker内存不足
修改JAVA_OPT vi /usr/local/rock/rock/distribution/target/apache-rocketmq/bin/runbroker.sh 修改举例 JAVA_OPT="${JAVA_OPT} -server -Xms528m -Xmx528m -Xmn256m"/usr/local/rocketmq/rocketmq-all-4.4.0/distribution/target/apache-rocketmq/bin vi runbroker.sh
查看是否全部启动 发送消息 Send & Receive Messages
Before sending/receiving messages, we need to tell clients the location of name servers. RocketMQ provides multiple ways to achieve this. For simplicity, we use environment variable NAMESRV_ADDR
> 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 #消费消息关闭服务 Shutdown Servers /usr/local/rocketmq/rocketmq-all-4.4.0/distribution/target/apache-rocketmq
> sh bin/mqshutdown broker The mqbroker(36695) is running... Send shutdown request to mqbroker(36695) OK > sh bin/mqshutdown namesrv The mqnamesrv(36664) is running... Send shutdown request to mqnamesrv(36664) OKrocketmq-externals-master.zip
解压 unzip rocketmq-externals-master.zip cd rocketmq-externals-master/rocketmq-console 修改pom vi pom.xml修改application.xml里面的nameserver地址 cd rocketmq-externals-master/rocketmq-console/src/main/resources vi application.properties
进入pom.xml所在的目录
编译打包:mvn clean package -Dmaven.test.skip=true 进入target目录: 普通启动:java -jar rocketmq-console-ng-1.0.0.jar 守护进程启动:nohup java -jar rocketmq-console-ng-1.0.0.jar & 访问:http://192.168.10.100:8080