Rocketmq安裝(Linux)

  1. 建立用戶
groupadd rocketmq #建立rocketmq用戶組
useradd -d /usr/rocketmq  -g rocketmq -m rocketmq #建立rocketmq用戶
passwd  rocketmq  #設置rocketmq密碼
  1. 查看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)
  1. 下載編譯
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
  1. 下載(暫不使用,使用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
  1. 修改環境變量
[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
  1. 編譯
[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
  1. 啓動配置
[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      -
  1. 去除警告信息和調整內存佔用
#修改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)java

[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
相關文章
相關標籤/搜索