使用rocketuser作为rocketmq的服务启动账户

资源下载

jdk1.8

http://archive.apache.org/dist/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.zip

https://www-us.apache.org/dist/rocketmq/4.1.0-incubating/rocketmq-all-4.1.0-incubating-bin-release.zip

1、解压并赋予权限

解压jdk

# tar -zxf jdk-8u181-linux-x64.tar.gz -C /usr/local

# cd /usr/local

# ln -s jdk1.8.0_181 jdk

解压maven

# tar -zxf apache-maven-3.5.2-bin.tar.gz -C /usr/local

# chown rocketuser:rocketuser /usr/local/apache-maven-3.5.2

解压rocketmq

# unzip rocketmq-all-4.1.0-incubating-bin-release.zip -D /data/webApps

# cd /data/webApps 

# ln -s rocketmq-all-4.1.0-incubating rocketmq

# chown -R rocketuser:rocketuser rocketmq-all-4.1.0-incubating

2、配置环境变量、

# vi /etc/profile

JAVA_HOME=/usr/local/jdk

MAVEN_HOME=/usr/local/maven

export JAVA_HOME MAVEN_HOME PATH

PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH

# source /etc/profile

3、启动服务

$ cd /data/webApps/rocketmq/bin 

$ ./mqnamesrv &

[1] 6691

$ 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.

The Name Server boot success. serializeType=JSON

$ ./mqbroker -n localhost:9876 &

[2] 9395

$ Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=256m; support was removed in 8.0

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=640m; support was removed in 8.0

后台启动服务

$ nohup sh mqnamesrv >/dev/null 2>&1 &

查看日志

$ tail -f ~/logs/rocketmqlogs/namesrv.log

The Name Server boot success

关闭服务的命令

$ ./mqshutdown namesrv

$ ./mqshutdown broker

4、对外提供服务

想要对外提供服务需要修改配置

$ vi /data/webApps/rocketmq/conf/broker.conf 

namesrvAddr = 192.168.11.115:9876

brokerIP1 = 192.168.11.115

之后再启动服务

$ nohup sh mqnamesrv >/dev/null 2>&1 &

$ nohup ./mqbroker -n 192.168.11.115:9876 autoCreateTopicEnable=true -c /data/webApps/rocketmq/conf/broker.conf >/dev/null 2>&1 &

[2] 29382

查看日志

$ tail -f ~/logs/rocketmqlogs/broker.log

2019-04-10 09:18:00 INFO main - load exist local topic, TopicConfig [topicName=SELF_TEST_TOPIC, readQueueNums=1, writeQueueNums=1, perm=RW-, topicFilterType=SINGLE_TAG, topicSysFlag=0, order=false]

2019-04-10 09:18:00 INFO main - load exist local topic, TopicConfig [topicName=DefaultCluster, readQueueNums=16, writeQueueNums=16, perm=RWX, topicFilterType=SINGLE_TAG, topicSysFlag=0, order=false]

2019-04-10 09:18:00 INFO main - load /home/rocketuser/store/config/topics.json OK

2019-04-10 09:18:00 INFO main - load /home/rocketuser/store/config/consumerOffset.json OK

2019-04-10 09:18:00 INFO main - load /home/rocketuser/store/config/consumerFilter.json OK

2019-04-10 09:18:00 INFO main - load /home/rocketuser/store/config/delayOffset.json OK

2019-04-10 09:18:00 INFO main - Set user specified name server address: 192.168.11.115:9876

2019-04-10 09:18:00 INFO PullRequestHoldService - PullRequestHoldService service started

2019-04-10 09:18:01 INFO main - register broker to name server 192.168.11.115:9876 OK

2019-04-10 09:18:01 INFO main - The broker[broker-a, 192.168.11.115:10911] boot success. serializeType=JSON and name server is 192.168.11.115:9876

2019-04-10 09:18:10 INFO BrokerControllerScheduledThread1 - dispatch behind commit log 0 bytes

2019-04-10 09:18:10 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 719560 bytes

2019-04-10 09:18:11 INFO BrokerControllerScheduledThread1 - register broker to name server 192.168.11:9876 OK

5、部署控制台

下载rocketmq-console并编译,链接如下

https://github.com/apache/incubator-rocketmq-externals/tree/master/rocketmq-console

但是我把项目上传到eclipse进行编译失败了,所以直接下载了CSDN上别人上传的jar包

启动服务

$ java -jar rocketmq-console-ng-1.0.0.jar --server.port=12581 --rocketmq.config.namesrvAddr=192.168.11.115:9876 &

Started App in 9.306 seconds (JVM running for 10.977)

设置nginx代理

# vi /etc/nginx/nginx.conf

        location /rocketmq {

            proxy_pass              http://192.168.11.115:12581;

            proxy_set_header Host $host;

            proxy_redirect off;

            proxy_cache_valid 200 302 1h;

            proxy_cache_valid 301 1d;

            proxy_cache_valid any 1024m;

            expires 30d;

        }

访问下面的地址就可以访问rocketmq管理页面了

http://192.168.11.115/rocketmq