5178 views|5 replies

205

Posts

0

Resources
The OP
 

[GD32E231 DIY Contest]——04. Build an IoT cloud server based on MQTT communication [Copy link]

Brief description: Linux servers are now mature, and due to their outstanding performance in cloud platforms and emerging technologies, they are becoming more and more popular with organizations. Currently, BAT's cloud server platforms also support Linux servers, but considering the cost of DIY, without affecting the differences in the deployment process in actual applications, combined with the functions of Windows 10 itself, it is decided to install the Linux subsystem under the Windows 10 system for server deployment. 1. Windows 10 system preparation and configuration The following preparations need to be made for the Windows 10 operating system before installing the Linux subsystem: 1.1. Confirm the Windows 10 version: Use the WIN+R command to call out the Run window and enter the WINVER command to view the current operating system version. The system must be a 64-bit operating system. 1.2. Enable Windows functions: Use the WIN+R command to bring up the Run window, and enter the CONTROL command to bring up the Control Panel. In the Control Panel, select Programs->Turn Windows features on or off->Windows Subsystem for Linux, confirm the installation, and restart the computer after the installation is complete. 1.3. Enable developer mode: Use the WIN+I command to bring up the Windows settings interface, select "Developer mode" in Windows Settings->Update and Security->Developer Options, confirm to enable developer mode, and wait for the installation to complete. 2.Install Linux Subsystem: Ubuntu 18.04 LTS 2.1.Install Microsoft Store software2.2.Open Microsoft Store software, enter Ubuntu in the search bar, select Ubuntu 18.04 LTS to obtain and install it for free, and pin it to the Start menu after completion. 2.3.Click in the Start menu to start Ubuntu 18.04. The first startup will display "Installing, this may take a few minutes...", wait for the installation initialization to complete. After adjusting the user and password according to the interface prompts, the Ubuntu 18.04 Linux subsystem is successfully installed. 2.4. The current Linux subsystem in Windows 10 shares hard disk resources. The C drive and D drive in "My Computer" in the Windows 10 system can be accessed under the Linux /mnt/ path. 3. Install JDK in the Linux subsystem 3.1. Download JDK software Use wget command to download the JDK software package jdk-8u202-linux-x64.tar.gz and store it in the /tmp/ directory. Download addresshttps://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 3.2. Unzip the JDK software installation package
Use the tar command to unzip the installation package: tar-zxvfjdk-8u202-linux-x64.tar.gz. After the decompression is complete, a jdk1.8.0_202 folder will be generated in the current directory. 3.3. Move the unzipped folder to the /usr/lib/directory Create a new directory: sudomkdir/usr/lib/jdk Move files: sudomv/tmp/jdk1.8.0_202/usr/lib/jdk 3.4. Configure JAVA environment variables Use the sudovim/etc/profile command to edit the profile file in the /etc/ directory (it is best to make a backup before operating this file: sudocpprofileprofile_backup), and add the following lines at the end: #set java environment
exportJAVA_HOME=/usr/lib/jdk/jdk1.8.0_202
exportJRE_HOME=${JAVA_HOME}/jre
exportCLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
[align=left ] exportPATH=${JAVA_HOME}/bin:$PATH
[size=3 ]
*Use the source/etc/profile command to execute the modification and it will take effect immediately[ /align] 3.5. Verify whether JDK is installed successfully
Enter java-version in the terminal. If the version number appears, it means the installation is successful, as shown below: java version "1.8.0_202" =3] Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-bit Server VM (build 25.202-b08, mixed mode)4. Linux subsystem installs MQTT server: Apache Apollo ] 4.1. Download Apache Apollo Software ]Use the wget command to download the Apache Apollo software package apache-apollo-1.7.1-unix-distro.tar and store it in the /tmp/ directory. Download address: http://mirrors.shu.edu.cn. cn/apache/activemq/activemq-apollo/1.7.1/[/url]
[/ size] [size= 3]4.2. Unzip the Apache Apollo software installation package ] Use the tar command to decompress the installation package: tar-zxvfapache-apollo-1.7.1-unix-distro.tar, and wait for the decompression to complete. A folder named apache-apollo-1.7.1 will be generated in the current directory.
[font =Tahoma] 4.3. Move the decompressed folder to the /home/ubuntu/ directory [/font ]
[size= 3]mv/tmp/apache-apollo-1.7.1/home/ubuntu
[ font=Tahoma]
4.4. Create a broker instance: mybroker
  • [ size=3] cd/home/ubuntu/apache-apollo-1.7.1/bin/
  • [size=3 ] ./apollo create mybroker
[ font=Tahoma] 4.5. Modify configuration[ /size]
vim/home/ubuntu/apache-apollo-1.7.1 /bin/mybroker/etc/apollo.xml
[ font=Tahoma]will
[size=3 ] http://127.0.0.1:61680”/">
[ /font]https://127.0.0.1:61681”/">
[ /font] is modified to:
[/font ] http://0.0.0.0:61680”/">
[ /font]https://0.0.0.0:61681”/">
[font =Tahoma] 4.6. Start the mybroker instance of Apache Apollo
  • cd/home/ubuntu/apache-apollo-1.7.1/bin/mybroker/bin/[/font ]
  • ./apollo-broker run
After successful startup, the following figure is shown:
[size =3]
4.7. Set the instance Start as Linux Service
sudoln-s/home/ubuntu/apache-apollo-1.7.1/bin/mybroker/bin/apollo-broker-service /etc/init.d/apollo [/ size] 4.8. Access the monitoring interface of Apache Apollo
[size=3 ] on Windows 10 Open the browser and visit: http://localhost:61680. The default username and password are: admin/password
5. Install Peanut Shell software on Windows 10 system 5.1. Install Peanut Shell
Visit[ u]https://hsk.oray.com/download/Download the Peanut Shell software and install it. After the installation is complete, open the Peanut Shell software , enter your username and password to log in.
If you do not have an account, you need to apply for one. It is recommended to purchase a domain name and intranet penetration personal version. The total cost is within RMB 10, which is much cheaper than renting a cloud server. 5.2. New Mapping /font]
Click on the intranet penetration in the Peanut PC Shell client software, and the interface will automatically jump to the web version of the intranet penetration configuration interface. [/ size]
Click Add Mapping, configure the corresponding parameters and confirm and save.
[align= Description: /align]
  • Application name: MQTT (choose one at random)
  • Choose a domain name: A domain name you purchased
  • [size=3 ] Mapping type: Application class
  • External network port: dynamic port
  • Internal Network host: IP address of the computer running Peanut Shell PC client
  • Intranet port: 61613[/ 6. Install MQTT client on Windows 10 system 6.1.Install the MQTT client Visit http://www.jensd.de/apps/mqttfx/1.7.1/ to download the MQTT client software mqttfx-1.7.1-windows-x64.exe and install the MQTT.fx software. 6.2.Configure MQTT Client
    6.2.Configure MQTT Client
    Run MQTT.FX software, click the gear configuration button, enter the Edit Connection Profiles interface, and click "+" to add a new connection. After the configuration is complete, click OK to return to the MQTT.fx operation interface.
    [/ font] Description:
    MQTT Broker Profile Settings configuration item:
    Broker Address: The domain name purchased by Peanut Shell
    Broker Port: The port number dynamically generated by Peanut Shell
    General configuration items: Configure as shown in the screenshot above
    User Credentials configuration items:
    User Name: Fixed For admin
    Password: fixed as password
    6.3. Connect to MQTT server Select the newly created MQTT connection in the drop-down list and click Connect to connect to the MQTT server. When connecting to the MQTT server, you must ensure that the Peanut Shell client software under Windows 10 is open and logged in, and the Apache Apollo MQTT server software under the Linux subsystem is running.
    6.4.Operate the MQTT client
    After the MQTT client successfully connects to the MQTT server, you can publish Topics on the Publish interface and subscribe to Topics on the Subscribe interface.
    The following figure is an example of self-transmission and self-reception.


This post is from GD32 MCU

Latest reply

Thanks for sharing   Details Published on 2021-4-25 14:58
Personal signatureWe are a team and we work as a team !
 

205

Posts

0

Resources
2
 
This post was last edited by xld0932 on 2019-5-16 16:34 If the download link of apache-apollo-1.7.1-unix-distro cannot be opened, I will upload the installation package apache-apollo-1.7.1.part1.rar (10 MB, downloads: 1) apache-apollo-1.7.1.part2.rar (10 MB, downloads: 1) apache-apollo-1.7.1.part3.rar (6.2 MB, downloads: 0)


This post is from GD32 MCU
 
Personal signatureWe are a team and we work as a team !
 
 

61

Posts

1

Resources
3
 
Thanks for sharing
This post is from GD32 MCU
 
Personal signature

intersil Techwell应用工程师

 
 

113

Posts

1

Resources
4
 
This post is from GD32 MCU
 
 
 

31

Posts

0

Resources
5
 

Great stuff, thank you, this must be topped

This post is from GD32 MCU
 
 
 

661

Posts

0

Resources
6
 

Thanks for sharing

This post is from GD32 MCU
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list