Run the backend service
1. Create the database
Create the fastbee database. Use the utf8 or utf8mb4 character set, then import the SQL script:
springboot/sql/fastbee.sqlTips
When installing MySQL on Linux, configure case-insensitive table names. Add lower_case_table_names=1 to /etc/my.cnf, then restart MySQL.
2. Open the project
Open the springboot directory with IntelliJ IDEA. Maven dependencies will be installed automatically. The installation speed depends on the network.
3. Modify the main configuration file
File path:
springboot/fastbee-admin/src/main/resources/application.ymlRefer to the comments in the file for detailed configuration.
fastbee:
name: fastbee # Application name.
profile: /uploadPath # Upload path. End with uploadPath, for example D:/uploadPath on Windows or /uploadPath on Linux.
addressEnabled: true # Enable IP address lookup.
captchaType: math # Captcha type. math = arithmetic captcha, char = character captcha.
server:
port: 8080 # HTTP port. Default is 8080.
servlet:
context-path: / # Application access path.
tomcat:
uri-encoding: UTF-8 # Tomcat URI encoding.
accept-count: 1000 # Queue size after all connections are used. Default is 100.
threads:
max: 800 # Maximum Tomcat threads. Default is 200.
min-spare: 100 # Initial Tomcat spare threads. Default is 10.
broker:
enabled: false # MQTT broker type. true = built-in Netty MQTT broker and WebSocket; false = EMQX broker.
broker-node: node1 # Broker cluster node.
port: 1883
openws: false # Enable WebSocket.
websocket-port: 8083
websocket-path: /mqtt
keep-alive: 70 # Default keep-alive upload time for all clients.
tcp:
enabled: true # Enable TCP service port.
port: 8888
keep-alive: 70
delimiter: 0x7e
spring:
profiles:
active: prod # Environment. dev = development, prod = production.Tips
YAML indentation must be aligned. Pay special attention to:
- File upload path. Windows and Linux use different path formats.
- MQTT broker selection. The backend can use the built-in Netty MQTT service or EMQX.
- Environment profile. Development and production use different sub-configuration files.
produsesapplication-prod.yml.
4. Modify the environment configuration file
File path for the development environment:
springboot/fastbee-admin/src/main/resources/application-dev.ymlFor production, use application-prod.yml.
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
master:
url: jdbc:mysql://localhost:3306/fastbee?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: fastbee
password: fastbee
tdengine-server:
enabled: false
driverClassName: com.taosdata.jdbc.TSDBDriver
url: jdbc:TAOS://fastbee:6030/fastbee_log?timezone=UTC-8&charset=utf-8
username: root
password: taosdata
dbName: fastbee_log
redis:
host: localhost
port: 6379
database: 0
password: fastbee
timeout: 10s
lettuce:
pool:
min-idle: 0
max-idle: 8
max-active: 8
max-wait: -1ms
mqtt:
username: fastbee
password: fastbee
host-url: tcp://localhost:1883
client-id: ${random.int}
default-topic: test
timeout: 30
keepalive: 30
clearSession: trueTips
Check the following items carefully:
- MySQL, TDengine, Redis, and MQTT addresses, accounts, and passwords.
- TDengine must be installed and configured correctly. Server, client, and driver versions should be compatible.
- The MQTT address should point to the backend broker or EMQX according to the main configuration.
5. Modify log configuration
Log path configuration file:
springboot/fastbee-admin/src/main/resources/logback.xmlExample:
<!-- Windows example: D:/logs. Linux example: /var/data/java/logs. -->
<property name="log.path" value="/var/data/java/logs" />6. Run the project
Run FastBeeApplication.java. The following output means the backend has started successfully.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* _⚲_⚲_ ______ _ ____ *
* | / \ | | ____| | | | _ \ *
* | | | ● | | | | |__ __ _ ___| |_ | |_) | ___ ___ *
* | \ / | | __/ _` / __| __| | _ < / _ \/ _ \ *
* \ / | | | (_| \__ \ |_ | |_) | __/ __/ *
* V |_| \__,_|___/\__| |____/ \___|\___| *
* *
* * * * * * * * * * * * FastBee IoT Platform [Started] * * * * * * * *