From 4a96c02b9ac1026811acef86cdeabd0ef58c387b Mon Sep 17 00:00:00 2001 From: zqr10159 Date: Tue, 23 Apr 2024 10:35:21 +0800 Subject: [PATCH 1/4] [remove]Remove optional comments. --- manager/src/main/resources/application.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/manager/src/main/resources/application.yml b/manager/src/main/resources/application.yml index 33fecabfd04..f2fc41a5739 100644 --- a/manager/src/main/resources/application.yml +++ b/manager/src/main/resources/application.yml @@ -76,8 +76,6 @@ spring: jpa: hibernate: ddl-auto: update - # Not Require, Please config if you need email notify - # 非必填:不使用邮箱作为警告通知可以去掉spring.mail配置 mail: # Attention: this is mail server address. # 请注意此为邮件服务器地址:qq邮箱为 smtp.qq.com qq 企业邮箱为 smtp.exmail.qq.com From 1f6614d1a18468bc5e5f59b223579cba80c60935 Mon Sep 17 00:00:00 2001 From: zqr10159 Date: Tue, 23 Apr 2024 10:36:58 +0800 Subject: [PATCH 2/4] [remove]Remove optional comments. --- manager/src/main/resources/application.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manager/src/main/resources/application.yml b/manager/src/main/resources/application.yml index f2fc41a5739..63af8baf9d0 100644 --- a/manager/src/main/resources/application.yml +++ b/manager/src/main/resources/application.yml @@ -84,9 +84,9 @@ spring: # Attention: this is not email account password, this requires an email authorization code # 请注意此非邮箱账户密码 此需填写邮箱授权码 password: your-password - #Attention: Tencent mail smtps 465,smtp 587 - #请注意腾讯邮箱465为smtps,587为smtp - port: 587 + # Attention: qq mailbox default is 465 port, if you use 587 port, please configure port: 587 in application.yml + #请注意腾讯邮箱默认为465端口,如果使用587端口请在application.yml中配置port: 587 + port: 465 properties: mail: smtp: From 9c5ea20b15dbf8df9077608842a106e62db7fd16 Mon Sep 17 00:00:00 2001 From: zqr10159 Date: Tue, 11 Jun 2024 14:57:35 +0800 Subject: [PATCH 3/4] [doc]HertzBeat 1.6.0 Upgrade Guide. --- .../2024-06-11-hertzbeat-v1.6.0-update.md | 147 ++++++++++ .../2024-06-11-hertzbeat-v1.6.0-update.md | 258 ++++++++++++++++++ 2 files changed, 405 insertions(+) create mode 100644 home/blog/2024-06-11-hertzbeat-v1.6.0-update.md create mode 100644 home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-06-11-hertzbeat-v1.6.0-update.md diff --git a/home/blog/2024-06-11-hertzbeat-v1.6.0-update.md b/home/blog/2024-06-11-hertzbeat-v1.6.0-update.md new file mode 100644 index 00000000000..6e7bf7749b1 --- /dev/null +++ b/home/blog/2024-06-11-hertzbeat-v1.6.0-update.md @@ -0,0 +1,147 @@ +# HertzBeat 1.6.0 Upgrade Guide + +**Note: This guide is applicable for upgrading from versions prior to 1.6.0 to version 1.6.0.** + +## Binary Installation Package Upgrade + +### Upgrade Java Environment + +Since version 1.6.0 uses Java 17 and the installation package no longer provides a built-in JDK version, use the new Hertzbeat according to the following situations: + +- When the default environment variable on your server is Java 17, you do not need to take any action for this step. +- When the default environment variable on your server is not Java 17, such as Java 8 or Java 11, and if there are no other applications on your server that require a lower version of Java, download the appropriate version from [https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) according to your system, and search the engine for how to set a new environment variable pointing to the new Java 17. +- When the default environment variable on your server is not Java 17, such as Java 8 or Java 11, and if there are other applications on your server that require a lower version of Java, download the appropriate version from [https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) according to your system, and rename the extracted folder to `java`, then copy it to the Hertzbeat extraction directory. + +### Upgrade Database + +Go to [https://github.com/apache/hertzbeat/tree/master/manager/src/main/resources/db/migration](https://github.com/apache/hertzbeat/tree/master/manager/src/main/resources/db/migration), choose the directory of your database and execute the corresponding `V160__update_column.sql` file for the upgrade SQL. + +### Upgrade Configuration Files + +Due to significant changes in `application.yml` and `sureness.yml`, it is recommended to directly use the new `yml` configuration files and then modify them based on your own needs. + +#### `application.yml` generally needs to modify the following parts: + +Default is: +```yaml + datasource: + driver-class-name: org.h2.Driver + username: sa + password: 123456 + url: jdbc:h2:./data/hertzbeat;MODE=MYSQL + hikari: + max-lifetime: 120000 + + jpa: + show-sql: false + database-platform: org.eclipse.persistence.platform.database.MySQLPlatform + database: h2 + properties: + eclipselink: + logging: + level: SEVERE +``` +If you change to a MySQL database, here is an example: +```yaml + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + username: root + password: root + url: jdbc:mysql://localhost:3306/hertzbeat?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai + hikari: + max-lifetime: 120000 + + jpa: + show-sql: false + database-platform: org.eclipse.persistence.platform.database.MySQLPlatform + database: mysql + properties: + eclipselink: + logging: + level: SEVERE +``` + +#### `sureness.yml` modification is optional, usually when you need to change account passwords: + +```yaml +# account info config +# eg: admin has role [admin,user], password is hertzbeat +# eg: tom has role [user], password is hertzbeat +# eg: lili has role [guest], plain password is lili, salt is 123, salted password is 1A676730B0C7F54654B0E09184448289 +account: + - appId: admin + credential: hertzbeat + role: [admin] + - appId: tom + credential: hertzbeat + role: [user] + - appId: guest + credential: hertzbeat + role: [guest] + - appId: lili + # credential = MD5(password + salt) + # plain password: hertzbeat + # attention: digest authentication does not support salted encrypted password accounts + credential: 94C6B34E7A199A9F9D4E1F208093B489 + salt: 123 + role: [user] +``` + +### Add the corresponding database drivers + +Due to the Apache Foundation's requirements for license compliance, HertzBeat's installation package cannot include dependencies with GPL licenses such as MySQL, Oracle, etc. Users need to add them themselves. Users can download the drivers from the following links and copy them to the `ext-lib` directory of the installation: + +- MySQL: [https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.25.zip](https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.25.zip) +- Oracle (If you want to monitor Oracle, these two drivers are required): + - [https://download.oracle.com/otn-pub/otn_software/jdbc/234/ojdbc8.jar](https://download.oracle.com/otn-pub/otn_software/jdbc/234/ojdbc8.jar) + - [https://repo.mavenlibs.com/maven/com/oracle/database/nls/orai18n/21.5.0.0/orai18n-21.5.0.0.jar](https://repo.mavenlibs.com/maven/com/oracle/database/nls/orai18n/21.5.0.0/orai18n-21.5.0.0.jar) + +Next, run the start-up script as before to experience the latest HertzBeat 1.6.0! + +## Docker Upgrade - Mysql Database + +- Stop the HertzBeat container: + ``` + docker stop hertzbeat + ``` + +- Upgrade the database script: + - Go to [https://github.com/apache/hertzbeat/tree/master/manager/src/main/resources/db/migration](https://github.com/apache/hertzbeat/tree/master/manager/src/main/resources/db/migration), choose the directory of your database and execute the corresponding `V160__update_column.sql` file in MySQL. + +- Upgrade the configuration files: + - As mentioned, due to significant changes in `application.yml` and `sureness.yml`, it is recommended to directly mount and use the new `yml` configuration files, and then modify them based on your own needs. + +- Add the corresponding database drivers: + - Due to the Apache Foundation's license compliance requirements, HertzBeat's installation package cannot include MySQL, Oracle, and other GPL-licensed dependencies. Users need to add them themselves by downloading the driver jars from the above links and placing them in the local `ext-lib` directory, then mounting `ext-lib` to the container's `/opt/hertzbeat/ext-lib` directory when starting. + +Next, run HertzBeat using Docker as before to experience the latest HertzBeat 1.6.0! + +## Docker Installation Upgrade - H2 Built-in Database (Not recommended for production use) + +- Stop the HertzBeat container: + ``` + docker stop hertzbeat + ``` + +- Edit the H2 database files: + - Assuming you have mounted the H2 database files in the `data` directory to the local system, or copied the `/opt/hertzbeat/data` directory from the old container manually. + - Download the H2 driver jar from [https://mvnrepository.com/artifact/com.h2database/h2/2.2.220](https://mvnrepository.com/artifact/com.h2database/h2/2.2.220). + - Start the database locally using the H2 driver jar: + ``` + java -jar h2-2.2.220.jar -url jdbc:h2:file:./hertzbeat -user sa -password 123456 + ``` + +- Upgrade the configuration files: + - As mentioned, due to significant changes in `application.yml` and `sureness.yml`, it is recommended to directly mount and use the new `yml` configuration files, and then modify them based on your own needs. + +- Add the corresponding database drivers: + - As mentioned, due to the Apache Foundation's license compliance requirements, HertzBeat's installation package cannot include MySQL, Oracle, and other GPL-licensed dependencies. Users need to add them themselves by downloading the driver jars from the above links and placing them in the local `ext-lib` directory, then mounting `ext-lib` to the container's `/opt/hertzbeat/ext-lib` directory when starting. + +Next, run the Docker to start HertzBeat as before to experience the latest HertzBeat 1.6.0! + +## Upgrade via Export and Import + +If you do not want to go through the tedious script upgrade method mentioned above, you can directly export and import the monitoring tasks and threshold information from the old environment. + +- Deploy a new environment with the latest version. +- Export the monitoring tasks and threshold information from the old environment on the page \ No newline at end of file diff --git a/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-06-11-hertzbeat-v1.6.0-update.md b/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-06-11-hertzbeat-v1.6.0-update.md new file mode 100644 index 00000000000..f6bd48ae1a5 --- /dev/null +++ b/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-06-11-hertzbeat-v1.6.0-update.md @@ -0,0 +1,258 @@ +# HertzBeat 1.6.0 升级指南 + +### 注意:该指适用于1.6.0之前的版本向1.6.0版本升级 + +### 二进制安装包升级 + +1. 升级Java环境 + +由于1.6.0版本使用Java17,且安装包不再提供内置jdk的版本,参考以下情况使用新版Hertzbeat。 + +- 当你的服务器中默认环境变量为Java17时,这一步你无需任何操作。 +- 当你的服务器中默认环境变量不为Java17时,如Java8、Java11,若你服务器中**没有**其他应用需要低版本Java,根据你的系统,到 [https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) 选择相应的发行版下载,并在搜索引擎搜索如何设置新的环境变量指向新的Java17。 +- 当你的服务器中默认环境变量不为Java17时,如Java8、Java11,若你服务器中**有**其他应用需要低版本Java,根据你的系统,到 [https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) 选择相应的发行版下载,并将解压后的文件夹重命名为java,复制到Hertzbeat的解压目录下。 +2. 升级数据库 + +打开[https://github.com/apache/hertzbeat/tree/master/manager/src/main/resources/db/migration](https://github.com/apache/hertzbeat/tree/master/manager/src/main/resources/db/migration), +选择你使用的数据库的目录下相应的 `V160__update_column.sql`文件执行升级sql。 + +3. 升级配置文件 + +由于 `application.yml`和 `sureness.yml`更新变动较大,建议直接使用新的yml配置文件,然后在自己的需求基础上进行修改。 + +- `application.yml`一般需要修改以下部分 + + 默认为: +```yaml + datasource: + driver-class-name: org.h2.Driver + username: sa + password: 123456 + url: jdbc:h2:./data/hertzbeat;MODE=MYSQL + hikari: + max-lifetime: 120000 + + jpa: + show-sql: false + database-platform: org.eclipse.persistence.platform.database.MySQLPlatform + database: h2 + properties: + eclipselink: + logging: + level: SEVERE +``` +如若修改为mysql数据库,给出一个示例: +```yaml + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + username: root + password: root + url: jdbc:mysql://localhost:3306/hertzbeat?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai + hikari: + max-lifetime: 120000 + + jpa: + show-sql: false + database-platform: org.eclipse.persistence.platform.database.MySQLPlatform + database: mysql + properties: + eclipselink: + logging: + level: SEVERE +``` + +- `sureness.yml`修改是可选的,一般在你需要修改账号密码时 +```yaml +# account info config +# eg: admin has role [admin,user], password is hertzbeat +# eg: tom has role [user], password is hertzbeat +# eg: lili has role [guest], plain password is lili, salt is 123, salted password is 1A676730B0C7F54654B0E09184448289 +account: + - appId: admin + credential: hertzbeat + role: [admin] + - appId: tom + credential: hertzbeat + role: [user] + - appId: guest + credential: hertzbeat + role: [guest] + - appId: lili + # credential = MD5(password + salt) + # plain password: hertzbeat + # attention: digest authentication does not support salted encrypted password accounts + credential: 94C6B34E7A199A9F9D4E1F208093B489 + salt: 123 + role: [user] +``` + + +4. 添加相应的数据库驱动 + + 由于apache基金会对于license合规的要求,HertzBeat的安装包不能包含mysql,oracle等gpl许可的依赖,需要用户自行添加,用户可通过以下链接自行下载驱动,复制到安装目录下`ext-lib`中。 +mysql:[https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.25.zip](https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.18.zip) +oracle(如果你要监控oracle,这两个驱动是必须的) +[https://download.oracle.com/otn-pub/otn_software/jdbc/234/ojdbc8.jar](https://download.oracle.com/otn-pub/otn_software/jdbc/234/ojdbc8.jar) +[https://repo.mavenlibs.com/maven/com/oracle/database/nls/orai18n/21.5.0.0/orai18n-21.5.0.0.jar](https://repo.mavenlibs.com/maven/com/oracle/database/nls/orai18n/21.5.0.0/orai18n-21.5.0.0.jar?utm_source=mavenlibs.com) +接下来,像之前那样运行启动脚本,即可体验最新的HertzBeat1.6.0! + +### Docker 方式升级 - Mysql数据库 + +1. 关闭 HertzBeat 容器 +``` +docker stop hertzbeat +``` + +2. 升级数据库脚本 + +打开[https://github.com/apache/hertzbeat/tree/master/manager/src/main/resources/db/migration](https://github.com/apache/hertzbeat/tree/master/manager/src/main/resources/db/migration), +选择你使用的数据库的目录下相应的 `V160__update_column.sql`文件在 Mysql 执行升级sql。 + +3. 升级配置文件 + +由于 `application.yml`和 `sureness.yml`更新变动较大,建议直接挂载使用新的yml配置文件,然后在自己的需求基础上进行修改。 + +- `application.yml`一般需要修改以下部分 + + 默认为: +```yaml + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + username: root + password: root + url: jdbc:mysql://localhost:3306/hertzbeat?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai + hikari: + max-lifetime: 120000 + + jpa: + show-sql: false + database-platform: org.eclipse.persistence.platform.database.MySQLPlatform + database: mysql + properties: + eclipselink: + logging: + level: SEVERE +``` + +- `sureness.yml`修改是可选的,一般在你需要修改账号密码时 +```yaml +# account info config +# eg: admin has role [admin,user], password is hertzbeat +# eg: tom has role [user], password is hertzbeat +# eg: lili has role [guest], plain password is lili, salt is 123, salted password is 1A676730B0C7F54654B0E09184448289 +account: + - appId: admin + credential: hertzbeat + role: [admin] + - appId: tom + credential: hertzbeat + role: [user] + - appId: guest + credential: hertzbeat + role: [guest] + - appId: lili + # credential = MD5(password + salt) + # plain password: hertzbeat + # attention: digest authentication does not support salted encrypted password accounts + credential: 94C6B34E7A199A9F9D4E1F208093B489 + salt: 123 + role: [user] +``` + +4. 添加相应的数据库驱动 + + 由于apache基金会对于license合规的要求,HertzBeat的安装包不能包含mysql,oracle等gpl许可的依赖,需要用户自行添加,用户可通过以下链接自行下载驱动 jar 放到本地 `ext-lib`目录下,然后启动时将`ext-lib`挂载到容器的 `/opt/hertzbeat/ext-lib`目录。 +mysql:[https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.25.zip](https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.18.zip) +oracle(如果你要监控oracle,这两个驱动是必须的) +[https://download.oracle.com/otn-pub/otn_software/jdbc/234/ojdbc8.jar](https://download.oracle.com/otn-pub/otn_software/jdbc/234/ojdbc8.jar) +[https://repo.mavenlibs.com/maven/com/oracle/database/nls/orai18n/21.5.0.0/orai18n-21.5.0.0.jar](https://repo.mavenlibs.com/maven/com/oracle/database/nls/orai18n/21.5.0.0/orai18n-21.5.0.0.jar?utm_source=mavenlibs.com) +接下来,像之前那样 Docker 运行启动 HertzBeat,即可体验最新的HertzBeat1.6.0! + +### Docker安装升级 - H2内置数据库(生产环境不推荐使用H2) + +1. 关闭 HertzBeat 容器 +``` +docker stop hertzbeat +``` + +2. 编辑H2数据库文件 + + 前题你已经将 H2 数据库文件 data 目录挂载到本地,或者启动老容器手动将 /opt/hertzbeat/data 目录拷贝出来。 + 下载 h2 驱动 jar [https://mvnrepository.com/artifact/com.h2database/h2/2.2.220](https://mvnrepository.com/artifact/com.h2database/h2/2.2.220) + 使用 h2 驱动 jar 本地启动数据库 +``` +java -jar h2-2.2.220.jar -url jdbc:h2:file:./hertzbeat -user sa -password 123456 +``` +打开[https://github.com/apache/hertzbeat/tree/master/manager/src/main/resources/db/migration](https://github.com/apache/hertzbeat/tree/master/manager/src/main/resources/db/migration), +选择你使用的数据库的目录下相应的 `V160__update_column.sql`文件在 H2 执行升级sql。 + +3. 升级配置文件 + +由于 `application.yml`和 `sureness.yml`更新变动较大,建议直接挂载使用新的yml配置文件,然后在自己的需求基础上进行修改。 + +- `application.yml`一般需要修改以下部分 + + 默认为: +```yaml + datasource: + driver-class-name: org.h2.Driver + username: sa + password: 123456 + url: jdbc:h2:./data/hertzbeat;MODE=MYSQL + hikari: + max-lifetime: 120000 + + jpa: + show-sql: false + database-platform: org.eclipse.persistence.platform.database.MySQLPlatform + database: h2 + properties: + eclipselink: + logging: + level: SEVERE +``` + +- `sureness.yml`修改是可选的,一般在你需要修改账号密码时 +```yaml +# account info config +# eg: admin has role [admin,user], password is hertzbeat +# eg: tom has role [user], password is hertzbeat +# eg: lili has role [guest], plain password is lili, salt is 123, salted password is 1A676730B0C7F54654B0E09184448289 +account: + - appId: admin + credential: hertzbeat + role: [admin] + - appId: tom + credential: hertzbeat + role: [user] + - appId: guest + credential: hertzbeat + role: [guest] + - appId: lili + # credential = MD5(password + salt) + # plain password: hertzbeat + # attention: digest authentication does not support salted encrypted password accounts + credential: 94C6B34E7A199A9F9D4E1F208093B489 + salt: 123 + role: [user] +``` + + +4. 添加相应的数据库驱动 + + 由于apache基金会对于license合规的要求,HertzBeat的安装包不能包含mysql,oracle等gpl许可的依赖,需要用户自行添加,用户可通过以下链接自行下载驱动 jar 放到本地 `ext-lib`目录下,然后启动时将`ext-lib`挂载到容器的 `/opt/hertzbeat/ext-lib`目录。 +mysql:[https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.25.zip](https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.18.zip) +oracle(如果你要监控oracle,这两个驱动是必须的) +[https://download.oracle.com/otn-pub/otn_software/jdbc/234/ojdbc8.jar](https://download.oracle.com/otn-pub/otn_software/jdbc/234/ojdbc8.jar) +[https://repo.mavenlibs.com/maven/com/oracle/database/nls/orai18n/21.5.0.0/orai18n-21.5.0.0.jar](https://repo.mavenlibs.com/maven/com/oracle/database/nls/orai18n/21.5.0.0/orai18n-21.5.0.0.jar?utm_source=mavenlibs.com) +接下来,像之前那样 Docker 运行启动,即可体验最新的HertzBeat1.6.0! + +### 通过导出导入升级 +> 若不想如上繁琐的脚本升级方式,可以直接将老环境的监控任务和阈值信息导出导入 + + +1. 部署一套最新版本的新环境 +2. 在页面上将老环境的监控任务和阈值信息导出。 +3. 在页面上将监控任务和阈值信息文件导入。 + +⚠️注意此方式只保留了老环境的监控任务信息和阈值信息,没有其它数据。 From fdcac6ee278357f31f3635b5803af2ab1bac6489 Mon Sep 17 00:00:00 2001 From: Logic Date: Fri, 10 Jan 2025 08:01:38 +0800 Subject: [PATCH 4/4] fix(warehouse): add metrics data update logic in memory storage - Add check for existing metrics data before updating - Close old metrics data to release resources --- .../store/realtime/memory/MemoryDataStorage.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/realtime/memory/MemoryDataStorage.java b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/realtime/memory/MemoryDataStorage.java index 4d7ecba7c0a..5ae9d250ca1 100644 --- a/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/realtime/memory/MemoryDataStorage.java +++ b/hertzbeat-warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/realtime/memory/MemoryDataStorage.java @@ -72,7 +72,13 @@ public void saveData(CollectRep.MetricsData metricsData) { if (metricsData.getCode() != CollectRep.Code.SUCCESS) { return; } - Map metricsDataMap = monitorMetricsDataMap.computeIfAbsent(monitorId, key -> new ConcurrentHashMap<>(METRICS_SIZE)); + Map metricsDataMap = + monitorMetricsDataMap.computeIfAbsent(monitorId, key -> new ConcurrentHashMap<>(METRICS_SIZE)); + + CollectRep.MetricsData oldMetricsData = metricsDataMap.get(metrics); + if (oldMetricsData != null) { + oldMetricsData.close(); + } metricsDataMap.put(metrics, metricsData); }