环境需求:
64位操作系统,建议使用Linux / Unix /
CentOs7.3
64bit JDK 1.8+
Maven 3.2.x
一、安装Maven
安装过程请查看:
二、安装RocketMQ
1、关闭防火墙
systemctl stop firewalld.service
2、下载和构建
wget http://mirrors.hust.edu.cn/apache/rocketmq/4.2.0/rocketmq-all-4.2.0-source-release.zipunzip rocketmq-all-4.2.0-source-release.zipcd rocketmq-all-4.2.0mvn -Prelease-all -DskipTests clean install -Umv distribution/target/apache-rocketmq /opt/apache-rocketmqcd /opt/apache-rocketmq/
编译成功的响应
3、配置rocketmq的环境变量,在/etc/profile最后添加
export ROCKETMQ_HOME=/opt/apache-rocketmqexport PATH=$JAVA_HOME/bin:$ROCKETMQ_HOME/bin:$PATH
4、使rocketmq的环境变量生效
source /etc/profile
5、给下列命令可执行权限
cd /opt/apache-rocketmq/bin/chmod +x mqadmin mqbroker mqfiltersrv mqshutdown mqnamesrv
三、启动Name Server
1、修改runserver,默认 RocketMQ Server 内存需要很大的
vim bin/runserver.sh--------------------------------------------------------------JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
2、启动 Name Server
mkdir /opt/apache-rocketmq/lognohup mqnamesrv >/opt/apache-rocketmq/log/nameserver.log 2>&1 &tail -10f /opt/apache-rocketmq/log/nameserver.log
启动成功信息如下
The Name Server boot success. serializeType=JSON
四、启动broker
1、修改runbroker,默认 RocketMQ Broker 内存需要很大的。
vim bin/runbroker.sh--------------------------------------------------------------JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m"
2、启动Broker
nohup mqbroker -n "127.0.0.1:9876" >/opt/apache-rocketmq/log/mq.log 2>&1 &tail -10f /opt/apache-rocketmq/log/mq.log
启动成功信息如下
2018-10-30 15:26:06 INFO main - Set user specified name server address: 172.17.17.1:98762018-10-30 15:26:06 INFO PullRequestHoldService - PullRequestHoldService service started2018-10-30 15:26:06 INFO main - register broker to name server 172.17.17.1:9876 OK2018-10-30 15:26:06 INFO main - The broker[env1, 172.17.17.1:10911] boot success. serializeType=JSON and name server is 172.17.17.1:9876
五、查看进程
[root@env1 apache-rocketmq]# jps2374 BrokerStartup2350 NamesrvStartup[root@env1 apache-rocketmq]# netstat -ntlpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1508/master tcp6 0 0 :::9876 :::* LISTEN 2350/java tcp6 0 0 ::1:25 :::* LISTEN 1508/master tcp6 0 0 :::10909 :::* LISTEN 2374/java tcp6 0 0 :::10911 :::* LISTEN 2374/java tcp6 0 0 :::10912 :::* LISTEN 2374/java [root@node1 apache-rocketmq]#
六、关闭服务
#关闭nameserver mqshutdown namesrv#关闭brokermqshutdown broker