启动入口

启动步骤
创建NamesrvController
NamesrvController controller = createNamesrvController(args);
设置rocketmq.remoting.version版本
System.setProperty(RemotingCommand.REMOTING_VERSION_KEY, Integer.toString(MQVersion.CURRENT_VERSION));
解析参数信息
| 短 | 长 | 是否必须 | 是否需要参数 | 描述 |
|---|
| h | help | 否 | 否 | 打印帮助命令 |
| n | namesrvAddr | 否 | 是 | Name server address list,eg:192.168.0.1:9876;192.168.0.2:9876 |
| c | configFile | 否 | 是 | Name server config properties file |
| p | printConfigItem | 否 | 否 | Print all config item |
如果参数包含c/configFile属性则获取configFile文件配置信息赋值至NamesrvConfig及NettyServerConfig
命令行内的参数配置优先于configFile里的配置
命令实战
h help命令 打印支持的参数信息
rocketmq-all-4.8.0-bin-release/bin » ./mqnamesrv -h 146 ↵
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.
usage: mqnamesrv [-c <arg>] [-h] [-n <arg>] [-p]
-c,--configFile <arg> Name server config properties file
-h,--help Print help
-n,--namesrvAddr <arg> Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876
-p,--printConfigItem Print all config item
p printConfigItem命令 打印程序运行时的配置信息
/rocketmq-all-4.8.0-bin-release/bin » ./mqnamesrv -p
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.
12:32:01.785 [main] INFO RocketmqNamesrvConsole - rocketmqHome=/Users/rocketmq-all-4.8.0-bin-release
12:32:01.788 [main] INFO RocketmqNamesrvConsole - kvConfigPath=/Users/namesrv/kvConfig.json
12:32:01.788 [main] INFO RocketmqNamesrvConsole - configStorePath=/Users/namesrv/namesrv.properties
12:32:01.788 [main] INFO RocketmqNamesrvConsole - productEnvName=center
12:32:01.788 [main] INFO RocketmqNamesrvConsole - clusterTest=false
12:32:01.788 [main] INFO RocketmqNamesrvConsole - orderMessageEnable=false
12:32:01.788 [main] INFO RocketmqNamesrvConsole - listenPort=9876
12:32:01.788 [main] INFO RocketmqNamesrvConsole - serverWorkerThreads=8
12:32:01.788 [main] INFO RocketmqNamesrvConsole - serverCallbackExecutorThreads=0
12:32:01.788 [main] INFO RocketmqNamesrvConsole - serverSelectorThreads=3
12:32:01.788 [main] INFO RocketmqNamesrvConsole - serverOnewaySemaphoreValue=256
12:32:01.788 [main] INFO RocketmqNamesrvConsole - serverAsyncSemaphoreValue=64
12:32:01.788 [main] INFO RocketmqNamesrvConsole - serverChannelMaxIdleTimeSeconds=120
12:32:01.788 [main] INFO RocketmqNamesrvConsole - serverSocketSndBufSize=65535
12:32:01.788 [main] INFO RocketmqNamesrvConsole - serverSocketRcvBufSize=65535
12:32:01.788 [main] INFO RocketmqNamesrvConsole - serverPooledByteBufAllocatorEnable=true
12:32:01.788 [main] INFO RocketmqNamesrvConsole - useEpollNativeSelector=false
c configFile 指定配置文件位置
/rocketmq-all-4.8.0-bin-release/bin » ./mqnamesrv -c ../conf/2m-2s-async/broker-a.properties
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.
load config properties file OK, ../conf/2m-2s-async/broker-a.properties
The Name Server boot success. serializeType=JSON