rocketmq的安装使用
先安装maven:
https://maven.apache.org/download.cgi
解压:
tar -zxvf apache-maven-3.6.0-src.tar.gz
配置环境变量:
vim /etc/profile
MAVEN_HOME=/home/xxx/xxx/apache-maven-3.6.3 //这边是我的apache-maven-3.6.3的解压路径 export MAVEN_HOME export PATH=${PATH}:${MAVEN_HOME}/bin
最后执行:
source /etc/profile 使配置生效。
下载rocketmq。
wget https://github.com/apache/rocketmq/archive/rocketmq-all-4.6.0.tar.gz
解压:
tar -zxvf rocketmq-all-4.6.0.tar.gz
接下来需要使用maven对项目进行编译:
mvn -Prelease-all -DskipTests clean install -U
表示 成功!
配置下环境变量:
vim /etc/profile
添加:
这个一定要配置对,在distribution的target的下面的下面,直到看到bin
export rocketmq=/home/linewell/rocketmq-rocketmq-all-4.6.0/distribution/target/rocketmq-4.6.0/rocketmq-4.6.0
export NAMESRV_ADDR=192.168.71.170:9876
export PATH=$PATH:$rocketmq/bin
然后
source /etc/profile使之生效。
在当前解压目录下的:
./distribution/target/rocketmq-4.6.0/rocketmq-4.6.0/bin
这边可以执行相关的命令。
可以查看下README.md文件:
### Operating system tuning Before deploying broker servers, it's highly recommended to run **os.sh**, which is to optimize your operating system for better performance. ## Notice ### os.sh should be executed only once with root permission. ### os.sh parameter settings are for reference purpose only. You can tune them according to your target host configurations. ### Start broker * Unix platform `nohup sh mqbroker &` ### Shutdown broker sh mqshutdown broker ### Start Nameserver * Unix platform `nohup sh mqnamesrv &` ### Shutdown Nameserver sh mqshutdown namesrv ### Update or create Topic sh mqadmin updateTopic -b 127.0.0.1:10911 -t TopicA ### Update or create subscription group sh mqadmin updateSubGroup -b 127.0.0.1:10911 -g SubGroupA
由于RocketMQ默认的java内存配置有点大,服务器内存没那么大就会报错
只要修改一下bin目录下的runserver.sh和runbroker.sh文件的配置就好了
然后修改conf目录下的broker.conf文件:
brokerClusterName = DefaultCluster brokerName = broker-a brokerId = 0 deleteWhen = 04 fileReservedTime = 48 brokerRole = ASYNC_MASTER flushDiskType = ASYNC_FLUSH brokerIP1=192.168.71.170 namesrvAddr = 192.168.71.170:9876 autoCreateTopicEnable = true
到ROCKET_HOME对应的目录下:
启动Nameserver:
nohup sh 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.
The Name Server boot success. serializeType=JSON
启动broker:
nohup sh mqbroker &
输出:
The broker[localhost.localdomain, 192.168.71.170:10911] boot success. serializeType=JSON