一般我们在OSX下使用vagrant+virtualbox部署虚拟机集群做开发测试。现在我们还可以有更轻量的选择——xhyve。xhyve是FreeBSD 下的虚拟技术 bhyve (The BSD Hypervisor) 的OSX移植,在OS X 10.10.3 Yosemite 之后的版本中可以使用。由于xhyve是基于FreeBSD原生的虚拟方案,所以它性能好并且非常的轻量,只有 230 KB,不依赖其他软件或库。当xhyve发布时CoreOS快速的跟进,推出了基于xhyve的coreos-xhyve。这里我们使用corectl——一个coreos-xhyve的命令行工具来搭建CoreOS集群。

安装corectl

最快的方法使用brew

1
brew install corectl

从源码编译

1
2
3
git clone git@github.com:TheNewNormal/corectl.git
cd corectl
make

安装好后运行corectl -h可以看到所支持的命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
corectl -h
CoreOS over OSX made simple.
❯❯❯ http://github.com/TheNewNormal/corectlUsage:corectl [flags]corectl [command]Available Commands:rm          Removes one or more CoreOS images from local fskill        Halts one or more running CoreOS instancesls          Lists locally available CoreOS imagesload        Loads CoreOS instances defined in an instrumentation file.version     Shows corectl version informationps          Lists running CoreOS instancesquery       Display information about the running CoreOS instancespull        Pulls a CoreOS image from upstreamrun         Starts a new CoreOS instancessh         Attach to or run commands inside a running CoreOS instanceput         copy file to inside VMFlags:--debug   adds extra verbosity, and options, for debugging purposes and/or power usersUse "corectl [command] --help" for more information about a command.All flags can also be configured via upper-case environment variables prefixed with "COREOS_"
For example, "--debug" => "COREOS_DEBUG"

运行CoreOS VM

加载镜像

第一次输入sudo corectl run即会自动下载最新的 CoreOS Alpha 镜像并加载运行,镜像文件放置的位置是$HOME/.coreos/

run的参数还有

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Usage:corectl run [flags]Aliases:run, startFlags:--cdrom string          append an CDROM (.iso) to VM--channel string        CoreOS channel (default "alpha")--cloud_config string   cloud-config file location (either a remote URL or a local path)--cpus int              VM's vCPUS (default 1)-d, --detached              starts the VM in detached (background) mode-h, --help                  help for run-l, --local latest          consumes whatever image is latest locally instead of looking online unless there's nothing available.--memory int            VM's RAM, in MB, per instance (1024 < memory < 8192) (default 1024)-n, --name string           names the VM. (if absent defaults to VM's UUID)--root string           append a (persistent) root volume to VM--sshkey string         VM's default ssh key--tap string            append tap interface to VM--uuid string           VM's UUID (default "random")--version string        CoreOS version (default "latest")--volume value          append disk volumes to VM (default [])Global Flags:--debug   adds extra verbosity, and options, for debugging purposes and/or power usersAll flags can also be configured via upper-case environment variables prefixed with "COREOS_"
For example, "--debug" => "COREOS_DEBUG"

想使用不同的镜像版本可以由--channel alpha/beta/stable指定

数据持久化

先新建一个5G的persistent.img盘

1
dd if=/dev/zero of= persistent.img  bs=1g count=5

格式化成ext4(需要e2fsprogs工具,安装brew install e2fsprogs)

1
/usr/local/Cellar/e2fsprogs/1.42.12/sbin/mke2fs  -t ext4 -m0 -F persistent.img

运行时加上

1
corectl run --name core --volume absolute_or_relative_path/to/persistent.img

启动后persistent.img被挂载在/dev/vda

ssh进入VM将/dev/vda 挂载 在 /data上

1
2
3
corectl ssh core
mkdir /data
sudo mount /dev/vda /data

后面数据就可以写入/data

启动集群

从https://discovery.etcd.io 获取token

1
curl -X GET 'https://discovery.etcd.io/new?size=3'

将token写入loud-config文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#cloud-configcoreos:etcd2:# generate a new token for each unique cluster# from https://discovery.etcd.io/new?size=n where n = cluster size# discovery url to bootstrap the clusterdiscovery: hhttps://discovery.etcd.io/{$TOKEN}# multi-region and multi-cloud deployments need to use $public_ipv4# list of member’s client urls to advertise information to the rest of the clusteradvertise-client-urls: http://$public_ipv4:2379# this address is used to communicate etcd data around the clusterinitial-advertise-peer-urls: http://$private_ipv4:2380# listen on both the official ports and the legacy ports# legacy ports can be omitted if your application doesn't depend on them# url to listen for client trafficlisten-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001# url to listen for peer trafficlisten-peer-urls: http://$private_ipv4:2380,http://$private_ipv4:7001fleet:public-ip: $public_ipv4flannel:interface: $public_ipv4units:- name: etcd2.servicecommand: start- name: fleet.servicecommand: start

启动三个CoreVM

1
2
3
sudo corectl run --cloud_config ./cloud-config-file --name core-1
sudo corectl run --cloud_config ./cloud-config-file --name core-2
sudo corectl run --cloud_config ./cloud-config-file --name core-3

随便ssh进一个VM使用etcdctl member list看到集群已经建立

1
2
3
4
etcdctl  member list
28fede81eb6ee920: name=78c956f8b901497fbd909c0a4fa4a9f7 peerURLs=http://192.168.64.30:2380 clientURLs=http://192.168.64.30:2379 isLeader=false
a4661fcb2e28c76a: name=1a7f48cd84c540528b0a61483f071307 peerURLs=http://192.168.64.31:2380 clientURLs=http://192.168.64.31:2379 isLeader=false
eebd0c9e16e3e5be: name=fd92329bf3004bf98f3a6553606a00b0 peerURLs=http://192.168.64.32:2380 clientURLs=http://192.168.64.32:2379 isLeader=true

更多信息可以参考这个项目coreos-osx

Share

转载来源:http://sineyuan.github.io/2016/05/29/coreos-osx-without-vagrant/

OSX上摆脱vagrant搭建CoreOS集群相关推荐

  1. K8s上使用rook搭建Ceph集群

    目录 准备工作 一.安装kubectl 二:win10 安装Docker Desktop for Windows(非必须) 三.Harbor 知识补充: 1.Ceph mgr和mon 2:Ceph 中 ...

  2. 在Linux上如何快速搭建MongoDB集群

    搭建MongoDB集群的一个小妙招,教你快速搭建MonggoDB集群. 一.首先确认你的集群信息 三台机器的配置服务(27018)形成复制集,分片1.2.3也在各机器都部署一个实例,它们之间形成复制集 ...

  3. 在单机上通过docker搭建redis集群试验

    一 Redis集群搭建 1.1 运行redis镜像 [root@centos-linux docker]# docker run -id --name=redis-6379 -p 6379:6379 ...

  4. 一、史上最强hadoop分布式集群的搭建

    史上最强hadoop分布式集群的搭建 @Author:by Runsen @data:2020-02-23 原创文章,禁止转载 人生最重要的不是所站的位置,而是内心所朝的方向.只要我在每篇博文中写得自 ...

  5. 在windows上搭建redis集群(主从复制)

    Redis集群策略主要有: 主从复制 哨兵模式 (在windows上搭建redis集群(Redis-Sentinel)) 集群 (在windows上搭建redis集群(Redis-Cluster)) ...

  6. 在windows上搭建redis集群(Redis-Sentinel)

    Redis集群策略主要有: 哨兵模式 主从复制(在windows上搭建redis集群(主从复制)) 集群 (在windows上搭建redis集群(Redis-Cluster)) 分片 本文主要讲解如何 ...

  7. 在windows上搭建redis集群(Redis-Cluster)

    Redis集群策略主要有: 集群 主从复制(在windows上搭建redis集群(主从复制)) 哨兵模式 (在windows上搭建redis集群(Redis-Sentinel)) 分片 本文主要讲解如 ...

  8. 单机上搭建Node集群

    搭建Node集群需要复制进程,而且通过主从模式并行处理业务.主进程不负责具体的业务处理,而是负责调度或管理工作进程,它是趋向于稳定的.工作进程负责具体的业务处理. 关于本 Node 进程的介绍请看No ...

  9. 【运维开发】Mac OS(10.13.6)使用 vagrant+VirtualBox +centos7搭建k8s集群

    Mac OS(10.13.6)使用 vagrant+VirtualBox +centos7搭建k8s集群步骤 环境准备工作 下载VirtualBox 地址:https://www.virtualbox ...

最新文章

  1. Mac上 如何快速玩起rocksdb
  2. 转:Jquery AJAX POST与GET之间的区别
  3. VS2012生成ReactOS的VS工程失败(三)和 “ cl is not able to compile a simple test program“错误
  4. oracle PL/SQL
  5. CSDN markdown中实现首行缩进(空格)的两种方法(“  ”)
  6. 更改eclipse tomcat jvm heap
  7. python 代码片段6
  8. 201621123058 《java课程设计》第九周学习总结
  9. easyui datagrid java_java_easyui体系之DataGrid(4)[转]
  10. matlab 稀疏矩阵(sparse matrix)
  11. 怎样利用Python制作守护进程
  12. Java一套拳法刷掉n个遍历树的问题
  13. Java基础(二):面向对象
  14. 滑动窗口协议如何实现流量控制
  15. python中的计数函数_Python Numpy统计函数
  16. 企业微信登录本地调试
  17. 富爸爸实现财务自由七步骤
  18. LINUX企业应用案例精解 第2版 李晨光
  19. Tomasulo算法与记分牌算法的区别
  20. 价值3888开源企业发卡网源码/全网对接/全新UI风格/完美运营

热门文章

  1. Bootstrap 3 : 图片上传预览 image upload preview
  2. JS判断浏览器是否支持某一个CSS3属性
  3. 图解SQL inner join、left join、right join、full outer join、union、union all的区别
  4. PHP下载CSS文件中的图片
  5. 轻量级的 JavaScript 弹出框脚本:TinyBox
  6. ubuntu14.04+eigen3安裝(亲测)
  7. restorecon命令
  8. 【AI视野·今日NLP 自然语言处理论文速览 第十八期】Fri, 2 Jul 2021
  9. sqlserver的登陆操作
  10. django模板变量的使用详解 200309