硬碟安裝 CoreOS 三節點叢集
本例在 VirtualBox
虛擬機器,以 ISO
或者 PXE
或者 iPXE
模式啟動 CoreOS
,然後安裝到硬碟。
更新記錄
- 2017/12:預設啟用 Docker Daemon TLS 遠端連線。
- 2017/8:CoreOS 配置工具使用新的
Ignition
代替cloud-config
,舊的安裝方法已經刪除,但 GitHub 仍保留該配置檔案。
設定網絡卡模式
VirtualBox
虛擬機器網路設定如下
網絡卡 |
模式 |
IP |
---|---|---|
網絡卡1 |
host-only (DHCP) |
192.168.57.* |
網絡卡2 |
橋接 (DHCP) |
192.168.199.* |
本例中三個節點 IP 分別為:
- 192.168.57.110
- 192.168.57.111
- 192.168.57.112
VirtualBox 可以新建該網段,如果你的節點不是以上 IP 請按照 https://www.khs194.com/docker/dockerd.html 提供的方法,生成證書。
準備檔案
進入 http://alpha.release.core-os.net/amd64-usr/ 點選版本號或 current
,下載以下檔案:
iso 啟動檔案 coreos_production_iso_image.iso
映象檔案 coreos_production_image.bin.bz2
簽名檔案 coreos_production_image.bin.bz2.sig
克隆示例配置檔案
GitHub:https://github.com/khs1994-docker/coreos
$ git clone --depth=1 https://github.com/khs1994-docker/coreos
$ cd coreos
修改 .env
檔案中的變數值
各項變數含義都已經註明,按實際修改即可
放入檔案
把 coreos_production_image.bin.bz2
coreos_production_image.bin.bz2.sig
放入 current
資料夾中。
啟動容器
$ docker-compose up
安裝 CoreOS
啟動
虛擬機器記憶體最低設定為
2G
,否則將不能使用!
新建虛擬機器,新增按照文章開頭設定兩塊網絡卡,選擇載入 coreos_production_iso_image.iso
ISO 映象之後啟動。
ISO 啟動方式不支援 UEFI
# 檢視 IP 以便後邊登入
$ ip addr
# 需要改密碼 虛擬機器裡輸入命令不方便,本機 ssh 登入操作
$ sudo passwd core
SSH 登入並安裝
本機登陸
$ ssh core@IP
$ wget http://192.168.57.1:8080/disk/ignition-1.json
# 必須以 root 使用者執行,安裝指令碼通過 `-i` 選項載入配置檔案 `ignition.json`
$ sudo coreos-install
-d /dev/sda
-C alpha
# -V 1590.0.0
-i ignition-1.json
-b http://192.168.57.1:8080
-v
+ echo 'Success! CoreOS Container Linux alpha 1590.0.0 is installed on /dev/sda'
Success! CoreOS Container Linux alpha 1590.0.0 is installed on /dev/sda
# 執行成功後,關閉虛擬機器
$ sudo shutdown now
關閉虛擬機器之後移除 ISO
,在虛擬機器設定 系統
裡選擇 啟用 EFI
。稍後啟動,接下來在其他兩個節點進行安裝。
在另外兩個節點安裝
重複上邊兩步,注意每次 wget
所下載的檔案是不同的,coreos-install
命令 -i
引數後邊跟著 wget
所下載的檔案。
$ ssh core@IP
$ wget http://192.168.57.1:8080/disk/ignition-2.json
# $ wget http://192.168.57.1:8080/disk/ignition-3.json
$ sudo coreos-install -d /dev/sda -C alpha
-i ignition-2.json -v -b http://192.168.57.1:8080
# $ sudo coreos-install -d /dev/sda -C alpha
# -i ignition-3.json -v -b http://192.168.57.1:8080
引數說明
$ coreos-install -h
Usage: /usr/bin/coreos-install [-C channel] -d /dev/device
Options:
-d DEVICE Install Container Linux to the given device.
-V VERSION Version to install (e.g. current) [default: 1590.0.0]
-B BOARD Container Linux board to use [default: amd64-usr]
-C CHANNEL Release channel to use (e.g. beta) [default: alpha]
-o OEM OEM type to install (e.g. ami) [default: (none)]
-c CLOUD Insert a cloud-init config to be executed on boot.
-i IGNITION Insert an Ignition config to be executed on boot.
-b BASEURL URL to the image mirror (overrides BOARD)
-k KEYFILE Override default GPG key for verifying image signature
-f IMAGE Install unverified local image file to disk instead of fetching
-n Copy generated network units to the root partition.
-v Super verbose, for debugging.
-h This ;-)
This tool installs CoreOS Container Linux on a block device. If you PXE booted
Container Linux on a machine then use this tool to make a permanent install.
啟動
三個節點全部安裝之後,依次啟動虛擬機器。
SSH 登入
$ ssh [email protected]
Last login: Wed Nov 29 11:52:26 UTC 2017 from 192.168.57.1 on pts/0
Container Linux by CoreOS alpha (1590.0.0)
core@coreos1 ~ $ docker --version
Docker version 17.10.0-ce, build afdb6d4
網路配置
刪除內網路由
根據實際配置網路
$ ip route show
$ sudo ip route del default