linux bridge → openvSwitch
(L2 only)
ovs → vlan, overlay network, SDN(Software Defined Network)
ACL,NAT,QoS
mount 정보 확인
mount | grep /remote
cat /etc/fstab
여기에 아래의 내용이 포함되어 있어야함
storage:/cloud /remote nfs defaults 0 0
만약 없다면 mount -t nfs storage:/cloud /remote (일회성)
virsh list --all
virsh dumpxml centos1
virsh edit centos1
[root@kvm1 ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29d77e7d no eth0
virbr1 8000.52540074a21c yes virbr1-nic
가상머신을 이용한 실습 → 클라우드에서는 적절하지 않음 → 사용자가 인스턴스를 생성 요청 시 디스크(보륨) 사이즈 지정 할 수 있어야하고 각 인스턴스 별로 별도의 퍼블릭 키를 추가할 수 있어야 함 → virt-customize , virt-builder를 이용한 인스턴스 배포
OVS(OpenvSwitch)
SDN(Software Defined Network)
OVS 설치
yum -y install epel-release https://www.rdoproject.org/repos/rdo-release.rpm
yum -y install openvswitch bridge-utils
yum update -y
systemctl start openvswitch && systemctl enable openvswitch
[root@kvm1 remote]# cd /etc/sysconfig/network-scripts/
[root@kvm1 network-scripts]# mv ifcfg-br0 ifcfg-vswitch01
[root@kvm1 network-scripts]# vi ifcfg-vswitch01
TYPE=OVSBridge
BOOTPROTO=none
NAME=vswitch01
DEVICE=vswitch01
DEVICETYPE=ovs
ONBOOT=yes
IPADDR=211.183.3.101
PREFIX=24
GATEWAY=211.183.3.2
DNS1=8.8.8.8
[root@kvm1 network-scripts]# vi ifcfg-eth0
TYPE=OVSPort
BOOTPROTO=none
NAME=eth0
DEVICE=eth0
DEVICETYPE=ovs
ONBOOT=yes
OVS_BRIDGE=vswitch01
재부팅 후 확인
ifconfig → vswitch01에 ip 주소가 할당되어 있다.
ovs-vsctl show
내부에서 사설 용으로 사용하는 ovs 스위치 생성하기
ovs-vsctl add-br vswitch02
kvm1
virt-install --name centos01 --vcpus 1 --ram 1024 --disk /remote/centos01.qcow2 --import --network bridge:vswitch01,model=virtio,virtualport_type=openvswitch --network bridge:vswitch02,model=virtio,virtualport_type=openvswitch,target=centos01_port1 --graphics vnc --noautoconsole
kvm2
virt-install --name centos02 --vcpus 1 --ram 1024 --disk /remote/centos02.qcow2 --import --network bridge:vswitch01,model=virtio,virtualport_type=openvswitch --network bridge:vswitch02,model=virtio,virtualport_type=openvswitch,target=centos02_port1 --graphics vnc --noautoconsole
예) centos01에서
cd /etc/sysconfig/network-scripts
cp ifcfg-ens3 ifcfg-eth1
vi ifcfg-eth1
TYPE=Ethernet
NAME=eth1
DEVICE=eth1
IPADDR=172.16.123.101
PREFIX=24
ONBOOT=yes
이후
ifdown eth1
ifup eth1
ip a 하면 eth1에 ip 주소가 보여야함
vswitch02 ←(gre12)——(gre21)→ vswitch02
[root@kvm1 ~]# ovs-vsctl add-port vswitch02 gre12 -- set interface gre12 type=gre options:remote_ip=211.183.3.102
kvm2
[root@kvm1 ~]# ovs-vsctl add-port vswitch02 gre21 -- set interface gre21 type=gre options:remote_ip=211.183.3.101
확인
centos01: ping 172.16.123.102
kvm1
ovs-vsctl set port centos01_port1 tag=123
kvm2
ovs-vsctl set port centos02_port1 tag=123
tag : 엑세스 포트 지정
trunk : 트렁크 포트 지정
virt-customize -a Cent…qcow2 —root-password password:test123
인스턴스 또는 VM을 만드는 방법
볼륨 사이즈 지정 + 웹서버 배포 + index.html 배포
virt-customize는 볼륨 사이즈에 대한 조절은 없다.
resize의 기능이 포함되어있어 원하는 크기의 볼륨지정 및 패스워드, 패키지 설치 등이 가능하다.
[root@kvm1 ~]# virt-builder centos-7.0 --size 20G --format qcow2 -o /remote/test1.qcow2 --root-password password:test123 --install httpd,net-tools --selinux-relabel
virt-builder : 인터넷에 있는 클라우드 이미지 다운로드 하기
centos7.0 클라우드 이미지
virt-resize 기능이 포함되어 있어 클라우드 이미지(볼륨)사이즈를 확장할 수 있다.
—size 20G : 클라우드용 볼륨 이미지를 20GB로 확장시킴 → 볼륨의 이름은 test1.qcow2
—root-password password:test123 : 볼륨 내에 설치되어 있는 centos의 루트패스워드를 test123으로 설정
—install : 볼륨 내에 미리 필요한 패키지를 설치해두겠다.
— install httpd,net-tools ⇒ (yum -y install httpd net-tools)
[root@kvm1 ~]# virt-install --name test1 --vcpus 1 --ram 1024 --network bridge:vswitch01,model=virtio,virtualport_type=openvswitch --disk /remote/test1.qcow2 --import --graphics none
위의 명령어를 실행하면 자동으로 해당 인스턴스로 들어감.
빠져나오고싶다면 Ctrl + ]
다시 인스턴스로 접속하고 싶다면 virsh console test1
virt-builder os-version -o /remote/centos1.qcow2 --size 20G --format qcow2 --install httpd,nfs-utils,vim --upload index.html:/var/www/html/index.html
https://libguestfs.org/virt-builder.1.html
—firstboot-install : virt-install을 통해 인스턴스로 배포될 때 처음 부팅하면서 설치할 패키지
—install : 볼륨 자체에 필요한 패키지를 설치하는 것
—run 스크립트파일 : 호스트에 스크립트를 작성해두고 이 내용을 볼륨에 적용하는 것, 볼륨 내에 여러 명령어를 적용시키고자 할 때
—run-command ‘명령어’ : 한개정도의 간단한 명령어를 볼륨에 적용하고자 하는 경우
—firstboot-command ‘명령어’ : 인스턴스로 처음 부팅될 때 인스턴스 내에서 실행할 명령어
—mkdir DIR : 볼륨 내에 미리 필요한 디렉토리를 생성해두고 싶을 때
—selinux-relabel : selinux 활성화
Quiz. 나는 생성된 이미지가 인스턴스화 될 때 자동으로 웹서비스가 실행되도록 하고싶다.
—install httpd —run-command ‘systemctl enable httpd’
—install httpd —firstboot-command ‘systemctl start httpd’
Quiz
echo "TEST PAGE" > index.html
virt-builder centos-7.0 --size 20G --format qcow2 -o /remote/test2.qcow2 --root-password password:test123 --install httpd --selinux-relabel --upload index.html:/var/www/html/index.html --run-command 'systemctl enable httpd' --run-command 'systemctl disable firewalld'
[root@kvm1 ~]# virt-install --name test2 --vcpus 1 --ram 1024 --network bridge:vswitch01,model=virtio,virtualport_type=openvswitch --disk /remote/test2.qcow2 --import --graphics vnc --noautoconsole