openstack-keystone外組件命令行
摘自openstack文檔
鏡像(glance)
列出您可以訪問的鏡像
$ openstack image list
刪除指定的鏡像
$ openstack image delete IMAGE
描述一個指定的鏡像
$ openstack image show IMAGE
更新鏡像
$ openstack image set IMAGE
上傳內核鏡像
$ openstack image create "cirros-threepart-kernel" --disk-format aki --container-format aki --public --file ~/images/cirros-0.3.5-x86_64-kernel
上傳RAM鏡像
$ openstack image create "cirros-threepart-ramdisk" --disk-format ari --container-format ari --public --file ~/images/cirros-0.3.5-x86_64-initramfs
上傳第三方鏡像
$ openstack image create "cirros-threepart" --disk-format ami --container-format ami --public --property kernel_id=$KID-property ramdisk_id=$RID --file ~/images/cirros-0.3.5-x86_64-rootfs.img
註冊raw鏡像
$ openstack image create "cirros-raw" --disk-format raw --container-format bare --public --file ~/images/cirros-0.3.5-x86_64-disk.img
計算 (nova)
列出實例,核實實例狀態
$ openstack server list
列出鏡像
$ openstack image list
Create a flavor named m1.tiny
$ openstack flavor create --ram 512 --disk 1 --vcpus 1 m1.tiny
列出規格類型
$ openstack flavor list
用類型和鏡像名稱(如果名稱唯一)來啟動雲主機
$ openstack server create --image IMAGE --flavor FLAVOR INSTANCE_NAME
$ openstack server create --image cirros-0.3.5-x86_64-uec --flavor m1.tiny MyFirstInstance
Log in to the instance (from Linux)
註解
The ip command is available only on Linux. Using ip netns provides your environment a copy of the network stack with its own routes, firewall rules, and network devices for better troubleshooting.
# ip netns
# ip netns exec NETNS_NAME ssh USER@SERVER
# ip netns exec qdhcp-6021a3b4-8587-4f9c-8064-0103885dfba2 ssh [email protected]
註解
In CirrOS, the password for user cirros
is cubswin:)
. For any other operating system, use SSH keys.
Log in to the instance with a public IP address (from Mac)
$ ssh [email protected]
顯示實例詳細信息
$ openstack server show NAME
$ openstack server show MyFirstInstance
查看雲主機的控制臺日誌
$ openstack console log show MyFirstInstance
設置雲主機的元數據
$ nova meta volumeTwoImage set newmeta=‘my meta data‘
創建一個實例快照
$ openstack image create volumeTwoImage snapshotOfVolumeImage
$ openstack image show snapshotOfVolumeImage
實例的暫停、掛起、停止、救援、調整規格、重建、重啟
暫停
$ openstack server pause NAME
$ openstack server pause volumeTwoImage
取消掛起
$ openstack server unpause NAME
掛起
$ openstack server suspend NAME
Unsuspend
$ openstack server resume NAME
關機
$ openstack server stop NAME
開始
$ openstack server start NAME
恢復
$ openstack server rescue NAME
$ openstack server rescue NAME --rescue_image_ref RESCUE_IMAGE
調整大小
$ openstack server resize NAME FLAVOR
$ openstack server resize my-pem-server m1.small
$ openstack server resize --confirm my-pem-server1
重建
$ openstack server rebuild NAME IMAGE
$ openstack server rebuild newtinny cirros-qcow2
重啟
$ openstack server reboot NAME
$ openstack server reboot newtinny
將用戶數據和文件註入到實例
$ openstack server create --user-data FILE INSTANCE
$ openstack server create --user-data userdata.txt --image cirros-qcow2 --flavor m1.tiny MyUserdataInstance2
使用ssh連接到實例,查看``/var/lib/cloud``驗證文件是否成功註入
給實例註入一個密鑰對並通過密鑰對來訪問實例
創建秘鑰對
$ openstack keypair create test > test.pem
$ chmod 600 test.pem
啟動實例
$ openstack server create --image cirros-0.3.5-x86_64 --flavor m1.small --key-name test MyFirstServer
使用ssh連接到實例
# ip netns exec qdhcp-98f09f1e-64c4-4301-a897-5067ee6d544f ssh -i test.pem [email protected]
管理安全組
在默認的安全組中,添加ping和SSH規則
$ openstack security group rule create default --remote-group default --protocol icmp
$ openstack security group rule create default --remote-group default --dst-port 22
網絡 (neutron)?
創建網絡
$ openstack network create NETWORK_NAME
創建子網
$ openstack subnet create --subnet-pool SUBNET --network NETWORK SUBNET_NAME
$ openstack subnet create --subnet-pool 10.0.0.0/29 --network net1 subnet1
塊存儲(cinder)
用於管理連接到實例的卷和卷快照。
創建一個新卷
$ openstack volume create --size SIZE_IN_GB NAME
$ openstack volume create --size 1 MyFirstVolume
啟動實例並將它鏈接到卷上
$ openstack server create --image cirros-qcow2 --flavor m1.tiny MyVolumeInstance
列出所有卷,註意卷狀態
$ openstack volume list
當實例為正常狀態且卷為可用狀態時,將卷連接到實例。
$ openstack server add volume INSTANCE_ID VOLUME_ID
$ openstack server add volume MyVolumeInstance 573e024d-5235-49ce-8332-be1576d323f8
註解
在Xen Hypervisor可以指定具體的設備名,而不使用自動分配的名稱,例如:
$ openstack server add volume --device /dev/vdb MyVolumeInstance 573e024d..1576d323f8
This is not currently possible when using non-Xen hypervisors with OpenStack.
登陸進實例之後管理卷組
列出存儲器
# fdisk -l
在卷上建立文件系統
# mkfs.ext3 /dev/vdb
創建一個掛載點
# mkdir /myspace
在掛載點掛載卷
# mount /dev/vdb /myspace
在卷上創建一個文件
# touch /myspace/helloworld.txt
# ls /myspace
卸載卷
# umount /myspace
對象存儲(Swift)
展示賬戶,容器以及對象的信息
$ swift stat
$ swift stat ACCOUNT
$ swift stat CONTAINER
$ swift stat OBJECT
列出容器
$ swift list
openstack-keystone外組件命令行