mq(activemq kafka rocketmq)安装配置笔记

ActiveMq

下载

http://activemq.apache.org/download.html 这里下载最快
window直接用网页下载,
linux 下 获取真实路径后 用wget 命令 下载
wget http://mirrors.hust.edu.cn/apache//activemq/5.15.7/apache-activemq-5.15.7-bin.tar.gz

安装

解压
tar -zxvf apache-activemq-5.15.7-bin.tar.gz

cd [activemq_install_dir]/bin
chmod 755 activemq

配置

maven 版本必须与服务器版本一致

<dependency>
  <groupId>org.apache.activemq</groupId>
  <artifactId>activemq-all</artifactId>
  <version>5.15.7</version>
</dependency>

支持jdk8 以上版本

启动

cd [activemq_install_dir]
bin/activemq start
OR
bin/activemq start > /tmp/smlog 2>&1 &;

  • 注: /tmp/smlog 可以改为其他文件名
    启动以后不要关闭shell 窗口

调试

  • window
    netstat -an|find "61616"
  • linux
    netstat -an|grep 61616
  • 访问
    http://192.168.X.X:8161/admin/
    用户名: admin ; 密码 :admin
    注: 可以改( 在 conf/jetty-realm.properties 文件中)
    更多信息看 docs/WebConsole-README.txt

关闭

cd [activemq_install_dir]

  • window
    bin/activemq stop
  • linux
    ps -ef|grep activemq
    kill [PID]
    注: where [PID] is the process id of the ActiveMQ process.

参考

http://activemq.apache.org/version-5-getting-started.html

Kafka

下载

官网下载
http://kafka.apache.org/downloads
虚拟路径
https://www.apache.org/dyn/closer.cgi?path=/kafka/2.0.1/kafka_2.12-2.0.1.tgz
实际路径
http://mirrors.shu.edu.cn/apache/kafka/2.0.1/kafka_2.12-2.0.1.tgz
linux 下 获取真实路径后 用wget 命令 下载
wget http://mirrors.shu.edu.cn/apache/kafka/2.0.1/kafka_2.12-2.0.1.tgz

安装

tar -xzf kafka_2.11-2.0.0.tgz
cd kafka_2.11-2.0.0

启动与调试 单个节点

先启动
nohup sh bin/zookeeper-server-start.sh config/zookeeper.properties >> zoo.log 2>&1 &

后启动单个服务节点
nohup sh bin/kafka-server-start.sh config/server.properties >> kafka.log 2>&1 &

创建topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic my-replicated-topic

查看topic

bin/kafka-topics.sh --list --zookeeper localhost:2181
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test

发送

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
输入发送的消息
^C

接收

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
显示接收的消息
^C

启动与调试 新增两个broker服务节点

先备份

cp config/server.properties config/server-1.properties
cp config/server.properties config/server-2.properties
vim config/server-1.properties:
    broker.id=1
    listeners=PLAINTEXT://:9093
    log.dirs=/tmp/kafka-logs-1

vim config/server-2.properties:

   broker.id=2
   listeners=PLAINTEXT://:9094
   log.dirs=/tmp/kafka-logs-2

bin/kafka-server-start.sh config/server-1.properties &
bin/kafka-server-start.sh config/server-2.properties &

查看topic
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic

发送
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic my-replicated-topic

输入发送的消息
my test message 1
my test message 2
^C

接收
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic my-replicated-topic

显示接收的消息
my test message 1
my test message 2
^C

关闭

linux

ps aux | grep server-1.properties
kill -9 7564

window:

wmic process where “caption = ‘java.exe’ and commandline like ‘%server-1.properties%’” get processid
ProcessId
6016
taskkill /pid 6016 /f

参考

http://kafka.apache.org/quickstart

RocketMq

下载

下载rocketmq
wget http://mirrors.shu.edu.cn/apache/rocketmq/4.3.1/rocketmq-all-4.3.1-bin-release.zip

安装

源码安装

unzip rocketmq-all-4.3.2-source-release.zip
cd rocketmq-all-4.3.2/
mvn -Prelease-all -DskipTests clean install -U
cd distribution/target/apache-rocketmq

二进制文件安装

解压到当前目录
unzip rocketmq-all-4.3.1-bin-release.zip
转移到指定目录
mv -d rocketmq rocketmq-all-4.3.1-bin-release
进入指定目录
cd rocketmq

配置

`export NAMESRV_ADDR=linuxprobe.com:9876`

vim runserver.sh改小内存
vim runbroker.sh 改小内存

sh bin/mqbroker -m > conf/broker.p
vim conf/broker.conf

namesrvAddr=192.168.x.x:9876
brokerIP1=192.168.x.x
brokerName=hyl
brokerClusterName=DefaultCluster
brokerId=0
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
rejectTransactionMessage=false
fetchNamesrvAddrByAddressServer=false
transactionTimeOut=6000
transactionCheckMax=15
transactionCheckInterval=60000
storePathRootDir=/root/store
storePathCommitLog=/root/store/commitlog
flushIntervalCommitLog=500
commitIntervalCommitLog=200
flushCommitLogTimed=false
deleteWhen=04
fileReservedTime=72
maxTransferBytesOnMessageInMemory=262144
maxTransferCountOnMessageInMemory=32
maxTransferBytesOnMessageInDisk=65536
maxTransferCountOnMessageInDisk=8
accessMessageInMemoryMaxRatio=40
messageIndexEnable=true
messageIndexSafe=false
haMasterAddress=
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
cleanFileForciblyEnable=true
transientStorePoolEnable=false

启动

启动名称空间服务

> nohup sh bin/mqnamesrv &
> tail -f ~/logs/rocketmqlogs/namesrv.log
  The Name Server boot success...

启动broker服务

> nohup sh bin/mqbroker -n localhost:9876 &
> tail -f ~/logs/rocketmqlogs/broker.log 

or
nohup sh bin/mqbroker -c conf/broker.conf >> broker.log 2>&1 &
nohup sh bin/mqnamesrv >> namesrv.log 2>&1 &
nohup sh bin/mqbroker -n localhost:9876 autoCreateTopicEnable=true >> broker.log 2>&1 &
nohup sh bin/mqbroker -n linuxprobe.com:9876 &
nohup sh bin/mqbroker -n 192.168.0.145:9876 autoCreateTopicEnable=true >> broker.log 2>&1 &

调试

查看日志
tail -f ~/logs/rocketmqlogs/namesrv.log
tail -f ~/logs/rocketmqlogs/broker.log
发送

export NAMESRV_ADDR=localhost:9876
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
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) OK

参考

https://rocketmq.apache.org/docs/quick-start/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值