当前位置: 首页 > news >正文

网站代运营做哪些无网站无产品链接如何做SOHO

网站代运营做哪些,无网站无产品链接如何做SOHO,嵌入式软件开发文档,php网站建设招聘高可用连接方式 1、双机部署#xff1a;Eureka的server端相互注册#xff0c;自动相互同步应用信息。Eureka的client端注册到任意一个上面即可#xff0c;但为了保险起见#xff0c;可以同时注册到两个上面#xff0c;防止client注册到server1后#xff0c;server1挂掉Eureka的server端相互注册自动相互同步应用信息。Eureka的client端注册到任意一个上面即可但为了保险起见可以同时注册到两个上面防止client注册到server1后server1挂掉client重启后注册不上。 2、集群部署至少需要3个Eureka实例才能满足高可用配置方法如下准备三个节点node1、node2、node3。在每个实例的application.xml文件里加入eureka.client.service-url.defaultZone{address}address是其他节点的地址。如果是node1address就是http://node2/eureka、http://node3/eureka其他节点依次类推。启动三个实例注册信息会在他们之间互相同步。 3、负载均衡客户端可以向多个Eureka节点发起请求通过负载均衡算法选择一个节点来获取服务。这种方式可以在多个Eureka节点之间实现负载均衡和故障转移。 以上是Eureka高可用连接方式的一些实现方式可以根据实际场景选择适合的方式来实现高可用连接。 双机部署方式–实践 架构图 1、Eureka-server1 java代码 package com.ldzg;import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.Environment;import java.net.InetAddress; import java.net.UnknownHostException;Slf4j EnableEurekaServer SpringBootApplication public class EurekaServerApplication {public static void main(String[] args) throws UnknownHostException {ConfigurableApplicationContext application SpringApplication.run(EurekaServerApplication.class, args);Environment env application.getEnvironment();String ip InetAddress.getLocalHost().getHostAddress();String port env.getProperty(server.port);String path ;// env.getProperty(server.servlet.context-path);log.info(\n----------------------------------------------------------\n\t Application Eureka is running! Access URLs:\n\t Local: \t\thttp://localhost: port path /\n\t External: \thttp:// ip : port path /\n\t swagger-ui: \thttp:// ip : port path /swagger-ui.html\n\t Doc: \t\thttp:// ip : port path /doc.html\n ----------------------------------------------------------);}}package com.ldzg.config;import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;/*** 默认情况下SpringSecurity依赖的应用每个请求都需要添加CSRF token才能访问* Eureka客户端注册时并不会添加所以需要配置/eureka/**路径不需要CSRF token。* Created by macro on 2024/1/12.*/ EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter {Overrideprotected void configure(HttpSecurity http) throws Exception {http.csrf().ignoringAntMatchers(/eureka/**);super.configure(http);} } pom.xml文件 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdspringcloud-learning/artifactIdgroupIdcom.ldzg/groupIdversion1.1-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdeureka-server1/artifactIddependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-server/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-security/artifactId/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build/projectapplication.yml配置文件说明 spring:profiles:active: replica1 #需要使用的配置文件的后缀application-replica1.yml server:port: 60001 spring:application:name: eureka-serversecurity: #配置SpringSecurity登录用户名和密码basic:enabled: trueuser:name: ldzgpassword: 123456 eureka:instance:hostname: replica1client:serviceUrl:defaultZone: http://ldzg:123456replica2:60002/eureka/ #注册到另一个Eureka注册中心fetch-registry: falseregister-with-eureka: false运行结果 2、Eureka-server2 java代码 package com.ldzg;import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.Environment;import java.net.InetAddress; import java.net.UnknownHostException;Slf4j EnableEurekaServer SpringBootApplication public class EurekaServerApplication {public static void main(String[] args) throws UnknownHostException {ConfigurableApplicationContext application SpringApplication.run(EurekaServerApplication.class, args);Environment env application.getEnvironment();String ip InetAddress.getLocalHost().getHostAddress();String port env.getProperty(server.port);//String path env.getProperty(server.servlet.context-path);log.info(\n----------------------------------------------------------\n\t Application Eureka is running! Access URLs:\n\t Local: \t\thttp://localhost: port /\n\t External: \thttp:// ip : port /\n\t swagger-ui: \thttp:// ip : port /swagger-ui.html\n\t Doc: \t\thttp:// ip : port /doc.html\n ----------------------------------------------------------);}}package com.ldzg.config;import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;/*** 默认情况下SpringSecurity依赖的应用每个请求都需要添加CSRF token才能访问* Eureka客户端注册时并不会添加所以需要配置/eureka/**路径不需要CSRF token。* Created by macro on 2024/1/12.*/ EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter {Overrideprotected void configure(HttpSecurity http) throws Exception {http.csrf().ignoringAntMatchers(/eureka/**);super.configure(http);} } pom.xml文件 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdspringcloud-learning/artifactIdgroupIdcom.ldzg/groupIdversion1.1-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdeureka-server2/artifactIddependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-server/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-security/artifactId/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build/projectapplication.yml配置文件说明 spring:profiles:active: replica2 #需要使用的配置文件的后缀application-replica2.yml server:port: 60002 spring:application:name: eureka-serversecurity: #配置SpringSecurity登录用户名和密码basic:enabled: trueuser:name: ldzgpassword: 123456 eureka:instance:hostname: replica2client:serviceUrl:defaultZone: http://ldzg:123456replica1:60001/eureka/ #注册到另一个Eureka注册中心fetch-registry: trueregister-with-eureka: true运行结果 3、Eureka-client java代码 package com.ldzg;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;EnableDiscoveryClient SpringBootApplication public class EurekaClientApplication {public static void main(String[] args) {SpringApplication.run(EurekaClientApplication.class, args);}} pom.xml文件 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdspringcloud-learning/artifactIdgroupIdcom.ldzg/groupIdversion1.1-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdeureka-client/artifactIdversion0.0.1-SNAPSHOT/versionnameeureka-client/namedescription Spring cloud/description!-- dependencies-- !-- dependency-- !-- groupIdorg.springframework.boot/groupId-- !-- artifactIdspring-boot-starter-security/artifactId-- !-- /dependency-- !-- /dependencies--buildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build/projectapplication.yml配置文件说明 spring:profiles:active: replica #需要使用的配置文件的后缀application-replica.yml server:port: 8102 spring:application:name: eureka-client eureka:client:register-with-eureka: truefetch-registry: trueservice-url:defaultZone: http://ldzg:123456replica1:60001/eureka/,http://ldzg:123456replica2:60002/eureka/ #同时注册到两个注册中心运行结果 4、Eureka-consumer java代码 package com.ldzg;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; EnableDiscoveryClient SpringBootApplication public class UserServiceApplication {public static void main(String[] args) {SpringApplication.run(UserServiceApplication.class, args);}} pom.xml文件 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdparentartifactIdspringcloud-learning/artifactIdgroupIdcom.ldzg/groupIdversion1.1-SNAPSHOT/version/parentmodelVersion4.0.0/modelVersionartifactIdspringcloud-consumer/artifactIdpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.target/propertiesdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-client/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-openfeign/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build /projectapplication.yml配置文件说明 spring:profiles:active: replica #需要使用的配置文件的后缀application-replica.yml server:port: 61002 spring:application:name: eureka-consumer eureka:client:register-with-eureka: truefetch-registry: trueservice-url:defaultZone: http://ldzg:123456replica1:60001/eureka/,http://ldzg:123456replica2:60002/eureka/ #同时注册到两个注册中心运行结果 5、注册服务中心结果页面 注册中心1 注册中心2 欢迎关注我的公众号不仅为你推荐最新的博文还有更多惊喜和资源在等着你!一起学习共同进步
http://www.pierceye.com/news/12427/

相关文章:

  • 连云港建设网站公司江西企业登记网络服务平台
  • 潍坊网站制作建设学校网站建设注意什么
  • 单位网站建设情况总结网站建设及相关流程
  • 南京城乡建设局网站首页青海最新信息
  • 电子商务网站建设平台wordpress网站logo没显示
  • 微信公众号红包网站开发漳州企业网站建设制作
  • 网站及微站建设合同验收网站开发需求分析内容
  • 安徽 电子政务网站定制北京网站公司哪家好
  • 企业网站建立wordpress设置内容标题
  • 免版权图片网站西宁建设工程信息网站
  • visual制作网站开发建设银行反钓鱼网站
  • 咋样着做自己的网站营销型网站建设区别
  • 包头网站建设 奥北服装设计好找工作吗
  • 电子商务系统建设网站策划书上海网页制作系统
  • 做网站用软件广告网络用语
  • 网站建设-丹东wordpress php文件
  • 石家庄网站搭建定制微信怎样建立公众号
  • 做整装的网站google中文搜索引擎入口
  • 迪奥生物做图网站餐厅网站建设
  • 做一个同城便民信息网站怎么做网站建设网络公
  • 做ppt卖给网站长春网站建设服务
  • 即墨哪里有做网站的河北项目网手机版
  • 北京seo公司网站游戏优化大师官网
  • 万网怎么做网站临海建设规划局网站
  • frontpage做的社交网站简述你身边的网络营销事件
  • app网站公司名称网络舆情监测工作总结
  • 网站设计公司成都一些做淘宝优惠券的网站
  • 网站系统制作教程建设网站是什么
  • 网站设计平台青岛城运控股集团
  • 做公益网站怎么赚钱成品电影网站建设