openstack 常用命令
source ~/base/src/kayobe-config/etc/kolla/admin-openrc.sh
镜像下载点
bash
http://cloud.centos.org/centos/7/images/
创建虚拟机
bash
openstack server create --image 13d0686a-a7cc-4cc6-8bf7-769dde9bcf29 \
--flavor centosF1 --key-name mykey \
--network demo-net demo1
openstack server create --flavor centosF1 --image 13d0686a-a7cc-4cc6-8bf7-769dde9bcf29\
--nic net-id=8d5a15c3-e54c-4a23-91eb-0f468fd4dcd7 <port-id=port-uuid> --security-group bd7c46f6-1214-46a2-b918-dcff4d1742f5 \
--key-name mykey TestInstance
上传镜像
bash
glance image-create --name CentosFirstTest --file ./CentOS-7-aarch64-GenericCloud-1708.qcow2 \
--disk-format qcow2 --container-format bare --visibility public --progress
bash
openstack image create <image_name> --file <input_file> --disk-format <disk_format> --container-format <container_format>
保存镜像
bash
for i in $(cat a |awk -F' ' '{print $1","$3}');do openstack image save --file $( echo $i|awk -F',' '{print $2}').qcow2 $( echo $i|awk -F',' '{print $1}'); echo $( echo $i|awk -F',' '{print $1}') success.. ;done
a 是一个文件
文件格式
ad4a90c8-6a11-4650-9029-92a3046ba2a4 | Centos7
bash
openstack image save <image_id> --file <output_file>
创建规格
bash
openstack flavor create --disk 50 --ram 4096 --vcpus 2 --id 10 centosF1
创建网络
bash
openstack network create net1 --provider-network-type vxlan --share --enable --default --tag "default network"
创建子网
bash
openstack subnet create --network net1 --subnet-range 192.168.10.0/26 --gateway 192.168.10.1 my_subnet
创建路由
bash
openstack router create router1
创建安全组
bash
openstack security group create my_security_group
openstack security group rule create --protocol tcp --dst-port 22 --egress my_security_group
openstack security group rule create --protocol tcp --dst-port 22 --ingress my_security_group
openstack security group rule create --protocol icmp my_security_group
创建mykey
bash
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
查询
bash
openstack keypair list
openstack security group list
openstack security group show \<ID>
openstack console url show 727d00d0-52ee-48b2-9554-164f1bcb6d11
IP protocol (ah, dccp, egp, esp, gre, icmp, igmp, ipv6-encap, ipv6-frag, ipv6-icmp, ipv6-nonxt, ipv6-opts, ipv6-route, ospf, pgm, rsvp, sctp, tcp, udp, udplite, vrrp and integer
bash
if [ $2 = "out" ];then
forward=egress
elif [ $2 = "in" ];then
forward=ingress
fi
openstack security group rule create --protocol ${1} --dst-port ${3} \--${forward} my_security_group
default.conf
bash
server {
listen 9999;
server_name localhost;
location / {
proxy_pass http://192.168.33.3:80;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /console {
proxy_pass http://192.168.33.2:6080/vnc_lite.html?path=%3Ftoken%3Da0116fba-10b9-4573-840f-3c979f35034d;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /falsk {
proxy_pass http://127.0.0.1:5000;
}
}
bash
qemu-img create -f raw raw-image.raw 2G
测试
/root/base/venvs/kolla-ansible/share/kolla-ansible/ansible/roles/service-images-pull/tasks/main.yml
bash
---
- name: "{{ kolla_role_name | default(project_name) }} | Pull images"
vars:
service: "{{ item.value }}"
become: true
kolla_container:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ service.image }}"
retries: "{{ service_images_pull_retries }}"
delay: "{{ service_images_pull_delay }}"
register: result
until: result is success
with_dict: "{{ lookup('vars', (kolla_role_name | default(project_name)) + '_services') | select_services_enabled_and_mapped_to_host }}"
loop_control:
label: "{{ item.key }}"
tags:
- service-images-pull
- 一
Q:
bash
- name: "{{ kolla_role_name | default(project_name) }} | Pull images"
A:
/root/base/venvs/kolla-ansible/share/kolla-ansible/ansible/roles/ovn-controller/vars/main.yml
kolla_role_name: "ovn_controller"
/root/base/venvs/kolla-ansible/share/kolla-ansible/ansible/roles/ovn-db/vars/main.yml
kolla_role_name: "ovn_db"
/root/base/venvs/kolla-ansible/share/kolla-ansible/ansible/roles/nova-cell/vars/main.yml
kolla_role_name: "nova_cell"
Q:
bash
0 lrwxrwxrwx 1 root root 23 Jan 8 08:16 /etc/localtime -> /usr/share/zoneinfo/CST
A:Ubuntu22.04没有CST时间。Can't find file or directory
bash
ln -sf /usr/share/zoneinfo/Asia/Hong_Kong /etc/localtime