nacos-group / nacos-plugin Goto Github PK
View Code? Open in Web Editor NEWA collection of Nacos plug-ins, providing Nacos with pluggable plug-in capabilities, support for user customization and high scalability
License: Apache License 2.0
A collection of Nacos plug-ins, providing Nacos with pluggable plug-in capabilities, support for user customization and high scalability
License: Apache License 2.0
版本: nacos-server v2.2.1
参考 https://github.com/wuchubuzai2018/nacos-datasource-extend-plugins
测试windows/linux 基于官方的pg配置都可以使用, 但是制作成的nacos镜像始终在报错,配置如下
nacos.core.auth.system.type=nacos
nacos.core.auth.enabled=true
nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
nacos.core.auth.server.identity.key=test
nacos.core.auth.server.identity.value=test
spring.datasource.platform=postgresql
db.url.0=jdbc:postgresql://xxx:xxx/xxx?tcpKeepAlive=true&reWriteBatchedInserts=true&ApplicationName=nacos_java
db.num=1
db.user=postgres
db.password=123456
db.pool.config.driverClassName=org.postgresql.Driver
2023-09-14 03:24:22,306 ERROR
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'db.pool.config' to com.zaxxer.hikari.HikariDataSource:
Property: db.pool.config.driver-class-name
Value: "org.postgresql.Driver"
Origin: InputStream resource [resource loaded through InputStream] - 284:32
Reason: java.lang.RuntimeException: Failed to load driver class org.postgresql.Driver in either of HikariConfig class loader or Thread context classloader
Action:
Update your application's configuration
2023-09-14 03:24:22,308 WARN [ThreadPoolManager] Start destroying ThreadPool
2023-09-14 03:24:22,308 WARN [ThreadPoolManager] Destruction of the end
参考 issues 做过一些排查发现没用 wuchubuzai2018/nacos-datasource-extend-plugins#2
目前是否有相关的解决方案?
引入nacos-aes-encryption-plugin-1.0.0-SNAPSHOT.jar 中文配置乱码,不加密的配置中文正常
我这边支持了一下Sqlserver数据源,完成了plugin的编写,是需要将实现复制到nacos/plugin项目中,还是有其他方式?官网说明中是先编译nacos本体,然后install插件就没了。请大佬们赐教~
大部分兼容mysql语法的信创数据库不需要这些插件,只要吧驱动包放到plugins目录,然后正确配置驱动类就好了很简单。
例如nacos-dm-datasource-plugin-ext
的实现,既然全都是空实现继承 Base*
的,那么说明完全没有必要存在这个插件,除非是有不兼容的语法才需要定制插件。
我们只需要把驱动包放入plugins
目录,然后配置如下
spring.datasource.platform=mysql
db.pool.config.driverClassName=dm.jdbc.driver.DmDriver
db.url.0=jdbc:dm://[ip]:[port]
``[INFo]` Scanning
for projects...
[INFO]
[INFO]
--------< com.alibaba.nacos:nacos-oracle-datasource-plugin-ext
IERROR] Failed to execute goal on project nacos-oracle-datasource-plugin-ext: Could not resolve dependencies for
project com.alibaba.nacos:nacos-oracle-datasource-plugin-ext:jar:1.0.0-sNAPsHoT: The following artifacts could not be
resolved: com. alibaba.nacos:nacos-datasource-plugin-ext-base:jar:1.0.0-SNAPSH0T (absent), com.alibaba
.nacos: nacos-datasource-plugin:iar:2.3.0-SNAPsHoT (absent), com.alibaba.nacos:nacos-common:iar:2.3.0-SNAPSHOT
(absent); could not find artifact com,alibaba.nacos:nacos-datasource-plugin-ext-base:iar:1.0.0-SNAPSHOT -> [Help 1]
ERROR]
[ERROR]
To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR]
For more information about the errors and possible solutions, please read the following articles:
LERRORI
[Help 1] `http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException``
在HistoryConfigInfoMapperOracle文件中有这样一段sql
DELETE FROM his_config_info WHERE ROWID in (SELECT ROWID FROM his_config_info WHERE gmt_modified < ? FETCH FIRST ? ROWS ONLY)
这段sql在oracle中执行不了啊,oracle不支持FETCH FIRST ? ROWS ONLY这种用法,给我整无语了。。。
目前很多国产数据库都可以兼容PG的SQL,PG数据库适配插件理论上是都可以支持的,但是在运行时需要使用厂商自己的jdbc包(典型问题就是数据库认证方式不兼容)。
所以目前的插件最好不要打包JDBC驱动,因为有些国产数据库的JDBC驱动和PG的驱动同名,包里面的类名也有同名。从外部加载JDBC驱动是一个比较好的选择,实际是使用也不会太麻烦,因为我们本身就要修改nacos配置,使用loader机制加载插件,再多放一个JDBC驱动包完全不是问题。
我看只有develop版本有oracle部分代码,为啥下来之后报错找不到依赖,然后我自己写的配置管理那一块的查询有点问题https://gitee.com/aaqw12/nacos-plugin.git
nacos-encryption-plugin模块是不是在2.0.4的版本中还未发布,目前依赖不到
caused: PreparedStatementCallback; bad SQL grammar [INSERT INTO permissions (role, resource, action) VALUES (?, ?, ?)]; nested exception is java.sql.SQLSyntaxErrorException: ORA-01747: user.table.column, table.column 或列说明无效 ;caused: ORA-01747: user.table.column, table.column 或列说明无效 ;caused: ORA-01747: user.table.column, table.column 或列说明无效 ;
使用的oracle作为数据源,新增角色资源关联时报错,看了一下代码,貌似Nacos官网还没开放这个Mapper的重写适配,关于permissions表的查询和新增的sql都是在ExternalPermissionPersistServiceImpl类里整的硬编码,刚好permissions表中的resource字段,是oracle数据库里的关键字了,使用的oracle版本为19c
当我准备把刚刚完成的SQL Server支持准备打包时,发生了找不到jar包的错误。经过排查后,总结一下方法
alibaba-nacos.version
的值。如目前的值为2.4.0-SNAPSHOT
。com.dameng:DmJdbcDriver18:jar:8.1.2.114
,这可能是因为你的电脑上没有该jar包。这时可以根据注释的提示修改版本为8.1.2.79
,并将达梦依赖的systemPath
和scope
的标签删除,以便从在线仓库中下载。十分感谢
使用如下配置,在登录时提示找不到用户,org.springframework.security.core.userdetails.UsernameNotFoundException: User nacos not found:
spring.sql.init.platform=dm
db.num=1
db.url.0=jdbc:dm://127.0.0.1:5236/NACOS?schema=NACOS&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
db.user.0=SYSDBA
db.password.0=123456
db.pool.config.driverClassName=dm.jdbc.driver.DmDriver
调式发现 nacos-default-auth-plugin 模块下出现出错,没有对应分页实现,如果把spring.sql.init.platform=mysql就是好的,请问这块如何扩展
/**
* Get handler adapter.
*
* @param dataSourceType data source type.
* @return
*/
protected PageHandlerAdapter getHandlerAdapter(String dataSourceType) {
List handlerAdapters = PageHandlerAdapterFactory.getInstance().getHandlerAdapters();
for (PageHandlerAdapter adapter : handlerAdapters) {
if (adapter.supports(dataSourceType)) {
return adapter;
}
}
return PageHandlerAdapterFactory.getInstance().getHandlerAdapterMap()
.get(DefaultPageHandlerAdapter.class.getName());
}
缺少一个OFFSET
At present, Nacos has completed the expansion of sql, so that the sql adaptation of multiple data sources can be performed. Now the adaptation of mysql and derby has been completed, and adaptation plug-ins for other databases are required. Are you willing to complete it?
Link: https://nacos.io/zh-cn/docs/v2/plugin/datasource-plugin.html
项目版本:
tag:[2.2.x] (https://github.com/nacos-group/nacos-plugin/releases/tag/2.2.x)
脚本位置:
nacos-postgresql-datasource-plugin-ext/src/main/resources/schem
数据库:
PostgreSQL
导入psql报错:
Task execution failed, reason: NOTICE: table "config_info" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "config_info_id_seq" for serial column "config_info.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "config_info_id_key" for table "config_info"
NOTICE: table "config_info_aggr" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "config_info_aggr_id_seq" for serial column "config_info_aggr.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "config_info_aggr_id_key" for table "config_info_aggr"
NOTICE: table "config_info_beta" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "config_info_beta_id_seq" for serial column "config_info_beta.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "config_info_beta_id_key" for table "config_info_beta"
NOTICE: table "config_info_tag" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "config_info_tag_id_seq" for serial column "config_info_tag.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "config_info_tag_id_key" for table "config_info_tag"
NOTICE: table "config_tags_relation" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "config_tags_relation_id_seq" for serial column "config_tags_relation.id"
NOTICE: CREATE TABLE will create implicit sequence "config_tags_relation_nid_seq" for serial column "config_tags_relation.nid"
ERROR: Incorrect table definition, there can be only one auto_increment column
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
NOTICE: table "group_capacity" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "group_capacity_id_seq" for serial column "group_capacity.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "group_capacity_id_key" for table "group_capacity"
NOTICE: table "his_config_info" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "his_config_info_nid_seq" for serial column "his_config_info.nid"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "his_config_info_nid_key" for table "his_config_info"
NOTICE: table "permissions" does not exist, skipping
NOTICE: table "roles" does not exist, skipping
NOTICE: table "tenant_capacity" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "tenant_capacity_id_seq" for serial column "tenant_capacity.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "tenant_capacity_id_key" for table "tenant_capacity"
NOTICE: table "tenant_info" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "tenant_info_id_seq" for serial column "tenant_info.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "tenant_info_id_key" for table "tenant_info"
NOTICE: table "users" does not exist, skipping
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "config_info_pkey" for table "config_info"
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "config_info_aggr_pkey" for table "config_info_aggr"
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "config_info_beta_pkey" for table "config_info_beta"
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "config_info_tag_pkey" for table "config_info_tag"
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "group_capacity_pkey" for table "group_capacity"
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "his_config_info_pkey" for table "his_config_info"
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "tenant_capacity_pkey" for table "tenant_capacity"
Task execution failed, reason: NOTICE: table "config_info" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "config_info_id_seq" for serial column "config_info.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "config_info_id_key" for table "config_info"
NOTICE: table "config_info_aggr" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "config_info_aggr_id_seq" for serial column "config_info_aggr.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "config_info_aggr_id_key" for table "config_info_aggr"
NOTICE: table "config_info_beta" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "config_info_beta_id_seq" for serial column "config_info_beta.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "config_info_beta_id_key" for table "config_info_beta"
NOTICE: table "config_info_tag" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "config_info_tag_id_seq" for serial column "config_info_tag.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "config_info_tag_id_key" for table "config_info_tag"
NOTICE: table "config_tags_relation" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "config_tags_relation_id_seq" for serial column "config_tags_relation.id"
NOTICE: CREATE TABLE will create implicit sequence "config_tags_relation_nid_seq" for serial column "config_tags_relation.nid"
ERROR: Incorrect table definition, there can be only one auto_increment column
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
NOTICE: table "group_capacity" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "group_capacity_id_seq" for serial column "group_capacity.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "group_capacity_id_key" for table "group_capacity"
NOTICE: table "his_config_info" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "his_config_info_nid_seq" for serial column "his_config_info.nid"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "his_config_info_nid_key" for table "his_config_info"
NOTICE: table "permissions" does not exist, skipping
NOTICE: table "roles" does not exist, skipping
NOTICE: table "tenant_capacity" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "tenant_capacity_id_seq" for serial column "tenant_capacity.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "tenant_capacity_id_key" for table "tenant_capacity"
NOTICE: table "tenant_info" does not exist, skipping
NOTICE: CREATE TABLE will create implicit sequence "tenant_info_id_seq" for serial column "tenant_info.id"
NOTICE: CREATE TABLE / UNIQUE will create implicit index "tenant_info_id_key" for table "tenant_info"
NOTICE: table "users" does not exist, skipping
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "config_info_pkey" for table "config_info"
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "config_info_aggr_pkey" for table "config_info_aggr"
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "config_info_beta_pkey" for table "config_info_beta"
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "config_info_tag_pkey" for table "config_info_tag"
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
ERROR: relation "config_tags_relation" does not exist
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "group_capacity_pkey" for table "group_capacity"
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "his_config_info_pkey" for table "his_config_info"
NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "tenant_capacity_pkey" for table "tenant_capacity"
原因:
重复的自增列:每个表只能有一个自增列,而config_tags_relation表定义了两个自增列(id和nid),因此报错。
At present, Nacos has completed the expansion of sql, so that the sql adaptation of multiple data sources can be performed. Now the adaptation of mysql and derby has been completed, and adaptation plug-ins for other databases are required. Are you willing to complete it?
Link: https://nacos.io/zh-cn/docs/v2/plugin/datasource-plugin.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.