Browse Source

[Improvement][Registry][Jdbc] Add option can use ds database directly (#14369)

3.2.1-prepare
旺阳 1 year ago committed by GitHub
parent
commit
a7b8e071b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 59
      dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/README.md
  2. 1
      dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcRegistryConfiguration.java

59
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/README.md

@ -1,20 +1,48 @@
# Introduction
This module is the mysql registry plugin module, this plugin will use mysql as the registry center.
This module is the jdbc registry plugin module, this plugin will use jdbc as the registry center. Will use the database configuration same as DolphinScheduler in api'yaml default.
# How to use
## Use Mysql as registry center
If you want to set mysql as the registry center, you need to do the below two steps:
1. Initialize the database table
1. Initialize the mysql table
- If you use Mysql you can directly execute the sql script `src/main/resources/mysql_registry_init.sql`.
You can directly execute the sql script `src/main/resources/mysql_registry_init.sql`.
- If you use Postgresql you can directly execute the sql script `src/main/resources/postgresql_registry_init.sql`.
2. Open the config
2. Change the config
You need to set the registry properties in master/worker/api's appplication.yml
```yaml
registry:
type: jdbc
```
After do this two steps, you can start your DolphinScheduler cluster, your cluster will use mysql as registry center to
store server metadata.
NOTE: You need to add `mysql-connector-java.jar` into DS classpath if you use mysql database, since this plugin will not bundle this driver in distribution.
You can get the detail about <a href="https://dolphinscheduler.apache.org/en-us/docs/3.1.2/guide/installation/pseudo-cluster">Initialize the Database</a>.
## Optional configuration
```yaml
registry:
type: jdbc
# Used to schedule refresh the ephemeral data/ lock.
term-refresh-interval: 2s
# Used to calculate the expire time,
# e.g. if you set 2, and latest two refresh error, then the ephemeral data/lock will be expire.
term-expire-times: 3
```
## Use different database configuration for jdbc registry center
You need to set the registry properties in master/worker/api's appplication.yml
### Use Mysql as registry center
```yaml
registry:
type: jdbc
@ -29,22 +57,7 @@ registry:
idle-timeout: 600000
```
After do this two steps, you can start your DolphinScheduler cluster, your cluster will use mysql as registry center to
store server metadata.
NOTE: You need to add `mysql-connector-java.jar` into DS classpath, since this plugin will not bundle this driver in distribution.
You can get the detail about <a href="https://dolphinscheduler.apache.org/en-us/docs/3.1.2/guide/installation/pseudo-cluster">Initialize the Database</a>
## Use Postgresql as registry center
If you want to set Postgresql as the registry center, you need to do the below two steps:
1. Initialize the PostgreSQL table
You can directly execute the sql script `src/main/resources/postgresql_registry_init.sql`.
2. Open the config
You need to set the registry properties in master/worker/api's appplication.yml
### Use Postgresql as registry center
```yaml
registry:
@ -60,5 +73,3 @@ registry:
idle-timeout: 600000
```
After do this two steps, you can start your DolphinScheduler cluster, your cluster will use postgresql as registry center to
store server metadata.

1
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcRegistryConfiguration.java

@ -35,6 +35,7 @@ import com.zaxxer.hikari.HikariDataSource;
public class JdbcRegistryConfiguration {
@Bean
@ConditionalOnProperty(prefix = "registry.hikari-config", name = "jdbc-url")
public SqlSessionFactory jdbcRegistrySqlSessionFactory(JdbcRegistryProperties jdbcRegistryProperties) throws Exception {
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(new HikariDataSource(jdbcRegistryProperties.getHikariConfig()));

Loading…
Cancel
Save