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

K8S cluster with multi-masters on Azure VM

拓扑参考:

在这里插入图片描述

在 Azure VM 实例上部署 KubeSphere

  • 基础模板
    需要修改 IP 地址和 VM Image的可以在模板中修改。

    {"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#","contentVersion": "1.0.0.0","parameters": {"vmNamePrefix": {"defaultValue": "master-","type": "String","metadata": {"description": "The name of your VM master node."}},"vmssName": {"defaultValue": "node","type": "String","metadata": {"description": "The name of your VMSS cluster."}},"location": {"defaultValue": "[resourceGroup().location]","type": "String","metadata": {"description": "Location for all resources."}},"adminUsername": {"type": "String","metadata": {"description": "Username for the Virtual Machine."}},"adminKey": {"type": "SecureString","metadata": {"description": "SSH Key for the Virtual Machine."}},"defaultMasterCount": {"defaultValue": 3,"type": "Int","metadata": {"description": "The default instances count of master"}},"defaultNodeCount": {"defaultValue": 3,"type": "Int","metadata": {"description": "The initial node size of your VMSS cluster."}},"minNodeCount": {"defaultValue": 1,"type": "Int","metadata": {"description": "The min node size of your VMSS cluster."}},"maxNodeCount": {"defaultValue": 20,"type": "Int","metadata": {"description": "The max node size of your VMSS cluster."}},"dnsLabelPrefix": {"defaultValue": "[toLower(concat('k8s-cluster-', uniqueString(resourceGroup().id)))]","type": "String","metadata": {"description": "Unique DNS Name for the Public IP used to access the Virtual Machine."}},"vmSize": {"defaultValue": "Standard_DS2_v2","type": "String","metadata": {"description": "The size of the VM"}},"virtualNetworkName": {"defaultValue": "vNetwork","type": "String","metadata": {"description": "Name of the Virtual Network"}},"subnetName": {"defaultValue": "Subnet","type": "String","metadata": {"description": "Name of the subnet in the virtual network"}},"vmssSubnetName": {"defaultValue": "nodeSubnet","type": "String","metadata": {"description": "Name of the VMSS subnet in the virtual network"}},"publicLBName": {"defaultValue": "publicLB","type": "String","metadata": {"description": "Internal Load Balancer name"}}},"variables": {"publicIPAddressName": "[concat(parameters('publicLBName'), 'IP' )]","availabilitySetName": "masterAvSet","networkInterfaceName": "[concat(parameters('vmNamePrefix'),'Interface')]","networkSecurityGroupName": "[concat(parameters('virtualNetworkName'),'nsg-default')]","subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworkName'), parameters('subnetName'))]","vmssSubnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworkName'), parameters('vmssSubnetName'))]","osDiskType": "Standard_LRS","publicLBID": "[resourceId('Microsoft.Network/loadBalancers',parameters('publicLBName'))]"},"resources": [{"type": "Microsoft.Network/networkSecurityGroups","apiVersion": "2015-06-15","name": "[variables('networkSecurityGroupName')]","location": "[parameters('location')]","properties": {"securityRules": [{"name": "Port_SSH","properties": {"description": "SSH","protocol": "*","sourcePortRange": "*","destinationPortRange": "22","sourceAddressPrefix": "*","destinationAddressPrefix": "*","access": "Allow","priority": 100,"direction": "Inbound","sourcePortRanges": [],"destinationPortRanges": [],"sourceAddressPrefixes": [],"destinationAddressPrefixes": []}},{"name": "Port_API_Server","properties": {"description": "k8s API Server","protocol": "TCP","sourcePortRange": "*","destinationPortRange": "6443","sourceAddressPrefix": "*","destinationAddressPrefix": "*","access": "Allow","priority": 140,"direction": "Inbound","sourcePortRanges": [],"destinationPortRanges": [],"sourceAddressPrefixes": [],"destinationAddressPrefixes": []}},{"name": "Port_Http","properties": {"description": "Web","protocol": "TCP","sourcePortRange": "*","destinationPortRange": "80","sourceAddressPrefix": "*","destinationAddressPrefix": "*","access": "Allow","priority": 120,"direction": "Inbound","sourcePortRanges": [],"destinationPortRanges": [],"sourceAddressPrefixes": [],"destinationAddressPrefixes": []}},{"name": "Port_Https","properties": {"protocol": "TCP","sourcePortRange": "*","destinationPortRange": "443","sourceAddressPrefix": "*","destinationAddressPrefix": "*","access": "Allow","priority": 130,"direction": "Inbound","sourcePortRanges": [],"destinationPortRanges": [],"sourceAddressPrefixes": [],"destinationAddressPrefixes": []}}]}},{"type": "Microsoft.Network/virtualNetworks","apiVersion": "2019-11-01","name": "[parameters('virtualNetworkName')]","location": "[parameters('location')]","dependsOn": ["[resourceId('Microsoft.Network/networkSecurityGroups/', variables('networkSecurityGroupName'))]"],"properties": {"addressSpace": {"addressPrefixes": ["10.211.0.0/16"]},"subnets": [{"name": "[parameters('vmssSubnetName')]","properties": {"networkSecurityGroup": {"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"},"addressPrefix": "10.211.0.0/24"}},{"name": "[parameters('subnetName')]","properties": {"networkSecurityGroup": {"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"},"addressPrefix": "10.211.1.0/24"}}]}},{"type": "Microsoft.Network/networkInterfaces","apiVersion": "2019-11-01","name": "[concat(variables('networkInterfaceName'), copyindex())]","location": "[parameters('location')]","dependsOn": ["[resourceId('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]","[resourceId('Microsoft.Network/loadBalancers/', parameters('publicLBName'))]"],"properties": {"ipConfigurations": [{"name": "ipconfig1","properties": {"subnet": {"id": "[variables('subnetRef')]"},"loadBalancerBackendAddressPools": [{"id": "[concat(variables('publicLBID'), '/backendAddressPools/BackendPoolMaster')]"}],"loadBalancerInboundNatRules": [{"id": "[concat(variables('publicLBID'), '/inboundNatRules/lbNAT-master',copyindex())]"}],"privateIPAllocationMethod": "Dynamic"}}]},"copy": {"name": "nicLoop","count": "[parameters('defaultMasterCount')]"}},{"type": "Microsoft.Network/publicIPAddresses","apiVersion": "2019-09-01","name": "[variables('publicIPAddressName')]","location": "[parameters('location')]","sku": {"name": "Standard"},"properties": {"publicIPAllocationMethod": "Static","publicIPAddressVersion": "IPv4","dnsSettings": {"domainNameLabel": "[parameters('dnsLabelPrefix')]"},"idleTimeoutInMinutes": 10}},{"type": "Microsoft.Network/loadBalancers","apiVersion": "2018-06-01","name": "[parameters('publicLBName')]","location": "[parameters('location')]","dependsOn": ["[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"],"sku": {"name": "Standard"},"properties": {"frontendIPConfigurations": [{"name": "LoadBalancerFrontEnd","properties": {"publicIPAddress": {"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"}}}],"backendAddressPools": [{"name": "BackendPoolNode"},{"name": "BackendPoolMaster"}],"loadBalancingRules": [{"name": "HttpLBRule","properties": {"frontendIPConfiguration": {"id": "[concat(variables('publicLBID'),'/frontendIPConfigurations/LoadBalancerFrontEnd')]"},"backendAddressPool": {"id": "[concat(variables('publicLBID'),'/backendAddressPools/BackendPoolNode')]"},"protocol": "Tcp","frontendPort": 80,"backendPort": 80,"enableFloatingIP": false,"disableOutboundSnat": false,"idleTimeoutInMinutes": 5,"probe": {"id": "[concat(variables('publicLBID'),'/probes/tcpProbe')]"}}},{"name": "APILBRule","properties": {"frontendIPConfiguration": {"id": "[concat(variables('publicLBID'),'/frontendIPConfigurations/LoadBalancerFrontEnd')]"},"backendAddressPool": {"id": "[concat(variables('publicLBID'),'/backendAddressPools/BackendPoolMaster')]"},"protocol": "Tcp","frontendPort": 6443,"backendPort": 6443,"enableFloatingIP": false,"disableOutboundSnat": false,"idleTimeoutInMinutes": 5,"probe": {"id": "[concat(variables('publicLBID'),'/probes/apitcpProbe')]"}}}],"probes": [{"name": "tcpProbe","properties": {"protocol": "Tcp","port": 80,"intervalInSeconds": 5,"numberOfProbes": 2}},{"name": "apitcpProbe","properties": {"protocol": "Tcp","port": 6443,"intervalInSeconds": 5,"numberOfProbes": 2}}],"inboundNatRules": [{"name": "lbNAT-master0","properties": {"frontendIPConfiguration": {"id": "[concat(variables('publicLBID'),'/frontendIPConfigurations/LoadBalancerFrontEnd')]"},"protocol": "Tcp","frontendPort": "50200","backendPort": "22"}},{"name": "lbNAT-master1","properties": {"frontendIPConfiguration": {"id": "[concat(variables('publicLBID'),'/frontendIPConfigurations/LoadBalancerFrontEnd')]"},"protocol": "Tcp","frontendPort": "50201","backendPort": "22"}},{"name": "lbNAT-master2","properties": {"frontendIPConfiguration": {"id": "[concat(variables('publicLBID'),'/frontendIPConfigurations/LoadBalancerFrontEnd')]"},"protocol": "Tcp","frontendPort": "50202","backendPort": "22"}}],"inboundNatPools": [{"name": "lbNAT-node","properties": {"frontendIPConfiguration": {"id": "[concat(variables('publicLBID'),'/frontendIPConfigurations/LoadBalancerFrontEnd')]"},"protocol": "Tcp","frontendPortRangeStart": 50100,"frontendPortRangeEnd": 50199,"backendPort": 22}}]}},{"type": "Microsoft.Compute/availabilitySets","apiVersion": "2016-04-30-preview","name": "[variables('availabilitySetName')]","location": "[parameters('location')]","properties": {"platformFaultDomainCount": 2,"platformUpdateDomainCount": 2,"managed": true}},{"type": "Microsoft.Compute/virtualMachines","apiVersion": "2019-07-01","name": "[concat(parameters('vmNamePrefix'), copyindex())]","location": "[parameters('location')]","dependsOn": ["[concat('Microsoft.Network/networkInterfaces/', variables('networkInterfaceName'), copyindex())]","[concat('Microsoft.Compute/availabilitySets/', variables('availabilitySetName'))]","[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('vmssName'))]"],"properties": {"availabilitySet": {"id": "[resourceId('Microsoft.Compute/availabilitySets',variables('availabilitySetName'))]"},"hardwareProfile": {"vmSize": "[parameters('vmSize')]"},"storageProfile": {"osDisk": {"createOption": "FromImage","managedDisk": {"storageAccountType": "[variables('osDiskType')]"}},"imageReference": {"publisher": "Canonical","offer": "0001-com-ubuntu-server-focal","sku": "20_04-lts-gen2","version": "latest"}},"networkProfile": {"networkInterfaces": [{"id": "[resourceId('Microsoft.Network/networkInterfaces',concat(variables('networkInterfaceName'),copyindex()))]"}]},"osProfile": {"computerName": "[concat(parameters('vmNamePrefix'), copyindex())]","adminUsername": "[parameters('adminUsername')]","adminPassword": "[parameters('adminKey')]","linuxConfiguration": {"disablePasswordAuthentication": true,"ssh": {"publicKeys": [{"path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]","keyData": "[parameters('adminKey')]"}]}}}},"copy": {"name": "virtualMachineLoop","count": "[parameters('defaultMasterCount')]"}},{"type": "Microsoft.Compute/virtualMachineScaleSets","apiVersion": "2019-07-01","name": "[parameters('vmssName')]","location": "[parameters('location')]","dependsOn": ["[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]","[concat('Microsoft.Network/loadBalancers/', parameters('publicLBName'))]"],"tags": {"cluster-autoscaler-enabled": "true","cluster-autoscaler-name": "[resourceGroup().name]","min": "[parameters('minNodeCount')]","max": "[parameters('maxNodeCount')]","poolName": "[parameters('vmssName')]"},"sku": {"name": "[parameters('vmSize')]","tier": "Standard","capacity": "[parameters('defaultNodeCount')]"},"properties": {"overprovision": false,"upgradePolicy": {"mode": "Manual"},"virtualMachineProfile": {"storageProfile": {"osDisk": {"createOption": "FromImage","caching": "ReadWrite"},"imageReference": {"publisher": "Canonical","offer": "0001-com-ubuntu-server-focal","sku": "20_04-lts-gen2","version": "latest"}},"osProfile": {"computerNamePrefix": "[parameters('vmssName')]","adminUsername": "[parameters('adminUsername')]","adminPassword": "[parameters('adminKey')]","linuxConfiguration": {"disablePasswordAuthentication": true,"ssh": {"publicKeys": [{"path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]","keyData": "[parameters('adminKey')]"}]}}},"networkProfile": {"networkInterfaceConfigurations": [{"name": "[concat(parameters('vmssName'),'nic')]","properties": {"primary": true,"ipConfigurations": [{"name": "[concat('ipconfigVmss', parameters('vmssName'))]","properties": {"subnet": {"id": "[variables('vmssSubnetRef')]"},"loadBalancerBackendAddressPools": [{"id": "[concat(variables('publicLBID'), '/backendAddressPools/BackendPoolNode')]"}],"loadBalancerInboundNatPools": [{"id": "[concat(variables('publicLBID'), '/inboundNatPools/lbNAT-node')]"}]}}]}}]}}}}],"outputs": {"adminUsername": {"type": "String","value": "[parameters('adminUsername')]"},"hostname": {"type": "String","value": "[reference(variables('publicIPAddressName')).dnsSettings.fqdn]"},"sshCommand": {"type": "String","value": "[concat('ssh ', parameters('adminUsername'), '@', reference(variables('publicIPAddressName')).dnsSettings.fqdn)]"}}
    }
    
    • 可以修改 master 和 node 的名字前缀、部署区域、数量和 VM 类型

      在这里插入图片描述

      • ssh 22 对外由 LB 配置 NAT 端口实现,如配置文件中 50200 → master-0
        • 已经包含的规则转换(不含 30880)

          服务协议规则后端端口前端端口节点池
          sshTCP入站 NAT2250200, 50201, 50202, 50100~50199主节点, 普通节点
          api 服务器TCP负载均衡64436443主节点
          ks 控制台TCP负载均衡3088030880主节点
          httpTCP负载均衡8080普通节点
          httpsTCP负载均衡443443普通节点
      • node 使用 VMSS
  • 部署 K8S cluster
    最简单的方式还是用 kk 完成,注意在 kubernetes 1.24 以后,psp 弃用,在 kk 中还有 psp 权限管理,安装的时候会报错。建议使用 1.23.10,也是 kk 现在默认的版本。

    • 证书传输 → Master-0

      scp  -i zyi.pem -P 50200 zyi.pem zyi@20.247.0.170:/home/zyi/.ssh/
    • 每一台安装 socat 等必须的软件

      ssh -i zyi.pem -p50200 zyi@20.247.0.170 'sudo apt install socat conntrack'
      
    • 登录到 Mater-0

      ssh -i zyi.pem -p50200 zyi@20.247.0.170
      
    • 下载 kk 并赋予可执行权限

    curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.10 sh -chmod +x kk
    
    • 创建配置文件模板

      ./kk create config --with-kubesphere v3.3.2 --with-kubernetes v1.22.12
      
      • KubeSphere 3.3 对应 Kubernetes 版本推荐:v1.20.x、v1.21.x、* v1.22.x、* v1.23.x 和 * v1.24.x。带星号的版本可能出现边缘节点部分功能不可用的情况。因此,如需使用边缘节点,推荐安装 v1.21.x。如果未指定 Kubernetes 版本,KubeKey 将默认安装 Kubernetes v1.23.10。有关支持的 Kubernetes 版本请参阅支持矩阵。

      • 如果在此步骤中的命令中未添加标志 -with-kubesphere,则不会部署 KubeSphere,除非您使用配置文件中的 addons 字段进行安装,或稍后使用 ./kk create cluster 时再次添加此标志。

      • 如果在未指定 KubeSphere 版本的情况下添加标志 --with kubesphere`,将安装 KubeSphere 的最新版本。

      • 修改的内容用红色标注

        apiVersion: kubekey.kubesphere.io/v1alpha2
        kind: Cluster
        metadata:name: kubeCluster
        spec:hosts:- {name: master-0, address: 20.210.0.156, port: 50200, internalAddress: 10.211.1.5, user: zyi, privateKeyPath: "~/.ssh/zyi.pem"}- {name: master-1, address: 20.210.0.156, port: 50201, internalAddress: 10.211.1.6, user: zyi, privateKeyPath: "~/.ssh/zyi.pem"}- {name: master-2, address: 20.210.0.156, port: 50202, internalAddress: 10.211.1.4, user: zyi, privateKeyPath: "~/.ssh/zyi.pem"}- {name: node000000, address: 20.210.0.156, port: 50100, internalAddress: 10.211.0.4, user: zyi, privateKeyPath: "~/.ssh/zyi.pem"}- {name: node000001, address: 20.210.0.156, port: 50101, internalAddress: 10.211.0.5, user: zyi, privateKeyPath: "~/.ssh/zyi.pem"}- {name: node000002, address: 20.210.0.156, port: 50102, internalAddress: 10.211.0.6, user: zyi, privateKeyPath: "~/.ssh/zyi.pem"}roleGroups:etcd:- master-0- master-1- master-2control-plane:- master-0- master-1- master-2worker:- node000000- node000001- node000002controlPlaneEndpoint:## Internal loadbalancer for apiservers# internalLoadbalancer: haproxydomain: lb.etaon.labaddress: "20.210.0.156"port: 6443kubernetes:version: v1.23.10clusterName: cluster.localautoRenewCerts: truecontainerManager: dockeretcd:type: kubekeynetwork:plugin: flannelkubePodsCIDR: 10.233.64.0/18kubeServiceCIDR: 10.233.0.0/18## multus support. https://github.com/k8snetworkplumbingwg/multus-cnimultusCNI:enabled: falseregistry:privateRegistry: ""namespaceOverride: ""registryMirrors: []insecureRegistries: []addons: []---
        apiVersion: installer.kubesphere.io/v1alpha1
        kind: ClusterConfiguration
        metadata:name: ks-installernamespace: kubesphere-systemlabels:version: v3.3.2
        spec:persistence:storageClass: ""authentication:jwtSecret: ""zone: ""local_registry: ""namespace_override: ""# dev_tag: ""etcd:monitoring: falseendpointIps: localhostport: 2379tlsEnable: truecommon:core:console:enableMultiLogin: trueport: 30880type: NodePort# apiserver:#  resources: {}# controllerManager:#  resources: {}redis:enabled: falsevolumeSize: 2Giopenldap:enabled: falsevolumeSize: 2Giminio:volumeSize: 20Gimonitoring:# type: externalendpoint: http://prometheus-operated.kubesphere-monitoring-system.svc:9090GPUMonitoring:enabled: falsegpu:kinds:- resourceName: "nvidia.com/gpu"resourceType: "GPU"default: truees:# master:#   volumeSize: 4Gi#   replicas: 1#   resources: {}# data:#   volumeSize: 20Gi#   replicas: 1#   resources: {}logMaxAge: 7elkPrefix: logstashbasicAuth:enabled: falseusername: ""password: ""externalElasticsearchHost: ""externalElasticsearchPort: ""alerting:enabled: false# thanosruler:#   replicas: 1#   resources: {}auditing:enabled: false# operator:#   resources: {}# webhook:#   resources: {}devops:enabled: false# resources: {}jenkinsMemoryLim: 8GijenkinsMemoryReq: 4GijenkinsVolumeSize: 8Gievents:enabled: false# operator:#   resources: {}# exporter:#   resources: {}# ruler:#   enabled: true#   replicas: 2#   resources: {}logging:enabled: falselogsidecar:enabled: truereplicas: 2# resources: {}metrics_server:enabled: falsemonitoring:storageClass: ""node_exporter:port: 9100# resources: {}# kube_rbac_proxy:#   resources: {}# kube_state_metrics:#   resources: {}# prometheus:#   replicas: 1#   volumeSize: 20Gi#   resources: {}#   operator:#     resources: {}# alertmanager:#   replicas: 1#   resources: {}# notification_manager:#   resources: {}#   operator:#     resources: {}#   proxy:#     resources: {}gpu:nvidia_dcgm_exporter:enabled: false# resources: {}multicluster:clusterRole: nonenetwork:networkpolicy:enabled: falseippool:type: nonetopology:type: noneopenpitrix:store:enabled: falseservicemesh:enabled: falseistio:components:ingressGateways:- name: istio-ingressgatewayenabled: falsecni:enabled: falseedgeruntime:enabled: falsekubeedge:enabled: falsecloudCore:cloudHub:advertiseAddress:- ""service:cloudhubNodePort: "30000"cloudhubQuicNodePort: "30001"cloudhubHttpsNodePort: "30002"cloudstreamNodePort: "30003"tunnelNodePort: "30004"# resources: {}# hostNetWork: falseiptables-manager:enabled: truemode: "external"# resources: {}# edgeService:#   resources: {}terminal:timeout: 600
        
    • 安装部署

      ./kk create cluster -f config-sample.yaml
      
      • 安装日志
      kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f
      
      #####################################################
      ###              Welcome to KubeSphere!           ###
      #####################################################Console: http://10.211.1.5:30880
      Account: admin
      Password: P@88w0rd
      NOTES:1. After you log into the console, please check themonitoring status of service components in"Cluster Management". If any service is notready, please wait patiently until all components are up and running.2. Please change the default password after login.#####################################################
      https://kubesphere.io             2023-08-11 03:31:56
      #####################################################
      
    • 在 LBer 上为 30880端口 配置规则并在 ASG 上 permit

      在这里插入图片描述

      在这里插入图片描述

    • http://hostip:30880

      在这里插入图片描述

  • 测试

    apiVersion: v1
    kind: Service
    metadata:name: hello-kubernetes
    spec:type: NodePortports:- port: 80targetPort: 8080selector:app: hello-kubernetes
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:name: hello-kubernetes
    spec:replicas: 3selector:matchLabels:app: hello-kubernetestemplate:metadata:labels:app: hello-kubernetesspec:containers:- name: hello-kubernetesimage: paulbouwer/hello-kubernetes:1.5ports:- containerPort: 8080env:- name: MESSAGEvalue: I just deployed a PodVM on the Azure VM Cluster!!
    
    • 配置外部访问30596 → 80

      kubectl get svc
      NAME               TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
      hello-kubernetes   NodePort    10.233.31.158   <none>        80:30596/TCP   167m
      
    • 负载均衡上配置

      在这里插入图片描述

    • 访问前端 公网 IP 或 DNS 名称

      在这里插入图片描述

      在这里插入图片描述

相关文章:

K8S cluster with multi-masters on Azure VM

拓扑参考&#xff1a; 在 Azure VM 实例上部署 KubeSphere 基础模板 需要修改 IP 地址和 VM Image的可以在模板中修改。 {"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#","contentVersion": &q…...

初阶c语言:趣味扫雷游戏

目录 前言 制作菜单 构建游戏选择框架 实现游戏功能 模块化编程&#xff1a;查看前节三子棋的内容 初始化雷区 ​编辑 优化棋盘 随机埋入地雷 点击后的决策 实现此功能代码 game&#xff08;&#xff09;&#xff1b;的安排 前言 《扫雷》是一款大众类的益智小游戏&…...

JVM——内存模型

1.java内存模型 1.1 原子性 1.2 问题分析 这里与局部变量自增不同&#xff0c;局部变量调用iinc是在局部变量表槽位上进行自增。 静态变量是在操作数栈自增。 这里的主内存和工作内存时再JMM里的说法。 因为操作系统是时间片切换的多个线程轮流使用CPU. 1.3解决方法 JMM中…...

java八股文面试[JVM]——元空间

JAVA8为什么要增加元空间 为什么要移除永久代&#xff1f; 知识来源&#xff1a; 【2023年面试】JVM8为什么要增加元空间_哔哩哔哩_bilibili...

科技云报道:云计算下半场,公有云市场生变,私有云风景独好

科技云报道原创。 大数据、云计算、人工智能&#xff0c;组成了恢弘的万亿级科技市场。这三个领域&#xff0c;无论远观近观&#xff0c;都如此性感和魅力&#xff0c;让一代又一代创业者为之杀伐攻略。 然而高手过招往往一瞬之间便已胜负知晓&#xff0c;云计算市场的巨幕甫…...

Oracle 如何给大表添加带有默认值的字段

一、讲故事 你是否遇到过开发人员添加字段&#xff0c;导致数据库锁表问题&#xff1f; 但是令开发疑惑的事&#xff0c;他们添加字段&#xff0c;有的时候很快&#xff0c;有的时候很慢&#xff1f; 为什么呢&#xff1f; 询问得知&#xff0c;**加的慢时候是带上了default默…...

记录Taro大坑2丢失api无法启动

现象 解决方案 看了很多。很多说要改成一致的版本号。其实没什么用。 正确方案 再新建一个模板跑起来对比config的配置&#xff0c;以及package.json发现关闭预编译即可。预编译导致api丢失...

Java-Maven-解决maven deploy时报 401 Reason Phrase Unauthorized 错误

Java-Maven-解决maven deploy时报 401 Reason Phrase Unauthorized 错误 环境 Java JDK 1.8Maven 3.3.9 引言 项目需要打成jar包上传到私服&#xff0c;供其它项目引用。此时需要执行 mvn clean deploy 命令&#xff0c;执行过程中报 401 错误。 解决401错误 报错信息 执…...

【数据结构】 栈(Stack)的应用场景

文章目录 &#x1f30f;前言&#x1f340;改变元素的序列&#x1f6a9;场景一&#x1f4cc;解析&#xff1a; &#x1f6a9;场景二&#x1f4cc;解析&#xff1a; &#x1f38d;将递归转化为循环&#x1f333;[括号匹配](https://leetcode.cn/problems/valid-parentheses/)&…...

人力资源小程序的设计原则与实现方法

随着移动互联网的快速发展&#xff0c;小程序成为了各行各业推广和服务的新利器。对于人力资源行业来说&#xff0c;开发一款定制化的小程序不仅可以提升服务效率&#xff0c;还可以增强品牌形象和用户粘性。那么&#xff0c;如何定制开发人力资源类的小程序呢&#xff1f;下面…...

检查Javascript对象数组中是否存在对象值,如果没有向数组添加新对象

需求&#xff1a; 如果我有以下对象数组&#xff1a; [ { id: 1, username: fred }, { id: 2, username: bill }, { id: 2, username: ted } ]有没有办法循环遍历数组&#xff0c;以检查特定的用户名值是否已经存在&#xff0c;如果它什么都不做&#xff0c;但是如果它没有用…...

UG\NX二次开发 使用录制功能录制操作记录时,如何设置默认的开发语言?

文章作者&#xff1a;里海 来源网站&#xff1a;王牌飞行员_里海_里海NX二次开发3000例,C\C,Qt-CSDN博客 简介&#xff1a; NX二次开发使用BlockUI设计对话框时&#xff0c;如何设置默认的代码语言&#xff1f; 效果&#xff1a; 方法&#xff1a; 依次打开“文件”->“实用…...

【业务功能篇83】微服务SpringCloud-ElasticSearch-Kibanan-docke安装-应用层实战

五、ElasticSearch应用 1.ES 的Java API两种方式 Elasticsearch 的API 分为 REST Client API&#xff08;http请求形式&#xff09;以及 transportClient API两种。相比来说transportClient API效率更高&#xff0c;transportClient 是通过Elasticsearch内部RPC的形式进行请求…...

VBJSON报错:缺少:语句结束

项目中使用JSON库VBJSON时报错&#xff1a; 编译错误&#xff1a;缺少&#xff1a;语句结束 cJSONScript和cStringBuilder报相同的错误&#xff0c;都在第一行: VERSION 1.0 CLASS 研究了半天没啥结果&#xff0c;之前使用这个库的时候没有什么问题&#xff0c;所以判定是当前…...

Docker安装ES+kibana8.9.1

参考&#xff1a;基于Docker安装Elasticsearch【保姆级教程、内含图解】_docker elasticsearch_Acloasia的博客-CSDN博客 创建网络 docker network create es-net 基于Docker安装Elasticsearch 拉取镜像 docker pull elasticsearch:8.9.1 挂载文件 mkdir -p /usr/local/e…...

12. Oracle中case when详解

格式&#xff1a; case expression when condition_01 then result_01 when condition_02 then result_02 ...... when condition_n then result_n else result_default end 表达式expression符合条件condition_01&#xff0c;则返回…...

【电路设计】220V AC转低压DC电路概述

前言 最近因项目需要,电路板上要加上一个交流220V转低压直流,比如12V或者5V这种。一般来说,比较常见也比较简单的做法是使用一个变压器将220V AC进行降压,比如降到22V AC,但是很遗憾的是,支持220V的变压器一般体积很大,而板子留给电源部分的面积又非常有限,所以不得不研…...

网络地址转换NAT-动态NAT的使用范围和配置-思科EI,华为数通

网络地址转换NAT-动态NAT的使用范围和配置 什么是动态NAT&#xff1f; 使用公有地址池&#xff0c;并以先到先得的原则分配这些地址。当具有私有 IP 地址的主机请求访问 Internet 时&#xff0c;动态 NAT 从地址池中选择一个未被其它主机占用的 IP 地址一对一的转化。当数据会话…...

远程连接虚拟机中ubuntu报错:Network error:Connection refused

ping检测一下虚拟机 可以ping通&#xff0c;说明主机是没问题 #检查ssh是否安装&#xff1a; ps -e |grep ssh发现ssh没有安装 #安装openssh-server sudo apt-get install openssh-server#启动ssh service ssh startps -e |grep ssh检查一下防火墙 #防火墙状态查看 sudo ufw…...

快速排序三种思路详解!

一、快速排序的介绍 快速排序是Hoare于1962年提出的一种二叉树结构的交换排序方法&#xff0c;其基本思想为&#xff1a;任取待排序元素序列中 的某元素作为基准值&#xff0c;按照该排序码将待排序集合分割成两子序列&#xff0c;左子序列中所有元素均小于基准值&#xff0c;…...

【二叉树入门指南】链式结构的实现

【二叉树入门指南】链式结构的实现 一、前置说明二、二叉树的遍历2.1前序遍历2.2中序遍历2.3 后序遍历 三、以前序遍历为例&#xff0c;递归图解四、层序遍历五、节点个数以及高度等5.1 二叉树节点个数5.2二叉树叶子节点个数5.3 二叉树第k层节点个数5.4 二叉树查找值为x的节点5…...

【位运算】算法实战

文章目录 一、算法原理常见的位运算总结 二、算法实战1. leetcode面试题01.01. 判断字符是否唯一2. leetcode268 丢失的数字3. leetcode371 两整数之和4. leetcode004 只出现一次的数字II5. leetcode面试题17.19. 消失的两个数字 三、总结 一、算法原理 计算机中的数据都以二进…...

C++构建系统

收集C构建系统(2023)&#xff1a; 跟我一起写Makefile (PDF重制版)CMake tutorialConan, software package manager for C and C developersvcpkg-repovcpkgGoogle Bazel Build System { Fast, Correct } — Choose twoGN gn_quick_start当前Chromium构建系统 GYP Generate You…...

“深入探索JVM内部机制:理解Java虚拟机的运行原理“

标题&#xff1a;深入探索JVM内部机制&#xff1a;理解Java虚拟机的运行原理 摘要&#xff1a;本篇博客将深入探索Java虚拟机&#xff08;JVM&#xff09;的内部机制&#xff0c;帮助读者理解JVM的运行原理。我们将介绍JVM的组成结构&#xff0c;包括类加载器、运行时数据区域…...

java八股文面试[JVM]——双亲委派模型

1.当AppClassLoader去加载一个class时&#xff0c;它首先不会自己去尝试加载这个类&#xff0c;而是把类加载请求委托给父加载器ExtClassLoader去完成。 2.当ExtClassLoader去加载一个class时&#xff0c;它首先也不会去尝试加载这个类&#xff0c;而是把类加载请求委托给父加载…...

NLP与大模型主题全国师资培训班落地,飞桨持续赋能AI人才培养

为了推动大模型及人工智能相关专业人员的培养&#xff0c;8月11日-8月13日&#xff0c;由中国计算机学会主办、机械工业出版社、北京航空航天大学、百度飞桨联合承办 “CCF群星计划之文心高校行- NLP与大模型”主题师资培训班&#xff08;以下简称培训班&#xff09;在北京天信…...

Jupyter Notebook 配置根目录

注&#xff1a;本文是在 Windows 10 上配置 Jupyter Notebook 打开的默认根目录&#xff0c;Linux 同。 步骤一&#xff1a;创建 Jupyter Notebook 配置文件 使用以下命令创建 Jupyter Notebook 配置文件&#xff08;如果尚未创建&#xff09;&#xff1a; jupyter notebook …...

算法 位运算

文章目录 一、&&#xff08;按位与&#xff09;运算符二、|&#xff08;按位或&#xff09;运算符三、^&#xff08;异或&#xff09;运算符四、~&#xff08;取反&#xff09;运算符五、<<&#xff08;左移&#xff09;运算符六、>>&#xff08;右移&#xff…...

Linux 虚拟机常用命令

一、文件/文件夹管理 1. ls命令 就是 list 的缩写&#xff0c;通过 ls 命令不仅可以查看 linux 文件夹包含的文件&#xff0c;而且可以查看文件权限(包括目录、文件夹、文件权限)查看目录信息等等。 ls -a 列出目录所有文件&#xff0c;包含以.开始的隐藏文件ls -A 列出除.…...

解决抖音semi-ui的Input无法获取到onChange事件

最近在使用semi-ui框架的Input实现一个上传文件功能时遇到了坑&#xff0c;就是无法获取到onChange事件&#xff0c;通过console查看只是拿到了一个文件名。但若是把<Input>换成原生的<input>&#xff0c;就可以正常获取到事件。仔细看了下官方文档&#xff0c;发现…...

免费的png打包plist工具CppTextu,一款把若干资源图片拼接为一张大图的免费工具

经常做游戏打包贴图的都知道&#xff0c;要把图片打包为一张或多张大图&#xff0c;要使用打包工具TexturePacker。 TexturePacker官方版可以直接导入PSD、SWF、PNG、BMP等常见的图片格式&#xff0c;主要用于网页、游戏和动画的制作&#xff0c;它可以将多个小图片汇聚成一个…...

深层次分析字符数组和字符串的区别是什么?

前言 &#xff08;1&#xff09;休闲时刻刷B站&#xff0c;看到一个卖课的&#xff0c;发视频问&#xff0c;char arr1[]{‘H’,‘E’,‘L’,‘L’,‘O’};和char arr2[]“HELLO”;区别是什么。 &#xff08;2&#xff09;看那个卖课博主一顿分析&#xff0c;最后成功得出&…...

Redis 的主从复制、哨兵模式、集群脑裂

主从复制 主从复制是 Redis 高可用服务最基础的保证&#xff0c;将一台 Redis 主服务器&#xff0c;同步数据到多台 Redis 从服务器上&#xff0c;即一主多从的模式&#xff0c;且主从服务器之间采用的是「读写分离」的方式。 主服务器可以进行读写操作&#xff0c;当发生写操…...

Pycharm通过SSH配置centos上Spark环境

直接在shell进行pyspark进行编程&#xff0c;程序没有办法写得太长&#xff0c;而且我们希望能够实现一个及时给出结果的编程环境&#xff0c;可以使用pycharm连接centos上的spark&#xff0c;进行本地编程&#xff0c;同步到centos系统中运行程序&#xff0c;并把结果返回pych…...

leetcode做题笔记98. 验证二叉搜索树

给你一个二叉树的根节点 root &#xff0c;判断其是否是一个有效的二叉搜索树。 有效 二叉搜索树定义如下&#xff1a; 节点的左子树只包含 小于 当前节点的数。节点的右子树只包含 大于 当前节点的数。所有左子树和右子树自身必须也是二叉搜索树。 思路一&#xff1a;递归 …...

C# 中Lambda中的的匿名函数

/// <summary>/// 根据设备号&#xff0c;获取故障列表/// </summary>/// <param name"scanCode">主键</param>/// <returns></returns>[HttpGet]public async Task<IActionResult> GetItemPageList(string scanCode){//v…...

铰接式车辆的横向动力学仿真提供车辆模型研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…...

Ubuntu20 安装 libreoffice

1 更新apt-get sudo apt-get update2 安装jdk 查看jdk安装情况 Command java not found, but can be installed with:sudo apt install default-jre # version 2:1.11-72, or sudo apt install openjdk-11-jre-headless # version 11.0.138-0ubuntu1~20.04 sud…...

HTTP协议(JavaEE初阶系列15)

目录 前言&#xff1a; 1.HTTP协议 1.1HTTP协议是什么 1.2HTTP协议的报文格式 1.2.1抓包工具的使用 1.2.2HTTP请求 1.2.3HTTP响应 2.HTTP请求 2.1首行的组成 2.2.1URL的组成 2.2认识“方法”&#xff08;method&#xff09; 2.2.1GET方法 2.2.2POST方法 2.2.3GET…...

机器学习基础10-审查回归算法(基于波士顿房价的数据集)

上一节介绍了如何审查分类算法&#xff0c;并介绍了六种不同的分类算法&#xff0c;还 用同一个数据集按照相同的方式对它们做了审查&#xff0c;本章将用相同的方式对回归算法进行审查。 在本节将学到&#xff1a; 如何审查机器学习的回归算法。如何审查四种线性分类算法。如…...

基于 CentOS 7 构建 LVS-DR 群集。配置nginx负载均衡。

1、基于 CentOS 7 构建 LVS-DR 群集。 [root132 ~]# nmcli c show NAME UUID TYPE DEVICE ens33 c89f4a1a-d61b-4f24-a260-6232c8be18dc ethernet ens33 [root132 ~]# nmcli c m ens33 ipv4.addresses 192.168.231.200/24 [r…...

【云原生】Docker的数据管理(数据卷、容器互联)

目录 一、数据卷&#xff08;容器与宿主机之间数据共享&#xff09; 二、数据卷容器&#xff08;容器与容器之间数据共享&#xff09; 三、 容器互联&#xff08;使用centos镜像&#xff09; 总结 用户在使用Docker的过程中&#xff0c;往往需要能查看容器内应用产生的数据…...

使用vlc在线播放rtsp视频url

1. 2. 3. 工具链接&#xff1a; https://download.csdn.net/download/qq_43560721/88249440...

copy is all you need前向绘图 和疑惑标记

疑惑的起因 简化前向图 GPT4解释 这段代码实现了一个神经网络模型&#xff0c;包含了BERT、GPT-2和MLP等模块。主要功能是给定一个文本序列和一个查询序列&#xff0c;预测查询序列中的起始和结束位置&#xff0c;使其对应文本序列中的一个短语。具体实现细节如下&#xff1a…...

【附安装包】Vred2023安装教程

软件下载 软件&#xff1a;Vred版本&#xff1a;2023语言&#xff1a;简体中文大小&#xff1a;2.39G安装环境&#xff1a;Win11/Win10/Win8/Win7硬件要求&#xff1a;CPU2.0GHz 内存4G(或更高&#xff09;下载通道①百度网盘丨64位下载链接&#xff1a;https://pan.baidu.com…...

ASP.NET Core 中的 Dependency injection

依赖注入&#xff08;Dependency Injection&#xff0c;简称DI&#xff09;是为了实现各个类之间的依赖的控制反转&#xff08;Inversion of Control&#xff0c;简称IoC &#xff09;。 ASP.NET Core 中的Controller 和 Service 或者其他类都支持依赖注入。 依赖注入术语中&a…...

优化物料编码规则,提升物料管理效率

导 读 ( 文/ 2358 ) 物料是生产过程的必需品。对物料进行身份的唯一标识&#xff0c;可以更好的管理物料库存、库位&#xff0c;更方便的对物料进行追溯。通过编码规则的设计&#xff0c;可以对物料按照不同的属性、类别或特征进行分类&#xff0c;从而更好地进行库存分析、计划…...

Jetbrains IDE新UI设置前进/后退导航键

背景 2023年6月&#xff0c;Jetbrains在新发布的IDE&#xff08;Idea、PyCharm等&#xff09;中开放了新UI选项&#xff0c;我们勾选后重启IDE&#xff0c;便可以使用这一魔性的UI界面了。 但是前进/后退这对常用的导航键却找不到了&#xff0c;以前的设置方式&#xff08;Vi…...

借助frp的xtcp+danted代理打通两边局域网p2p方式访问

最终效果 实现C内网所有设备借助c1内网代理访问B内网所有服务器 配置公网服务端A frps 配置frps.ini [common] # 绑定frp穿透使用的端口 bind_port 7000 # 使用token认证 authentication_method token token xxxx./frps -c frps.ini启动 配置service自启(可选) /etc/…...

2023年高教社杯数学建模思路 - 案例:FPTree-频繁模式树算法

文章目录 算法介绍FP树表示法构建FP树实现代码 建模资料 ## 赛题思路 &#xff08;赛题出来以后第一时间在CSDN分享&#xff09; https://blog.csdn.net/dc_sinor?typeblog 算法介绍 FP-Tree算法全称是FrequentPattern Tree算法&#xff0c;就是频繁模式树算法&#xff0c…...