linux下安裝rocketmq訊息中介軟體

linux下安裝rocketmq訊息中介軟體

本專案安裝需要事先安裝maven專案

1.下載(/user/local目錄下)

下載地址:https://github.com/apache/rocketmq

本地下載的tar包是基礎包,只能通過maven打包可以打包出rocketmq啟動的專案。會生成在/rocketmq-all-4.2.0/distribution/target目錄下apache-rocketmq檔案,裡面包含啟動檔案

wget https://github.com/apache/rocketmq/archive/rocketmq-all-4.2.0.tar.gz

2.解壓

tar -zxvf rocketmq-all-4.2.0.tar.gz

3.maven編譯生成rocketmq依賴的架包(包含生成rocketmq啟動的專案)在usr/local/rocketmq-all-4.2.0目錄下

mvn -Dmaven.test.skip=true clean package install assembly:assembly   -p release-all  -u

mvn install:install-file -Dfile=lucene-analyzers-common-6.3.0.jar -DgroupId=org.apache.lucene -DartifactId=lucene-analyzers-common-6.3.0 -Dversion=6.3.0 -Dpackaging=jar

用該命令,上面兩個命令有問題
mvn -Prelease-all -DskipTests clean install -U

最後顯示編譯完成

編譯完成後發現在/usr/local/rocketmq-all-4.2.0/distribution/target目錄下apache-rocketmq檔案,所有啟動的專案命令都在這個專案裡面裡

4.配置系統環境變數

vi /etc/profile

新增如下兩行

export rocketmq=/usr/local/rocketmq-rocketmq-all-4.2.0/distribution/target/apache-rocketmq
export PATH=$PATH:$rocketmq/bin

5.讓系統環境變數生效

source /etc/profile

6.啟動mqnameserver(/usr/local/rocketmq-rocketmq-all-4.2.0/distribution/target/apache-rocketmq/bin目錄下)

建立rocketmq日誌資料夾(/usr/local/logs/rocketmqlogs檔案)

cd /usr/local/logs/

mkdir rocketmqlogs

nohup sh mqnamesrv > ~/logs/rocketmqlogs/namesrv.log 2>&1 &

啟動後 可根據ps -ef|grep rocketmq檢視程序

root     18706 18702  0 20:22 pts/0    00:00:00 sh /usr/local/rocketmq-rocketmq-all-4.2.0/distribution/target/apache-rocketmq/bin/runserver.sh org.apache.rocketmq.namesrv.NamesrvStartup
root     18708 18706  0 20:22 pts/0    00:00:03 /usr/local/java/jdk1.8.0_144/bin/java -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX: UseConcMarkSweepGC -XX: UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70
-XX: CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX: CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:-UseParNewGC -verbose:gc -Xloggc:/dev/shm/rmq_srv_gc.log -XX: PrintGCDetails -XX:-OmitStackTraceInFastThrow -XX:-UseLargePages -Djava.ext.dirs=/usr/local/java/jdk1.8.0_144/jre/lib/ext:/usr/local/rocketmq-rocketmq-all-4.2.0/distribution/target/apache-rocketmq/bin/../lib
-cp .:/usr/local/rocketmq-rocketmq-all-4.2.0/distribution/target/apache-rocketmq/bin/../conf: org.apache.rocketmq.namesrv.NamesrvStartup
root     18884 18657  0 21:31 pts/0    00:00:00 grep –color=auto rocketmq
[2]   Exit 1                  nohup sh mqnamesrv > ~/logs/rocketmqlogs/namesrv.log 2>&1

7.啟動mqbroker(/usr/local/rocketmq-rocketmq-all-4.2.0/distribution/target/apache-rocketmq/bin目錄下)

nohup sh mqbroker -n localhost:9876 autoCreateTopicEnable=true > ~/logs/rocketmqlogs/broker.log
2>&1 &

注意:localhost可以換成你剛才啟動mqnamesrv的ip