今天用安装配置rocketmq-3.2.6的方式配置rocketmq-3.5.8
结果输入 nohup sh mqnamesrv &
报错:Could not find or load main class com.alibaba.rocketmq.namesrv.NamesrvStartup
检查了环境变量始终没排除错误,最终知晓安装rocketmq-3.5.8要先编译(笑哭)
以下转自:http://www.fx114.net/qa-37-152744.aspx (谷歌浏览器会危险屏蔽网址)
1:在安装mq之前先确保安装了以下软件 不然会在编译时报 git,mvn命令找不到,这几个文件均安装在 /usr/local
下
git-2 13.1.tar.gz
apache-maven-3.5.0-bin.tar.gz
RocketMQ-3.5.8.tar.gz
jdk-8u131-linux-x64.tar.gz
2 :安装完 jdk和maven之后再/ect/profile
中配置环境变量 执行 source /etc/profile
使得环境变量生效
export JAVA_HOME=/usr/local/jdk1.8.0_131
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
MAVEN_HOME=/usr/local/apache-maven-3.5.0
export MAVEN_HOME
export PATH=${PATH}:${MAVEN_HOME}/bin
3:将rocketMQ解压到/usr/local/rockemq-source下,解压过后在/usr/local/rockemq-source/RocketMQ-3.5.8/
下执行命令 sh Install.sh
进行编译
4:配置mq的环境变量并使其生效
echo "ROCKETMQ_HOME=`pwd`" >> ~/.bash_profile
source ~/.bash_profile
我查看了下./bash_profile中写入的配置(/root文件夹下用 ls -al命令查看)
PATH=$PATH:$HOME/bin
export PATH
ROCKETMQ_HOME=/usr/local/rockemq-source/RocketMQ-3.5.8/devenv
5:启动 mqnameserver
nohup sh mqnamesrv &
注意启动时报错如下:
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=320m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
Error: Could not find or load main class com.alibaba.rocketmq.namesrv.NamesrvStartup
不能加载启动类说明配置mq环境变量不对,我之前是在/ect/profile文件中配置的环境变量死活报这个错 后来改成了【步骤四】设置mq环境变量的方式就好使了,当然也可以参考下面链接分析这个问题
https://stackoverflow.com/questions/43709352/rocketmq-nameserver-start-error-could-not-find-or-load-main-class
再次启动报如下错误:
java.lang.ExceptionInInitializerError
at com.alibaba.rocketmq.namesrv.NamesrvStartup.main0(NamesrvStartup.java:103)
at com.alibaba.rocketmq.namesrv.NamesrvStartup.main(NamesrvStartup.java:51)
Caused by: java.lang.RuntimeException: InetAddress java.net.InetAddress.getLocalHost() throws UnknownHostException
See http://docs.aliyun.com/cn#/pub/ons/faq/exceptions&unknown_host for further details.
at com.alibaba.rocketmq.common.MixAll.localhost(MixAll.java:433)
at com.alibaba.rocketmq.common.MixAll.(MixAll.java:67)
... 2 more
Caused by: java.net.UnknownHostException: nginx57: nginx57: Name or service not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
at com.alibaba.rocketmq.common.MixAll.localhost(MixAll.java:429)
... 3 more
Caused by: java.net.UnknownHostException: nginx57: Name or service not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getLocalHost(InetAddress.java:1500)
... 4 more
这个问题是由于/etc/sysconfig/network
中的记录的hostname和/etc/hosts中的主机名绑定不一致造成的改成一样的就行如图所示:
network文件配置
NETWORKING=yes
HOSTNAME=nginx57
hosts文件配置
127.0.0.1 nginx57
::1 localhost localhost.localdomain localhost7 localhost7.localdomain7
再次重新启动启动成功
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=320m; support was removed in 8.0
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
6:启动mqbroker
nohup sh mqbroker -n localhost:9876 autoCreateTopicEnable=true &
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=320m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file /root/tmpfs/logs/gc.log due to No such file or directory
The broker[nginx57, 192.168.100.57:10911] boot success. serializeType=JSON and name server is localhost:9876
7:查看是否启动正常
ps aux | grep java
root 7894 0.1 1.5 6327268 127820 pts/0 Sl Jun27 2:12 /usr/local/jdk1.8.0_131/bin/java -server -Xms4g -Xmx4g -Xmn2g -XX:PermSize=128m -XX:MaxPermSize=320m -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:+DisableExplicitGC -verbose:gc -Xloggc:/root/rmq_srv_gc.log -XX:+PrintGCDetails -XX:-OmitStackTraceInFastThrow -Djava.ext.dirs=/usr/local/rockemq-source/RocketMQ-3.5.8/devenv/bin/../lib -cp .:/usr/local/rockemq-source/RocketMQ-3.5.8/devenv/bin/../conf:.:/usr/local/jdk1.8.0_131/lib/tools.jar:/usr/local/jdk1.8.0_131/lib/dt.jar com.alibaba.rocketmq.namesrv.NamesrvStartup
root 8174 36.0 7.3 6313384 593116 pts/0 Sl 14:25 7:18 /usr/local/jdk1.8.0_131/bin/java -server -Xms4g -Xmx4g -Xmn2g -XX:PermSize=128m -XX:MaxPermSize=320m -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:+DisableExplicitGC -verbose:gc -Xloggc:/root/tmpfs/logs/gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:-OmitStackTraceInFastThrow -XX:+AlwaysPreTouch -Djava.ext.dirs=/usr/local/rockemq-source/RocketMQ-3.5.8/devenv/bin/../lib -cp .:/usr/local/rockemq-source/RocketMQ-3.5.8/devenv/bin/../conf:.:/usr/local/jdk1.8.0_131/lib/tools.jar:/usr/local/jdk1.8.0_131/lib/dt.jar com.alibaba.rocketmq.broker.BrokerStartup -n localhost:9876 autoCreateTopicEnable=true