Kylin OS
In this guide, you will deploy MyEMS on a Kylin V11 server.
Prerequisites
This guide describes how to install MyEMS on Kylin V11. Hardware requirements depend on the chosen database and the number of devices connected to the system. To run MyEMS and MySQL on a single machine, you need at least 8GB of RAM.
Update the system and install tools:
sudo yum update
sudo yum install git
systemctl stop firewalld
Clone the source code:
cd ~
git clone https://gitee.com/myems/myems
Step 1 Database
See Database
Step 2 myems-api
- Install the myems-api service:
sudo cp -r ~/myems/myems-api /myems-api
cd /myems-api
sudo pip install -r requirements.txt
Create the .env file based on example.env and edit it as needed:
sudo cp /myems-api/example.env /myems-api/.env
sudo nano /myems-api/.env
Add the port to the firewall:
sudo firewall-cmd --zone=public --add-port=8000/tcp --permanent
sudo firewall-cmd --reload
Install the systemd configuration files:
sudo cp /myems-api/myems-api.service /lib/systemd/system/
sudo cp /myems-api/myems-api.socket /lib/systemd/system/
sudo cp /myems-api/myems-api.conf /usr/lib/tmpfiles.d/
Next, enable the services so they start automatically on boot:
sudo systemctl enable myems-api.socket
sudo systemctl enable myems-api.service
Start the services:
sudo systemctl start myems-api.socket
sudo systemctl start myems-api.service
Step 3 myems-admin
- Install the NGINX server
See http://nginx.org/en/linux_packages.html#RHEL
Enable the nginx service:
yum install -y nginx
sudo systemctl start nginx.service
- Configure NGINX
sudo vi /etc/nginx/nginx.conf
In the 'http' section, add some directives:
http {
client_header_timeout 600;
client_max_body_size 512M;
gzip on;
gzip_min_length 512;
gzip_proxied any;
gzip_types *;
gzip_vary on;
proxy_buffering off;
...
}
Create a new file under /etc/nginx/conf.d/:
sudo vi /etc/nginx/conf.d/myems-admin.conf
Write the following directives. If the myems-api service runs on another server, replace the default myems-api address http://127.0.0.1:8000/ with the actual address.
server {
listen 8001;
server_name myems-admin;
location / {
root /var/www/myems-admin;
index index.html index.htm;
}
## To avoid CORS issue, use Nginx to proxy myems-api to path /api
## Add another location /api in 'server'
## Replace the default myems-api url http://127.0.0.1:8000/ with actual url if the myems-api servcie hosted on different server
location /api {
proxy_pass http://127.0.0.1:8000/;
proxy_connect_timeout 75;
proxy_read_timeout 600;
send_timeout 600;
}
}
- Install myems-admin: If the server cannot connect to the internet, compress the myems/myems-admin folder, upload it to the server, then extract it to ~/myems/myems-admin
sudo mkdir /var/www
sudo cp -r ~/myems/myems-admin /var/www/myems-admin
sudo chmod 0755 -R /var/www/myems-admin
Check the configuration file and make changes if necessary:
sudo nano /var/www/myems-admin/app/api.js
Warning
The 'upload' folder is for user-uploaded files. Do not delete/move/overwrite the 'upload' folder when upgrading myems-admin.
/var/www/myems-admin/upload
Add the port to the firewall:
sudo semanage port -a -t http_port_t -p tcp 8001
sudo firewall-cmd --zone=public --add-port=8001/tcp --permanent
sudo firewall-cmd --reload
Restart the nginx service:
sudo systemctl restart nginx.service
Tip
If you encounter a '403 Forbidden' nginx error, you can fix it by changing the SELinux mode using the command 'sudo setforce 0'.
Step 4 myems-modbus-tcp
In this step, you will install the myems-modbus-tcp service.
sudo cp -r ~/myems/myems-modbus-tcp /myems-modbus-tcp
cd /myems-modbus-tcp
sudo pip install -r requirements.txt
Copy the example.env file to .env and modify the .env file:
sudo cp /myems-modbus-tcp/example.env /myems-modbus-tcp/.env
sudo nano /myems-modbus-tcp/.env
Install the systemd service:
sudo cp myems-modbus-tcp.service /lib/systemd/system/
Enable the service:
sudo systemctl enable myems-modbus-tcp.service
Start the service:
sudo systemctl start myems-modbus-tcp.service
Monitor the service:
sudo systemctl status myems-modbus-tcp.service
View the log:
cat /myems-modbus-tcp.log
Step 5 myems-cleaning
In this step, you will install the myems-cleaning service.
sudo cp -r ~/myems/myems-cleaning /myems-cleaning
cd /myems-cleaning
sudo pip install -r requirements.txt
Copy the example.env file to .env and modify the .env file:
sudo cp /myems-cleaning/example.env /myems-cleaning/.env
sudo nano /myems-cleaning/.env
Install the systemd service:
sudo cp /myems-cleaning/myems-cleaning.service /lib/systemd/system/
Enable the service:
sudo systemctl enable myems-cleaning.service
Start the service:
sudo systemctl start myems-cleaning.service
Monitor the service:
sudo systemctl status myems-cleaning.service
View the log:
cat /myems-cleaning.log
Step 6 myems-normalization
In this step, you will install the myems-normalization service.
sudo cp -r ~/myems/myems-normalization /myems-normalization
cd /myems-normalization
sudo pip install -r requirements.txt
Copy the example.env file to .env and modify the .env file:
sudo cp /myems-normalization/example.env /myems-normalization/.env
sudo nano /myems-normalization/.env
Install the systemd service
sudo cp /myems-normalization/myems-normalization.service /lib/systemd/system/
Enable the service:
sudo systemctl enable myems-normalization.service
Start the service:
sudo systemctl start myems-normalization.service
Monitor the service:
sudo systemctl status myems-normalization.service
View the log:
cat /myems-normalization.log
Step 7 myems-aggregation
In this step, you will install the myems-aggregation service.
sudo cp -r ~/myems/myems-aggregation /myems-aggregation
cd /myems-aggregation
sudo pip install -r requirements.txt
Copy the example.env file to .env and modify the .env file:
sudo cp /myems-aggregation/example.env /myems-aggregation/.env
sudo nano /myems-aggregation/.env
Install the systemd service
sudo cp /myems-aggregation/myems-aggregation.service /lib/systemd/system/
Enable the service:
sudo systemctl enable myems-aggregation.service
Start the service:
sudo systemctl start myems-aggregation.service
Monitor the service:
sudo systemctl status myems-aggregation.service
View the log:
cat /myems-aggregation.log
Step 8 myems-web
In this step, you will install the myems-web service.
- Install NGINX server. See http://nginx.org/en/linux_packages.html#Debian
- Configure NGINX. Remove the default file
sudo rm /etc/nginx/sites-enabled/default
sudo rm /etc/nginx/conf.d/default.conf
Add a new file under /etc/nginx/conf.d/:
sudo nano /etc/nginx/conf.d/myems-web.conf
Write the following directives. If the myems-api service is hosted on a different server, replace the default myems-api address http://127.0.0.1:8000/ with the actual address.
server {
listen 80;
server_name myems-web;
location / {
root /var/www/myems-web;
index index.html index.htm;
# add try_files directive to avoid 404 error while refreshing pages
try_files $uri /index.html;
}
## To avoid CORS issue, use Nginx to proxy myems-api to path /api
## Add another location /api in 'server'
## replace the default myems-api url http://127.0.0.1:8000/ with actual url if the myems-api servcie hosted on different server
location /api {
proxy_pass http://127.0.0.1:8000/;
proxy_connect_timeout 75;
proxy_read_timeout 600;
send_timeout 600;
}
}
- Install MyEMS Web UI:
Edit the configuration file:
Note
Get a mapboxToken from https://mapbox.com then set showOnlineMap to true. If you want to turn off the online map function, set showOnlineMap to false.
cd ~/myems/myems-web
sudo nano src/config.js
Build:
sudo npm i --unsafe-perm=true --allow-root --legacy-peer-deps
sudo npm run build
Install: Note that the path below should match the path configured in nginx.conf.
sudo rm -r /var/www/myems-web
sudo mv build /var/www/myems-web
Add the port to the firewall:
sudo semanage port -a -t http_port_t -p tcp 80
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --reload
Restart NGINX
sudo systemctl restart nginx
Tip
If you encounter a '500 Internal Server Error' nginx error, you can fix it by changing the SELinux mode using the command 'sudo setforce 0'.
After Installation
Congratulations! You can now log in to the MyEMS Admin UI and Web UI.
Default Ports
MyEMS Web UI: 80 MyEMS API: 8000 MyEMS Admin UI: 8001
Assume the server address is 192.168.1.8 (replace with your real server address) MyEMS Web UI address: http://192.168.1.8 (port 80 can be omitted) MyEMS Admin UI address: http://192.168.1.8:8001
Default Passwords
MyEMS Admin UI Username:
administrator
Password:
!MyEMS1
MyEMS Web UI Username:
administrator
Password:
!MyEMS1
Troubleshooting
MySQL 8.0 Installation
1. Preparation
Check the system environment
# Check system version
cat /etc/redhat-release
# Check if MySQL is already installed
rpm -qa | grep mysql
rpm -qa | grep mariadb
# Uninstall mariadb if it exists
rpm -e --nodeps mariadb-libs-*
2. Download the official MySQL rpm bundle
https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.45-1.el8.x86_64.rpm-bundle.tar
3. Install MySQL 8.0
tar -xvf *.tar
yum localinstall *.rpm
# If you encounter GPG key issues, use this temporarily
yum install -y mysql-community-server --nogpgcheck
4. Start MySQL Service
# Start MySQL
systemctl start mysqld
# Enable auto-start on boot
systemctl enable mysqld
# Check service status
systemctl status mysqld
5. Get the Initial Password
# Check the temporary password generated by MySQL
grep 'temporary password' /var/log/mysqld.log
6. Secure Configuration
# Run the secure installation script
mysql_secure_installation
Follow the prompts:
- Enter the temporary password
- Set a new password (must include uppercase, lowercase, numbers, and special characters)
- Change the root password? Y
- Remove anonymous users? Y
- Disallow root login remotely? Choose as needed
- Remove test database? Y
- Reload privilege tables? Y
7. Log in and Verify MySQL
# Log in to MySQL
mysql -u root -p
# Check version
SELECT VERSION();
# List databases
SHOW DATABASES;
8. Configure Character Set (Optional)
Edit the configuration file:
vi /etc/my.cnf
Add the following:
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
# Lower password policy if needed
validate_password.policy = LOW
validate_password.length = 6
validate_password.mixed_case_count = 0
validate_password.number_count = 0
validate_password.special_char_count = 0
Restart the service:
systemctl restart mysqld
9. Firewall Settings
# Open port 3306
firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --reload
# Or stop firewall (not recommended)
# systemctl stop firewalld
10. Remote Access Configuration (Optional)
-- Log in to MySQL
mysql -u root -p
-- Create remote access user
CREATE USER 'root'@'%' IDENTIFIED BY '!MyEMS1';
-- Update password
ALTER USER 'root'@'%' IDENTIFIED BY '!MyEMS1';
-- Grant privileges
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
-- Apply changes
FLUSH PRIVILEGES;
Common Issues
1. Insufficient Memory Error
If the server has low memory, limit MySQL memory usage:
vi /etc/my.cnf
# Add these settings
innodb_buffer_pool_size = 256M
innodb_log_buffer_size = 16M
max_connections = 100
2. Startup Failure Troubleshooting
# View error log
tail -f /var/log/mysqld.log
# Check port usage
netstat -tlnp | grep 3306
3. Password Policy Modification
-- View current password policy
SHOW VARIABLES LIKE 'validate_password%';
-- Lower policy (if simple password is needed)
SET GLOBAL validate_password.policy = LOW;
SET GLOBAL validate_password.length = 6;
Verify Installation
# Check MySQL process
ps aux | grep mysql
# Check port
netstat -tlnp | grep 3306
# Check MySQL version
mysql --version