搭建RocketMQ运行环境
零、准备
首先从github上将项目拉取下来:
RocketMQ链接
使用Idea的VCS的git将项目Clone下来。
一、启动NameServer
启动该类时会提示我们没有ROCKETMQ_HOME所以我们需要配合环境变量。
配置完成之后我们需要在环境变量(就是我们clone下来的文件存放路径【自己也可以新建一个目录来作为环境变量测试可以成功】)所在的目录下 新建下图的目录:
在conf目录下 将nameServer中的conf里面的这三个文件移进去。
修改logback开头的文件中的路径,修改broker.conf的文件内容如下:
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
namesrvAddr = 127.0.0.1:9876
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
storePathRootDir = /Users/lsjr3/rocketmq/store
storePathCommitLog = /Users/lsjr3/rocketmq/store/commitlog
storePathConsumeQueue = /Users/lsjr3/rocketmq/consumequeue
storePathIndex = /Users/lsjr3/rocketmq/index
storeCheckPoint = /Users/lsjr3/rocketmq/checkpoint
abortFile = /Users/lsjr3/rocketmq/abort
启动nameServer:如下
二、启动Broker
如下图修改:
修改后启动broker:如图——————
检查是否成功:去我们的logs目录:
打开该文件查看:
没有报错出现这些信息表示成功。
三、运行生产者程序
修改example中的producer程序释放setNameServer 修改为我们自己的ip。
四、运行消费者程序
修改example中的producer程序释放setNameServer 修改为我们自己的ip。
还没有评论,来说两句吧...