您的位置:首页 > 游戏 > 游戏 > 安徽省疫情防控最新政策_安阳县政府网_近期热点新闻事件50个_seo哪家强

安徽省疫情防控最新政策_安阳县政府网_近期热点新闻事件50个_seo哪家强

2024/12/26 1:44:44 来源:https://blog.csdn.net/qq_43417559/article/details/144273626  浏览:    关键词:安徽省疫情防控最新政策_安阳县政府网_近期热点新闻事件50个_seo哪家强
安徽省疫情防控最新政策_安阳县政府网_近期热点新闻事件50个_seo哪家强

一、前言

  由于公司的要求下要使Nacos集群以Oracle作为外部数据源,前期咱们已经阐述了如何在本地搭建(Nacos集群搭建【Oracle作外部数据源】),本次将带领大家在k8s上部署Nacos集群并以Oracle作为外部数据源。

二、软件包

  • nacos-finder-plugin.tar官方镜像包
  • nacos-server-oracle.tar自定义镜像包

说明:nacos-server-oracle.tar该镜像包经过本人dockerfile构建修改、加入了oracle相关变量、参数、以及支持oracle 11g的二次编译nacos-server.jar程序包。

三、环境

  • k8s1.23.1
  • nacos-server2.3.2
  • Oracle 11g RAC集群
    在这里插入图片描述

四、部署

1.创建命名空间

ls
cat 00-ns.yaml apiVersion: v1
kind: Namespace
metadata:name: nacosclusterlabels:app: nacosclusterkubectl apply -f 00-ns.yaml

在这里插入图片描述

2.创建存储类

cat 00-sc.yamlkind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:name: local-storage2
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumerkubectl apply -f 00-sc.yaml

3.创建pv卷

 cat pv.yaml 
apiVersion: v1
kind: PersistentVolume
metadata:name: local-storage-nacos-pv-0namespace: nacoscluster     # 空间名称labels:name: local-storage-nacos-pv-0
spec:capacity:storage: 100GiaccessModes:- ReadWriteOncepersistentVolumeReclaimPolicy: RetainstorageClassName: local-storage2local:path: /srv/nacos_data #存储卷的实际位置,与nfs暴露的文件地址相同nodeAffinity:required:nodeSelectorTerms:        # 节点选择- matchExpressions:- key: kubernetes.io/hostnameoperator: Invalues:- node3            # 根据自己节点名称
---
apiVersion: v1
kind: PersistentVolume
metadata:name: local-storage-nacos-pv-1namespace: nacoscluster     # 空间名称labels:name: local-storage-nacos-pv-1
spec:capacity:storage: 100GiaccessModes:- ReadWriteOncepersistentVolumeReclaimPolicy: RetainstorageClassName: local-storage2local:path: /srv/nacos_data #存储卷的实际位置,与nfs暴露的文件地址相同nodeAffinity:required:nodeSelectorTerms:        # 节点选择- matchExpressions:- key: kubernetes.io/hostnameoperator: Invalues:- node4            # 根据自己节点名称
---
apiVersion: v1
kind: PersistentVolume
metadata:name: local-storage-nacos-pv-2namespace: nacoscluster     # 空间名称labels:name: local-storage-nacos-pv-2
spec:capacity:storage: 100GiaccessModes:- ReadWriteOncepersistentVolumeReclaimPolicy: RetainstorageClassName: local-storage2local:path: /srv/nacos_data #存储卷的实际位置,与nfs暴露的文件地址相同nodeAffinity:required:nodeSelectorTerms:        # 节点选择- matchExpressions:- key: kubernetes.io/hostnameoperator: Invalues:- node5            # 根据自己节点名称kubectl apply -f  pv.yaml

注意:需要在对应节点(例:node3、node4、node5)创建该目录/srv/nacos_data

3.给相应节点打标签

# 用于nacos容器绑定到指定节点(可选)
kubectl label nodes node3 app=nacos
kubectl label nodes node4 app=nacos
kubectl label nodes node5 app=nacos

4.创建nacos集群

cat nacos-pvc.yaml###使用自建数据库;使用Ingress发布配置后台###
---
apiVersion: v1
kind: Service
metadata:name: nacos-headlessnamespace: nacosclusterlabels:app: nacos-headless
spec:type: ClusterIPclusterIP: Noneports:- name: tcp-8848protocol: TCPport: 8848targetPort: 8848- name: tcp-9848protocol: TCPport: 9848targetPort: 9848- name: tcp-9849protocol: TCPport: 9849targetPort: 9849- name: tcp-7848protocol: TCPport: 7848targetPort: 7848selector:app: nacos
---
# 修改以下数据库配置
apiVersion: v1
kind: ConfigMap
metadata:name: nacos-cmnamespace: nacoscluster
data:oracle.db.name: "traffic_dev"oracle.host: "192.168.200.122"oracle.password: "Sjgj20241107"oracle.port: '1521'oracle.user: "zkdn_os_init"nacos-auth-enable: 'true'nacos-auth-identity-key: nacosPlus496nacos-auth-identity-value: nacosPlus628nacos-auth-token: TmFjb3NQbHVzMDEyMzQ1Njc4OTAxMjM0NTY3ODk5ODc2NTQzMjEwMDEyMzQ1Njc4OTk4NzY1NDMyMTAwMTIzNDU2Nzg5
---
apiVersion: apps/v1
kind: StatefulSet
metadata:name: nacosnamespace: nacoscluster
spec:serviceName: nacos-headlessreplicas: 3template:metadata:labels:app: nacosannotations:pod.alpha.kubernetes.io/initialized: "true"spec:affinity:podAntiAffinity:requiredDuringSchedulingIgnoredDuringExecution:- labelSelector:matchExpressions:- key: "app"operator: Invalues:- nacostopologyKey: "kubernetes.io/hostname"initContainers:- name: peer-finder-plugin-installimage: '192.168.200.133:8080/sjgj/nacos/nacos-peer-finder-plugin:1.1'resources: {}volumeMounts:- name: pv-storage-elastic-mastermountPath: /home/nacos/plugins/peer-findersubPath: peer-findercontainers:- name: nacosimagePullPolicy: Alwaysimage: 192.168.200.133:8080/sjgj/nacos/nacos-server:v2.3.2resources:requests:memory: "2Gi"cpu: "500m"ports:- name: client-portcontainerPort: 8848protocol: TCP- name: client-rpccontainerPort: 9848protocol: TCP- name: raft-rpccontainerPort: 9849protocol: TCP- name: old-raft-rpccontainerPort: 7848protocol: TCPenv:- name: NACOS_REPLICASvalue: "3"- name: ORACLE_SERVICE_HOSTvalueFrom:configMapKeyRef:name: nacos-cmkey: oracle.host- name: ORACLE_SERVICE_DB_NAMEvalueFrom:configMapKeyRef:name: nacos-cmkey: oracle.db.name- name: ORACLE_SERVICE_PORTvalueFrom:configMapKeyRef:name: nacos-cmkey: oracle.port- name: ORACLE_SERVICE_USERvalueFrom:configMapKeyRef:name: nacos-cmkey: oracle.user- name: ORACLE_SERVICE_PASSWORDvalueFrom:configMapKeyRef:name: nacos-cmkey: oracle.password- name: MODEvalue: "cluster"- name: SPRING_DATASOURCE_PLATFORMvalue: oracle- name: NACOS_APPLICATION_PORTvalue: "8848"- name: PREFER_HOST_MODEvalue: "hostname"- name: NACOS_SERVERSvalue: "nacos-0.nacos-headless.nacoscluster.svc.cluster.local:8848 nacos-1.nacos-headless.nacoscluster.svc.cluster.local:8848 nacos-2.nacos-headless.nacoscluster.svc.cluster.local:8848"- name: NACOS_AUTH_ENABLEvalueFrom:configMapKeyRef:name: nacos-cmkey: nacos-auth-enable- name: NACOS_AUTH_IDENTITY_KEYvalueFrom:configMapKeyRef:name: nacos-cmkey: nacos-auth-identity-key- name: NACOS_AUTH_IDENTITY_VALUEvalueFrom:configMapKeyRef:name: nacos-cmkey: nacos-auth-identity-value- name: NACOS_AUTH_TOKENvalueFrom:configMapKeyRef:name: nacos-cmkey: nacos-auth-tokenvolumeMounts:- name: pv-storage-elastic-mastermountPath: /home/nacos/peer-findervolumeClaimTemplates:- metadata:name: pv-storage-elastic-masterspec:accessModes: [ "ReadWriteOnce" ]storageClassName: "local-storage2"resources:requests:storage: 100Giselector:matchLabels:app: nacoskubectl apply -f nacos-pvc.yaml 

5.创建服务端口

cat nacos-service.yaml#特别强调一点,k8s的版本不同ingress配置的一些细节不同,具体可以看看官网,
#我展示的配置信息,只能保证1.23.1版本的k8s可以使用。
#nacos-k8s里也有ingress的配置,可以参考一下
#./nacos-k8s/deploy/nacos/nacos-no-pvc-ingress.yaml
apiVersion: v1
kind: Service
metadata:name: nacosnamespace: nacoscluster
spec:ports:- name: tcp-8848protocol: TCPport: 8848targetPort: 8848- name: tcp-9848protocol: TCPport: 9848targetPort: 9848- name: tcp-9849protocol: TCPport: 9849targetPort: 9849- name: tcp-7848protocol: TCPport: 7848targetPort: 7848selector:app: nacos
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:name: nacosnamespace: nacosclusterlabels:nacos: ingress-httpannotations:kubernetes.io/ingress.class: nginx
spec:rules:- host: nacos.hdjsjb.com #自定义,ingress规定只能使用域名,没有的可以去修改host文件http:paths:- path: / #自定义,建议就这样,不然在springCloud服务注册时报错405pathType: Prefix #必须配置匹配策略backend:service: name: nacos-headlessport: number: 8848kubectl apply -f nacos-service.yaml

说明:可以在kuboard上查看

在这里插入图片描述
在这里插入图片描述

6.Nacos镜像内application.properties配置展示

cat application.properties# nacos-oracle-config
# spring
server.servlet.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos}
server.contextPath=/nacos
server.port=${NACOS_APPLICATION_PORT:8848}
server.tomcat.accesslog.max-days=30
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
server.tomcat.accesslog.enabled=${TOMCAT_ACCESSLOG_ENABLED:false}
server.error.include-message=ALWAYS
# default current work dir
server.tomcat.basedir=file:.
#*************** Config Module Related Configurations ***************#
### Deprecated configuration property, it is recommended to use `spring.sql.init.platform` replaced.
#spring.datasource.platform=${SPRING_DATASOURCE_PLATFORM:}
nacos.plugin.datasource.log.enabled=true##### If use Oracle as datasource:
spring.sql.init.platform=${SPRING_DATASOURCE_PLATFORM:}
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
db.num=${ORACLE_DATABASE_NUM:1}
db.url.0=jdbc:oracle:thin:@//${ORACLE_SERVICE_HOST}:${ORACLE_SERVICE_PORT:1521}/${ORACLE_SERVICE_DB_NAME}
db.user.0=${ORACLE_SERVICE_USER}
db.password.0=${ORACLE_SERVICE_PASSWORD}
## DB connection pool settings
db.pool.config.connectionTimeout=${DB_POOL_CONNECTION_TIMEOUT:30000}
db.pool.config.validationTimeout=10000
db.pool.config.maximumPoolSize=20
db.pool.config.minimumIdle=2
db.pool.config.driver-class-name=oracle.jdbc.OracleDriver
db.testQuery=select 1 from dual
### The auth system to use, currently only 'nacos' and 'ldap' is supported:
nacos.core.auth.enabled=${NACOS_AUTH_ENABLE:false}
nacos.core.auth.system.type=${NACOS_AUTH_SYSTEM_TYPE:nacos}
### worked when nacos.core.auth.system.type=nacos
### The token expiration in seconds:
nacos.core.auth.plugin.nacos.token.expire.seconds=${NACOS_AUTH_TOKEN_EXPIRE_SECONDS:18000}
### The default token:
nacos.core.auth.plugin.nacos.token.secret.key=${NACOS_AUTH_TOKEN:}
### 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=${NACOS_AUTH_CACHE_ENABLE:false}
nacos.core.auth.enable.userAgentAuthWhite=${NACOS_AUTH_USER_AGENT_AUTH_WHITE_ENABLE:false}
nacos.core.auth.server.identity.key=${NACOS_AUTH_IDENTITY_KEY:}
nacos.core.auth.server.identity.value=${NACOS_AUTH_IDENTITY_VALUE:}
## spring security config
### turn off security
nacos.security.ignore.urls=${NACOS_SECURITY_IGNORE_URLS:/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**}# metrics for elastic search
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
nacos.naming.distro.taskDispatchThreadCount=10
nacos.naming.distro.taskDispatchPeriod=200
nacos.naming.distro.batchSyncKeyCount=1000
nacos.naming.distro.initDataRatio=0.9
nacos.naming.distro.syncRetryDelay=5000
nacos.naming.data.warmup=true
nacos.console.ui.enabled=true
nacos.core.param.check.enabled=true

五、测试

用户名/密码:nacos/nacos
http://< IP >:8848/nacos/#/login
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

六、结束语

  到此k8sNacos集群部署Oracle作外部数据源使用讲解就完毕啦,如果有其它问题欢迎大家评论留言,如果觉得还可以,那么给作者点赞、收藏、关注吧!‌

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com