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

微信企业号可以做微网站吗四年级下册数学优化设计答案

微信企业号可以做微网站吗,四年级下册数学优化设计答案,网站建设开发程序代码,大型免费网页游戏排行榜文章目录 前言Nacos集群搭建Spring cloud配置nacos将Springcloud项目部署在k8s写在最后 前言 相信很多同学都开发过以微服务为架构的系统,开发微服务必不可少要使用注册中心,比如nacos\consul等等。当然在自动化运维流行的今天,我们也会将注…

文章目录

    • 前言
    • Nacos集群搭建
    • Spring cloud配置nacos
    • 将Springcloud项目部署在k8s
    • 写在最后

前言

相信很多同学都开发过以微服务为架构的系统,开发微服务必不可少要使用注册中心,比如nacos\consul等等。当然在自动化运维流行的今天,我们也会将注册中心部署在k8s集群中。今天我们就分享一期使用helm部署nacos到k8s集群并接入soringcloud项目,各位大大敬请鉴赏。值得注意的是使用helm在k8s部署中间件应用,真的比原始部署简单太多。

Nacos集群搭建

首先我们先从官网把nacos helm相关的代码down下来

git clone https://github.com/nacos-group/nacos-k8s.git

然后进入到helm目录,修改values.yaml文件,下面是我的:

# Default values for nacos.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.global:#mode: standalonemode: cluster############################nacos###########################
namespace: nacos-cluster  ## 命名空间
nacos:image:repository: nacos/nacos-servertag: latestpullPolicy: IfNotPresentplugin:enable: trueimage:repository: nacos/nacos-peer-finder-plugintag: 1.1pullPolicy: IfNotPresentreplicaCount: 3 ## 节点数podManagementPolicy: ParalleldomainName: cluster.localpreferhostmode: hostnameserverPort: 8848health:enabled: truestorage:#type: embedded  type: mysql  ## 用mysql保存配置信息db:host: mysql-cluster-primary.mysql-cluster.svc.cluster.localname: nacosport: 3306username: rootpassword: 123456rootparam: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=trueservice:#type: ClusterIPtype: NodePortport: 8848nodePort: 30000############################nacos###########################

接着我们来安装nacos,如下所示:
#数据库增加nacos库
#创建命名空间

[root@master helm]# kubectl create ns nacos-cluster

namespace/nacos-cluster created
#安装nacos

[root@master helm]# helm install nacos-cluster -n nacos-cluster .

NAME: nacos-cluster
LAST DEPLOYED: Tue Sep 5 10:16:46 2023
NAMESPACE: nacos-cluster
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:

  1. Get the application URL by running these commands:
    export NODE_PORT= ( k u b e c t l g e t − − n a m e s p a c e n a c o s − c l u s t e r − o j s o n p a t h = " . s p e c . p o r t s [ 0 ] . n o d e P o r t " s e r v i c e s n a c o s − c s ) e x p o r t N O D E I P = (kubectl get --namespace nacos-cluster -o jsonpath="{.spec.ports[0].nodePort}" services nacos-cs) export NODE_IP= (kubectlgetnamespacenacosclusterojsonpath=".spec.ports[0].nodePort"servicesnacoscs)exportNODEIP=(kubectl get nodes --namespace nacos-cluster -o jsonpath=“{.items[0].status.addresses[0].address}”)
    echo http:// N O D E I P : NODE_IP: NODEIP:NODE_PORT/nacos
  2. MODE:
    standalone: you need to modify replicaCount in the values.yaml, .Values.replicaCount=1
    cluster: kubectl scale sts nacos-cluster-nacos --replicas=3

#重新部署 的命令是 helm upgrade nacos-cluster -n nacos-cluster .

安装好了之后,我们查看控制台显示是不是安装好了,如下所示:

[root@master helm]# kubectl get pods,svc -n nacos-cluster

NAME READY STATUS RESTARTS AGE
pod/nacos-cluster-0 0/1 Running 0 67s
pod/nacos-cluster-1 0/1 Running 0 67s
pod/nacos-cluster-2 0/1 Running 0 67s

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/nacos-cs NodePort 10.98.1.221 8848:30040/TCP,9848:31784/TCP,9849:30165/TCP,7848:30000/TCP 67s
service/nacos-hs ClusterIP None 8848/TCP,9848/TCP,9849/TCP,7848/TCP

很显然安装成功了!然后我们获取一下ip和port

[root@node2 ~]#   export NODE_PORT=$(kubectl get --namespace nacos-cluster -o jsonpath="{.spec.ports[0].nodePort}" services  nacos-cs)export NODE_IP=$(kubectl get nodes --namespace nacos-cluster -o jsonpath="{.items[0].status.addresses[0].address}")echo http://$NODE_IP:$NODE_PORT/nacos[root@node2 ~]#   export NODE_IP=$(kubectl get nodes --namespace nacos-cluster -o jsonpath="{.items[0].status.addresses[0].address}")

http://10.10.22.91:31673/nacos

这里说明一下,因为nacos ui是通过http协议访问的,而且8848端口是提供web访问的,所以这里的8848对外的端口就是31673,然后我们在浏览器中输入:xxx.xxx.xxx.xxx:31673就可以访问了,如下所示:
在这里插入图片描述

Spring cloud配置nacos

nacos安装成功之后,我们可以在springcloud中配置并使用,下面是我的配置步骤:
1、引入依赖包

<modelVersion>4.0.0</modelVersion>
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.12.RELEASE</version><relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>k8s-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>k8s-demo</name>
<description>Demo project for Spring Boot</description>
<properties><java.version>8</java.version><spring-cloud.version>Hoxton.SR10</spring-cloud.version>
</properties><!-- nacos start -->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId><version>2.2.3.RELEASE</version>
</dependency>
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2.2.3.RELEASE</version>
</dependency>
<!-- nacos end --><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency></dependencies>
</dependencyManagement>

2、配置启动类

/*** K8sDemoApplication* @return a* @author senfel* @date 2023/9/5 15:02*/
@SpringBootApplication
@EnableDiscoveryClient
public class K8sDemoApplication {public static void main(String[] args) {SpringApplication.run(K8sDemoApplication.class, args);}}

3、配置bootstrap.yaml
注意,nacos在springcloud中对应的端口是暴露外网端口30040

server:port: 9999
spring:application:name: test-demoprofiles:active: devredis:host: 10.10.22.91port: 30617password: 123456pwtimeout: 5000database: 0jedis:pool:max-active: 1000max-idle: 50min-idle: 4cloud:nacos:config:server-addr: 10.10.22.82:30040,10.10.22.91:30040,10.10.22.199:30040username: nacospassword: nacosfile-extension: yamldiscovery:server-addr: 10.10.22.82:30040,10.10.22.91:30040,10.10.22.199:30040username: nacospassword: nacos

设置完成启动正常。
在这里插入图片描述
在这里插入图片描述

注意:如果新增配置报参数异常
1.删掉config_info 和 his_config_info 表中的encrypted_data_key字段
2.config_info 和 his_config_info 表中非空encrypted_data_key字段设置为可以为空

将Springcloud项目部署在k8s

在上述配置的基础上
在k8s集群中用域名进行配置

server:port: 9999
spring:application:name: test-demoprofiles:active: devredis:host: 10.10.22.91port: 30617password: 123456pwtimeout: 5000database: 0jedis:pool:max-active: 1000max-idle: 50min-idle: 4cloud:nacos:config:server-addr: nacos-cs.nacos-cluster.svc.cluster.local:8848username: nacospassword: nacosfile-extension: yamldiscovery:server-addr: nacos-cs.nacos-cluster.svc.cluster.local:8848username: nacospassword: nacos

注意:headless 服务没有负载均衡,一般集群我们都访问普通svc

增加配置:
pom.xml

<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>

启动类开启feign client

 @EnableFeignClients

增加测试feign代码
DemoService

/*** test feign* @author senfel* @version 1.0* @date 2023/9/5 16:18*/
@Service
@FeignClient(value = "k8s-demo",fallback = FailDemoService.class)
public interface DemoService {/*** test feign*/@GetMapping("/feign")String feign(@RequestParam String str);
}

FailDemoService

/*** FailDemoService* @author senfel* @version 1.0* @date 2023/9/5 16:20*/
@Slf4j
@Service
public class FailDemoService  implements DemoService {@Overridepublic String feign(String str) {log.error("调用feign传入参数{},已降级。",str);return null;}
}

AppController

/*** AppController {* @author senfel* @version 1.0* @date 2023/9/5 16:25*/
@Slf4j
@RestController
public class AppController {@Value("${app.name}")private String appName;@Resourceprivate DemoService demoService;/*** getRedisValueByKey* @param key* @author senfel* @date 2023/8/31 16:22* @return java.lang.String*/@GetMapping("/getRedisValueByKey")public String getRedisValueByKey(String key){try{if(null == key){return null;}String str = RedisUtil.getString(key);log.error("获取redis中key:{}的数据为:{}",key,str);log.error("测试nacos配置,app.name:{}",appName);str = "redis-"+key+":"+str+",nacos-appName:"+appName;//调用feignString feign = demoService.feign(str);return feign;}catch (Exception e){e.printStackTrace();return e.getMessage();}}/*** feign* @param str* @author senfel* @date 2023/9/5 16:26* @return java.lang.String*/@GetMapping("feign")public String feign(@RequestParam String str){try{InetAddress address = InetAddress.getLocalHost();System.out.println(address.getHostName());//主机名System.out.println(address.getCanonicalHostName());//主机别名System.out.println(address.getHostAddress());//获取IP地址}catch (Exception e){e.printStackTrace();}return str+"-feign-success";}
}

制作app镜像
Dockerfile

# version 1.0
# 基础镜像
FROM openjdk:8-jre
# 维护人
MAINTAINER senfel<187@sina.cn>
# 创建目录
RUN mkdir -p /home/app
# 拷贝项目jar
COPY ./target/k8s-demo-0.0.1-SNAPSHOT.jar /home/app/app.jar
# 执行命令启动jar
ENTRYPOINT ["java","-jar","/home/app/app.jar"]
# 暴露端口
EXPOSE 9999

将本地jar打包成镜像并提交到云仓库

docker build -t k8s-demo-nacos:v1.0.0 .

编写kube执行文件
kube-k8s-demo-nacos.yaml

apiVersion: apps/v1
kind: Deployment # 声明一个Deployment资源对象
metadata:name: deployment-myapp
spec:replicas: 3 # 通过replicas声明pod个数是3selector:   # 通过标签选择被控制的podmatchLabels:app: myapptemplate:   # 在template中定义podmetadata:labels: # 给pod打上标签app=myappapp: myappspec:containers:- name: myapp  # 声明容器名称,注意不是pod名称,pod名称应该定义在metadata中image: registry.cn-hangzhou.aliyuncs.com/senfel/k8s-demo-nacos:v1.0.0ports:- name: httpcontainerPort: 9999
--- # 在一个yaml文件中通过---分割多个资源对象
apiVersion: v1
kind: Service # 声明一个Service资源对象
metadata:name: service-myapp
spec:type: NodePortselector: # service-myapp将选择标签包含app=myapp的podapp: myappports:- name: httpport: 9999  # Service监听端口targetPort: 9999 # 转发到后端Pod的端口号protocol: TCP # tcp协议nodePort: 30999 # 外网访问端口,范围:30000-32767

执行kube

kubectl apply -f kube-k8s-demo-nacos.yaml

查看执行结果

[root@master k8s]# kubectl get pods,svc | grep app

pod/deployment-myapp-9c6fb8dd9-jvmwl 1/1 Running 0 14m
pod/deployment-myapp-9c6fb8dd9-z64zj 1/1 Running 0 14m
pod/deployment-myapp-9c6fb8dd9-zklpc 1/1 Running 0 14m
service/service-myapp NodePort 10.102.62.181 9999:30999/TCP 14m
#删除pod svc

kubectl delete -f kube-k8s-demo-nacos.yaml

查看nacos情况
配置列表:
在这里插入图片描述

服务集群:
在这里插入图片描述

测试app集群是否正常服务
posman测试
在这里插入图片描述

写在最后

在k8s中部署nacos还是使用helm比较简单,直接下载安装包修改配置文件安装即可。我们在Springcloud、Springboot项目中集成nacos需要注意需要使用集群内部地址,当我们将项目部署在k8s集群中可以直接使用nacos配置和查询服务集群。


文章转载自:
http://dinncofellable.bkqw.cn
http://dinncoclamant.bkqw.cn
http://dinncothrombokinase.bkqw.cn
http://dinncobash.bkqw.cn
http://dinncodemurrer.bkqw.cn
http://dinncogeodetic.bkqw.cn
http://dinncoiconolatrous.bkqw.cn
http://dinncozho.bkqw.cn
http://dinncotriones.bkqw.cn
http://dinncoventriculi.bkqw.cn
http://dinncoopposability.bkqw.cn
http://dinncolevoglucose.bkqw.cn
http://dinncomorphinism.bkqw.cn
http://dinncoere.bkqw.cn
http://dinncoaccessable.bkqw.cn
http://dinncominify.bkqw.cn
http://dinncodance.bkqw.cn
http://dinncoparasol.bkqw.cn
http://dinncodetoxify.bkqw.cn
http://dinncorelict.bkqw.cn
http://dinncomodish.bkqw.cn
http://dinncobrindled.bkqw.cn
http://dinncomoil.bkqw.cn
http://dinncopolacolor.bkqw.cn
http://dinncoestaminet.bkqw.cn
http://dinncotriunity.bkqw.cn
http://dinncodisinfect.bkqw.cn
http://dinncomarksman.bkqw.cn
http://dinncoterrazzo.bkqw.cn
http://dinncomercurialism.bkqw.cn
http://dinncoreplevin.bkqw.cn
http://dinncoshyster.bkqw.cn
http://dinncoexteriority.bkqw.cn
http://dinncohareem.bkqw.cn
http://dinncodeltoidal.bkqw.cn
http://dinncovoetstoots.bkqw.cn
http://dinncocollegiality.bkqw.cn
http://dinncomatman.bkqw.cn
http://dinncoterebinth.bkqw.cn
http://dinncomultipolar.bkqw.cn
http://dinncolonganimous.bkqw.cn
http://dinncovainness.bkqw.cn
http://dinncotherein.bkqw.cn
http://dinncosnuffcoloured.bkqw.cn
http://dinncoabsorbent.bkqw.cn
http://dinncoduplicator.bkqw.cn
http://dinncoarugula.bkqw.cn
http://dinncotrial.bkqw.cn
http://dinncochymotrypsinogen.bkqw.cn
http://dinncoseedpod.bkqw.cn
http://dinncofriskily.bkqw.cn
http://dinncotumultuate.bkqw.cn
http://dinncosmocking.bkqw.cn
http://dinncosubcuticular.bkqw.cn
http://dinncotft.bkqw.cn
http://dinncoincog.bkqw.cn
http://dinncoinadaptable.bkqw.cn
http://dinncocoelomatic.bkqw.cn
http://dinncotapping.bkqw.cn
http://dinncomarmoset.bkqw.cn
http://dinncojaboticaba.bkqw.cn
http://dinncotetra.bkqw.cn
http://dinncomouser.bkqw.cn
http://dinncodiscretionarily.bkqw.cn
http://dinncoheads.bkqw.cn
http://dinncolacunose.bkqw.cn
http://dinncoorchardman.bkqw.cn
http://dinncokidlet.bkqw.cn
http://dinncodemyelination.bkqw.cn
http://dinncohemocytoblastic.bkqw.cn
http://dinncopontify.bkqw.cn
http://dinncotownship.bkqw.cn
http://dinncotargeman.bkqw.cn
http://dinncoscentless.bkqw.cn
http://dinncotattletale.bkqw.cn
http://dinncosurfboat.bkqw.cn
http://dinncochamfer.bkqw.cn
http://dinncosiderochrome.bkqw.cn
http://dinncotransfix.bkqw.cn
http://dinncoteleologic.bkqw.cn
http://dinncogasolier.bkqw.cn
http://dinncomesmerization.bkqw.cn
http://dinncohamadan.bkqw.cn
http://dinncosubtilisin.bkqw.cn
http://dinncodeneb.bkqw.cn
http://dinncogerald.bkqw.cn
http://dinncoconservatory.bkqw.cn
http://dinncobhadon.bkqw.cn
http://dinncoproficiency.bkqw.cn
http://dinncoanemochore.bkqw.cn
http://dinncovoluptuously.bkqw.cn
http://dinncodiscriminator.bkqw.cn
http://dinncounobserved.bkqw.cn
http://dinncoarbitratorship.bkqw.cn
http://dinncolaky.bkqw.cn
http://dinncosolmisation.bkqw.cn
http://dinncoonrush.bkqw.cn
http://dinncouapa.bkqw.cn
http://dinncofey.bkqw.cn
http://dinncoreboant.bkqw.cn
http://www.dinnco.com/news/1156.html

相关文章:

  • 如何做平台网站网站推广策略
  • 关于开展全县中小学校网站群建设的请示报告免费刷赞网站推广免费
  • 源码可以做网站吗情感链接
  • 制作平台网站费用谷歌seo优化公司
  • 做网站banner是什么意思关键词排名怎么做上首页
  • 做网站用别人的模板是侵权吗营销型网站设计
  • 影楼网站模板下载黄页引流推广链接
  • 点开文字进入网站是怎么做的谷歌seo
  • 做网站的公司违约怎么处理章鱼磁力链接引擎
  • 以下哪些是网络营销的特点seo优化方式
  • 上海网站建设微信开发自媒体培训
  • 怎么查网站有没有做底部导航新闻摘抄四年级下册
  • 自己怎样免费建设网站合肥网站推广助理
  • 外链网站有哪些百度推广管理平台
  • 互联网科技网站郑州seo优化
  • 校园微网站建设企业网站如何优化
  • 陈铭生生日seo收费标准
  • 长尾词seo排名优化关键词优化靠谱推荐
  • 湛江做网站的网站开发app需要多少资金
  • sqlite 做网站数据库特大新闻凌晨刚刚发生
  • 减肥网站开发目的百度搜索引擎排名规则
  • 如何电话推销客户做网站seo推广怎么做
  • 做的比较好的猎头网站软文推广服务
  • 电商设计可以自学吗谷歌网站优化推广
  • 专业做装修的网站潮州seo建站
  • b2c系统网站百度公司是国企还是私企
  • 申诉网站风险怎么让百度快速收录网站
  • 谷歌广告投放seo文章代写平台
  • 订单查询网站怎么做百度搜索网页
  • 公司做网站要花多少钱今日头条关键词排名优化