swupdate+hawkbit部署以及測試 二

Amumu1發表於2024-08-27

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-addressmysqlx-bind-address

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

bind-address            = 0.0.0.0
mysqlx-bind-address     = 0.0.0.0
  1. 重啟資料庫
sudo systemctl restart mysql

二、編譯安裝hawkbit

環境準備

1.更新jdk到17

sudo apt install openjdk-17-jdk

2.下載新版Maven

官網下載地址:https://maven.apache.org/download.cgi

v3.9.9下載地址

如果只是臨時編譯用一下,解壓安裝到一個指定臨時目錄即可

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>

編譯安裝

  1. 下載程式碼
git clone https://github.com/eclipse/hawkbit.git
git checkout 0.3.0M9 #切換到TAG 0.3.0M9
  1. 新增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

相關文章