Coreos mainly includes the following:
(1) Minimum OS: Kernel + systemd
(2) run the application using docker
(3) Use fleet to manage Clusters
(4) using etcd for service discovery: a distributed K/V Storage engine stores configuration data
Download the vagrant coreos configuration file
$ Git clone https://github.com/coreos/coreos-vagrant.git
$ Vagrant up
$ Vagrant status
Current Machine states:
Core-01 running (virtualbox)
Core-02 running (virtualbox)
Core-03 running (virtualbox)
$ Ssh-add ~ /. Vagrant. d/insecure_private_key
Identity added:/users/yy/. vagrant. d/insecure_private_key (/users/yy/. vagrant. d/insecure_private_key)
$ Vagrant SSH core-01
Last login: Sun Sep 7 16:23:31 2014 from 10.0.2.2
Coreos (Beta)
[Email protected] ~ $ Fleetctl list-Machines
Machine IP metadata
542a4130... 172.17.8.101-
Bcb90abf... 172.17.8.102-
E6a8eaa9... 172.17.8.103-
Read and Write etcd
[Email protected] ~ $ Etcdctl set first-etcd-key "Hello World"
Hello World
[Email protected] ~ $ Etcdctl get first-etcd-Key
Hello World
On core-02, you can read the value corresponding to first-etcd-key:
[Email protected] ~ $ Etcdctl get first-etcd-Key
Hello World
You can also directly provide an API to read the corresponding key:
[Email protected] ~ $ Curl-l http: // 127.0.0.1: 4001/V1/keys/first-etcd-Key
{& Quot; Action & quot;: & quot; get & quot;, & quot; Key & quot;: & quot;/first-etcd-Key & quot;, & quot; Value & quot;: & quot; Hello World & quot;, & quot; index & quot;: 2264}
Use fleetctl to manage services
[Email protected] ~ $ Cat hello. Service
[Unit]
Description = my service
After = docker. Service
[Service]
Timeoutstartsec = 0
Execstartpre =-/usr/bin/docker kill hello
Execstartpre =-/usr/bin/docker RM hello
Execstartpre =/usr/bin/docker pull busybox
Execstart =/usr/bin/docker run -- name Hello busybox/bin/sh-c "While true; do echo Hello world; sleep 1; done"
Execstop =/usr/bin/docker stop hello
[Email protected] ~ $ Fleetctl load hello. Service
Job hello. Service loaded on 542a4130.../172.17.8.101
[Email protected] ~ $ Fleetctl start hello. Service
Job hello. Service launched on 542a4130.../172.17.8.101
View service status
[Email protected] ~ $ Fleetctl status hello. Service
● Hello. Service-my service
Loaded: loaded (/run/fleet/units/Hello. Service; linked-runtime)
Active: active (running) Since mon 2014-09-08 04:21:13 UTC; 1 min 25 s ago
Process: 1117 execstartpre =/usr/bin/docker pull busybox (code = exited, status = 0/success)
Process: 1108 execstartpre =/usr/bin/docker RM Hello (code = exited, status = 1/failure)
Process: 1046 execstartpre =/usr/bin/docker kill Hello (code = exited, status = 1/failure)
Main PID: 1185 (docker)
Cgroup:/system. Slice/Hello. Service
Container-1185/usr/bin/docker run -- name Hello busybox/bin/sh-c While true; do echo Hello world; sleep 1; done
SEP 08 04:22:28 core-01 docker [1185]: Hello World
SEP 08 04:22:29 core-01 docker [1185]: Hello World
SEP 08 04:22:30 core-01 docker [1185]: Hello World
SEP 08 04:22:31 core-01 docker [1185]: Hello World
SEP 08 04:22:32 core-01 docker [1185]: Hello World
SEP 08 04:22:33 core-01 docker [1185]: Hello World
SEP 08 04:22:34 core-01 docker [1185]: Hello World
SEP 08 04:22:35 core-01 docker [1185]: Hello World
SEP 08 04:22:36 core-01 docker [1185]: Hello World
SEP 08 04:22:37 core-01 docker [1185]: Hello World
[Email protected] ~ $ Docker PS
Container ID image Command created status ports names
Fa7084105f19 busybox: buildroot-2014.02/bin/sh-c 'while tr 2 minutes ago up 2 minutes Hello
View service status in another coreos
$ Vagrant SSH core-02 ---
Last login: Mon Sep 8 04:35:40 2014 from 10.0.2.2
Coreos (Beta)
[Email protected] ~ $ Fleetctl list-Units
Unit dstate tmachine state machine active
Hello. Service launched 542a4130.../172.17.8.101 launched 542a4130.../172.17.8.101 active
[Email protected] ~ $ Fleetctl status hello. Service
● Hello. Service-my service
Loaded: loaded (/run/fleet/units/Hello. Service; linked-runtime)
Active: active (running) Since mon 2014-09-08 04:21:13 UTC; 15 min ago
Process: 1117 execstartpre =/usr/bin/docker pull busybox (code = exited, status = 0/success)
Process: 1108 execstartpre =/usr/bin/docker RM Hello (code = exited, status = 1/failure)
Process: 1046 execstartpre =/usr/bin/docker kill Hello (code = exited, status = 1/failure)
Main PID: 1185 (docker)
Cgroup:/system. Slice/Hello. Service
Container-1185/usr/bin/docker run -- name Hello busybox/bin/sh-c While true; do echo Hello world; sleep 1; done
SEP 08 04:36:20 core-01 docker [1185]: Hello World
SEP 08 04:36:21 core-01 docker [1185]: Hello World
SEP 08 04:36:22 core-01 docker [1185]: Hello World
SEP 08 04:36:23 core-01 docker [1185]: Hello World
SEP 08 04:36:24 core-01 docker [1185]: Hello World
SEP 08 04:36:25 core-01 docker [1185]: Hello World
SEP 08 04:36:26 core-01 docker [1185]: Hello World
SEP 08 04:36:27 core-01 docker [1185]: Hello World
SEP 08 04:36:28 core-01 docker [1185]: Hello World
SEP 08 04:36:29 core-01 docker [1185]: Hello World
[Email protected] ~ $ Fleetctl destroy hello. Service
Destroyed hello. Service
References
[1] https://coreos.com/docs/quickstart/
YY brother
Source: http://www.cnblogs.com/hustcat/
The copyright of this article is shared by the author and the blog Park. You are welcome to repost this article. However, you must retain this statement without the author's consent and provide a clear link to the original article on the article page. Otherwise, you will be held legally liable.
Coreos practice (1)-coreos initial experience