利用Vagrant and VirtualBox搭建core os环境

利用Vagrant and VirtualBox搭建core os环境

系统环境

  • ubuntu 14.04 x64
  • vagrant 1.7.4
  • virtualbox 4.3.10
  • git 1.9.1
# 安装 virtualbox, git
sudo apt-get install virtualbox, git

# 软件中心的vagrant版本太低,因此去官网获取最新的软件包地址
wget https://releases.hashicorp.com/vagrant/1.7.4/vagrant_1.7.4_x86_64.deb
sudo dpkg -i vagrant_1.7.4_x86_64.deb

下载及配置安装脚本

# 下载coreos-vagrant配置
git clone https://github.com/coreos/coreos-vagrant.git
cd coreos-vagrant

# 复制配置
cp config.rb.sample config.rb
cp user-data.sample user-data

# 编辑配置,以下两个配置文件根据自己的实际情况修改
vim config.rb
# 修改之前 => 修改之后
$num_instances=1 => $num_instances=3 # 这里表示coreos的台数,集群自组网最小为3
#$update_channel='alpha' => $update_channel='stable'   # 去掉配置文件前面的#

vim user-data

在这里简单介绍一下,有许多改进的地方

  • 看到网上好多博主都说coreos的下载被墙了,我好奇的试验了一下。结果是意料之外,访问正常,所以这里不用搭建下载源了
  • 不再需要访问 https://discovery.etcd.io/new 来获得集群标识, 在config.rb中有自动获取并配置的脚本

启动

# 启动CoreOS,这里需要一定的下载等待时间
vagrant up

# 登录到CoreOS
vagrant ssh core-01 -- -A
#输出
CoreOS stable (766.5.0)

# 查看集群列表
Core@core-01 ~ $ fleetctl list-machines
#输出
MACHINE     IP      METADATA
90d9d1e4... 172.17.8.102    -
bb4c8bd1... 172.17.8.103    -
ee18c9fd... 172.17.8.101    -

# 启动一个容器
Core@core-01 ~ $ docker run hello-world
#将输出一份docker的hello-world文档


安装过程就此结束,接下来将探索更多的功能

原文地址:https://www.cnblogs.com/wanghongxu/p/4989170.html