提示:文章写完后,目次可以自动天生,怎样天生可参考右边的帮助文档
前言
随着国家书息技术应用创新(信创)战略的深入推进,越来越多的关键技术和组件正徐徐被替换为国产化的产品与服务。这一变化不光是为了增强国家的信息安全,淘汰对外部技术的依赖,更是为了促进本土信息技术财产的自主创新本领和发展。在这一过程中,包括操纵体系、数据库、中心件、服务器硬件以及核心芯片在内的多个范畴都在经历着一场深刻的变革。
具体而言,国产化替换涉及以下几个方面:
- 操纵体系:推广利用如麒麟软件、统信UOS等国产操纵体系,以替换传统的Windows或Unix体系。
- 数据库管理体系:研发并部署达梦、人大金仓Kingbase等国产数据库,淘汰对Oracle、SQL Server等国外产品的依赖。
- 中心件:诸如东方通、中创中心件等国产产品正在逐渐取代IBM WebSphere和Oracle WebLogic等外资品牌。
- 服务器及PC终端:利用基于国产CPU架构(如龙芯、飞腾、兆芯等)的服务器和电脑,以替换Intel和AMD等厂商的产品。
- 基础软件与工具:包括办公软件、设计软件等,也在向WPS Office、中望CAD等国产化方向迁移。
此外,政策层面的支持也在不停加码,通过设立专项基金、制定行业标准、举行各类信创大赛等方式,激励企业和科研机构加快技术创新和产品迭代。同时,市场需求的增长也为国产信息技术产品和服务提供了广阔的市场空间,促进了整个财产链的成熟与发展。随着这些措施的有效实施,不光能够提拔国家书息基础办法的安全性和自主性,还将极大地推动中国信息技术财产的整体进步与国际竞争力的提拔。
提示:以下是本篇文章正文内容,下面案例可供参考
一、Nacos2.4.1版本适配人大金仓数据库
近期,Nacos爆出了任意文件读写毛病,Nacos2版本影响的为2.0.0-2.4.0.1,需要升级到2.4.1版本,为了相应国家号召,本次利用了人大金仓数据库,版本为8.6.0
二、适配步骤
1.修改Nacos最外层pom,参加人大金仓依赖版本
- <properties>
- <kingbase8-connector-java.version>8.6.0</kingbase8-connector-java.version>
- </properties>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>com.kingbase8</groupId>
- <artifactId>kingbase8</artifactId>
- <version>${kingbase8-connector-java.version}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
复制代码 2.修改config模块下的pom,增加人大金仓依赖
- <dependency>
- <groupId>com.kingbase8</groupId>
- <artifactId>kingbase8</artifactId>
- </dependency>
复制代码 3.修改console模块下resources中的application.properties和distribution模块下conf包中的application.properties
注意,其中{}中的内容替换成本身的
- #
- # Copyright 1999-2021 Alibaba Group Holding Ltd.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- #
- #*************** Spring Boot Related Configurations ***************#
- ### Default web context path:
- server.servlet.contextPath=/nacos
- ### Default web server port:
- server.port=8858
- #*************** Network Related Configurations ***************#
- ### If prefer hostname over ip for Nacos server addresses in cluster.conf:
- # nacos.inetutils.prefer-hostname-over-ip=false
- ### Specify local server's IP:
- # nacos.inetutils.ip-address=
- #*************** Config Module Related Configurations ***************#
- ### If use MySQL or KingbaseES as datasource:
- spring.datasource.platform=mysql
- ### Count of DB:
- db.num=1
- ### Connect URL of DB:
- # db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
- # db.user.0=nacos
- # db.password.0=nacos
- ### KingbaseES
- db.jdbcDriverName=com.kingbase8.Driver
- db.url.0=jdbc:kingbase8://{ip}:{port}/{dataSourceName}
- db.user.0={username}
- db.password.0={password}
- ### Connection pool configuration: hikariCP
- db.pool.config.connectionTimeout=30000
- db.pool.config.validationTimeout=10000
- db.pool.config.maximumPoolSize=20
- db.pool.config.minimumIdle=2
- #*************** Naming Module Related Configurations ***************#
- ### Data dispatch task execution period in milliseconds: Will removed on v2.1.X, replace with nacos.core.protocol.distro.data.sync.delayMs
- # nacos.naming.distro.taskDispatchPeriod=200
- ### Data count of batch sync task: Will removed on v2.1.X. Deprecated
- # nacos.naming.distro.batchSyncKeyCount=1000
- ### Retry delay in milliseconds if sync task failed: Will removed on v2.1.X, replace with nacos.core.protocol.distro.data.sync.retryDelayMs
- # nacos.naming.distro.syncRetryDelay=5000
- ### If enable data warmup. If set to false, the server would accept request without local data preparation:
- # nacos.naming.data.warmup=true
- ### If enable the instance auto expiration, kind like of health check of instance:
- # nacos.naming.expireInstance=true
- ### will be removed and replaced by `nacos.naming.clean` properties
- nacos.naming.empty-service.auto-clean=true
- nacos.naming.empty-service.clean.initial-delay-ms=50000
- nacos.naming.empty-service.clean.period-time-ms=30000
- ### Add in 2.0.0
- ### The interval to clean empty service, unit: milliseconds.
- # nacos.naming.clean.empty-service.interval=60000
- ### The expired time to clean empty service, unit: milliseconds.
- # nacos.naming.clean.empty-service.expired-time=60000
- ### The interval to clean expired metadata, unit: milliseconds.
- # nacos.naming.clean.expired-metadata.interval=5000
- ### The expired time to clean metadata, unit: milliseconds.
- # nacos.naming.clean.expired-metadata.expired-time=60000
- ### The delay time before push task to execute from service changed, unit: milliseconds.
- # nacos.naming.push.pushTaskDelay=500
- ### The timeout for push task execute, unit: milliseconds.
- # nacos.naming.push.pushTaskTimeout=5000
- ### The delay time for retrying failed push task, unit: milliseconds.
- # nacos.naming.push.pushTaskRetryDelay=1000
- ### Since 2.0.3
- ### The expired time for inactive client, unit: milliseconds.
- # nacos.naming.client.expired.time=180000
- #*************** CMDB Module Related Configurations ***************#
- ### The interval to dump external CMDB in seconds:
- # nacos.cmdb.dumpTaskInterval=3600
- ### The interval of polling data change event in seconds:
- # nacos.cmdb.eventTaskInterval=10
- ### The interval of loading labels in seconds:
- # nacos.cmdb.labelTaskInterval=300
- ### If turn on data loading task:
- # nacos.cmdb.loadDataAtStart=false
- #*************** Metrics Related Configurations ***************#
- ### Metrics for prometheus
- #management.endpoints.web.exposure.include=*
- ### Metrics for elastic search
- management.metrics.export.elastic.enabled=false
- #management.metrics.export.elastic.host=http://localhost:9200
- ### Metrics for influx
- management.metrics.export.influx.enabled=false
- #management.metrics.export.influx.db=springboot
- #management.metrics.export.influx.uri=http://localhost:8086
- #management.metrics.export.influx.auto-create-db=true
- #management.metrics.export.influx.consistency=one
- #management.metrics.export.influx.compressed=true
- #*************** Access Log Related Configurations ***************#
- ### If turn on the access log:
- server.tomcat.accesslog.enabled=true
- ### The access log pattern:
- server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
- ### The directory of access log:
- server.tomcat.basedir=file:.
- #*************** Access Control Related Configurations ***************#
- ### If enable spring security, this option is deprecated in 1.2.0:
- #spring.security.enabled=false
- ### The ignore urls of auth, is deprecated in 1.2.0:
- nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
- ### The auth system to use, currently only 'nacos' and 'ldap' is supported:
- nacos.core.auth.system.type=nacos
- ### If turn on auth system:
- nacos.core.auth.enabled=true
- ### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
- nacos.core.auth.caching.enabled=true
- ### Since 1.4.1, Turn on/off white auth for user-agent: nacos-server, only for upgrade from old version.
- nacos.core.auth.enable.userAgentAuthWhite=false
- ### Since 1.4.1, worked when nacos.core.auth.enabled=true and nacos.core.auth.enable.userAgentAuthWhite=false.
- ### The two properties is the white list for auth and used by identity the request from other server.
- nacos.core.auth.server.identity.key=serverIdentity
- nacos.core.auth.server.identity.value=security
- ### worked when nacos.core.auth.system.type=nacos
- ### The token expiration in seconds:
- nacos.core.auth.plugin.nacos.token.expire.seconds=18000
- ### The default token:
- nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
- ### worked when nacos.core.auth.system.type=ldap?{0} is Placeholder,replace login username
- #nacos.core.auth.ldap.url=ldap://localhost:389
- #nacos.core.auth.ldap.basedc=dc=example,dc=org
- #nacos.core.auth.ldap.userDn=cn=admin,${nacos.core.auth.ldap.basedc}
- #nacos.core.auth.ldap.password=admin
- #nacos.core.auth.ldap.userdn=cn={0},dc=example,dc=org
- #*************** Istio Related Configurations ***************#
- ### If turn on the MCP server:
- nacos.istio.mcp.server.enabled=false
- #*************** Core Related Configurations ***************#
- ### set the WorkerID manually
- # nacos.core.snowflake.worker-id=
- ### Member-MetaData
- # nacos.core.member.meta.site=
- # nacos.core.member.meta.adweight=
- # nacos.core.member.meta.weight=
- ### MemberLookup
- ### Addressing pattern category, If set, the priority is highest
- # nacos.core.member.lookup.type=[file,address-server]
- ## Set the cluster list with a configuration file or command-line argument
- # nacos.member.list=192.168.16.101:8847?raft_port=8807,192.168.16.101?raft_port=8808,192.168.16.101:8849?raft_port=8809
- ## for AddressServerMemberLookup
- # Maximum number of retries to query the address server upon initialization
- # nacos.core.address-server.retry=5
- ## Server domain name address of [address-server] mode
- # address.server.domain=jmenv.tbsite.net
- ## Server port of [address-server] mode
- # address.server.port=8080
- ## Request address of [address-server] mode
- # address.server.url=/nacos/serverlist
- #*************** JRaft Related Configurations ***************#
- ### Sets the Raft cluster election timeout, default value is 5 second
- # nacos.core.protocol.raft.data.election_timeout_ms=5000
- ### Sets the amount of time the Raft snapshot will execute periodically, default is 30 minute
- # nacos.core.protocol.raft.data.snapshot_interval_secs=30
- ### raft internal worker threads
- # nacos.core.protocol.raft.data.core_thread_num=8
- ### Number of threads required for raft business request processing
- # nacos.core.protocol.raft.data.cli_service_thread_num=4
- ### raft linear read strategy. Safe linear reads are used by default, that is, the Leader tenure is confirmed by heartbeat
- # nacos.core.protocol.raft.data.read_index_type=ReadOnlySafe
- ### rpc request timeout, default 5 seconds
- # nacos.core.protocol.raft.data.rpc_request_timeout_ms=5000
- #*************** Distro Related Configurations ***************#
- ### Distro data sync delay time, when sync task delayed, task will be merged for same data key. Default 1 second.
- # nacos.core.protocol.distro.data.sync.delayMs=1000
- ### Distro data sync timeout for one sync data, default 3 seconds.
- # nacos.core.protocol.distro.data.sync.timeoutMs=3000
- ### Distro data sync retry delay time when sync data failed or timeout, same behavior with delayMs, default 3 seconds.
- # nacos.core.protocol.distro.data.sync.retryDelayMs=3000
- ### Distro data verify interval time, verify synced data whether expired for a interval. Default 5 seconds.
- # nacos.core.protocol.distro.data.verify.intervalMs=5000
- ### Distro data verify timeout for one verify, default 3 seconds.
- # nacos.core.protocol.distro.data.verify.timeoutMs=3000
- ### Distro data load retry delay when load snapshot data failed, default 30 seconds.
- # nacos.core.protocol.distro.data.load.retryDelayMs=30000
复制代码 3.修改persistence模块下com/alibaba/nacos/persistence/datasource包中ExternalDataSourceProperties类的JDBC_DRIVER_NAME常量
- // private static final String JDBC_DRIVER_NAME = "com.mysql.cj.jdbc.Driver";
- private static final String JDBC_DRIVER_NAME = "com.kingbase8.Driver";
复制代码 4.修改plugin模块下datasource子模块下com/alibaba/nacos/plugin/datasource/enums/mysql包中的TrustedMysqlFunctionEnum枚举类
- //人大金仓中NOW()函数没有入参,该入参是mysql的now(integer)函数为了设置毫秒位数使用,而人大金仓中NOW()函数默认是带着毫秒的
- // NOW("NOW()", "NOW(3)");
- NOW("NOW()", "NOW()");
复制代码 5.利用命令打包
- mvn -Prelease-nacos "-Dmaven.test.skip=true" clean install -U --settings {自己的settings.xml路径}
复制代码 至此,全部完成,天生的jar会存放在项目的distribution模块的target中
总结
本次升级完成,由原来的mysql支持替换成人大金仓kingbase,2.4.1版本适配人大金仓相对比较简单,如需要前期其他版本,可以留言给我,谢谢。
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |