時(shí)間:2023-07-12 10:57:01 | 來(lái)源:網(wǎng)站運(yùn)營(yíng)
時(shí)間:2023-07-12 10:57:01 來(lái)源:網(wǎng)站運(yùn)營(yíng)
如何使用cloud-init初始化云主機(jī):使用cloud-init初始化云主機(jī)// 在虛擬機(jī)安裝apt install cloud-init// 設(shè)置開機(jī)啟動(dòng)systemctl enable cloud-init-local.servicesystemctl enable cloud-init.servicesystemctl enable cloud-config.servicesystemctl enable cloud-final.service
// 編輯/etc/cloud/cloud.cfg添加 datasource_list: [NoCloud]
instance-id: my-instance-id1local-hostname: my-host-name4
cloud-init根據(jù)instance-id的值決定是否初始化,instance-id有變化則執(zhí)行初始化,一般來(lái)說(shuō)云主機(jī)只需要初始化一次,如果需要再次初始化,可以改變instance-id的值。#cloud-configwrite_files: - encoding: b64 content: aGVsbG8gd29ybGQK path: /rjy.test permissions: '0755' - content: | alias xxx hello world path: /etc/rjy.test
文件可以是明文傳輸也可以是base64加密傳輸。version: 2ethernets: eth0: match: mac_address: "52:54:00:da:17:ac" addresses: - 192.168.122.10/255.255.255.0 gateway4: 192.168.122.1 nameservers: addresses: [8.8.8.8]
genisoimage -o config.iso -V cidata -r -J meta-data user-data network-config
<disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/var/lib/libvirt/images/config.iso'/> <backingStore/> <target dev='hda' bus='ide'/> <readonly/> <alias name='ide0-0-0'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/></disk>
重啟云主機(jī),就可以看到初始化的效果了。關(guān)鍵詞:主機(jī),使用
客戶&案例
營(yíng)銷資訊
關(guān)于我們
客戶&案例
營(yíng)銷資訊
關(guān)于我們
微信公眾號(hào)
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。