This commit is contained in:
khs1994
2017-11-22 11:13:23 +08:00
parent c3c3cf98cb
commit 7cbdf27d93
30 changed files with 189 additions and 193 deletions

View File

@@ -10,7 +10,7 @@ CoreOS的第一个重要组件就是使用etcd来实现的服务发现。
例如:
```
```yml
#cloud-config
hostname: coreos0
@@ -51,7 +51,7 @@ Fleet通过接受systemd单元文件来工作同时在你集群的机器上
首先让我们构建一个简单的可以运行docker容器的systemd单元。把这个文件保存在home目录并命名为hello.service
```
```yml
hello.service
[Unit]
@@ -69,7 +69,7 @@ ExecStop=/usr/bin/docker stop hello
然后,读取并启动这个单元:
```
```yml
$ fleetctl load hello.service
=> Unit hello.service loaded on 8145ebb7.../172.17.8.105
$ fleetctl start hello.service
@@ -80,7 +80,7 @@ $ fleetctl start hello.service
下面我们查看下它的状态:
```
```yml
$ fleetctl status hello.service
● hello.service - My Service
Loaded: loaded (/run/fleet/units/hello.service; linked-runtime)
@@ -97,7 +97,7 @@ Jun 04 19:05:06 core-01 bash[27503]: Hello World
我们可以停止容器:
```
```yml
fleetctl destroy hello.service
```

View File

@@ -20,21 +20,21 @@
首先,获取模板配置文件
```
git clone https://github.com/coreos/coreos-vagrant
cd coreos-vagrant
cp user-data.sample user-data
```bash
$ git clone https://github.com/coreos/coreos-vagrant
$ cd coreos-vagrant
$ cp user-data.sample user-data
```
获取新的token
```
curl https://discovery.etcd.io/new
```bash
$ curl https://discovery.etcd.io/new
```
把获取的token放到user-data文件中示例如下
```
```yml
#cloud-config
coreos:
@@ -50,7 +50,7 @@ coreos:
复制文件
```
```bash
cp config.rb.sample config.rb
```
@@ -58,7 +58,7 @@ cp config.rb.sample config.rb
启动集群
```
```bash
vagrant up
=>
Bringing machine 'core-01' up with 'virtualbox' provider...
@@ -74,13 +74,13 @@ Bringing machine 'core-03' up with 'virtualbox' provider...
添加ssh的公匙
```
```bash
ssh-add ~/.vagrant.d/insecure_private_key
```
连接集群中的第一台机器
```
```bash
vagrant ssh core-01 -- -A
```
@@ -88,7 +88,7 @@ vagrant ssh core-01 -- -A
使用fleet来查看机器运行状况
```
```bash
fleetctl list-machines
=>
MACHINE IP METADATA
@@ -99,4 +99,4 @@ cb35b356... 172.17.8.103 -
如果你也看到了如上类似的信息,恭喜,本地基于三台机器的集群已经成功启动,是不是很简单。
那么之后你就可以基于CoreOS的三大工具做任务分发分布式存储等很多功能了。
那么之后你就可以基于CoreOS的三大工具做任务分发分布式存储等很多功能了。