在 Mac 上用 Vagrant 安裝 K8s

在這里插入圖片描述

文章目錄

    • 📋 1. 環境準備
      • 1.1 系統要求
      • 1.2 軟件清單
    • 🚀 2. 安裝步驟
      • 2.1 安裝Parallels Desktop
      • 2.2 配置網絡代理(可選)
      • 2.3 安裝Homebrew
      • 2,4 準備項目目錄
      • 2.5 安裝Vagrant及插件
      • 2.6 配置Python環境
        • 2.6.1 安裝Python管理工具
        • 2.6.2 配置Shell環境
        • 2.6.3 驗證Python環境
      • 2.6.4 安裝 pyenv
      • 2.6.5 升級Python工具
      • 2.6.6 創建Python虛擬環境
      • 2.7 配置Kubespray
        • 2.7.1 配置核心配置文件
          • 2.7.1.1 配置集群config.rb
          • 2.7.1.2 配置 containerd.yml(可選)
    • 🔧 3. 部署集群
      • 3.1 啟動虛擬機并部署K8s
      • 3.2 如果部署失敗,可以重試
    • 🎯 4. 配置kubectl訪問
      • 4.1 安裝kubectl客戶端
      • 4.2 配置集群訪問
    • 📦 5. 安裝Helm(可選)
    • 🧹 6. 清理環境
      • 6.1 銷毀虛擬機
      • 6.2 退出Python虛擬環境
    • 🛠? 7. 故障排除
      • 7.1 常見問題
      • 7.2 有用的調試命令
    • 📝 8. 總結

本指南將幫助你在macOS上使用Kubespray、Vagrant和Parallels Desktop搭建一個完整的Kubernetes測試集群。

📋 1. 環境準備

1.1 系統要求

  • macOS(Apple Silicon或Intel)
  • 至少16GB內存
  • 50GB以上可用磁盤空間

1.2 軟件清單

  • Parallels Desktop(商業版)
  • Homebrew
  • Vagrant + vagrant-parallels插件
  • Python 3.12+ 及虛擬環境
  • Git

🚀 2. 安裝步驟

2.1 安裝Parallels Desktop

💡 提示: 需要購買商業版許可證,可考慮在閑魚等平臺購買

安裝完成后確保Parallels Desktop正常運行。

2.2 配置網絡代理(可選)

如果你的網絡環境需要代理,創建代理配置腳本:

vim ~/.zshrc

添加以下內容:

# 網絡代理配置
proxy_url="http://172.0.0.1:7890"  # 修改為你的代理地址
export no_proxy="10.0.0.0/8,192.168.16.0/20,localhost,127.0.0.0/8,registry.ocp.local,.svc,.svc.cluster-27,.coding.net,.tencentyun.com,.myqcloud.com"# 代理控制函數
enable_proxy() {export http_proxy="${proxy_url}"export https_proxy="${proxy_url}"git config --global http.proxy "${proxy_url}"git config --global https.proxy "${proxy_url}"echo "? 代理已啟用: ${proxy_url}"
}disable_proxy() {unset http_proxyunset https_proxygit config --global --unset http.proxygit config --global --unset https.proxyecho "? 代理已禁用"
}# 默認禁用代理
disable_proxy

應用配置:

source ~/.zshrc# 如需啟用代理
enable_proxy

2.3 安裝Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"# 更新Homebrew
brew update

2,4 準備項目目錄

# 創建項目目錄
mkdir -p ~/Projects/k8s-testing
cd ~/Projects/k8s-testing# 克隆Kubespray項目
git clone https://github.com/upmio/kubespray-upm.git
cd kubespray-upm

2.5 安裝Vagrant及插件

# 安裝Vagrant
brew tap hashicorp/tap
brew install hashicorp/tap/hashicorp-vagrant# 驗證安裝
vagrant --version# 安裝Parallels插件
vagrant plugin install vagrant-parallels# 查看已安裝插件
vagrant plugin list

2.6 配置Python環境

2.6.1 安裝Python管理工具
brew install  python
2.6.2 配置Shell環境
vim ~/.zshrc

添加以下配置:

# Python環境配置
alias python=python3
alias pip=pip3

應用配置:

source ~/.zshrc
2.6.3 驗證Python環境
python --version
pip --version

2.6.4 安裝 pyenv

安裝依賴

brew install openssl readline sqlite3 xz zlib

安裝pyenv

curl https://pyenv.run | bash
vim ~/.zshrc

添加以下配置:

export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

應用配置:

source ~/.zshrc

2.6.5 升級Python工具

python -m pip install --upgrade pip
pyenv update

2.6.6 創建Python虛擬環境

# 安裝Python 3.12.11
pyenv install 3.12.11# 創建專用虛擬環境
pyenv virtualenv 3.12.11 kubespray-3.12.11-env#為項目設置默認 Python 環境
pyenv local kubespray-3.12.11-env# 安裝項目依賴
pip install -r requirements.txt

2.7 配置Kubespray

2.7.1 配置核心配置文件
# 復制Vagrant配置文件
cp vagrant_setup_scripts/Vagrantfile ./Vagrantfile# 創建vagrant配置目錄
mkdir -p vagrant
2.7.1.1 配置集群config.rb
$ vim  vagrant/config.rb
# Vagrant configuration file for Kubespray
# Vagrant configuration file for Kubespray
# Kubespray Vagrant Configuration Sample
# This file allows you to customize various settings for your Vagrant environment
# Copy this file to vagrant/config.rb and modify the values according to your needs# =============================================================================
# PROXY CONFIGURATION
# =============================================================================
# Configure proxy settings for the cluster if you're behind a corporate firewall
# Leave empty or comment out if no proxy is needed# HTTP proxy URL - used for HTTP traffic
# Example: "http://proxy.company.com:8080"
# $http_proxy = ""
$http_proxy = "http://10.211.55.2:7890"# HTTPS proxy URL - used for HTTPS traffic
# Example: "https://proxy.company.com:8080"
# $https_proxy = ""
$https_proxy = "http://10.211.55.2:7890"# No proxy list - comma-separated list of hosts/domains that should bypass proxy
# Common entries: localhost, 127.0.0.1, local domains, cluster subnets
# Example: "localhost,127.0.0.1,.local,.company.com,10.0.0.0/8,192.168.0.0/16"
# $no_proxy = ""
$no_proxy = "localhost,127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,::1,.demo.com"# Additional no proxy entries - will be added to the default no_proxy list
# Use this to add extra domains without overriding the defaults
# Example: ".internal,.corp,.k8s.local"
# $additional_no_proxy = ""
$additional_no_proxy = "localhost,127.0.0.1,192.168.0.0/16,10.0.0.0/8,172.16.0.0/12,::1,.demo.com"# =============================================================================
# ANSIBLE CONFIGURATION
# =============================================================================
# Ansible verbosity level for debugging (uncomment to enable)
# Options: "v" (verbose), "vv" (more verbose), "vvv" (debug), "vvvv" (connection debug)
#$ansible_verbosity = "vvv"# =============================================================================
# VIRTUAL MACHINE CONFIGURATION
# =============================================================================
# Prefix for VM instance names (will be followed by node number)
$instance_name_prefix = "k8s"# Default CPU and memory settings for worker nodes
$vm_cpus = 8                    # Number of CPU cores per worker node
$vm_memory = 16384              # Memory in MB per worker node (16GB)# Master/Control plane node resources
$kube_master_vm_cpus = 4        # CPU cores for Kubernetes master nodes
$kube_master_vm_memory = 4096   # Memory in MB for Kubernetes master nodes (4GB)# UPM Control plane node resources (if using UPM)
$upm_control_plane_vm_cpus = 12      # CPU cores for UPM control plane
$upm_control_plane_vm_memory = 24576 # Memory in MB for UPM control plane (24GB)# =============================================================================
# STORAGE CONFIGURATION
# =============================================================================
# Enable additional disks for worker nodes (useful for storage testing)
$kube_node_instances_with_disks = true# Size of additional disks in GB (200GB in this example)
$kube_node_instances_with_disks_size = "200G"# Number of additional disks per node
$kube_node_instances_with_disks_number = 1# Directory to store additional disk files
$kube_node_instances_with_disk_dir = ENV['HOME'] + "/kubespray_vm_disk/upm_disks"# Suffix for disk file names
$kube_node_instances_with_disk_suffix = "upm"# VolumeGroup configuration for additional disks
# Name of the VolumeGroup to create for additional disks
$kube_node_instances_volume_group = "local_vg_dev"# Enable automatic VolumeGroup creation for additional disks
$kube_node_instances_create_vg = true# =============================================================================
# CLUSTER TOPOLOGY
# =============================================================================
# Total number of nodes in the cluster (masters + workers)
$num_instances = 5# Number of etcd instances (should be odd number: 1, 3, 5, etc.)
$etcd_instances = 1# Number of Kubernetes master/control plane instances
$kube_master_instances = 1# Number of UPM control instances (if using UPM)
$upm_ctl_instances = 1# =============================================================================
# SYSTEM CONFIGURATION
# =============================================================================
# Vagrant Provider Configuration
# Specify the Vagrant provider to use for virtual machines
# If not set, Vagrant will auto-detect available providers in this order:
# 1. Command line --provider argument (highest priority)
# 2. VAGRANT_DEFAULT_PROVIDER environment variable
# 3. Auto-detection of installed providers (parallels > virtualbox > libvirt)
# 
# Supported options: "virtualbox", "libvirt", "parallels"
# 
# Provider recommendations:
# - virtualbox: Best for development and testing (free, cross-platform)
# - libvirt: Good for Linux production environments (KVM-based)
# - parallels: Good for macOS users with Parallels Desktop
# 
# Leave commented for auto-detection, or uncomment and set to force a specific provider
# $provider = "virtualbox"# Timezone for all VMs
$time_zone = "Asia/Shanghai"# Ntp Sever Configuration
$ntp_enabled = "True"
$ntp_manage_config = "True"# Operating system for VMs
# Supported options: "ubuntu2004", "ubuntu2204", "centos7", "centos8", "rockylinux8", "rockylinux9", etc.
$os = "rockylinux9"# =============================================================================
# NETWORK CONFIGURATION
# =============================================================================
# Network type: "nat" or "bridge"
#
# nat: Auto-detect provider network and assign IPs (recommended)
#   - Automatically detects provider default network (usually 192.168.x.0/24)
#   - Uses NAT networking for VM internet access
#   - VMs can communicate with each other and host
#   - Simpler setup, no bridge configuration required
#   - Recommended for development and testing
#
# bridge: Use bridge network with manual IP configuration
#   - Requires manual bridge interface setup on host
#   - VMs get IPs from same subnet as host network
#   - Direct network access, VMs appear as separate devices on network
#   - More complex setup, requires bridge configuration
#   - Recommended for production-like environments
$vm_network = "nat"# Starting IP for the 4th octet (VMs will get IPs starting from this number)
# Used in both nat (with auto-detected subnet) and bridge modes
$subnet_split4 = 100# The following network settings are only used when $vm_network = "bridge"
# For nat, subnet/gateway/netmask are auto-detected from provider# Network subnet (first 3 octets) - bridge only
# $subnet = "10.37.129"# Network configuration - bridge only
# $netmask = "255.255.255.0"      # Subnet mask
# $gateway = "10.37.129.1"        # Default gateway
# $dns_server = "8.8.8.8"         # DNS server
$dns_server = "10.211.55.2"  # (可選)如果配置私有dns,需要在macOS 安裝 dns server,否則重啟虛擬機,可能會有pod異常。
# Bridge network interface (required when using "bridge")
# Example: On linux, libvirt bridge interface name: br0
# $bridge_nic = "br0"
# Example: On linux, vitrulbox bridge interface name: virbr0
# $bridge_nic = "virbr0"# =============================================================================
# KUBERNETES CONFIGURATION
# =============================================================================
# Container Network Interface (CNI) plugin
# Options: "calico", "flannel", "weave", "cilium", "kube-ovn", etc.
$network_plugin = "calico"# Cert-Manager Configuration
$cert_manager_enabled = "True"             # Enable cert-manager# Local Path Provisioner Configuration
$local_path_provisioner_enabled = "False"    # Enable local path provisioner
$local_path_provisioner_claim_root = "/opt/local-path-provisioner/"  # Local path root# Ansible inventory directory
$inventory = "inventory/sample"# Shared folders between host and VMs (empty by default)
$shared_folders = {}# Kubernetes version to install
$kube_version = "1.33.3"
# Kubespray Vagrant Configuration Sample
2.7.1.2 配置 containerd.yml(可選)
$ vim inventory/sample/group_vars/all/containerd.yml
---
# Please see roles/container-engine/containerd/defaults/main.yml for more configuration options# containerd_storage_dir: "/var/lib/containerd"
# containerd_state_dir: "/run/containerd"
# containerd_oom_score: 0# containerd_default_runtime: "runc"
# containerd_snapshotter: "native"# containerd_runc_runtime:
#   name: runc
#   type: "io.containerd.runc.v2"
#   engine: ""
#   root: ""# containerd_additional_runtimes:
# Example for Kata Containers as additional runtime:
#   - name: kata
#     type: "io.containerd.kata.v2"
#     engine: ""
#     root: ""# containerd_grpc_max_recv_message_size: 16777216
# containerd_grpc_max_send_message_size: 16777216# Containerd debug socket location: unix or tcp format
# containerd_debug_address: ""# Containerd log level
# containerd_debug_level: "info"# Containerd logs format, supported values: text, json
# containerd_debug_format: ""# Containerd debug socket UID
# containerd_debug_uid: 0# Containerd debug socket GID
# containerd_debug_gid: 0# containerd_metrics_address: ""# containerd_metrics_grpc_histogram: false# Registries defined within containerd.
containerd_registries_mirrors:- prefix: quay.iomirrors:- host: https://quay.nju.edu.cncapabilities: ["pull", "resolve"]skip_verify: false- host: http://harbor.demo.comcapabilities: ["pull", "resolve"]skip_verify: true- prefix: docker.iomirrors:- host: http://harbor.demo.comcapabilities: ["pull", "resolve"]skip_verify: true- host: https://dockerproxy.comcapabilities: ["pull", "resolve"]skip_verify: false- prefix: ghcr.iomirrors:- host: https://ghcr.nju.edu.cncapabilities: ["pull", "resolve"]skip_verify: false- host: https://ghcr.dockerproxy.comcapabilities: ["pull", "resolve"]skip_verify: false- prefix: registry.k8s.iomirrors:- host: https://k8s.mirror.nju.edu.cncapabilities: ["pull", "resolve"]skip_verify: false- host: https://k8s.dockerproxy.comcapabilities: ["pull", "resolve"]skip_verify: false# containerd_max_container_log_line_size: -1

🔧 3. 部署集群

3.1 啟動虛擬機并部署K8s

?? 注意: 此過程需要10-15分鐘,具體時間取決于網絡狀況和硬件性能

vagrant up --no-parallel

3.2 如果部署失敗,可以重試

vagrant provision --provision-with ansible

🎯 4. 配置kubectl訪問

4.1 安裝kubectl客戶端

# 下載kubectl(Apple Silicon版本)
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl"# 設置執行權限并移動到PATH目錄
chmod +x kubectl && mv kubectl /usr/local/bin/kubectl# 驗證安裝
kubectl version --client

4.2 配置集群訪問

# 復制kubeconfig文件
mkdir -p ~/.kube
cp inventory/sample/artifacts/admin.conf ~/.kube/config# 驗證集群連接
kubectl get nodes
kubectl get pods --all-namespaces

📦 5. 安裝Helm(可選)

# 下載安裝腳本
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3# 執行安裝
chmod 700 get_helm.sh
./get_helm.sh# 驗證安裝
helm version

🧹 6. 清理環境

6.1 銷毀虛擬機

vagrant destroy -f

6.2 退出Python虛擬環境

pyenv deactivate

🛠? 7. 故障排除

7.1 常見問題

1. Vagrant啟動失敗

  • 檢查Parallels Desktop是否正常運行
  • 確認系統資源充足(內存、磁盤空間)
  • 檢查網絡連接狀態

2. Python依賴安裝失敗

  • 確認已激活正確的虛擬環境
  • 嘗試升級pip:pip install --upgrade pip
  • 檢查網絡代理設置

3. kubectl無法連接集群

  • 確認kubeconfig文件路徑正確
  • 檢查虛擬機網絡狀態:vagrant status
  • 驗證SSH連接:vagrant ssh

4. 網絡問題

  • 如在國內環境,建議配置代理
  • 可以嘗試使用國內鏡像源

7.2 有用的調試命令

# 檢查Vagrant狀態
vagrant status# 查看虛擬機日志
vagrant ssh -c "sudo journalctl -u kubelet"# 重新加載Vagrant配置
vagrant reload# 查看集群狀態
kubectl cluster-info
kubectl get componentstatuses

📝 8. 總結

通過以上步驟,你應該已經成功搭建了一個基于Kubespray的Kubernetes測試集群。這個環境非常適合:

  • 學習Kubernetes核心概念
  • 測試應用部署
  • 驗證集群配置
  • 開發云原生應用

💡 提示: 建議定期備份重要的配置文件和項目代碼,避免因誤操作導致數據丟失。


相關資源鏈接:

  • Kubespray官方文檔
  • Vagrant官方文檔
  • Kubernetes官方文檔
  • Helm官方文檔

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/917314.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/917314.shtml
英文地址,請注明出處:http://en.pswp.cn/news/917314.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【AI學習】RadioDiff:代碼學習

之前學習了RadioDiff這篇論文,最近在復刻相關代碼。 這段代碼實現了一個基于潛在擴散模型(Latent Diffusion Model, LDM)的訓練框架。借助DeepSeek總體學習一下: 1. 整體結構 代碼主要分為以下幾個部分: 參數解析和…

【專題十七】多源 BFS

📝前言說明: 本專欄主要記錄本人的基礎算法學習以及LeetCode刷題記錄,按專題劃分每題主要記錄:(1)本人解法 本人屎山代碼;(2)優質解法 優質代碼;&#xff…

京東零售在智能供應鏈領域的前沿探索與技術實踐

近日,“智匯運河 智算未來”2025人工智能創新創業大會在杭州召開。香港工程科學院院士、香港大學副校長、研究生院院長、講座教授、京東零售供應鏈首席科學家申作軍教授與供應鏈算法團隊技術總監戚永志博士受邀出席并擔任《AI智慧物流與供應鏈分享會》聯席主席&…

MyBatisPlus之CRUD接口(IService與BaseMapper)

MyBatisPlus之CRUD接口—IService與BaseMapper一、BaseMapper與IService的關系二、BaseMapper核心方法詳解2.1 新增操作(Insert)2.2 查詢操作(Select)2.3 更新操作(Update)2.4 刪除操作(Delete&…

axios請求的取消

axios請求的取消解決:axios請求的取消解決:axios請求的取消 在使用 Axios 發起請求時,有時候你可能需要取消這些請求,比如當組件銷毀時或者用戶操作導致不再需要獲取之前發起的請求結果。Axios 支持通過 Cancel Token 取消請求。 …

深入理解C++中的Lazy Evaluation:延遲計算的藝術

在編程世界里,“最好的運算就是從未執行的運算” —— 這句話深刻揭示了性能優化的核心思路。如果一個計算過程最終不會被使用,那么提前執行它就是純粹的資源浪費。這種思想衍生出了 Lazy Evaluation(緩式評估) 技術:延…

php完整處理word中表單數據的方法

使用php基礎方式實現word中表單處理<?php/*** zipFile 類用于處理 .docx 文件的解壓、修改和重新打包*/ class zipFile {/** var ZipArchive ZIP 文件對象 */private $zipFile;/** var string 臨時目錄路徑 */private $tempDir;/** var string 嵌入的 Excel 文件臨時目錄路…

Node.js 操作 MongoDB

目錄 Node.js 操作 MongoDB 一、什么是 MongoDB&#xff1f; 二、MongoDB 的功能概覽 三、MongoDB 的安裝與啟動 安裝 MongoDB&#xff08;以本地安裝為例&#xff09; 啟動 MongoDB 四、Node.js 如何連接 MongoDB&#xff1f; 使用 Mongoose ODM 工具 建立連接 五、…

先學Python還是c++?

選擇先學Python還是C&#xff0c;取決于你的學習目標、應用場景和職業規劃。以下是兩者的對比分析和建議&#xff0c;幫助你做出更適合自己的選擇&#xff1a;一、核心差異對比維度PythonC學習曲線簡單易上手&#xff08;語法接近自然語言&#xff09;復雜&#xff08;需理解指…

Trae + Notion MCP:將你的Notion數據庫升級為智能對話機器人

前言 Notion作為一款功能強大的信息管理工具&#xff0c;被廣泛用于項目跟蹤、知識庫構建和數據整理。然而&#xff0c;隨著數據量的增長&#xff0c;我們常常會發現自己陷入了重復和繁瑣的操作中。比如&#xff0c;為了找到符合特定條件的幾條數據&#xff0c;需要在龐大的數…

【iOS】retain/release底層實現原理

文章目錄前言前情知識retain和release的實現原理&#xff08;MRC手動管理&#xff09;retain&#xff08;MRC手動管理&#xff09;retain源碼內聯函數rootRetain源碼相關的sidetable_tryRetain()方法retain底層工作流程總結releaserelease源碼內聯函數rootRelease源碼小結前言 …

文件同步神器-rsync命令講解

rsync 是一個強大的文件同步與傳輸工具&#xff0c;廣泛用于本地或遠程服務器之間的高效文件備份、鏡像或同步。其核心優勢是通過增量傳輸?&#xff08;僅傳輸文件差異部分&#xff09;和壓縮減少數據傳輸量&#xff0c;同時支持保留文件元數據&#xff08;如權限、時間戳、所…

Rust: 工具鏈版本更新

遇到 cargo build --release 錯誤&#xff0c;比如&#xff0c;當前 Rust 工具鏈版本&#xff08;1.78.0&#xff09;低于依賴項所需的最低版本&#xff08;部分依賴要求 ≥1.82.0&#xff09;。以下是系統化的解決方案&#xff1a; &#x1f527; 一、升級 Rust 工具鏈&#x…

Prompt-to-Prompt| 修改Attention會有“反向傳播”或梯度計算?

需要注意的幾個問題&#xff1a;額外計算開銷&#xff1a;Cross-Attention Control原因&#xff1a;Prompt-to-Prompt的編輯方法需要動態干預交叉注意力&#xff08;Cross-Attention&#xff09;層的權重&#xff0c;這會引入額外的計算和顯存占用&#xff1a;需要緩存注意力矩…

電商API接口的優勢、數據采集方法及功能說明

一、電商API接口的核心優勢1. 高效性與準確性數據采集效率&#xff1a;API通過標準化參數&#xff08;如商品ID、類目&#xff09;直接獲取結構化數據&#xff08;JSON/XML&#xff09;&#xff0c;無需解析HTML&#xff0c;減少誤差。例如&#xff0c;采集1000條商品信息&…

iOS企業簽名掉簽,iOS企業簽名掉簽了怎么辦?

不能上架到App Store的iOS應用 &#xff0c;幾乎每一個開發者的選擇都是通過iOS簽名這種內測渠道來完成APP的上架任務&#xff0c;最常用的就是企業簽名、超級簽名以及TF上架&#xff0c;其中最受歡迎的當屬于企業簽名了。不過企業簽名會出現掉簽的現象&#xff0c;那么企業簽名…

存儲成本深度優化:冷熱分層與生命周期管理——從視頻平臺年省200萬實踐解析智能存儲架構

一、冷熱分層&#xff1a;存儲成本優化的核心邏輯1.1 數據訪問的“二八定律”據行業統計&#xff0c;80%的訪問集中在20%的熱數據上&#xff0c;而超過90天的歷史數據訪問頻率下降70%以上。某視頻平臺存儲超10PB媒體文件&#xff0c;未分層前年存儲成本高達680萬元&#xff0c;…

Java設計模式之《備忘錄模式》

目錄 1. 概念 1.1、定義 1.2、適用場景 2、角色劃分 3、實現 1、Originator&#xff08;發起人&#xff09; 2、Memento&#xff08;備忘錄&#xff09; 3、Caretaker&#xff08;管理者&#xff09; 4、使用示例 4、優缺點 4.1、優點 4.2、缺點 前言 備忘錄模式是…

SpringBoot 多環境配置

在實際項目開發中&#xff0c;不同環境往往有不同的配置需求&#xff1a; 開發環境&#xff08;dev&#xff09;&#xff1a;本地調試&#xff0c;連接測試數據庫&#xff1b;測試環境&#xff08;test&#xff09;&#xff1a;接口聯調&#xff0c;接近真實場景&#xff1b;生…

延凡智慧醫院數字孿生平臺

延凡智慧醫院數字孿生平臺是延凡科技依托物聯網、數字孿生、AI 算法及邊緣計算技術打造的醫療場景全要素數字化解決方案&#xff0c;通過構建醫院物理實體與虛擬空間的實時映射&#xff0c;實現醫療資源優化、運營效率提升及患者體驗升級。一、平臺價值&#xff08;一&#xff…