virt-install --name=v2 --vcpus=2 --memory=512 --os-variant=debian8
--cdrom /remote/images/vyos.iso --network bridge=br0 --graphic=vnc --noautoconsole --disk path=/remote/vm/v2.img,size=2
virt-install --name=c1 --ram=256 --network network=kvmnet1 --disk=/remote/vm/c1.img --import --noautoconsole --graphic=vnc
[root@srv1 qemu]# cp /remote/images/cent78.img /remote/vm/cent1.img
# 복사
[root@srv1 qemu]# virt-install --name=cent1 --ram=2048 --network bridge=br0 --disk=/remote/vm/cent1.img --import --noautoconsole --graphic=vnc
# 생성
<이미지 커스터마이징>
virt-customize
/remote/images/cent78.img 이미지 파일을 커스터마이징 해보자
[root@srv1 qemu]# virt-customize -a /remote/images/cent78.img --firstboot-install httpd \
--firstboot-command 'systemctl disable --now firewalld && systemctl enable --now httpd'
# 웹서버 설치, 방화벽 종료
[root@srv1 qemu]# cp /remote/images/cent78.img /remote/vm/cent2.img
[root@srv1 qemu]# virt-install --name=cent2 --ram=2048 --network bridge=br0 --disk=/remote/vm/cent2.img --import --noautoconsole --graphic=vnc
virt-builder centos-7.8 --size=6.5G --format=qcow2 -o /remote/images/cent78.img --root-password password:test123 --mkdir /root/.ssh --upload /root/.ssh/id_rsa.pub:/root/id_rsa.pub --firstboot-command 'cat /root/id_rsa.pub >> /root/.ssh/authorized_keys' --selinux-relabel
[root@srv1 ~]# cp /remote/images/cent78.img /remote/vm/cent1.img
# 빌드된원본은 소중히 간직하기 위해 복사를 해서 복사한 이미지로 vm을 생성
virt-install --name=cent1 --ram=2048 --network bridge=br0 --disk=/remote/vm/cent1.img --import --noautoconsole --graphic=vnc
<ssh-inject 를 통한 authorized_keys 등록>
--ssh-inject <사용자>:file:<파일경로>
를 통해 자동으로 authorized_keys 생성이 가능하다.
virt-builder centos-7.8 --size=6.5G --format=qcow2 -o /remote/images/cent78.img --root-password password:test123 --ssh-inject root:file:/root/.ssh/id_rsa.pub --selinux-relabel
[root@srv1 ~]# cp /remote/images/cent78.img /remote/vm/cent1.img
virt-install --name=cent1 --ram=2048 --network bridge=br0 --disk=/remote/vm/cent1.img --import --noautoconsole --graphic=vnc
virt-customize -a /remote/images/cent78.img --firstboot-install httpd \
--firstboot-command 'systemctl disable --now firewalld && systemctl enable --now httpd && echo I LOVE TEACHER > /var/www/html/index.html'
[root@srv1 ~]# cp /remote/images/cent78.img /remote/vm/cent2.img
[root@srv1 ~]# virt-install --name=cent2 --ram=2048 --network bridge=br0 --disk=/remote/vm/cent2.img --import --noautoconsole --graphic=vnc
'AWS Cloud School' 카테고리의 다른 글
[05.07-08] Openvswitch, GRE tunneling, VLAN (0) | 2024.05.08 |
---|---|
[05.04] KVM 네트워크 인터페이스 추가(CLI환경), 종합실습 (0) | 2024.05.04 |
[04.29-30] KVM, 하이퍼바이저, 전가상화, 반가상화, bridge대역 추가 (0) | 2024.04.29 |
[04.26] VPN + 3-tier architecture 팀플 실습 (0) | 2024.04.28 |
[04.25] VPN, overlay network, tunneling (0) | 2024.04.25 |