【Docker实战】华为Flexus X实例部署Solo博客,打造个性化的在线空间
前言
华为云Flexus X实例,为Solo博客插上云端翅膀,打造您的个性化在线空间!Flexus X以其强大的计算能力与灵活的资源配置,为Solo博客提供了理想的部署环境。无论是流畅的用户体验,还是个性化的页面设计,Flexus X都能完美支持。
链接直达:华为云Flexus云服务器X实例
solo博客的介绍
Solo是一款专为程序员设计的开源博客系统,也是B3log分布式社区的Java博客端节点系统。它以其简洁、美观和强大的功能而受到开发者和博主的青睐。Solo不仅支持Markdown语法撰写内容,还具备自适应前端设计和完备的后台管理功能,适合用于个人知识沉淀、项目介绍、技术分享等场景。
部署在华为云服务器Flexus X实例的优势
高性能:Flexus X实例在性能上表现出色,相较于传统云服务器,能够提供更高的计算能力和处理速度,确保Solo博客系统的稳定运行和快速响应。
智能调度:Flexus X实例具备创新柔性算力和动态画像规格优化能力,能够智能感知业务负载变化并自动调整资源配置,提高资源利用率和系统稳定性。
成本优化:通过智能动态业务画像技术,Flexus X实例在业务迁移上云方面能够综合降本30%,帮助用户降低部署成本。
灵活配置:用户可以根据自己的需求灵活调整Flexus X实例的vCPU和内存配比,以及存储和网络配置,满足Solo博客系统的不同场景需求。
接下来让我们一起走进Flexus X实例,大家属于我们自己的个性化博客平台。
环境规划
操作系统 | MySQL | openjdk | solo | 连接方式 |
---|---|---|---|---|
Huawei Cloud EulerOS 2.0 | 5.7 | 12.0.2 | 4.4.0 | 本地shell |
需要了解:
- 目标,在
华为Flexus X实例
上物理部署solo博客- 详细购买配置实例可参考文章: 快速部署华为云Flexus X实例,开启您的云端之旅
安装数据库(MySQL)
添加MySQL YUM仓库
由于操作系统中的yum源没有
MySQL
,需要到mysql的官网下载yum repo
配置文件
# 下载配置文件
[root@flexusx-251f ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
--2024-09-01 14:54:00-- https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 23.222.161.234, 2600:140b:2c00:abb::2e31, 2600:140b:2c00:aa5::2e31
Connecting to dev.mysql.com (dev.mysql.com)|23.222.161.234|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://repo.mysql.com//mysql57-community-release-el7-9.noarch.rpm [following]
--2024-09-01 14:54:01-- https://repo.mysql.com//mysql57-community-release-el7-9.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.198.121.163, 2600:1417:4400:e84::1d68, 2600:1417:4400:e8c::1d68
Connecting to repo.mysql.com (repo.mysql.com)|23.198.121.163|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9224 (9.0K) [application/x-redhat-package-manager]
Saving to: ‘mysql57-community-release-el7-9.noarch.rpm’
mysql57-community-releas 100%[================================>] 9.01K --.-KB/s in 0s
2024-09-01 14:54:02 (259 MB/s) - ‘mysql57-community-release-el7-9.noarch.rpm’ saved [9224/9224]
# 安装下载配置文件
[root@flexusx-251f ~]# rpm -ivh mysql57-community-release-el7-9.noarch.rpm
warning: mysql57-community-release-el7-9.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:mysql57-community-release-el7-9 ################################# [100%]
# 此时可以看到出现了两个关于mysql的yum源
[root@flexusx-251f ~]# ls /etc/yum.repos.d/
docker-ce.repo hce.repo mysql-community.repo mysql-community-source.repo
此时,
MySQL
的YUM仓库已经被添加成功
安装MySQL服务器
# 安装mysql
[root@flexusx-251f ~]# yum install -y mysql-community-server
Last metadata expiration check: 0:04:54 ago on Sun 01 Sep 2024 03:12:32 PM CST.
Dependencies resolved.
==================================================================================================
Package Architecture Version Repository Size
==================================================================================================
Installing:
mysql-community-server x86_64 5.7.44-1.el7 mysql57-community 184 M
Installing dependencies:
mysql-community-client x86_64 5.7.44-1.el7 mysql57-community 31 M
mysql-community-common x86_64 5.7.44-1.el7 mysql57-community 313 k
mysql-community-libs x86_64 5.7.44-1.el7 mysql57-community 3.0 M
Transaction Summary
==================================================================================================
Install 4 Packages
Total size: 219 M
Installed size: 930 M
Downloading Packages:
[SKIPPED] mysql-community-client-5.7.44-1.el7.x86_64.rpm: Already downloaded
[SKIPPED] mysql-community-common-5.7.44-1.el7.x86_64.rpm: Already downloaded
[SKIPPED] mysql-community-libs-5.7.44-1.el7.x86_64.rpm: Already downloaded
[SKIPPED] mysql-community-server-5.7.44-1.el7.x86_64.rpm: Already downloaded
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : mysql-community-common-5.7.44-1.el7.x86_64 1/4
Installing : mysql-community-libs-5.7.44-1.el7.x86_64 2/4
Running scriptlet: mysql-community-libs-5.7.44-1.el7.x86_64 2/4
Installing : mysql-community-client-5.7.44-1.el7.x86_64 3/4
Running scriptlet: mysql-community-server-5.7.44-1.el7.x86_64 4/4
Installing : mysql-community-server-5.7.44-1.el7.x86_64 4/4
Running scriptlet: mysql-community-server-5.7.44-1.el7.x86_64 4/4
/usr/lib/tmpfiles.d/mysql.conf:23: Line references path below legacy directory /var/run/, updating /var/run/mysqld → /run/mysqld; please update the tmpfiles.d/ drop-in file accordingly.
Verifying : mysql-community-client-5.7.44-1.el7.x86_64 1/4
Verifying : mysql-community-common-5.7.44-1.el7.x86_64 2/4
Verifying : mysql-community-libs-5.7.44-1.el7.x86_64 3/4
Verifying : mysql-community-server-5.7.44-1.el7.x86_64 4/4
Installed:
mysql-community-client-5.7.44-1.el7.x86_64 mysql-community-common-5.7.44-1.el7.x86_64
mysql-community-libs-5.7.44-1.el7.x86_64 mysql-community-server-5.7.44-1.el7.x86_64
Complete!
报错问题处理
- GPG密钥问题
如果限制安装MySQL 5.7客户端时,Yum发现安装包的GPG密钥与配置的密钥不匹配或者密钥丢失,导致无法验证软件包的完整性和来源。
.........................
Key import failed (code 2). Failing package is: mysql-community-client-5.7.44-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Public key for mysql-community-common-5.7.44-1.el7.x86_64.rpm is not installed. Failing package is: mysql-community-common-5.7.44-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Public key for mysql-community-libs-5.7.44-1.el7.x86_64.rpm is not installed. Failing package is: mysql-community-libs-5.7.44-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Public key for mysql-community-server-5.7.44-1.el7.x86_64.rpm is not installed. Failing package is: mysql-community-server-5.7.44-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'yum clean packages'.
Error: GPG check FAILED
# 备份原有的
[root@flexusx-251f rpm-gpg]# cp RPM-GPG-KEY-mysql RPM-GPG-KEY-mysql.bak
[root@flexusx-251f rpm-gpg]# ls
RPM-GPG-KEY-HCE-2 RPM-GPG-KEY-mysql RPM-GPG-KEY-mysql.bak
# 重新拉取
[root@flexusx-251f rpm-gpg]# sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
- 主机安装了mariadb,导致配置文件冲突
安装了mariadb,与mysql冲突,可以卸载解决
You can remove cached packages by executing 'yum clean packages'.
Error: Transaction test error:
file /etc/my.cnf from install of mysql-community-server-5.7.44-1.el7.x86_64 conflicts with file from package mariadb-config-4:10.5.22-1.hce2.x86_64
[root@flexusx-251f ~]# yum remove mariadb*
配置MySQL数据库
如果服务正在运行,你将看到类似
“active (running)”
的消息。
# 启动mysql服务并配置开机自启
[root@flexusx-251f ~]# systemctl start mysqld.service
[root@flexusx-251f ~]# systemctl enable mysqld.service
[root@flexusx-251f ~]# systemctl status mysqld.service
查看数据临时密码
[root@flexusx-251f ~]# cat /var/log/mysqld.log | grep password
2024-09-01T07:20:30.588456Z 1 [Note] A temporary password is generated for root@localhost: wBpk;8DevWSg
登录数据库(输入临时密码)
[root@flexusx-251f ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.44
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
修改数据库密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Abc123;';
Query OK, 0 rows affected (0.00 sec)
创建solo数据库
mysql> create database solo;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| solo |
| sys |
+--------------------+
5 rows in set (0.00 sec)
配置JDK
配置安全组,添加FTP端口
上传软件包
openjdk-12.0.2_linux-x64_bin.tar.gz
到实例中
[root@flexusx-251f ~]# mkdir /java
[root@flexusx-251f ~]# cd /java/
[root@flexusx-251f java]# ls
openjdk-12.0.2_linux-x64_bin.tar.gz
解压软件包
[root@flexusx-251f java]# tar -zxvf openjdk-12.0.2_linux-x64_bin.tar.gz
添加java环境变量,在文件最后添加
[root@flexusx-251f ~]# vim /etc/profile
[root@flexusx-251f ~]# cat /etc/profile
..........
export JAVA_HOME=/java/jdk-12.0.2
export PATH=$JAVA_HOME/bin:$PATH
# 加载配置文件
[root@flexusx-251f ~]# source /etc/profile
查看java版本
[root@flexusx-251f ~]# java -version
openjdk version "12.0.2" 2019-07-16
OpenJDK Runtime Environment (build 12.0.2+10)
OpenJDK 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
配置solo博客
上传
solo-v4.4.0.zip
到本实例中
[root@flexusx-251f ~]# mkdir /solo
[root@flexusx-251f ~]# cd /solo/
[root@flexusx-251f solo]# ls
solo-v4.4.0.zip
解压软件包
[root@flexusx-251f solo]# unzip solo-v4.4.0.zip
[root@flexusx-251f solo]# ls
admin images lib META-INF robots.txt static-site
CHANGE_LOGS.md js local.properties opensearch.xml scss sw.js
common-template lang_en_US.properties log4j2.xml org skins
dist lang_zh_CN.properties manifest.json.tpl plugins solo-v4.4.0.zip
error latke.properties markdowns repository.json static-resources.xml
修改数据库密码和地址
[root@flexusx-251f solo]# vim local.properties
.............
#### MySQL runtime ####
runtimeDatabase=MYSQL
jdbc.username=root
jdbc.password=abc123;
...........
配置安全组,solo默认使用
8080
端口
运行solo博客
# 检查防火墙是否关闭
[root@flexusx-251f ~]# systemctl status firewalld.service
[root@flexusx-251f ~]# systemctl stop firewalld.service
[root@flexusx-251f solo]# java -cp "lib/*:." org.b3log.solo.Server
[INFO ]-[2024-09-01 15:54:30]-[org.b3log.solo.Server:259]: Solo is booting [ver=4.4.0, os=Linux, isDocker=false, inJar=false, luteAvailable=false, pid=298359, runtimeDatabase=MYSQL, runtimeMode=PRODUCTION, jdbc.username=root, jdbc.URL=jdbc:mysql://localhost:3306/solo?useUnicode=yes&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true]
[INFO ]-[2024-09-01 15:54:30]-[org.b3log.solo.service.InitService:177]: It's your first time setup Solo, initialize tables in database [MYSQL]
[WARN ]-[2024-09-01 15:54:30]-[org.b3log.solo.service.InitService:150]: Solo has not been initialized, please open your browser to init Solo
# 启动成功
因为是第一次启动所以需要初始化
- 直接通过主机地址加端口号即可访问
- 我们在浏览器输入http://主机地址:8080
- 如果有账号,可以直接进行登录
进行初始化,可以使用手机号注册账号,进行登录(注册过程不进行演示)
注册成功后,可根据引导上传必要信息(也可直接下一步,全部选择默认)
注册配置完成
再次在浏览器输入网址:
http://主机地址:8080
行文至此,solo博客被成功搭建,可以开始打造属于自己的个性化在线空间啦!
体验和感受
Solo
博客,作为一款轻量级、易上手的博客系统,以其简洁的界面、强大的功能和良好的扩展性,赢得了众多博客爱好者的青睐。与Flexus X实例
的完美结合,不仅让Solo
博客的部署变得简单快捷,还确保了博客的稳定运行和高效访问。
在Flexus X实例的强大支撑下,您可以轻松打造属于自己的个性化在线空间。无论是选择独特的主题模板,还是自定义博客的布局和样式,都能让您的博客在众多网站中脱颖而出。同时,Flexus X实例还提供了丰富的资源调度和安全防护功能,确保您的博客数据安全无忧。
- 点赞
- 收藏
- 关注作者
评论(0)