OpenStack 常用命令

來源:互聯網
上載者:User

標籤:

常用操作:
常用的查詢命令
#keystone user-list 查詢使用者資訊
#keystone role-list 查詢角色資訊
#keystone tenant-list 

  查詢租戶資訊
#glance index   查詢當前存在的鏡像資訊
#nova image-list    查看當前存在的鏡像狀態
#nova secgroup-list 查看當前存在的安全性群組
#nova keypair-list  查看當前存在的密鑰
#nova flavor-list   查看當前可以建立的執行個體類型
#nova list  查看執行個體的狀態
#nova console-log cirros    查看執行個體cirros的開機記錄資訊
#nova-manage service list   查詢當前啟動的Compute服務狀態
#nova-manage version list   查詢當前安裝軟體的版本
#nova-manage vm list    列出所有的執行個體狀態
#nova-manage fixed list 列出所有的固定內網IP地址資訊及分配情況
#nova-manage floating list  列出所以浮動IP地址資訊及分配情況
#nova-manage host list  列出當前主機的資訊
#nova-manage network list   列出當前網路的相關資訊
#nova-manage logs errors    列出錯誤的日誌資訊
#nova-manage logs syslog    列出syslog日誌資訊

nova flavor-list
nova show myserver1
nova console-log myserver2
nova delete myserver2

虛擬網路命令
brctl
virsh

tgtadm --lld iscsi --op show --mode target 控制節點查看target
tgtadm --op new --lld=iscsi --mode=target --tid=1 --targetname=iqn.2010-10.org.openstack:volume-00000001 建立target

nova 掛接執行個體/分區
sudo nova-rootwrap guestmount --rw -a /home/instances/instance-0000001b/disk -m /dev/sda1 /tmp/tmpfe4fNg

配置:nova.conf
##################filter#############
#scheduler_default_filters=AvailabilityZoneFilter,RamFilter,ComputeFilter,IsolatedHostsFilter
#isolated_hosts=hyops2.elex.com
#isolated_images=ee30929c-a3bb-42a7-a494-9a77ae501c54
配置於nova.conf
規定在某個images上建立的執行個體位於固定計算節點主機

重新初始化nova庫:
停止控制和計算節點的nova服務,刪除/home/instances目錄下的檔案
nova-manage network delete 192.168.193.0/24
nova-manage network delete 10.18.4.0/24
mysql -uroot -p
mysql> drop database nova
mysql> create database nova;
mysql> grant all privileges on nova.* to ‘nova_user‘@‘%‘ identified by ‘nova_pw3465‘;
nova-manage db sync
nohup /usr/bin/python /usr/bin/nova-all >> /var/log/nova.log 2>&1 &
nova-manage network create --label=public --fixed_range_v4=10.18.4.0/24 --num_networks=1 --network_size=256 --gateway=10.18.4.254 --bridge=br_pu --bridge_interface=em1 --multi_host=‘F‘
nova-manage network create --label=private --fixed_range_v4=192.168.193.0/24 --num_networks=1 --network_size=256 --gateway=192.168.193.1 --bridge=br_pr --bridge_interface=em2 --multi_host=‘F‘
建立密鑰:
nova keypair-add mykey > oskey.priv
chmod 600 oskey.priv
設定安全性原則
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
nova secgroup-list
nova secgroup-list-rules default
上傳鏡像
glance add name="CentOS-6.3_Fina_qcow2" is_public=true container_format=bare disk_format=qcow2 < CentOS-6.3_Fina_qcow2.img
glance add name="CentOS-6.3_Fina_raw" is_public=true container_format=bare disk_format=raw < CentOS-6.3_Fina_raw.img
重建執行個體


常見錯誤:
已解決
註:vncserver_listen的值在計算節點上時應配置成計算節點的ip
  不然會報錯libvirtError: operation failed: failed to retrieve chardev info in qemu with ‘info chardev‘而無法啟動執行個體。

ERROR nova.manager [-] Error during ComputeManager.update_available_resource: list index out of range
  libvir: QEMU error : Domain not found: no domain with matching name ‘instance-00000002‘
  RemoteError: Remote error: InstanceNotFound Instance instance-00000002 could not be found.
  此三類錯誤解決方案:/usr/lib/python2.6/site-packages/nova-2012.1-py2.6.egg/nova/virt/libvirt/utils.py:95
    此檔案的backing_file = [i.split(‘actual path:‘)[1].strip()[:-1]替換為backing_file = [i.strip()[:-1]
    
解決啟動nova-network、nova-volume出現timeout錯誤:
   /usr/lib/python2.6/site-packages/eventlet/green/subprocess.py
   第35行換成def wait(self, check_interval=0.01, timeout=None):

nova-novncproxy啟動報錯
ImportError: No module named websockify
解決:yum install python-websockify

Stderr: ‘sudo: sorry, you must have a tty to run sudo\n‘
而 CentOS 的 sudo 選項 requiretty 是預設開啟的,ssh 需要一個 tty 才能執行,所以遠程 sudo 就會出錯
關閉(注釋掉) requiretty 這行:
# chmod 0440 /etc/sudoers; chmod 0440 /etc/sudoers.d/nova
# vi /etc/sudoers
注釋行 #Defaults requiretty
#cat /etc/sudoers.d/nova 或在 /etc/sudoers添加
nova        ALL=(ALL)       NOPASSWD: ALL

啟動rabbitmq-server出錯
ERROR: epmd error for host "hyops4": address (unable to establish tcp connection)
解決辦法:添加hyops4的解析到hosts檔案

glance資料庫已經有了,但是用glance index提示
glance index
Failed to show index. Got error:
You are not authenticated.
注意admin_passwd 和 service_passwd的區別

RemoteError: Remote error: NetworkNotFound Network 5 could not be found.
重新建立網路nova-manage network create後出現 要修改資料庫資料刪除virtual_interfaces表中網路ID為5的行

VNC始終轉寄的是127.0.0.1的IP,計算節點的nova.conf內的vncserver_proxyclient_address不起作用
原因:在計算節點程式啟動目錄有另外的nova.conf配置存在,且vncserver_proxyclient_address指向127.0.0.1

尚未解決
關閉nova DEBUG資訊

TRACE nova.api.openstack Timeout: Timeout while waiting on RPC response.
TRACE nova.rpc.common timeout: timed out
  RabbitMQ AQMP queue is full.

==> /var/log/nova/compute.log <==
libvir: QEMU error : Domain not found: no domain with matching name ‘instance-0000000f‘  建立執行個體時報此錯誤
...
2012-12-10 02:55:20 WARNING nova.virt.libvirt.connection [req-e4...db 6760c8a1013840aebd32655e379bca59] [instance: 77...ab24] \
  Ignoring error injecting data into image 517c8f63-d3fb-4112-b56c-6e80d65d4062 ([Errno 16] Device or resource busy: ‘/tmp/tmprI2cza‘)

WARNING nova.compute.manager [-] Found 1 in the database and 0 on the hypervisor.
WARNING nova.compute.manager [-] [instance: 5...7] Instance found in database but not known by hypervisor. Setting power state to NOSTATE


Ops建立VM流程(FlatDHCP)
工作流程
請求:nova boot --image ttylinux --flavor 1 i-01
nova-api 接受請求,一個tcp REST請求.
nova-api 發送一個建立虛擬機器的請求到訊息佇列,並會存資料庫,帶uuid.
nova-scheduler 接受這個訊息,並進行過濾,根據請求的虛擬資源,即flavor的資訊.
scheduler會找到一個可用的主機(裝有nova-compute的物理主機),如果沒有找到就虛擬機器的狀態設定成ERROR,
如果有可用主機,就發訊息到nova-network,就進入下一步,配置網路,註:此過程虛擬機器處於scheduling任務狀態。
nova-network 接收到訊息就,從fixed IP表(資料庫)裡拿出一個可用IP,
並設定dnsmsq(DHCP server),確保拿出的IP可以與對應的MAC地址(產生的)對應,
確保虛擬機器可以被賦予對應的IP設定IPTABLE.
對fixed IP 進行地址轉換,使虛擬機器可以訪問外網,
設定好network之後,會發訊息到訊息佇列,使要在其上建立虛擬機器的物理計算節點就收到建立虛擬機器的訊息,
計算節點接收到訊息後,就開始建立虛擬機器,首先會download鏡像從glance上
然後會根據之前產生的uuid,MAC,鏡像位置,
建立一個啟動虛擬機器的xml檔案,然後會調用libvirt介面,根據xml配置建立虛擬機器,虛擬機器建立完成之後,
會把虛擬機器狀態改成ACTIVE
至此,一台虛擬機器發布完成

OpenStack 常用命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.