swupdate+hawkbit部署以及测试 二
hawkbit部署以及测试
一、配置数据库
需要mysql 版本大于8
1.执行安装命令
sudo apt install mysql-server
2.初始化mysql并初次登陆
sudo mysql_secure_installation #根据提示信息配置mysql
sudo mysql -uroot -p #初次登陆mysql
3.修改root密码
update user set authentication_string=password('your_pass'),plugin='mysql_native_password' where user='root';
flush privileges;
4.Setup数据库
create user 'hawkbit'@'%' identified by 'test_pass_123'; #hawkbit用户并设置密码
create database hawkbit; #创建hawkbit数据库
grant all on hawkbit.* TO 'hawkbit'@'%'; #添加hawkbit用户权限
grant all privileges on *.* to 'hawkbit'@'%' with grant option;#添加hawkbit用户权限
5.允许远程访问
修改/etc/mysql/mysql.conf.d/mysqld.cnf
中的bind-address
与mysqlx-bind-address
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
bind-address = 0.0.0.0
mysqlx-bind-address = 0.0.0.0
- 重启数据库
sudo systemctl restart mysql
二、编译安装hawkbit
环境准备
1.更新jdk到17
sudo apt install openjdk-17-jdk
2.下载新版Maven
官网下载地址:https://maven.apache.org/download.cgi
如果只是临时编译用一下,解压安装到一个指定临时目录即可
3.设置Maven 国内下载源
添加到conf/settings.xml
中
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
编译安装
- 下载代码
git clone https://github.com/eclipse/hawkbit.git
git checkout 0.3.0M9 #切换到TAG 0.3.0M9
- 添加mysql支持
diff --git a/hawkbit-runtime/hawkbit-update-server/pom.xml b/hawkbit-runtime/hawkbit-update-server/pom.xml
index b75a5dc20..e8d621692 100644
--- a/hawkbit-runtime/hawkbit-update-server/pom.xml
+++ b/hawkbit-runtime/hawkbit-update-server/pom.xml
@@ -96,7 +96,7 @@
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
- <scope>test</scope>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.hawkbit</groupId>
diff --git a/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties b/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties
index a557a4ed2..d497eda33 100644
--- a/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties
+++ b/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties
@@ -18,12 +18,12 @@ server.servlet.encoding.enabled=true
server.servlet.encoding.force=true
# DDI authentication configuration
-hawkbit.server.ddi.security.authentication.anonymous.enabled=false
-hawkbit.server.ddi.security.authentication.targettoken.enabled=false
-hawkbit.server.ddi.security.authentication.gatewaytoken.enabled=false
+hawkbit.server.ddi.security.authentication.anonymous.enabled=true
+hawkbit.server.ddi.security.authentication.targettoken.enabled=true
+hawkbit.server.ddi.security.authentication.gatewaytoken.enabled=true
# Optional events
-hawkbit.server.repository.publish-target-poll-event=false
+hawkbit.server.repository.publish-target-poll-event=true
## Configuration for DMF/RabbitMQ integration
spring.rabbitmq.username=guest
@@ -42,3 +42,8 @@ spring.rabbitmq.port=5672
# Enable CORS and specify the allowed origins:
#hawkbit.server.security.cors.enabled=true
#hawkbit.server.security.cors.allowedOrigins=http://localhost
+spring.jpa.database=MYSQL
+spring.datasource.url=jdbc:mariadb://my-mysql-server:3306/hawkbit
+spring.datasource.username=hawkbit
+spring.datasource.password=test_pass_123
+spring.datasource.driverClassName=org.mariadb.jdbc.Driver
3.编译
path/to/mvn -s path/to/mvn/conf/settings.xml clean install -DskipTests
4.运行
java -jar hawkbit-runtime/hawkbit-update-server/target/hawkbit-update-server-0.3.0-SNAPSHOT.jar
3.测试
浏览器访问:http://127.0.0.1:8080
登录默认用户密码:admin,admin
[完整升级操作流程操作步骤参考视频第21分45秒]: https://www.youtube.com/watch?v=g-dhKMaaanE