问题描述
我在CentOS 7上安装好RocketMQ之后,使用mqadmin创建topic,命令如下:
./mqadmin updateTopic -n 192.168.77.129:9876 -c DefaultCluster -t test
然后报错信息如下:
org.apache.rocketmq.tools.command.SubCommandException: UpdateTopicSubCommand command failed
at org.apache.rocketmq.tools.command.topic.UpdateTopicSubCommand.execute(UpdateTopicSubCommand.java:181)
at org.apache.rocketmq.tools.command.MQAdminStartup.main0(MQAdminStartup.java:135)
at org.apache.rocketmq.tools.command.MQAdminStartup.main(MQAdminStartup.java:86)
Caused by: org.apache.rocketmq.acl.common.AclException: [10015:signature-failed] unable to calculate a request signature. error=[10015:signature-failed] unable to calculate a request signature. error=Algorithm HmacSHA1 not available
at org.apache.rocketmq.acl.common.AclSigner.signAndBase64Encode(AclSigner.java:84)
at org.apache.rocketmq.acl.common.AclSigner.calSignature(AclSigner.java:73)
at org.apache.rocketmq.acl.common.AclSigner.calSignature(AclSigner.java:68)
at org.apache.rocketmq.acl.common.AclUtils.calSignature(AclUtils.java:58)
at org.apache.rocketmq.acl.common.AclClientRPCHook.doBeforeRequest(AclClientRPCHook.java:44)
at org.apache.rocketmq.remoting.netty.NettyRemotingAbstract.doBeforeRpcHooks(NettyRemotingAbstract.java:172)
at org.apache.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:370)
at org.apache.rocketmq.client.impl.MQClientAPIImpl.getBrokerClusterInfo(MQClientAPIImpl.java:1180)
at org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl.examineBrokerClusterInfo(DefaultMQAdminExtImpl.java:275)
at org.apache.rocketmq.tools.admin.DefaultMQAdminExt.examineBrokerClusterInfo(DefaultMQAdminExt.java:222)
at org.apache.rocketmq.tools.command.CommandUtil.fetchMasterAddrByClusterName(CommandUtil.java:83)
at org.apache.rocketmq.tools.command.topic.UpdateTopicSubCommand.execute(UpdateTopicSubCommand.java:154)
... 2 more
Caused by: org.apache.rocketmq.acl.common.AclException: [10015:signature-failed] unable to calculate a request signature. error=Algorithm HmacSHA1 not available
at org.apache.rocketmq.acl.common.AclSigner.sign(AclSigner.java:63)
at org.apache.rocketmq.acl.common.AclSigner.signAndBase64Encode(AclSigner.java:79)
... 13 more
Caused by: java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available
at javax.crypto.Mac.getInstance(Mac.java:181)
at org.apache.rocketmq.acl.common.AclSigner.sign(AclSigner.java:57)
... 14 more
原因及解决方案
原因是安装CentOS 7的时候,系统自带的是jre,并没有安装jdk。通过javac命令可以发现:
[root@localhost local]# javac
bash: javac: command not found...
Similar command is: 'java'
[root@localhost local]# javac -version
bash: javac: command not found...
Similar command is: 'java'
因此我们重新安装一下jdk就好了,安装步骤如下:
1、yum list java-*
[root@localhost local]# yum list java-*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.njupt.edu.cn
* extras: centos.ustc.edu.cn
* updates: mirrors.njupt.edu.cn
Installed Packages
java-1.7.0-openjdk.x86_641:1.7.0.191-2.6.15.5.el7@anaconda
java-1.7.0-openjdk-headless.x86_641:1.7.0.191-2.6.15.5.el7@anaconda
java-1.8.0-openjdk.x86_641:1.8.0.181-7.b13.el7@anaconda
java-1.8.0-openjdk-headless.x86_641:1.8.0.181-7.b13.el7@anaconda
Available Packages
java-1.6.0-openjdk.x86_641:1.6.0.41-1.13.13.1.el7_3base
java-1.6.0-openjdk-demo.x86_641:1.6.0.41-1.13.13.1.el7_3base
java-1.6.0-openjdk-devel.x86_641:1.6.0.41-1.13.13.1.el7_3base
2、安装相应版本的jdk:yum install java-1.8.0-openjdk-devel.x86_64
[root@localhost local]# yum install java-1.8.0-openjdk-devel.x86_64
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.njupt.edu.cn
* extras: centos.ustc.edu.cn
* updates: mirrors.njupt.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.222.b10-0.el7_6 will be installed
--> Processing Dependency: java-1.8.0-openjdk(x86-64) = 1:1.8.0.222.b10-0.el7_6 for package: 1:java-1.8.0-openjdk-devel-1.8.0.222.b10-0.el7_6.x86_64
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.181-7.b13.el7 will be updated
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.222.b10-0.el7_6 will be an update
--> Processing Dependency: java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.222.b10-0.el7_6 for package: 1:java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64
--> Running transaction check
---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.181-7.b13.el7 will be updated
---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.222.b10-0.el7_6 will be an update
--> Finished Dependency ResolutionDependencies Resolved===================================================================================================================================================================================================================
PackageArchVersionRepositorySize
===================================================================================================================================================================================================================
Installing:
java-1.8.0-openjdk-develx86_641:1.8.0.222.b10-0.el7_6updates9.8 M
Updating for dependencies:
java-1.8.0-openjdkx86_641:1.8.0.222.b10-0.el7_6updates274 k
java-1.8.0-openjdk-headlessx86_641:1.8.0.222.b10-0.el7_6updates32 MTransaction Summary
===================================================================================================================================================================================================================
Install1 Package
Upgrade( 2 Dependent packages)Total size: 42 M
Total download size: 9.8 M
Is this ok [y/d/N]: y
Downloading packages:
java-1.8.0-openjdk-devel-1.8.0.222.b10-0.el7_6.x86_64.rpm| 9.8 MB00:00:21
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating: 1:java-1.8.0-openjdk-headless-1.8.0.222.b10-0.el7_6.x86_641/5
warning: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64/jre/lib/security/java.security created as /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64/jre/lib/security/java.security.rpmnew
restored /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64/jre/lib/security/java.security.rpmnew to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64/jre/lib/security/java.security
Updating: 1:java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_642/5
Installing : 1:java-1.8.0-openjdk-devel-1.8.0.222.b10-0.el7_6.x86_643/5
Cleanup: 1:java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_644/5
Cleanup: 1:java-1.8.0-openjdk-headless-1.8.0.181-7.b13.el7.x86_645/5
Verifying: 1:java-1.8.0-openjdk-headless-1.8.0.222.b10-0.el7_6.x86_641/5
Verifying: 1:java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_642/5
Verifying: 1:java-1.8.0-openjdk-devel-1.8.0.222.b10-0.el7_6.x86_643/5
Verifying: 1:java-1.8.0-openjdk-headless-1.8.0.181-7.b13.el7.x86_644/5
Verifying: 1:java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_645/5 Installed:
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.222.b10-0.el7_6Dependency Updated:
java-1.8.0-openjdk.x86_64 1:1.8.0.222.b10-0.el7_6java-1.8.0-openjdk-headless.x86_64 1:1.8.0.222.b10-0.el7_6Complete!
3、vim /etc/profile
添加环境变量:
export JAVA_HOME=/usr/lib/jvm/javaexport CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jarexport PATH=$PATH:$JAVA_HOME/bin
4、source /etc/profile
这样修改就生效了,通过javac命令可以看到:
[root@localhost bin]# javac
Usage: javac
where possible options include:
-gGenerate all debugging info
-g:noneGenerate no debugging info
-g:{lines,vars,source}Generate only some debugging info
-nowarnGenerate no warnings
-verboseOutput messages about what the compiler is doing
-deprecationOutput source locations where deprecated APIs are used
-classpath Specify where to find user class files and annotation processors
-cp Specify where to find user class files and annotation processors
-sourcepath Specify where to find input source files
-bootclasspath Override location of bootstrap class files
-extdirs Override location of installed extensions
-endorseddirs Override location of endorsed standards path
-proc:{none,only}Control whether annotation processing and/or compilation is done.
-processor [,,...] Names of the annotation processors to run;
bypasses default discovery process
-processorpath Specify where to find annotation processors
-parametersGenerate metadata for reflection on method parameters
-d Specify where to place generated class files
-s Specify where to place generated source files
-h Specify where to place generated native header files
-implicit:{none,class}Specify whether or not to generate class files for implicitly referenced files
-encoding Specify character encoding used by source files
-source Provide source compatibility with specified release
-target Generate class files for specific VM version
-profile Check that API used is available in the specified profile
-versionVersion information
-helpPrint a synopsis of standard options
-Akey[=value]Options to pass to annotation processors
-XPrint a synopsis of nonstandard options
-JPass directly to the runtime system
-WerrorTerminate compilation if warnings occur
@Read options and filenames from file
echo $PATH也可以看到:
root@localhost bin]# echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/bin:/usr/local/apache-maven-3.6.1/bin:/home/gameloft9/.local/bin:/home/gameloft9/bin:/usr/lib/jvm/java/bin:/usr/local/apache-maven-3.6.1/bin
[root@localhost bin]#
然后我们再运行创建topic的命令:
[gameloft9@localhost bin]$ ./mqadmin updateTopic -n 192.168.77.129:9876 -c DefaultCluster -t test
OpenJDK 64-Bit Server VM warning: ignoring option PermSize=128m;
support was removed in 8.0
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=128m;
support was removed in 8.0
create topic to 192.168.77.129:10911 success.
【RocketMQ|CentOS 7使用RocketMQ mqadmin命令工具报错】可以看到成功了。
推荐阅读
- RocketMQ - 理论篇
- RocketMQ - 应用篇
- RocketMQ-单机版安装及远程连接测试
- RocketMQ安装及测试
- RocketMQ原理
- Kafka|Kafka VS RocketMQ VS RabbitMQ
- 【运维】【一】RocketMQ 运维命令详解
- RocketMQ
- RocketMQ遇到的坑
- Rocketmq创建topic报错org.apache.rocketmq.acl.common.AclException: [10015:signature-failed] unable to cal