RocketMQ安装配置过程
官网
官方网站:http://rocketmq.apache.org
下载源码包:https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.8.0/rocketmq-all-4.8.0-source-release.zip
Github:https://github.com/apache/rocketmq
Linux+JDK1.8
服务器配置
- 服务器内配置JDK环境,将压缩包上传到/usr/local下进行解压
tar -zxvf jdk-8u231-linux-x64.tar.gz /usr/local
- 配置环境变量
vim /etc/profile
#插入内容
export JAVA_HOME=/usr/local/jdk1.8.0_231
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
#即时生效
source /etc/profile
- 在Windows上进入rocketmq主目录使用maven编译项目
mvn -Prelease-all -DskipTests clean install -U
编译后在这个文件夹找到压缩包
D:\config\apache-maven-3.6.2\Repository\org\apache\rocketmq\rocketmq-distribution\4.3.2
- 将编译好的压缩包上传到Linux系统中解压
#创建rocketmq目录
mkdir /usr/local/rocketmq
#解压rocketmq压缩包
tar -zxvf rocketmq-distribution-4.3.2.tar.gz -C /usr/local/rocketmq
- 运行rocketmq
#进入/usr/local/rocketmq/bin目录
cd /usr/local/rocketmq/bin
#修改配置文件runserver.sh与runbroker.sh启动参数
#JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m"
#执行mqnamesrv
./mqnamesrv
#执行runbroker
./mqbroker -n localhost:9876
控制台rocketmq-console编译安装
下载
https://github.com/apache/rocketmq-externals
中文指南
https://github.com/apache/rocketmq-externals/blob/master/rocketmq-console/doc/1_0_0/UserGuide_CN.md
上传到服务器并解压缩
编译
进入rocketmq-console目录
执行编译
mvn clean package -Dmaven.test.skip=true
启动
编译成功后在rocketmq-console/target目录下执行rocketmq-console-ng-1.0.1.jar
启动时,直接动态添加nameserver地址或编辑application.properties添加属性
java -jar rocketmq-console-ng-1.0.1.jar --rocketmq.config.namesrvAddr=127.0.0.1:9876
编译时包无法在mirror上找到 提示502错误
原因:网络不好或maven仓库服务器出错
重试即可,或者欢迎镜像仓库
发送失败提示connect to null failed
./tools.sh org.apache.rocketmq.example.quickstart.Producer 22:49:02.470 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as the default logging framework RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0). RocketMQLog:WARN Please initialize the logger system properly. java.lang.IllegalStateException: org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to null failed
原因:不知道
nameserver
在哪儿在
tools
脚本中添加export NAMESRV_ADDR=localhost:9876
启动broker失败 Cannot allocate memory
原因:jvm启动初始化内存分配大于物理内存
[root@node-113b bin]# ./mqbroker -n localhost:9876 Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000005c0000000, 8589934592, 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 8589934592 bytes for committing reserved memory. # An error report file with more information is saved as: # /usr/local/rocketmq/bin/hs_err_pid1997.log
修改启动脚本中的jvm参数
runbroker.sh
broker
runserver.sh
nameserver默认数值给的都很大,改小即可
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=100m"
启动broker成功但提示:Failed to obtain the host name
[root@node-113b bin]# ./mqbroker -n localhost:9876 22:30:42.307 [main] ERROR RocketmqCommon - Failed to obtain the host name java.net.UnknownHostException: node-113b: node-113b: No address associated with hostname at java.net.InetAddress.getLocalHost(InetAddress.java:1505) ~[na:1.8.0_181] at org.apache.rocketmq.common.BrokerConfig.localHostName(BrokerConfig.java:189) [rocketmq-common-4.6 .1.jar:4.6.1] at org.apache.rocketmq.common.BrokerConfig.<init>(BrokerConfig.java:38) [rocketmq-common-4.6.1.jar:4 .6.1] at org.apache.rocketmq.broker.BrokerStartup.createBrokerController(BrokerStartup.java:110) [rocketmq -broker-4.6.1.jar:4.6.1] at org.apache.rocketmq.broker.BrokerStartup.main(BrokerStartup.java:58) [rocketmq-broker-4.6.1.jar:4 .6.1]Caused by: java.net.UnknownHostException: node-113b: No address associated with hostname at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) ~[na:1.8.0_181] at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928) ~[na:1.8.0_181] at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323) ~[na:1.8.0_181] at java.net.InetAddress.getLocalHost(InetAddress.java:1500) ~[na:1.8.0_181] ... 4 common frames omitted The broker[DEFAULT_BROKER, 192.168.150.213:10911] boot success. serializeType=JSON and name server is localh ost:9876
原因:无法解析当前的主机名
hosts里添加映射即可
192.168.150.213 node-113b