맥에서 centos 7.2를 설치하려면 vagrant가 필요하다.


https://www.vagrantup.com/downloads.html

mac 버전 다운로드를 클릭해서 vagrant_1.8.5.mg 를 다운받고 실행한다.


$ vagrant init



다음에, mac 용 virtualbox를  설치한다.
https://www.virtualbox.org/


vagrant 이미지에 centos가 있는지 확인한다.
https://atlas.hashicorp.com/boxes/search?utm_source=vagrantcloud.com&vagrantcloud=1

centos 7 다운로드하기 전에 확인한다.
https://atlas.hashicorp.com/centos/boxes/7



이제 vagrant를 이용해서 centos 7을 설치한다. libvirt로 사용한다.

$ vagrant box add  centos/7
==> box: Loading metadata for box 'centos/7'
    box: URL: https://atlas.hashicorp.com/centos/7
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) libvirt
2) virtualbox

Enter your choice: 1
==> box: Adding box 'centos/7' (v1606.01) for provider: libvirt
    box: Downloading: https://atlas.hashicorp.com/centos/boxes/7/versions/1606.01/providers/libvirt.box
==> box: Successfully added box 'centos/7' (v1606.01) for 'libvirt'!


(참고로 삭제는 ~$ vagrant box remove  centos/7 --provider=libvirt  명령을 내린다)



vi Vagrantfiles를 실행하여 다음을 수정한다.

#config.vm.box = "base" 에서 주석 처리를 삭제하고, config.vm.box = "centos/7"으로 수정한다




vagrant 이미지를 실행한다. 

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'centos/7' is up to date...


실행은 되는데, ssh 연결이 되지 않는다. 아마도 많은 ssh 키 때문에 그런 것 같기도하고.

 vagrant ssh-config 를 실행해서 IdentifyFile 옵션이 가르키는 파일을 삭제하고, 다시 vagrant ssh를 실행해 본다. (파일은 다시 생성된다)


$ vagrant ssh-config

Host default

  HostName 127.0.0.1

  User vagrant

  Port 2200

  UserKnownHostsFile /dev/null

  StrictHostKeyChecking no

  PasswordAuthentication no

  IdentityFile /Users/계정명/.vagrant/machines/default/virtualbox/private_key

  IdentitiesOnly yes

  LogLevel FATAL





그래도 연결이 되지 않는다. 정확한 문제가 발생하는지 보려면, 다음 커맨드를 실행한다. hang되는 부분을 찾아본다.

~$ ssh vagrant@127.0.0.1 -p 2222 -v
OpenSSH_6.9p1, LibreSSL 2.1.7
..
debug1: Next authentication method: gssapi-with-mic



 virtualbox에서 running 중인 centos 7 터미널화면으로 접속한다.

vagrant centos/7의 기본 계정이름과 패스워드는 vagrant/vagrant 이다. vagrant 계정으로 로그인한 후, 다음을 실행한다.

1. sudo vi /etc/ssh/sshd_config 
  GSSAPIAuthentification yes를 GSSAPIAuthentification no로 수정한다

2. sudo /sbin/service sshd restart 




이제 mac으로 돌아가서 vagrant ssh,  또는 ssh vagrant@localhost -p 2222 를 실행하면, 접속이 잘 되는지 확인할 수 있다.





Posted by '김용환'
,