日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Eureka常用配置详解

發(fā)布時(shí)間:2024/4/13 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Eureka常用配置详解 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Part XVII. Appendix: Compendium of Configuration Properties

現(xiàn)在來討論一下Eureka的常用配置,Eureka有非常多的配置項(xiàng)Appendix:Compendium of Configuration Propertieshttps://cloud.spring.io/spring-cloud-static/Finchley.RELEASE/multi/ multi__appendix_compendium_of_configuration_properties.html所有SpringCloud的配置項(xiàng)都在這里那我們看一下Eureka有哪些,可能有上百個(gè)eureka.client.allow-redirects允許重定向eureka.client.availability-zones這個(gè)是AWS里面用的eureka.client.decoder-name解碼器的名稱This is a transient config and once the latest codecs are stable, can be removed (as there will only be one)eureka.client.enabledFlag to indicate that the Eureka client is enabled.表明Eureka Client是否可用的一個(gè)標(biāo)識(shí)eureka.client.fetch-registry在standalone里面我們有用過Indicates whether this client should fetch eureka registry information from eureka server.表明此客戶端是否從eureka服務(wù)器端拉取eureka注冊(cè)表的信息,也就是他要不要從eureka服務(wù)器上拉數(shù)據(jù),eureka.client.g-zip-content發(fā)現(xiàn)他默認(rèn)是true,說明eureka他傳輸?shù)膬?nèi)容是不是通過gzip壓縮的eureka.client.heartbeat-executor-thread-pool-size線程池的大小eureka.client.prefer-same-zone-eurekaeureka.client.region在us-east-1里面,默認(rèn)是美東,這個(gè)region,Gets the region (used in AWS datacenters) where this instance resides.eureka.client.register-with-eurekaIn some cases, you do not want your instances to be discovered whereas you just want do discover other instances.單點(diǎn)的eureka模式eureka.client.registry-fetch-interval-seconds這個(gè)是30秒Indicates how often(in seconds) to fetch the registry information from the eureka server.從eureka服務(wù)器獲取注冊(cè)信息的頻率,一秒為單位eureka.client.service-url他是個(gè)map,/*** Map of availability zone to list of fully qualified URLs to communicate with eureka* server. Each value can be a single URL or a comma separated list of alternative* locations.** Typically the eureka server URLs carry protocol,host,port,context and version* information if any. Example:* http://ec2-256-156-243-129.compute-1.amazonaws.com:7001/eureka/** The changes are effective at runtime at the next service url refresh cycle as* specified by eurekaServiceUrlPollIntervalSeconds.*/ private Map<String, String> serviceUrl = new HashMap<>();看下它是什么Map of availability zone to list of fully qualified URLs to communicate with eureka server. Each value can be a single URL or a comma separated list of alternative locations.Typically the eureka server URLs carry protocol,host,port,context and version information if any. Example: http://ec2-256-156-243-129.compute-1.amazonaws.com:7001/eureka/The changes are effective at runtime at the next service url refresh cycle as specified by eurekaServiceUrlPollIntervalSeconds.可用區(qū)的一個(gè)map,可用區(qū)的一個(gè)映射,可以理解為一個(gè)完整的URL,然后多個(gè)之間可以用逗號(hào)分隔,可以是一個(gè)URL,如果是多個(gè)的話可以用逗號(hào)分隔,通常包含很多東西,協(xié)議http,host,端口,上下文,版本信息,我們可以去改變配置,他有一個(gè)刷新周期eureka.dashboard.enabledeureka.dashboard.enabled=false會(huì)有什么效果呢,發(fā)現(xiàn)404了,dashboard是什么,其實(shí)就是eureka的首頁,就是他的界面eureka.dashboard.path默認(rèn)是/,那這個(gè)有什么應(yīng)用場(chǎng)景呢,假設(shè)我現(xiàn)在用的是高可用的eureka,那是不是每一個(gè)eureka都可以訪問,我可能不想記那么多,只允許一個(gè)可以進(jìn)行dashboard,其他的把它禁用,我只要記住端口IP就可以了,另外一個(gè)他可以自定義路徑,這樣我可以做一些偽裝之類的,就像有的時(shí)候一些系統(tǒng),他默認(rèn)的管理路徑是admin,我就可以自定義,當(dāng)然適用場(chǎng)景也非常有限了eureka.instance.appnamedruid德魯伊 eureka我找到了! eureka.instance.appname=USER-SERVICE-HAHA #debug=true server.port=7900#server.context-path=/boot02spring.http.encoding.charset=UTF-8 spring.http.encoding.enabled=true spring.http.encoding.force=truelogging.level.com.learn=trace #logging.file=D:/springboot.log logging.file=springboot.log logging.pattern.console=%d{yyyy-MM-dd} [%thread] %-5level %logger{50} - %msg%n logging.pattern.file=%d{yyyy-MM-dd} ==== [%thread] %-5level ==== %logger{50} ==== %msg%n #spring.resources.static-locations=classpath:/hello,classpath:/learnspring.datasource.username=root spring.datasource.password=123456 spring.datasource.url=jdbc:mysql://59.110.158.145:3306/SpringCloud?useSSL=false&useUnicode=true&characterEncoding=UTF-8 spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.initialSize=5 spring.datasource.minIdle=5 spring.datasource.maxActive=20 spring.datasource.maxWait=60000mybatis.config-location=classpath:mybatis/mybatis-config.xml mybatis.mapper-locations=classpath:mybatis/mapper/*.xmleureka.client.serviceUrl.defaultZone=http://admin:1234@10.40.8.152:8761/eurekaspring.application.name=microservice-simple-provider-user eureka.instance.prefer-ip-address=true eureka.instance.instance-id=${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}} #eureka.client.healthcheck.enabled=true spring.redis.host=10.40.8.152 spring.redis.password=aztech spring.redis.port=6379eureka.instance.appname=USER-SERVICE-HAHA eureka:client:healthcheck:enabled: trueserviceUrl:defaultZone: http://admin:1234@10.40.8.152:8761/eureka

org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean.appname/*** Get the name of the application to be registered with eureka.*/ private String appname = UNKNOWN;private static final String UNKNOWN = "unknown";他的作用是填坑,swagger(api document)它是可以支持聲明式的注解,然后通過注解幫我們自動(dòng)的生成API文檔,它是這樣的一個(gè)工具h(yuǎn)ttps://swagger.io/簡(jiǎn)單的說就是我寫幾個(gè)注解,Swagger的注解,跟Spring Cloud結(jié)合使用是有一定的沖突的,appname才是最原本的注冊(cè)到eureka上面的app的名稱eureka.instance.data-center-info也是AWS的eureka.instance.hostname在高可用的Eureka里面,指定這個(gè)eureka的主機(jī)名是什么,假設(shè)我現(xiàn)在在用戶微服務(wù)上面,配置hostname等于user,說明user的主機(jī)名是user,我就可以用http:user:7900/去訪問,我就會(huì)把這個(gè)信息注冊(cè)給eureka了Changing the Eureka Instance IDhttps://cloud.spring.io/spring-cloud-static/spring-cloud-netflix/1.3.1.RELEASE/A vanilla Netflix Eureka instance is registered with an ID that is equal to its host name (i.e. only one service per host). Spring Cloud Eureka provides a sensible default that looks like this: ${spring.cloud.client.hostname}:${spring.application.name} :${spring.application.instance_id:${server.port}}}. For example myhost:myappname:8080.eureka.instance.ip-addresseureka.instance.metadata-map獲取metadata的鍵值對(duì),跟instance有關(guān)系的鍵值對(duì),信息發(fā)送給eureka serverGets the metadata name/value pairs associated with this instance. This information is sent to eureka server and can be used by other instances.eureka.instance.namespaceGet the namespace used to find properties. Ignored in Spring Cloud.eureka.instance.non-secure-porteureka.instance.prefer-ip-address鼠標(biāo)拖上去的時(shí)候顯示的是IP,也就是鏈接是IP,注冊(cè)到eureka上面的是IPeureka.instance.secure-health-check-urleureka.instance.secure-port默認(rèn)HTTPS的端口,是否啟用HTTPS默認(rèn)是不啟用eureka.instance.secure-virtual-host-name虛擬的主機(jī)名eureka.instance.status-page-url狀態(tài)頁面的URLeureka.instance.virtual-host-name使用HTTP的虛擬主機(jī)名eureka.server.peer-eureka-status-refresh-time-interval-mseureka對(duì)等體狀態(tài)的刷新時(shí)間,刷新周期是毫秒

?

總結(jié)

以上是生活随笔為你收集整理的Eureka常用配置详解的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。