導航:首頁 > 網路營銷 > semopen用法

semopen用法

發布時間:2020-11-01 18:05:06

1、雲平台openstack中,cloudinit裝配,使用怎麼解決

雲平台中,cloudinit安裝、使用

cloudinit是專為雲環境中虛擬機的初始化而開發的工具,它從各種數據源讀取相關數據並據此對虛擬機進行配置。常見的數據源包括:雲平台的metadata服務、ConfigDrive等,常見的配置包括:設定虛擬機的hostname、hosts文件、設定用戶名密碼、更新apt -get的本地緩存、調整文件系統的大小(注意不是調整分區的大小)等。
本文在openstack下進行測試。
(1)安裝
centos 6.4和ubuntu server 12.04的官方源中已經包含cloudinit,直接採用yum 或者 apt -get安裝即可
源碼地址:https://launchpad.net/cloud-init
(2)配置
配置文件/etc/cloud/cloud.cfg
user: root
disable_root: 0
manage_etc_hosts: True
preserve_hostname: False

cloud_init_moles:
- bootcmd
- resizefs
- set_hostname
- update_hostname
- update_etc_hosts
- ca-certs
- rsyslog
- ssh

cloud_config_moles:
- mounts
- ssh-import-id
- locale
- set-passwords
- grub-dpkg
- landscape
- timezone
- puppet
- chef
- salt-minion
- mcollective
- disable-ec2-metadata
- runcmd
- byobu

cloud_final_moles:
- rightscale_userdata
- scripts-per-once
- scripts-per-boot
- scripts-per-instance
- scripts-user
- keys-to-console
- phone-home
- final-message

配置文件大致分為兩部分,開頭的變數/參數定義部分、後邊要運行的模塊列表(包括三大類cloud_init_moles、cloud_config_moles、cloud_final_moles)。
各模塊在運行時,會根據之前定義的變數/參數的值,配置虛擬機的狀態。
這里舉一個簡單的例子,update_etc_hosts模塊(源文件:/usr/lib/python2.7/dist-packages/cloudinit/CloudConfig/cc_update_etc_hosts.py)
顧名思義,該模塊用來設置主機的hosts文件,其中就用到了hostname、fqdn、manage_etc_hosts等變數的值。模塊首先嘗試從cloudinit的配置文件中讀取這些變數的值,如果沒有定義,則嘗試從其他的數據源中獲取變數的值,例如對於openstac來講,可以從metadata service(http://169.254.169.254/latest/meta-data/hostname)獲取虛擬機的主機名。
(3)運行流程
cloudinit會在虛擬機啟動的過程中分四個階段運行,按照時間順序分為:cloud-init-local, cloud-init, cloud-config, cloud-final,例如對於centos:

cloud-init-local階段主要是運行本地的一些初始化腳本(緩存下來的腳本??)
cloud-init階段執行配置文件中名為cloud_init_moles下的所有模塊,如果模塊列表為空,則什麼都不運行。其他兩個階段類似,就不介紹了。
分階段執行的必要性在於,有些模塊的執行對系統當前的狀態會有要求(比如網路ready、文件系統掛載over),因此cloudinit抽象出了四個階段,編寫自己的初始化模塊時可以根據情況歸入不同的階段。
另外,模塊有多種運行模式,包括per-once、per-instance、per-always,對於模式為per-once的模塊,一旦運行完畢會在一個名為sem的目錄中創建一個信號文件,從而防止模塊的在下次啟動時重復運行。

2、As____in today's newspaper,all the schools will open in Semptember.

it is announced,沒主語不行,as是副詞

3、linux信號燈使用sem_open的錯誤 sem_open_test.c:(.text+0x4c):對『sem_open』未定義的引用

g

4、emerge python * configure has detected that the sem_open function is broken.

* ERROR: dev-lang/python-2.7.5-r3::gentoo failed (configure phase):
* Broken sem_open function (bug 496328)
* die "Broken sem_open function (bug 496328)";
以上3條提示錯誤,你這個應該是應用程序的編程階段或者測試。錯誤處修改,或者上下路邏輯檢查

與semopen用法相關的知識