配置Apache Apollo作为MQTT broker

公西博实
2023-12-01

nix.long

1.部署环境

  • 阿里云 ECS /Centos 7.3
  • Win类似

2. 配置

2.1 安装Apache-Apollo

  • /usr/sdk/

2.2 安装JDK 1.8

  • /usr/jdk

2.3 设置环境变量 /etc/profile

export PATH=$PATH:/usr/sdk/apache-apollo-1.7.1/bin
export PATH=$PATH:/usr/sdk/jdk1.8.0_151/bin
export APOLLO_HOME=/usr/sdk/apache-apollo-1.7.1/
export JAVA_HOME=/usr/sdk/jdk1.8.0_151/

2.4 创建apollo broker

 [root@iZ2zec6a1xdo92fn7zib3rZ sdk]#apollo create myapollo /usr/workplace/apache-apollo/

Creating apollo instance at: /usr/workplace/apache-apollo
Generating ssl keystore...

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore keystore -destkeystore keystore -deststoretype pkcs12".

You can now start the broker by executing:  

   "/usr/workplace/apache-apollo/bin/apollo-broker" run

Or you can setup the broker as system service and run it in the background:

   sudo ln -s "/usr/workplace/apache-apollo/bin/apollo-broker-service" /etc/init.d/
   /etc/init.d/apollo-broker-service start | stop | restart

vi /opt/lib/mybroker/etc/apollo.xml
修改 
http://127.0.0.1:61680“/> 
https://127.0.0.1:61681“/> 
为 
http://0.0.0.0:61680“/> 
https://0.0.0.0:61681“/>

2.5 使用apollo

  • /etc/init.d/apollo-broker-service start | stop | restart

2.6 修改连接授权

​ 在apollo.xml:

<!-- Give admins full access -->
  <access_rule allow="admins" action="*"/>
  <access_rule allow="*" action="connect" kind="connector"/>

​ 默认配置为允许admins 组用户连接, 如果允许任意用户连接, 修改为:

<!-- Give admins full access -->
  <access_rule allow="*" action="*"/>
  <access_rule allow="*" action="connect" kind="connector"/>

​ 连接需要的用户密码对在 users.properities配置

#
# The list of users that can login.  This file supports both plain text or
# encrypted passwords.  Here is an example what an encrypted password
# would look like:
#
# admin=ENC(Cf3Jf3tM+UrSOoaKU50od5CuBa8rxjoL)
#
admin=password
nix=123456
 类似资料: