openstack

openstack - glance, instance, neutron provider network 생성

sysman 2021. 1. 31. 00:58

거의 1주간 삽질의 연속으로 만든 구성.

devstack, packstack , 재구성, 재배포등 os도 거의 수십번 깔아본 듯..ㅠㅠ

 

cirros 다운로드 // 가벼운 linux

[root@controller images]# wget https://download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img

 

[root@controller images]# source ~/keystonerc

[root@controller images]# openstack image create "cirros1" --file cirros-0.5.1-x86_64-disk.img --disk-format qcow2 --container-format bare --public

[root@controller images]# openstack image list

 

centos image 생성

#yum groups mark convert virtualization

#yum groups mark install virtualization

#yum install @virt* -y

#yum install libguestfs-tools-c -y

 

가상화 관리 데몬실행

#systemctl start libvirtd
#systemctl enable libvirtd
#systemctl status libvirtd

 

#virsh net-list

#mkdir -p /var/kvm/images

껍데기 만들기

#qemu-img create -f qcow2 /var/kvm/images/Centos7.img 5G

#virt-install --name centos7 --disk path=/var/kvm/images/Centos7.img,format=qcow2 --vcpus 1 --ram 1024 --os-type linux --os-variant rhel7 --network network=default –cdrom /var/kvm/image/ Centos-7-x86_64-disk.img –-graphics vnc,listen=0.0.0.0 --noautoconsole

 

#yum install virt-viewer -y

#virsh list --all

OS가 gui mode 여야됨

#virt-viewer centos7

os 설치함(생략)

 

#glance image-create --name "centos7" --file /var/kvm/images/centos7.img --disk-format qcow2 --container-format bare --visibility public

#openstack image list

 

 

인스턴스 생성

#openstack compute service list

 

사양 프로비저닝 리스트만들기(cpu: 1ea ram:512M disk:1G)

#openstack flavor create --id 1 --vpcus 1 --ram 512 --disk 1 m1.tiny

#openstack flavor list

 

#openstack image list

#openstack security group list

 

인스턴스 생성

#openstack server create --flavor m1.tiny --image cirros --security-group default cirros

#openstack server list

 

 

관리용 ens192 : x.x.100.0/24

프로바이더 ens224 : x.x.200.0/24

퍼블릭 g/w : x.x.200.254

dhcp pool : x.x.200.150~200

 

network/compute 둘 다 노드 설정

 

#cd /etc/sysconfig/network-scripts/

#cp ifcfg-ens192 ifcfg-ens224

# vi /etc/sysconfig/network-scripts/ifcfg-ens224
TYPE="Ethernet"
DEVICE="ens224"
ONBOOT="yes"

 

#systemctl restart network

#ovs-vsctl add-br br-provider

#ovs-vsctl add-port br-provider ens224

#ovs-vsctl list-ports br-provider

 

# vi /etc/neutron/neutron.conf

[DEFAULT]
service_plugins =

 

#vi /etc/neutron/plugins/ml2/ml2_conf.ini

[ml2_type_flat]
flat_networks = provider

[ml2_type_vlan]
network_vlan_ranges = provider

 

# vi /etc/neutron/plugins/ml2/openvswitch_agent.ini

[ovs]
bridge_mappings = provider:br-provider

 

#systemctl restart neutron-openvswitch-agent

#openstack network agent list

 

 

controller 세팅

네트워크 생성

#openstack project list

#openstack network create --share --project <project-id number> --provider-network-type flat --provider-physical-network provider provider

 

서브넷 생성

#openstack subnet create pro-subnet --project <project-id number> --network provider --subnet-range x.x.200.0/24 --allocation-pool start=x.x.200.150,end=x.x.200.200 --gateway x.x.200.254 --dns-nameserver 8.8.8.8

#openstack network list

#openstack subnet list

 

보안그룹 생성

#openstack security group list

#openstack security group create provider

#openstack security group rule create --protocol icmp --ingress provider

#openstack security group rule create --protocol tcp --dst-port 22:22 provider

#openstack security group rule list provider

 

인스턴스 생성

#openstack flavor list

#openstack image list

#openstack network list

#openstack server create --flavor m1.tiny --image cirros --security-group provider --nic net-id=<net-id number> cirros

#openstack server list

 

##############################################33

내부 구성 확인

[root@compute ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:0c:29:5b:61:a0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.111/24 brd 192.168.100.255 scope global ens192
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe5b:61a0/64 scope link
       valid_lft forever preferred_lft forever
3: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ovs-system state UP qlen 1000
    link/ether 00:0c:29:5b:61:aa brd ff:ff:ff:ff:ff:ff
    inet6 fe80::20c:29ff:fe5b:61aa/64 scope link
       valid_lft forever preferred_lft forever
4: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether c2:82:ee:a3:e1:bd brd ff:ff:ff:ff:ff:ff
5: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 56:b7:f9:9d:fc:40 brd ff:ff:ff:ff:ff:ff
6: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether 52:54:00:a7:a1:ca brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
7: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
    link/ether 52:54:00:a7:a1:ca brd ff:ff:ff:ff:ff:ff
8: br-provider: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 00:0c:29:5b:61:aa brd ff:ff:ff:ff:ff:ff
9: tapffe869e9-36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UNKNOWN qlen 1000
    link/ether fe:16:3e:6e:6e:e0 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc16:3eff:fe6e:6ee0/64 scope link
       valid_lft forever preferred_lft forever

 

 

compute 구성

[root@compute ~]# ovs-vsctl show
9b940942-77a9-4c16-ae66-a66bf71fe111
    Manager "ptcp:6640:127.0.0.1"
        is_connected: true
    Bridge br-provider
        Controller "tcp:127.0.0.1:6633"
            is_connected: true
        fail_mode: secure
        Port phy-br-provider
            Interface phy-br-provider
                type: patch
                options: {peer=int-br-provider}
        Port br-provider
            Interface br-provider
                type: internal
        Port "ens224"
            Interface "ens224"
    Bridge br-int
        Controller "tcp:127.0.0.1:6633"
            is_connected: true
        fail_mode: secure
        Port br-int
            Interface br-int
                type: internal
        Port int-br-provider
            Interface int-br-provider
                type: patch
                options: {peer=phy-br-provider}
        Port "tapffe869e9-36"
            tag: 1
            Interface "tapffe869e9-36"
    ovs_version: "2.11.0"

 

network node 구성

[root@network network-scripts]# ovs-vsctl show
abc1af19-6e90-4e43-9674-1faf75264a9b
    Manager "ptcp:6640:127.0.0.1"
        is_connected: true
    Bridge br-provider
        Controller "tcp:127.0.0.1:6633"
            is_connected: true
        fail_mode: secure
        Port br-provider
            Interface br-provider
                type: internal
        Port phy-br-provider
            Interface phy-br-provider
                type: patch
                options: {peer=int-br-provider}
        Port "ens224"
            Interface "ens224"
    Bridge br-int
        Controller "tcp:127.0.0.1:6633"
            is_connected: true
        fail_mode: secure
        Port br-int
            Interface br-int
                type: internal
        Port int-br-provider
            Interface int-br-provider
                type: patch
                options: {peer=phy-br-provider}
        Port "tapc13532de-99"
            tag: 1
            Interface "tapc13532de-99"
                type: internal
    ovs_version: "2.11.0"

 

 

cirros에서 테스트

다른 대역에서 cirros로 ssh 접속

dhcp(192.168.200.150~200) : dnsmasq를 통해 할당(iptable은 따로 관리됨)

 

 

 

인스턴스 생성 시 error 발생

증상 : 생성 시 error 뜨면서 확인시

OpenStack error: Host 'controller.park.com' is not mapped to any cell

 

해결책

아래 명령어 입력 후 다시 instance 생성하면 됨

[root@controller images]# nova-manage cell_v2 discover_hosts --verbose

Found 2 cell mappings.

Skipping cell0 since it does not contain hosts.

Getting computes from cell 'cell1': acc9a0bd-3fde-412f-86ff-14486e3cd4da

Checking host mapping for compute host 'controller.park.com': b18a3873-cbcf-48ac-8549-4de34665cf58

Creating host mapping for compute host 'controller.park.com': b18a3873-cbcf-48ac-8549-4de34665cf58

Found 1 unmapped computes in cell: acc9a0bd-3fde-412f-86ff-14486e3cd4da