■ Vagrant 란?
https://www.lesstif.com/laravelprog/vagrant-24445417.html
Vagrant 란
하이퍼바이저를 설치하는 실제 운영체제(윈도, OS X, 리눅스 등)를 호스트(Host) OS 라 하고 하이퍼바이저 위에 만든 가상 머신에 설치된 운영체제를 게스트 OS 라고 부릅니다.
www.lesstif.com
· 가상 머신에 운영체제(Os)를 설치하고, 개발 환경 구성 대상이 PC 에서 가상 머신으로 옮겨 진 것 외에 달라진 점이 없다는 점에서 오히려 가상머신을 설치하고 관리하여야 하는 부담이 늘었다는 부분을 해결하기 위해, 설정 스크립트를 기반으로 특정 환경의 가상 머신을 만들어 신속하게 개발 환경을 구축하고 공유할 수 있게 만들어진 솔루션
· 사용자가 원할 경우 시스템을 즉시 사용할 수 있도록 지원해주는 Provisioning 도구
· 간편하게 생성, 삭제, 수정 가능
· VirtualBox, VMWare 등을 지원 (단, VMWare는 별도의 드라이버를 구매해야 함)
☞ VirtualBox 기반으로 구성
■ Vagrant Install
1. VritualBox Install
https://www.virtualbox.org/wiki/Downloads
Downloads – Oracle VM VirtualBox
Download VirtualBox Here you will find links to VirtualBox binaries and its source code. VirtualBox binaries By downloading, you agree to the terms and conditions of the respective license. If you're looking for the latest VirtualBox 6.0 packages, see Virt
www.virtualbox.org
2. Vagrant Install
https://www.vagrantup.com/downloads.html
Downloads | Vagrant by HashiCorp
Vagrant enables users to create and configure lightweight, reproducible, and portable development environments.
www.vagrantup.com
3. 설치 후 Version 확인
vagrant --version
4. Box add
$ vagrant box add ubuntu/bionic64
· ubuntu/bionic64 이미지 다운로드
5. Hostmanager Install
$ vagrant plugin install vagrant-hostmanager
6. Disk 설정
$ vagrant plugin install vagrant-disksize
7. Vagrant 기본 내용 자동 작성
$ vagrant init ubuntu/bionic64
8. Vagrantfile 구성 (예시)
Vagrant.configure("2") do |config|
config.vm.define "controll-plane" do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provider "virtualbox" do |vb|
vb.name = "controll-plane"
vb.memory = "2048"
vb.cpus = 2
end
config.vm.hostname = "controll-plane.example.com"
config.vm.network "private_network", ip: "192.168.56.11"
end
config.vm.define "node1" do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provider "virtualbox" do |vb|
vb.name = "node1"
vb.memory = "1024"
vb.cpus = 1
end
config.vm.hostname = "node1.example.com"
config.vm.network "private_network", ip: "192.168.56.21"
end
config.vm.define "node2" do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provider "virtualbox" do |vb|
vb.name = "node2"
vb.memory = "1024"
vb.cpus = 1
end
config.vm.hostname = "node2.example.com"
config.vm.network "private_network", ip: "192.168.56.22"
end
config.vm.define "node3" do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provider "virtualbox" do |vb|
vb.name = "node3"
vb.memory = "1024"
vb.cpus = 1
end
config.vm.hostname = "node3.example.com"
config.vm.network "private_network", ip: "192.168.56.23"
end
config.hostmanager.enabled = true
config.hostmanager.manage_guest = true
config.vm.provision "shell", inline: <<-SHELL
sed -i 's/ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config
sed -i 's/archive.ubuntu.com/ftp.daum.net/g' /etc/apt/source.list
sed -i 's/security.ubuntu.com/ftp.daum.net/g' /etc/apt/source.list
systemctl restart sshd
SHELL
end
9. Vagrantfile을 이용해서 가상머신 배포
$ vagrant up
10 Vagrantfile을 이용해서 가상머신 종료
$ vagrant halt
11. Vagrantfile을 이용해서 가상머신 제거
$ vagrant destroy