【openstack基础操作】

openstack 常用命令

source ~/base/src/kayobe-config/etc/kolla/admin-openrc.sh

https://docs.openstack.org//kayobe/latest/doc-kayobe.pdf

镜像下载点

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
相关推荐
huhy~1 天前
基于Ubuntu2410脚本搭建OpenStack-D版
服务器·网络·openstack
xserver21 天前
Openstack9--安装etcd分布式键-值对存储系统
数据库·分布式·openstack·etcd
mqiqe10 天前
云计算Openstack 虚拟机调度策略
云计算·openstack
小安运维日记14 天前
Linux云计算 |【第五阶段】CLOUD-DAY2
linux·运维·云计算·openstack
南宫乘风21 天前
OpenStack将运行的系统导出 QCOW2 镜像并导入阿里云
阿里云·云计算·openstack
学习向前冲23 天前
开源OpenStack
openstack
suum1 个月前
openstack-swift.18421165
openstack
极客先躯1 个月前
开源的云平台有哪些?
kubernetes·开源·openstack·cloudstack·云平台·docker swarm·opennebula
mqiqe1 个月前
云计算Openstack Horizon
云计算·openstack·perl
zkyqss1 个月前
OpenStack Yoga版安装笔记(十六)Openstack网络理解
笔记·openstack