Build a WordPress program operation instance on the CoreOS _linux

Source: Internet
Author: User
Tags install go git clone etcd

CoreOS is a customized Linux streamlined system for large-scale servers that completely separates operating systems and applications, reducing the coupling of operating systems and applications, and solving problems with existing Linux servers in container resources and rights management. For now, CoreOS will be a trend for future operating systems.

So did you personally deploy an application on the CoreOS? I believe most people do not have the experience that building an application on the CoreOS can be said to be very hard and frustrating. Because you must first understand all the different technologies before you begin to establish a program.

Below, we will teach you hands-on to create a simple WordPress application, using MySQL as a server, running on the CoreOS.

1. Install CLI to control CoreOS

If your computer is a Mac, you can install Fleetctl and etcdctl on this machine to control the CoreOS cluster:

Copy Code code as follows:

$ Brew Install go Etcdctl
$ git clone https://github.com/coreos/fleet.git
$ CD Fleet
$./build
$ MV bin/fleetctl/usr/local/bin/

2. Install local cluster

It is easy to install a local cluster using the Deployment virtualization development environment vagrant:

Copy Code code as follows:

$ git clone https://github.com/CenturyLinkLabs/coreos-vagrant
$ CD Coreos-vagrant/cluster
$ vagrant Up--provision

Now the cluster is installed, simple! Now let's check out the local fleetctl:
Copy Code code as follows:
$ fleetctl List-machines
MACHINE IP METADATA
09fd0a88 ... 10.0.2.15-
77763947.10.0.2.15-
F31c383c ... 10.0.2.15-

Great, it's working!
3. Deploy an application using fleet

The FLEETCTL command can deploy the application to the nodes of the CoreOS cluster, but it is too bad to write a service file for fleet. Fortunately, you don't have to write it yourself, you can use YAML format to generate service files:

Copy Code code as follows:

$ sudo gem install bundler Fig2coreos

$ cat Fig.yml
Web:
Image:ctlc/wordpress
Ports
-80:80
Environment:
Db_user:root
Db_password:qa1n76pwari9
Links
-DB
Db:
Image:ctlc/mysql
Ports
-3,306:3,306
Environment:
Mysql_database:wordpress
Mysql_root_password:qa1n76pwari9

$ fig2coreos MyApp fig.yml coreos-files

$ CD Coreos-files

$ ls
Db-discovery.1.service
Db.1.service
Web-discovery.1.service
Web.1.service


The FLEETCTL client tool uses the Key/value storage form of the ETCD system to share configuration and service discovery. Here's how to deploy the program to the cluster:
Copy Code code as follows:
$ fleetctl Start Db.1.service

$ fleetctl List-units
Unit LOAD ACTIVE SUB DESC MACHINE
Db.1.service loaded active running Run db_1 9c008961.../10.0.2.15

$ fleetctl Start Web.1.service

$ fleetctl List-units
Unit LOAD ACTIVE SUB DESC MACHINE
Db.1.service loaded active running Run db_1 9c008961.../10.0.2.15
Web.1.service loaded active running Run web_1 9c008961.../10.0.2.15


The program is now running, but has not yet registered ETCD services, fortunately Fig2coreos generated service discovery files can help us:
Copy Code code as follows:
$ fleetctl Start Db-discovery.1.service
$ fleetctl Start Web-discovery.1.service

$ fleetctl List-units
Unit LOAD ACTIVE SUB DESC MACHINE
Db-discovery.1.service loaded active running announce db_1 9c008961.../10.0.2.15
Db.1.service loaded active running Run db_1 9c008961.../10.0.2.15
Web-discovery.1.service loaded active running announce web_1 9c008961.../10.0.2.15
Web.1.service loaded active running Run web_1 9c008961.../10.0.2.15

$ etcdctl ls--recursive
/services
/services/web
/services/web/web_1
/services/db
/services/db/db_1

$ etcdctl get/services/web/web_1
{"Host": "Core-03", "Port": "Version": "52c7248a14"}

$ etcdctl get/services/db/db_1
{"Host": "Core-03", "Port": 3306, "version": "52c7248a14"}


It's done! If you are using Vagrant 1.5 and vagrant Cloud, you can implement the WordPress program and see that it can be implemented:
Copy Code code as follows:

$ CD ~/coreos-vagrant/cluster/

# Find out which box is hosting your port 80
$ etcdctl get/services/web/web_1
{"Host": "Core-03", "Port": "Version": "52c7248a14"}

$ vagrant Share core-03--http 80
==> core-03:detecting Network information for machine ...
Core-03:local Machine address:192.168.65.2
Core-03:local HTTP port:80
Core-03:local HTTPS port:disabled
==> core-03:checking authentication and authorization ...
==> core-03:creating vagrant Share Session ...
Core-03:share would be at:quick-iguana-4689
==> core-03:your vagrant Share is running! name:quick-iguana-4689
==> core-03:url:http://quick-iguana-4689.vagrantshare.com


The following is a good effect:


In fact, we can do a lot of things on the CoreOS, today this is just the basis, interested you can try.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.