更新系统
[root@hcss-ecs-e943 ~]# sudo yum update -y
Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - AppStream 34 B/s | 38 B 00:01
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
如果出错了,修改repos,否则跳过
[root@hcss-ecs-e943 ~]# cd /etc/yum.repos.d/
[root@hcss-ecs-e943 yum.repos.d]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
[root@hcss-ecs-e943 yum.repos.d]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
[root@hcss-ecs-e943 yum.repos.d]# yum makecache
Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - AppStream 5.1 MB/s | 8.4 MB 00:01
CentOS Linux 8 - BaseOS 3.2 MB/s | 4.6 MB 00:01
CentOS Linux 8 - Extras 14 kB/s | 10 kB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 36 kB/s | 14 MB 06:27
Extra Packages for Enterprise Linux Modular 8 - x86_64 25 kB/s | 733 kB 00:29
Metadata cache created.
[root@hcss-ecs-e943 yum.repos.d]# client_loop: send disconnect: Broken pipe
安装nodejs v16
[root@hcss-ecs-e943 ~]# dnf module list nodejs
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:27:03 ago on Thu Jun 13 10:54:10 2024.
CentOS Linux 8 - AppStream
Name Stream Profiles Summary
nodejs 10 [d] common [d], development, minimal, s2i Javascript runtime
nodejs 12 common [d], development, minimal, s2i Javascript runtime
nodejs 14 common [d], development, minimal, s2i Javascript runtime
nodejs 16 common [d], development, minimal, s2i Javascript runtime
Extra Packages for Enterprise Linux Modular 8 - x86_64
Name Stream Profiles Summary
nodejs 13 default, development, minimal Javascript runtime
nodejs 16-epel default, development, minimal Javascript runtime
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
[root@hcss-ecs-e943 ~]# dnf module install -y nodejs:16
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:28:21 ago on Thu Jun 13 10:54:10 2024.
Dependencies resolved.
=============================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================
Installing group/module packages:
nodejs x86_64 1:16.13.1-3.module_el8.5.0+1059+1852da12 appstream 12 M
npm x86_64 1:8.1.2-1.16.13.1.3.module_el8.5.0+1059+1852da12 appstream 1.9 M
Installing weak dependencies:
nodejs-docs noarch 1:16.13.1-3.module_el8.5.0+1059+1852da12 appstream 8.7 M
nodejs-full-i18n x86_64 1:16.13.1-3.module_el8.5.0+1059+1852da12 appstream 7.6 M
Installing module profiles:
nodejs/common
Enabling module streams:
nodejs 16
Transaction Summary
=============================================================================================================================
Install 4 Packages
Total download size: 30 M
Installed size: 144 M
Downloading Packages:
(1/4): nodejs-full-i18n-16.13.1-3.module_el8.5.0+1059+1852da12.x86_64.rpm 3.2 MB/s | 7.6 MB 00:02
(2/4): nodejs-docs-16.13.1-3.module_el8.5.0+1059+1852da12.noarch.rpm 3.6 MB/s | 8.7 MB 00:02
(3/4): nodejs-16.13.1-3.module_el8.5.0+1059+1852da12.x86_64.rpm 4.8 MB/s | 12 MB 00:02
(4/4): npm-8.1.2-1.16.13.1.3.module_el8.5.0+1059+1852da12.x86_64.rpm 5.4 MB/s | 1.9 MB 00:00
-----------------------------------------------------------------------------------------------------------------------------
Total 11 MB/s | 30 MB 00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Running scriptlet: npm-1:8.1.2-1.16.13.1.3.module_el8.5.0+1059+1852da12.x86_64 1/1
Preparing : 1/1
Installing : nodejs-docs-1:16.13.1-3.module_el8.5.0+1059+1852da12.noarch 1/4
Installing : nodejs-full-i18n-1:16.13.1-3.module_el8.5.0+1059+1852da12.x86_64 2/4
Installing : npm-1:8.1.2-1.16.13.1.3.module_el8.5.0+1059+1852da12.x86_64 3/4
Installing : nodejs-1:16.13.1-3.module_el8.5.0+1059+1852da12.x86_64 4/4
Running scriptlet: nodejs-1:16.13.1-3.module_el8.5.0+1059+1852da12.x86_64 4/4
Verifying : nodejs-1:16.13.1-3.module_el8.5.0+1059+1852da12.x86_64 1/4
Verifying : nodejs-docs-1:16.13.1-3.module_el8.5.0+1059+1852da12.noarch 2/4
Verifying : nodejs-full-i18n-1:16.13.1-3.module_el8.5.0+1059+1852da12.x86_64 3/4
Verifying : npm-1:8.1.2-1.16.13.1.3.module_el8.5.0+1059+1852da12.x86_64 4/4
Installed:
nodejs-1:16.13.1-3.module_el8.5.0+1059+1852da12.x86_64
nodejs-docs-1:16.13.1-3.module_el8.5.0+1059+1852da12.noarch
nodejs-full-i18n-1:16.13.1-3.module_el8.5.0+1059+1852da12.x86_64
npm-1:8.1.2-1.16.13.1.3.module_el8.5.0+1059+1852da12.x86_64
Complete!
[root@hcss-ecs-e943 ~]# node -v
v16.13.1
[root@hcss-ecs-e943 ~]# npm -v
8.1.2
安装PM2
[root@hcss-ecs-e943 ~]# npm install pm2 -g
added 138 packages, and audited 139 packages in 13s
13 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
npm notice
npm notice New major version of npm available! 8.1.2 -> 10.8.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.1
npm notice Run npm install -g npm@10.8.1 to update!
npm notice
[root@hcss-ecs-e943 ~]# pm2 --version
-------------
__/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
_\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
_\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
_\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
_\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
_\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
_\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
_\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
_\///______________\///______________\///__\///////////////__
Runtime Edition
PM2 is a Production Process Manager for Node.js applications
with a built-in Load Balancer.
Start and Daemonize any application:
$ pm2 start app.js
Load Balance 4 instances of api.js:
$ pm2 start api.js -i 4
Monitor in production:
$ pm2 monitor
Make pm2 auto-boot at server restart:
$ pm2 startup
To go further checkout:
http://pm2.io/
-------------
[PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
[PM2] PM2 Successfully daemonized
5.4.0
下载rustdesk server
[root@hcss-ecs-e943 ~]# wget https://github.com/rustdesk/rustdesk-server/releases/download/1.1.11-1/rustdesk-server-linux-amd64.zip
--2024-06-13 11:25:27-- https://github.com/rustdesk/rustdesk-server/releases/download/1.1.11-1/rustdesk-server-linux-amd64.zip
Resolving github.com (github.com)... 20.205.243.166
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/299354666/0285ef87-85f9-441e-b8b8-8efc8c4f977b?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240613T032528Z&X-Amz-Expires=300&X-Amz-Signature=eb29659f30ddbcee7021d446e1a294d072065cff6dd793adf3d3b70771b8ad04&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=299354666&response-content-disposition=attachment%3B%20filename%3Drustdesk-server-linux-amd64.zip&response-content-type=application%2Foctet-stream [following]
--2024-06-13 11:25:28-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/299354666/0285ef87-85f9-441e-b8b8-8efc8c4f977b?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240613T032528Z&X-Amz-Expires=300&X-Amz-Signature=eb29659f30ddbcee7021d446e1a294d072065cff6dd793adf3d3b70771b8ad04&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=299354666&response-content-disposition=attachment%3B%20filename%3Drustdesk-server-linux-amd64.zip&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.110.133, 185.199.109.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8539403 (8.1M) [application/octet-stream]
Saving to: 'rustdesk-server-linux-amd64.zip'
rustdesk-server-linux-amd64.zip 100%[====================================================>] 8.14M 17.8KB/s in 12m 3s
2024-06-13 11:37:32 (11.5 KB/s) - 'rustdesk-server-linux-amd64.zip' saved [8539403/8539403]
[root@hcss-ecs-e943 ~]# ll
total 8344
-rw-r--r-- 1 root root 8539403 May 24 18:49 rustdesk-server-linux-amd64.zip
解压rustdesk server
[root@hcss-ecs-e943 ~]# unzip rustdesk-server-linux-amd64.zip
Archive: rustdesk-server-linux-amd64.zip
inflating: amd64/hbbr
inflating: amd64/hbbs
inflating: amd64/rustdesk-utils
[root@hcss-ecs-e943 ~]# ll
total 8348
drwxr-xr-x 2 root root 4096 Jun 13 11:38 amd64
-rw-r--r-- 1 root root 8539403 May 24 18:49 rustdesk-server-linux-amd64.zip
[root@hcss-ecs-e943 ~]# cd amd64/
[root@hcss-ecs-e943 amd64]# ll
total 27596
-rwxr-xr-x 1 root root 9165824 May 24 18:49 hbbr
-rwxr-xr-x 1 root root 14353352 May 24 18:49 hbbs
-rwxr-xr-x 1 root root 4734896 May 24 18:49 rustdesk-utils
安装rustdesk server
[root@hcss-ecs-e943 amd64]# pm2 start hbbs -- -k _
[PM2] Starting /root/amd64/hbbs in fork_mode (1 instance)
[PM2] Done.
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name │ mode │ ↺ │ status │ cpu │ memory │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 0 │ hbbs │ fork │ 0 │ online │ 0% │ 2.8mb │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
[root@hcss-ecs-e943 amd64]# pm2 start hbbr -- -k _
[PM2] Starting /root/amd64/hbbr in fork_mode (1 instance)
[PM2] Done.
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name │ mode │ ↺ │ status │ cpu │ memory │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 1 │ hbbr │ fork │ 0 │ online │ 0% │ 692.0kb │
│ 0 │ hbbs │ fork │ 0 │ online │ 0% │ 4.2mb │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
[root@hcss-ecs-e943 amd64]# pm2 save
[PM2] Saving current process list...
[PM2] Successfully saved in /root/.pm2/dump.pm2
[root@hcss-ecs-e943 amd64]# pm2 startup
[PM2] Init System found: systemd
Platform systemd
Template
[Unit]
Description=PM2 process manager
Documentation=https://pm2.keymetrics.io/
After=network.target
[Service]
Type=forking
User=root
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
Environment=PM2_HOME=/root/.pm2
PIDFile=/root/.pm2/pm2.pid
Restart=on-failure
ExecStart=/usr/local/lib/node_modules/pm2/bin/pm2 resurrect
ExecReload=/usr/local/lib/node_modules/pm2/bin/pm2 reload all
ExecStop=/usr/local/lib/node_modules/pm2/bin/pm2 kill
[Install]
WantedBy=multi-user.target
Target path
/etc/systemd/system/pm2-root.service
Command list
[ 'systemctl enable pm2-root' ]
[PM2] Writing init configuration in /etc/systemd/system/pm2-root.service
[PM2] Making script booting at startup...
[PM2] [-] Executing: systemctl enable pm2-root...
Created symlink /etc/systemd/system/multi-user.target.wants/pm2-root.service → /etc/systemd/system/pm2-root.service.
[PM2] [v] Command successfully executed.
+---------------------------------------+
[PM2] Freeze a process list on reboot via:
$ pm2 save
[PM2] Remove init script via:
$ pm2 unstartup systemd
查看是否安装成功
[root@hcss-ecs-e943 amd64]# pm2 list
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name │ mode │ ↺ │ status │ cpu │ memory │
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
│ 1 │ hbbr │ fork │ 0 │ online │ 0% │ 692.0kb │
│ 0 │ hbbs │ fork │ 0 │ online │ 0% │ 4.2mb │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
启动 firewalld
服务:
确保
firewalld
服务开机自启动
[root@hcss-ecs-e943 amd64]# systemctl start firewalld
[root@hcss-ecs-e943 amd64]# systemctl enable firewalld
Created symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service → /usr/lib/systemd/system/firewalld.service.
Created symlink /etc/systemd/system/multi-user.target.wants/firewalld.service → /usr/lib/systemd/system/firewalld.service.
设置防火墙
[root@hcss-ecs-e943 amd64]# firewall-cmd --zone=public --add-port=21115/tcp --permanent
success
[root@hcss-ecs-e943 amd64]# firewall-cmd --zone=public --add-port=21116/tcp --permanent
success
[root@hcss-ecs-e943 amd64]# firewall-cmd --zone=public --add-port=21117/tcp --permanent
success
[root@hcss-ecs-e943 amd64]# firewall-cmd --zone=public --add-port=21118/tcp --permanent
success
[root@hcss-ecs-e943 amd64]# firewall-cmd --zone=public --add-port=21119/tcp --permanent
success
[root@hcss-ecs-e943 amd64]# firewall-cmd --zone=public --add-port=21116/udp --permanent
success
[root@hcss-ecs-e943 amd64]# firewall-cmd --reload
success
[root@hcss-ecs-e943 amd64]# firewall-cmd --query-port=21115/tcp
yes
[root@hcss-ecs-e943 amd64]# firewall-cmd --query-port=21116/tcp
yes
[root@hcss-ecs-e943 amd64]# firewall-cmd --query-port=21117/tcp
yes
[root@hcss-ecs-e943 amd64]# firewall-cmd --query-port=21118/tcp
yes
[root@hcss-ecs-e943 amd64]# firewall-cmd --query-port=21119/tcp
yes
[root@hcss-ecs-e943 amd64]# firewall-cmd --query-port=21116/udp
yes
获取密钥
[root@hcss-ecs-e943 amd64]# ll
total 27684
-rw-r--r-- 1 root root 4096 Jun 13 11:39 db_v2.sqlite3
-rw-r--r-- 1 root root 32768 Jun 13 11:39 db_v2.sqlite3-shm
-rw-r--r-- 1 root root 41232 Jun 13 11:39 db_v2.sqlite3-wal
-rwxr-xr-x 1 root root 9165824 May 24 18:49 hbbr
-rwxr-xr-x 1 root root 14353352 May 24 18:49 hbbs
-rw-r--r-- 1 root root 88 Jun 13 11:39 id_ed25519
-rw-r--r-- 1 root root 44 Jun 13 11:39 id_ed25519.pub
-rwxr-xr-x 1 root root 4734896 May 24 18:49 rustdesk-utils
[root@hcss-ecs-e943 amd64]# cat id_ed25519.pub
5555mxYN9WYw00000000OMn7+42ITkRGl8FK3MUGtd0=