Taking the Port Energy Management System Microservice Project as an Example
Commonly Used Services
Service Name | Purpose | Mandatory |
---|---|---|
nacos | Service Registration and Discovery, Unified Configuration Center | Yes |
rabbitmq | Message Middleware | No |
xxl-job-admin | Distributed Timing Task | Yes |
sentinel | Sentinel Monitoring | No |
gateway | Gateway Microservice, Unified Data Entry | Yes |
system | Jeecg System Service, Provides Login, System Configuration, etc. | Yes |
demo | Business Code Microservice, Implements Main Business Functions | Yes |
zncb | Smart Meter Reading Microservice, Interfaces with Hardware Devices | Yes |
1. Install Baota Panel
Official Download and Installation Address: https://www.bt.cn/new/download.html
2. Create Databases
2.1 Create Nacos Database
- Add database, select Mysql database, configure database name.
- Import data SQL after addition, as shown in the attachment tables_nacos.sql.
2.2 Create XXL-JOB Database
- Add database, select Mysql database, configure database name.
- Import data SQL after addition, as shown in the attachment tables_xxl_job.sql.
2.3 Create Jeecg System Database
- Add database, select Mysql database, configure database name.
- Import data SQL after addition, as shown in the attachment ydb-wei-jeecg_2024-08-08_01-30-02_mysql_data.sql.gz.
2.4 Create MongoDB Database
- Install MongoDB on Baota and add a database.
- MongoDB is used to conveniently handle massive data (up to 25,000 data processing per second) and store data sent from hardware devices.
2.5 Create InfluxDB Time-Series Database
- InfluxDB focuses only on new data, not modifying or deleting data, enabling massive data insertion and querying, with millisecond-level response for billion-level data queries.
- Official Documentation: Install InfluxDB | InfluxDB OSS 2.7 Documentation (influxdata.com)
- Create a bucket after installation.
2.6 Create Redis Cache
- Install Redis directly from the software management in the Baota panel, set port and password.
3. Modify Project Configuration
After setting up the environment, modify the project configuration. Most configurations in microservice projects are done in Nacos.
3.1 Nacos Configuration
- Focus on the database connected by Nacos and configure the relevant database settings.
3.2 Package Nacos
- Modify and package the project. Other configurations need to be done in Nacos.
3.3 Deploy Nacos
- Add a Java project in the Baota panel, select Springboot type.
3.4 Nacos Operations
- Access Nacos via browser after deployment.
- Default Username and Password: nacos
3.4.1 Create Namespace
- Namespaces are concepts for separating and isolating different environments, like test and production.
3.4.2 Configure Namespace and Registration Address
- Modify the core POM file to change the namespace and registration address according to the environment.
3.5 XXL-JOB Configuration
- Focus on the data source and accessToken for distributed timing tasks.
3.6 Microservice Configuration
- Configure each microservice in Nacos for unified management.
4. Deploy Backend Projects
After completing the above configurations, deploy the projects by packaging and uploading them to the Baota panel.
4.1 Gateway Microservice Deployment
4.2 Timing Task Service Deployment
4.3 Jeecg System Microservice Deployment
4.4 Sentinel Monitoring Microservice Deployment
4.5 Smart Meter Reading Microservice Deployment
4.6 Business System Microservice Deployment
5. Deploy Frontend Project
Modify the frontend configuration, package, compile, and upload to the server.
5.1 Project Packaging
- Modify the .env.test file (or .env.prod for production) to configure the backend gateway URL.
5.2 Configure Project
- Upload the dist folder to the FTP and configure the HTML project in the Baota panel.
6. Advanced Deployment
Use Jenkins for one-click deployment to automate code pulling, compiling, uploading, and restarting projects.
Documentation: Jenkins Usage