맥에서 CoreOS 설치

in mac •  6 years ago 

환경준비

  1. Mac PC

  2. VirualBox

    Oracle_VM_VirtualBox
    http://download.virtualbox.org/virtualbox/5.1.22/VirtualBox-5.1.22-115126-OSX.dmg

    Oracle_VM_VirtualBox_Extension_Pack
    http://download.virtualbox.org/virtualbox/5.1.22/Oracle_VM_VirtualBox_Extension_Pack-5.1.22-115126.vbox-extpack

  3. Vagrant

    https://releases.hashicorp.com/vagrant/1.9.6/vagrant_1.9.6_x86_64.dmg?_ga=2.212561940.1055581220.1499149841-800739767.1499149841

4.CoreOs
git 통해 진행
git clone https://github.com/coreos/coreos-vagrant

CoreOs 5대 가상머신에 설치

  1. 환경설정 파일 정보 (config.rb, user-data)


config.rb 파일 수정

  cd coreos-vagrant/
  cp config.rb.sample config.rb
  vi config.rb

 $num_instances=5    -- 서버 댓수
 $update_channel='alpha'


user-data 파일 수정

  cp user-data.sample user-data
  vi user-data 
  discovery: https://discovery.etcd.io/cb91f2bb1357639707dbfb729583f22f

[변경전]
#discovery: https://discovery.etcd.io/< token>
[변경후]
discovery: https://discovery.etcd.io/cb91f2bb1357639707dbfb729583f22f


token 값 확인

  curl -w '\n' https://discovery.etcd.io/new?size=5
  * size=5 는 클러스터 사이즈 즉 클러스터를 5 개로묶을때  ( 3개이상 사용할때 size입력) 

실행결과 값

  cuhttps://discovery.etcd.io/cb91f2bb1357639707dbfb729583f22f 

실행결과 값 실행

  curl -w '\n' https://discovery.etcd.io/cb91f2bb1357639707dbfb729583f22f 

  {"action":"get","node":{"key":"/_etcd/registry/cb91f2bb1357639707dbfb729583f22f"
  ,"dir":true,"modifiedIndex":1359190404
  ,"createdIndex":1359190404}}

토큰값 : token cb91f2bb1357639707dbfb729583f22f

실행
vagrant up

Bringing machine 'core-01' up with 'virtualbox' provider...
Bringing machine 'core-02' up with 'virtualbox' provider...
Bringing machine 'core-03' up with 'virtualbox' provider...
Bringing machine 'core-04' up with 'virtualbox' provider...
Bringing machine 'core-05' up with 'virtualbox' provider...
==> core-01: Importing base box 'coreos-alpha'...
==> core-01: Matching MAC address for NAT networking...
==> core-01: Checking if box 'coreos-alpha' is up to date...
==> core-01: Setting the name of the VM: coreos-vagrant_core-01_1499153689075_7580
==> core-01: Clearing any previously set network interfaces...
==> core-01: Preparing network interfaces based on configuration...
core-01: Adapter 1: nat
core-01: Adapter 2: hostonly
==> core-01: Forwarding ports...
core-01: 22 (guest) => 2222 (host) (adapter 1)
==> core-01: Running 'pre-boot' VM customizations...
==> core-01: Booting VM...
==> core-01: Waiting for machine to boot. This may take a few minutes...
core-01: SSH address: 127.0.0.1:2222
core-01: SSH username: core
core-01: SSH auth method: private key


확인 하기
vagrant status

Current machine states:

core-01 running (virtualbox)
core-02 running (virtualbox)
core-03 running (virtualbox)
core-04 running (virtualbox)
core-05 running (virtualbox)

설치가 완료 되었습니다.

Coreos 접속

vagrant ssh core-01
  Last login: Tue Jul  4 07:37:49 UTC 2017 from 10.0.2.2 on ssh
  Container Linux by CoreOS alpha (1451.2.0)
  core@core-01 ~ $ 

클러스터 확인

core@core-01 ~ $ fleetctl list-machines
  MACHINE       IP      METADATA
  032bbb48...   172.17.8.101    -
  1f844cb3...   172.17.8.104    -
  2e1e8f31...   172.17.8.102    -
  8c5040c6...   172.17.8.103    -
  d49f8a7e...   172.17.8.105    - 

CoreOs 가상 머신 삭제

vagrant destroy
core-05: Are you sure you want to destroy the 'core-05' VM? [y/N] y
  ==> core-05: Forcing shutdown of VM...
  ==> core-05: Destroying VM and associated drives...
  ==> core-05: [vagrant-hostsupdater] Removing hosts
  Password: 
      core-04: Are you sure you want to destroy the 'core-04' VM? [y/N] y
  ==> core-04: Forcing shutdown of VM...
  ==> core-04: Destroying VM and associated drives...
  ==> core-04: [vagrant-hostsupdater] Removing hosts
      core-03: Are you sure you want to destroy the 'core-03' VM? [y/N] y
  ==> core-03: Forcing shutdown of VM...
  ==> core-03: Destroying VM and associated drives...
  ==> core-03: [vagrant-hostsupdater] Removing hosts
      core-02: Are you sure you want to destroy the 'core-02' VM? [y/N] y
  ==> core-02: Forcing shutdown of VM...
  ==> core-02: Destroying VM and associated drives...
  ==> core-02: [vagrant-hostsupdater] Removing hosts
      core-01: Are you sure you want to destroy the 'core-01' VM? [y/N] y
  ==> core-01: Forcing shutdown of VM...
  ==> core-01: Destroying VM and associated drives...
  ==> core-01: [vagrant-hostsupdater] Removing hosts 

vagrant up 시 아래의 오류 발생시
vagrant-ignition 플로그인 설치 하면 해결 됩니다.

  vagrant up 
  
  ERROR vagrant: There are errors in the configuration of this machine. Please fix
  the following errors and try again:
  
  VagrantPlugins::Ignition::Config:
  * The following settings shouldn't exist: drive_name 

vagrant-ignition 플로그인 설치

  $ git clone https://github.com/coreos/vagrant-ignition.git

  Cloning into 'vagrant-ignition'...
  remote: Counting objects: 52, done.
  remote: Compressing objects: 100% (18/18), done.
  remote: Total 52 (delta 7), reused 19 (delta 6), pack-reused 28
  Unpacking objects: 100% (52/52), done.

vagrant-ignition 플로그인 설치

  $ git clone https://github.com/coreos/vagrant-ignition.git

  Cloning into 'vagrant-ignition'...
  remote: Counting objects: 52, done.
  remote: Compressing objects: 100% (18/18), done.
  remote: Total 52 (delta 7), reused 19 (delta 6), pack-reused 28
  Unpacking objects: 100% (52/52), done.

  $ cd vagrant-ignition

  $ gem build vagrant-ignition.gemspec
  WARNING:  description and summary are identical
    Successfully built RubyGem
    Name: vagrant-ignition
    Version: 0.0.3
    File: vagrant-ignition-0.0.3.gem

  $ vagrant plugin install vagrant-ignition-0.0.3.gem

  Installing the 'vagrant-ignition-0.0.3.gem' plugin. This can take a few minutes...
  Successfully uninstalled vagrant-ignition-0.0.1
  Installed the plugin 'vagrant-ignition (0.0.3)'!

  $ vagrant up
  Bringing machine 'core-01' up with 'virtualbox' provider...
  Bringing machine 'core-02' up with 'virtualbox' provider...
  Bringing machine 'core-03' up with 'virtualbox' provider...
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!