You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 安装文档
> https://rocketmq.apache.org/zh/docs/4.x/quickstart/01quickstart
>
#### 安装$JDK$
```
cd /usr/local
rz -be
jdk-8u421-linux-x64.tar.gz
tar -xvf jdk-8u421-linux-x64.tar.gz
rm -rf jdk-8u421-linux-x64.tar.gz
mv jdk1.8.0_421/ jdk
vi /etc/profile
GG到最后
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
java -version
```
#### 安装$RocketMQ$
```shell
cd /usr/local
mkdir rocketmq
rz -be
rocketmq-all-4.9.4-bin-release.zip
unzip rocketmq-all-4.9.4-bin-release.zip
rm -rf rocketmq-all-4.9.4-bin-release.zip
mv rocketmq-all-4.9.4-bin-release/ rocketmq
cd rocketmq
### 启动namesrv
nohup sh bin/mqnamesrv &
### 验证namesrv是否启动成功
tail -f /root/logs/rocketmqlogs/namesrv.log
2024-07-31 13:48:37 INFO main - The Name Server boot success. serializeType=JSON
### 启动Broker
nohup sh bin/mqbroker -n localhost:9876 &
### 验证broker是否启动成功
tail -f /root/logs/rocketmqlogs/broker.log
main - The broker[RockyLinux, 10.10.14.210:10911] boot success. serializeType=JSON and name server is localhost:9876
```
#### 消息收发
```
export NAMESRV_ADDR=localhost:9876
cd /usr/local/rocketmq
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...
```
#### 关闭服务器
```shell
sh bin/mqshutdown broker
sh bin/mqshutdown namesrv
```