Compute Engine 服務支援使用 gcloud compute instances bulk create
指令建立多個 VM。
以下各節說明如何建立啟動指令碼,並將其部署至任意數量的 Compute Engine VM。
如需建立及連線至單一 VM 的詳細操作說明,請參閱「從 Compute Engine 連線:單一用戶端」。
所需權限
如要建立 Compute Engine VM,您必須具備下列 IAM 角色:
- Compute 執行個體管理員 (v1) (
roles/compute.instanceAdmin.v1
)。詳情請參閱 [Compute Engine 說明文件][gce-role]。
設定環境變數
本文範例指令會使用下列環境變數:
export SSH_USER="daos-user"
export CLIENT_PREFIX="daos-client-vm"
export NUM_CLIENTS=10
將這些值更新為所需值。
建立 SSH 金鑰
建立 SSH 金鑰並儲存至本機,以便分配給用戶端 VM。金鑰會與環境變數中指定的 SSH 使用者建立關聯,並在每個 VM 上建立:
# Generate an SSH key for the specified user
ssh-keygen -t rsa -b 4096 -C "${SSH_USER}" -N '' -f "./id_rsa"
chmod 600 "./id_rsa"
# Create a new file in the format [user]:[public key] user
echo "${SSH_USER}:$(cat "./id_rsa.pub") ${SSH_USER}" > "./keys.txt"
取得 Parallelstore 網路詳細資料
以 daos 代理可使用的格式取得 Parallelstore 伺服器 IP 位址:
export ACCESS_POINTS=$(gcloud beta parallelstore instances describe INSTANCE_NAME \
--location LOCATION \
--format "value[delimiter=', '](format("{0}", accessPoints))")
取得與 Parallelstore 執行個體相關聯的網路名稱:
export NETWORK=$(gcloud beta parallelstore instances describe INSTANCE_NAME \
--location LOCATION \
--format "value[delimiter=', '](format("{0}", network))") | awk -F '/' '{print $NF}'
建立開機指令碼
開機指令碼會附加至 VM,且每次系統啟動時都會執行。開機指令碼會執行下列作業:
- 設定 daos 代理程式
- 安裝必要程式庫
- 將 Parallelstore 執行個體掛接至每個 VM 的
/tmp/parallelstore/
下列指令碼適用於執行 HPC Rocky 8 的 VM。
# Create a startup script that configures the VM
cat > ./startup-script << EOF
sudo tee /etc/yum.repos.d/parallelstore-v2-6-el8.repo << INNEREOF
[parallelstore-v2-6-el8]
name=Parallelstore EL8 v2.6
baseurl=https://us-central1-yum.pkg.dev/projects/parallelstore-packages/v2-6-el8
enabled=1
repo_gpgcheck=0
gpgcheck=0
INNEREOF
sudo dnf makecache
# Install daos-client
dnf install -y epel-release # needed for capstone
dnf install -y daos-client
# Upgrade libfabric
dnf upgrade -y libfabric
systemctl stop daos_agent
mkdir -p /etc/daos
cat > /etc/daos/daos_agent.yml << INNEREOF
access_points: ${ACCESS_POINTS}
transport_config:
allow_insecure: true
fabric_ifaces:
- numa_node: 0
devices:
- iface: eth0
domain: eth0
INNEREOF
echo -e "Host *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile /dev/null" > /home/${SSH_USER}/.ssh/config
chmod 600 /home/${SSH_USER}/.ssh/config
usermod -u 2000 ${SSH_USER}
groupmod -g 2000 ${SSH_USER}
chown -R ${SSH_USER}:${SSH_USER} /home/${SSH_USER}
chown -R daos_agent:daos_agent /etc/daos/
systemctl enable daos_agent
systemctl start daos_agent
mkdir -p /tmp/parallelstore
dfuse -m /tmp/parallelstore --pool default-pool --container default-container --disable-wb-cache --thread-count=16 --eq-count=8 --multi-user
chmod 777 /tmp/parallelstore
EOF
如要瞭解如何最佳化 --thread-count
和 --eq-count
的值,請參閱「效能考量」頁面的「執行緒計數和事件佇列計數」一節。
建立用戶端 VM
工作負載的整體效能取決於用戶端機器類型。
以下範例使用 c2-standard-30
VM;請修改 machine-type
值,以更快的 NIC 提升效能。如要瞭解可用的機器類型,請參閱機器家族資源與比較指南。
如要大量建立 VM 執行個體,請使用 gcloud compute instances bulk create
指令:
gcloud compute instances bulk create \
--name-pattern="${CLIENT_PREFIX}-####" \
--zone="LOCATION" \
--machine-type="c2-standard-30" \
--network-interface=subnet=${NETWORK},nic-type=GVNIC \
--network-performance-configs=total-egress-bandwidth-tier=TIER_1 \
--create-disk=auto-delete=yes,boot=yes,device-name=client-vm1,image=projects/cloud-hpc-image-public/global/images/hpc-rocky-linux-8-v20240126,mode=rw,size=100,type=pd-balanced \
--metadata=enable-oslogin=FALSE \
--metadata-from-file=ssh-keys=./keys.txt,startup-script=./startup-script \
--count ${NUM_CLIENTS}