【问题标题】:A lot of problem when setting up hawkbit update server设置hawkbit更新服务器时出现很多问题
【发布时间】:2021-02-03 23:27:47
【问题描述】:

我正在尝试按照https://www.eclipse.org/hawkbit/gettingstarted/ 设置 hawkBit 更新服务器,但我不知道如何解决很多问题。 以下是简要设置步骤:

  1. 先决条件
sudo apt install -y default-jre default-jdk
java -version
*openjdk version "11.0.9.1" 2020-11-04*
*OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04)*
*OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)*

sudo apt install maven

sudo apt-get -y install mariadb-server
  1. 下载构建源代码
git clone https://github.com/eclipse/hawkbit.git
cd hawkbit
mvn clean install

*Start hawkBit update server*
*Access http://localhost:8080/UI/login to check*
java -jar ./hawkbit-runtime/hawkbit-update-server/target/hawkbit-update-server-0.3.0-SNAPSHOT.jar
  1. 自定义hawkBit 3.1。建立数据库
sudo mysql -u root
*Welcome to the MariaDB monitor.  Commands end with ; or \g.*
*Your MariaDB connection id is 31*
*Server version: 10.1.47-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04*
*Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.*
*Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.*

MariaDB [(none)]> USE mysql;
*Reading table information for completion of table and column names*
*You can turn off this feature to get a quicker startup with -A*
*Database changed*
MariaDB [mysql]> CREATE USER 'test'@'localhost' IDENTIFIED BY '123456a@';
*Query OK, 0 rows affected (0.00 sec)*
*MariaDB [mysql]> UPDATE user SET authentication_string=password('123456a@') where user='test';*
*Query OK, 0 rows affected (0.00 sec)*
*Rows matched: 1  Changed: 0  Warnings: 0*

MariaDB [mysql]> GRANT ALL PRIVILEGES ON *.* TO 'test'@'localhost';
*Query OK, 0 rows affected (0.00 sec)*

MariaDB [mysql]> UPDATE user SET plugin='mysql_native_password' WHERE User='test';
*Query OK, 1 row affected (0.01 sec)*
*Rows matched: 1  Changed: 1  Warnings: 0*

MariaDB [mysql]> FLUSH PRIVILEGES;
*Query OK, 0 rows affected (0.00 sec)*

MariaDB [mysql]> CREATE DATABASE hawkbit;
*Query OK, 1 row affected (0.00 sec)*

MariaDB [mysql]> ALTER DATABASE hawkbit COLLATE latin1_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [mysql]> grant all privileges on hawkbit.* TO 'test'@'localhost' identified by '123456a@';
*Query OK, 0 rows affected (0.01 sec)*

MariaDB [(none)]> exit
*Bye*

sudo service mysql restart

将以下代码附加到 hawkbit-runtime/hawkbit-update-server/pom.xml

<dependency>
    <groupId>org.mariadb.jdbc</groupId>
    <artifactId>mariadb-java-client</artifactId>
    <scope>compile</scope>
</dependency>

将以下代码覆盖到 hawkbit-runtime/hawkbit-update-server/src/main/resources/application-mysql.properties:

spring.jpa.database=mysql
spring.datasource.url=jdbc:mysql://localhost:3306/hawkbit
spring.datasource.username=test
spring.datasource.password=123456a@
spring.datasource.driverClassName=org.mariadb.jdbc.Driver

Application.properties 附加了新的 URL:

server.hostname=http://<my_ip_addr>   
server.port=<my_port>

重建并运行:

cd hawkbit
mvn clean install
java -jar ./hawkbit-runtime/hawkbit-update-server/target/hawkbit-update-server-0.3.0-SNAPSHOT.jar --spring.profiles.active=mysql

打开http://:,我无法使用“admin”用户名和“admin”密码登录。

不带--spring.profiles.active=mysql运行hawkBit,我通过admin,admin登录成功。 即使application.properties保持不变,结果也是一样的。

我尝试注释掉所有用户安全:

# spring.security.user.name=admin
# spring.security.user.password={noop}admin-pwd
# spring.main.allow-bean-definition-overriding=true

并取消注释定义自己的用户而不是默认的“admin”用户:

hawkbit.server.im.users[0].username=test
hawkbit.server.im.users[0].password={noop}123456a@
hawkbit.server.im.users[0].firstname=Huong
hawkbit.server.im.users[0].lastname=Ha
hawkbit.server.im.users[0].permissions=ALL

构建失败,日志如下:

[INFO] hawkBit :: Runtime :: Update Server ................ FAILURE [  7.579 s]
[INFO] hawkBit :: Test Report ............................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  14:59 min
[INFO] Finished at: 2020-12-26T16:47:05+07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project hawkbit-update-server: There are test failures.
[ERROR] 
[ERROR] Please refer to /home/huong/software-update-server/hawkbit/hawkbit-runtime/hawkbit-update-server/target/surefire-reports for the individual test results.

所以我有一些问题,希望有人能提供帮助:

  1. 设置 hawkBit 更新服务器的确切步骤。任何经验都会有所帮助
  2. hawkbit数据库(如上创建)是一个空数据库,你有兼容hawkbit的数据库吗?

谢谢, 黄河

【问题讨论】:

  • Docker 映像不适合您?
  • 我认为 Hawkbit 不支持 Java 11,因为他们在 Java 11 支持方面存在未解决的问题 (github.com/eclipse/hawkbit/issues/955)。虽然它可能会起作用,因为大多数 Java 11 问题似乎与构建/运行无关。
  • 我需要适应新的用户名/密码以及在外部(不是本地主机)运行,所以我想我必须从源代码开始。

标签: eclipse-hawkbit


【解决方案1】:

您所遵循的程序是完全正确的。但是,关于您的方法有几点说明:

  1. 通过指定skipTests maven 参数:mvn clean install -DskipTests,您可以在构建 Hawkbit 时省略运行所有测试。这将大大减少构建时间。
  2. 您无需修改​​application.properties 即可使用MySQL 数据库。相反,只需指定 --spring.profiles.active=mysql 程序参数来激活“mysql” Spring 配置文件并根据需要调整 application-mysql.properties(在您的情况下更改用户名和密码数据源配置)。
  3. 您需要使用spring.security.user.namespring.security.user.passwordhawkbit.server.im.users,而不是同时使用。 Spring 安全用户应该开箱即用。另外,不要注释掉spring.main.allow-bean-definition-overriding=true,它负责Spring的bean覆盖机制,与Spring Security无关。
  4. Hawkbit 正在使用 Flyway DB 版本控制 (https://flywaydb.org),这意味着它将在应用程序启动期间执行所有必需的 DB 迁移脚本。
  5. 是的,您可以使用 java11 运行 Hawkbit(请参阅 https://github.com/eclipse/hawkbit/commit/ed9a4b1bb31f4cd996e8af8867d67cdcda682d00

希望能让你走得更远;)

【讨论】:

  • 谢谢,博格丹。您的评论在某些方面很有帮助。但是我仍然无法登录到 hawkBit。你能看看我的评论和帮助吗?
  • 嗨@Bogdan,我已根据您的评论编辑了问题。但问题一直存在。使用 --spring.profiles.active=mysql 运行 hawkBit => 管理员无法登录,没有 --spring.profiles.active=mysql 的管理员 => 可以登录。
猜你喜欢
  • 2022-01-15
  • 2019-03-21
  • 1970-01-01
  • 1970-01-01
  • 2017-11-03
  • 2021-09-22
  • 1970-01-01
  • 1970-01-01
  • 2016-06-15
相关资源
最近更新 更多