- 创建用户
groupadd rocketmq #创建rocketmq用户组
useradd -d /usr/rocketmq -g rocketmq -m rocketmq #创建rocketmq用户
passwd rocketmq #设置rocketmq密码
- 查看JAVA环境
[rocketmq@localhost ~]$ java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
- 下载编译
https://github.com/alibaba/RocketMQ (老版本,3.*.*)
https://github.com/apache/incubator-rocketmq(最新地址,Rocketmq已捐赠给Apache基金会)(4.*.* 开始)
mvn 安装:https://my.oschina.net/u/1179666/blog/862778
#通过GIT下载最新的rocketmq,也可以下载对应版本的rocketmq源码
[root@localhost install]# git clone https://github.com/apache/incubator-rocketmq.git
- 下载(暂不使用,使用3的步骤)
[rocketmq@localhost install]$ wget https://github.com/alibaba/RocketMQ/archive/v3.5.8.zip
wget https://github.com/apache/incubator-rocketmq/archive/ROCKETMQ-62.zip
[rocketmq@localhost install]$ git clone https://github.com/apache/incubator-rocketmq/archive/release-4.0.0-incubating.zip
- 修改环境变量
[root@b5eaa70483ff install]# echo 'export JAVA_HOME=/usr/java/jdk1.8.0_111' >> /etc/profile
#安装maven
[root@b5eaa70483ff install]# unzip apache-maven-3.3.3.zip
[root@b5eaa70483ff install]# echo 'export M2_HOME=/usr/local/maven/apache-maven-3.3.3' >> /etc/profile
[root@b5eaa70483ff install]# echo 'export M2=$M2_HOME/bin' >> /etc/profile
[root@b5eaa70483ff install]# echo 'export MAVEN_OPTS="-Xms256m-Xmx512m"' >> /etc/profile
[root@b5eaa70483ff install]# echo 'export PATH=$M2:$PATH' >> /etc/profile
- 编译
[root@9a4ee3593c26 incubator-rocketmq]# mvn clean package install -Prelease-all assembly:assembly -U
4.2.0前面命令编译报错:Could not find goal 'assembly' in plugin org.apache.maven.plugins:maven-assembly-plugin:3.0.0 among available goals help, single
4.2.0新编译命令:mvn -Prelease-all -DskipTests clean install -U
#编译,在target目录下打包编译后的项目为tar.gz包
[root@localhost target]# ls
apache-rocketmq-all archive-tmp checkstyle-checker.xml effective-pom
apache-rocketmq-all.tar.gz checkstyle-cachefile checkstyle-result.xml maven-shared-archive-resources
拷贝项目到用户rocketmq目录下:
/usr/rocketmq/rocketmq/apache-rocketmq-all.tar.gz
[rocketmq@localhost bin]$ tar -zxvf apache-rocketmq-all.tar.gz
- 启动配置
[rocketmq@localhost bin]$ chmod +x mqadmin mqbroker mqfiltersrv mqshutdown mqnamesrv
[rocketmq@localhost bin]$ ./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: 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.
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file /dev/shm/rmq_srv_gc.log due to Permission denied
The Name Server boot success. serializeType=JSON
[rocketmq@localhost bin]$ nohup ./mqnamesrv & #后台启动 Name Server
[rocketmq@localhost bin]$ nohup ./mqbroker -n localhost:9876 & #后台启动Broker
[rocketmq@localhost bin]$ nohup ./mqbroker -c /usr/rocketmq/rocketmq/conf/2m-2s-sync/broker-a.properties -n 127.0.0.1:9876 &#使用配置文件,设置本机IP,解决多网卡识别错误问题,可考虑在docker下错误问题(待测试)
[rocketmq@localhost 2m-2s-sync]$ more broker-a.propertie
#Broker对外服务的监听端口
#listenPort = 10911
## Name Server地址
#namesrvAddr=192.168.0.26:9876
#本机IP地址,默认系统自动识别,但是某些多网卡机器会存在识别错误的情况,这种情况下可以人工配置
brokerIP1=192.168.0.26
#Broker所属哪个集群,其中缺省值为DefaultCluster
brokerClusterName=DefaultCluster
#本机主机名
brokerName=broker-a
#BrokerId,必须是大等于0的整数,0表示Master,>0表示Slave,一个Master可以挂多个Slave,Master与Slave通过BrokerName来配对
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
[rocketmq@localhost bin]$ sh mqshutdown namesrv #关闭Name Server
[rocketmq@localhost bin]$ sh mqshutdown broker #关闭Broker
[rocketmq@localhost bin]$ jps #查看是否启动成功
2949 NamesrvStartup
3039 Jps
[rocketmq@localhost bin]$ ./mqadmin topicList -n 127.0.0.1:9876
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=128m; support was removed in 8.0
BenchmarkTest
OFFSET_MOVED_EVENT
TBW102
localhost.localdomain
SELF_TEST_TOPIC
DefaultCluster
[rocketmq@localhost bin]$ sh mqadmin updateTopic -n 127.0.0.1:9876 -c DefaultCluster -t TopicTest1 #创建名称为TopicTest1 的topic
[rocketmq@localhost bin]$ sh mqadmin clusterList -n 127.0.0.1:9876 #查看集群信息
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=128m; support was removed in 8.0
#Cluster Name #Broker Name #BID #Addr #Version #InTPS(LOAD) #OutTPS(LOAD) #PCWait(ms) #Hour #SPACE
[rocketmq@localhost network-scripts]$ netstat -ntlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:32000 0.0.0.0:* LISTEN -
tcp6 0 0 127.0.0.1:8105 :::* LISTEN -
tcp6 0 0 :::8009 :::* LISTEN -
tcp6 0 0 :::3306 :::* LISTEN -
tcp6 0 0 :::8109 :::* LISTEN -
tcp6 0 0 :::8080 :::* LISTEN -
tcp6 0 0 :::10001 :::* LISTEN -
tcp6 0 0 :::10002 :::* LISTEN -
tcp6 0 0 :::10003 :::* LISTEN -
tcp6 0 0 :::9876 :::* LISTEN 3815/java
tcp6 0 0 :::8180 :::* LISTEN -
tcp6 0 0 :::21 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:25 :::* LISTEN -
tcp6 0 0 :::10909 :::* LISTEN 5354/java
tcp6 0 0 :::10911 :::* LISTEN 5354/java
tcp6 0 0 :::10912 :::* LISTEN 5354/java
tcp6 0 0 127.0.0.1:8005 :::* LISTEN -
- 去除警告信息和调整内存占用
#修改xml文件
vi mqadmin.xml
vi mqbroker.xml
vi mqnamesrv.xml
vi mqfiltersrv.xml
删除对应的:<-XX:PermSize>128M</-XX:PermSize> <-XX:MaxPermSize>128M</-XX:MaxPermSize>
<options>
<-Xms512m></-Xms512m>
<-Xmx1g></-Xmx1g>
<-XX:NewSize>256M</-XX:NewSize>
<-XX:MaxNewSize>512M</-XX:MaxNewSize>
<-XX:PermSize>128M</-XX:PermSize>
<-XX:MaxPermSize>128M</-XX:MaxPermSize>
</options>
#修改启动文件
vi runserver.sh
vi runbroker.sh
#===========================================================================================
# JVM Configuration
#===========================================================================================
JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:PermSize=128m -XX:MaxPermSize=320m"
JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPer
#删除-XX:PermSize=128m -XX:MaxPermSize=320m #JDK1.8开始
-XX:+UseCMSCompactAtFullCollection #JDK1.8开始
修改 -Xms4g -Xmx4g -Xmn2g 大小
9 启动配置(错误事例,暂不使用,启动问题已解决,不用配置rocketmq全局环境变量,/etc/profile 2017.3.20)
[rocketmq@localhost rocketmq-r4.0.0]$ cd bin
[rocketmq@localhost bin]$ ls
cachedog.sh mqadmin mqbroker.numanode0 mqbroker.numanode3 mqfiltersrv.xml mqshutdown README.md setcache.sh
cleancache.sh mqadmin.xml mqbroker.numanode1 mqbroker.xml mqnamesrv os.sh runbroker.sh startfsrv.sh
cleancache.v1.sh mqbroker mqbroker.numanode2 mqfiltersrv mqnamesrv.xml play.sh runserver.sh tools.sh
[rocketmq@localhost bin]$ chmod +x mqadmin mqbroker mqfiltersrv mqshutdown mqnamesrv
[rocketmq@localhost ~]$ mkdir log
[rocketmq@localhost ~]$ mqnamesrv 1>/usr/rocketmq/log/ng.log 2>/usr/rocketmq/log/ng-err.log
#启动报错
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: 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.
Java HotSpot(TM) 64-Bit Server VM warning: Cannot open file /dev/shm/rmq_srv_gc.log due to Permission denied
Error: Could not find or load main class org.apache.rocketmq.namesrv.NamesrvStartup