赞
踩
Linux安装环境
1、jdk1.8
2、maven
如果 linux没安装,请自行搜索,很多教程
链接:https://pan.baidu.com/s/1oJ0F-GQNjA9a4kpDQcI5KA
提取码:zxq6
master:为主要安装包
externals-master:为可视化管理工具包
将文件移入linux root目录下
分别解压
unzip rocketmq-master.zip
unzip rocketmq-externals-master.zip
如图:
进入rocketmq-master主目录下
运行编译指令进行编译:
mvn -Prelease-all -DskipTests clean install -U
编译成功会生成distribution
文件夹,进入该文件夹的target文件夹下
找到编译成功后的rocketmq-4.6.1
将改文件移动到/usr/local/目录下
进入该文件夹的bin目录下
cd /usr/local/rocketmq-4.6.1/bin
然后运行./mqnamesrv
运行成功后为:
在这可能会报错,最后附上报错怎么处理
这里运行的./mqnamesrv
类似与一个注册中心
broker
服务在当前目录下 另外开一个窗口运行
./mqbroker -n localhost:9876
运行成功后为:
使用tool.sh
脚本执行测试程序
在bin
目录下执行
./tools.sh org.apache.rocketmq.example.quickstart.Producer
提示如下,则表示成功
在开一个窗口在bin
目录下运行
./tools.sh org.apache.rocketmq.example.quickstart.Consumer
能接收到信息表示环境部署成功;
原因:网络不好或maven仓库服务器出错
重试即可,或者欢迎镜像仓库
./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
原因: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参数
vim runbroker.sh
broker
vim runserver.sh
nameserver
默认数值给的都很大,改小即可
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=100m"
[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.... ... 主机别名
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。