当前位置:网站首页>在CoreOS下部署WordPress实例教程
在CoreOS下部署WordPress实例教程
2022-07-03 11:02:00 【星哥玩云】
CoreOS是一个专门为大规模服务器部署定制的Linux精简系统,它将操作系统和应用程序完全分离,从而降低操作系统和应用程序的耦合度,同时解决了现有Linux服务器在容器资源、权限管理方面出现的问题。就目前来说,CoreOS会是未来操作系统的发展趋势。
那你有没有亲自在CoreOS上部署一个应用程序呢?相信大多数人都没有过这样的经验,在CoreOS上建立一个应用程序可以说是非常辛苦及沮丧的。因为在开始建立程序之前你首先必须了解所有不同的技术。
下面,我们将手把手地教你来创建一个简单的WordPress应用程序,采用MySQL作为服务器,在CoreOS上运行。
服务器操作系统CoreOS初体验 http://www.linuxidc.com/Linux/2014-07/104807.htm
1. 安装CLI来控制CoreOS
如果你的电脑是Mac,可以在本机安装fleetctl和etcdctl来控制CoreOS集群:
$ brew install go etcdctl
$ git clone https://github.com/coreos/fleet.git
$ cd fleet
$ ./build
$ mv bin/fleetctl /usr/local/bin/
2. 安装本地集群
使用部署虚拟化开发环境Vagrant来安装本地集群很容易:
$ git clone https://github.com/CenturyLinkLabs/coreos-vagrant
$ cd coreos-vagrant/cluster
$ vagrant up --provision
现在集群就安装好了,简单吧!下面就让我们来检查一下本地fleetctl:
$ fleetctl list-machines
MACHINE IP METADATA
09fd0a88... 10.0.2.15 -
77763947... 10.0.2.15 -
f31c383c... 10.0.2.15 -
真棒,它起作用了!
3. 使用fleet部署一个应用程序
fleetctl命令可把应用程序部署到CoreOS集群的节点中,但要为fleet写服务文件真的是太糟糕了。幸运的是,你不必自己编写,你可以使用yaml format来生成服务文件:
$ 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:
- 3306:3306
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
fleetctl客户端工具使用的是etcd系统的Key/Value存储形式,以分享配置和服务发现。下面教大家如何把程序部署到集群中:
$ 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
现在程序就运行了,但是还没有注册etcd的服务,幸运的是fig2coreos生成的服务发现文件可以帮助我们:
$ 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": 80, "version": "52c7248a14" }
$ etcdctl get /services/db/db_1
{ "host": "core-03", "port": 3306, "version": "52c7248a14" }
这样就完成了!如果你使用的是Vagrant 1.5及Vagrant Cloud,那么你就可以实现 WordPress程序并看到它可以实行了:
$ cd ~/coreos-vagrant/cluster/
# find out which box is hosting your port 80
$ etcdctl get /services/web/web_1
{ "host": "core-03", "port": 80, "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 will 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
下面就是做好的效果图:
其实我们可以在CoreOS上能做很多事,今天这个只是基础,感兴趣的你可以动手试一试。
边栏推荐
- Unity3D学习笔记5——创建子Mesh
- R language uses data The table package performs data aggregation statistics, calculates window statistics, calculates the median of sliding groups, and merges the generated statistical data into the o
- ASP.NET-酒店管理系統
- Extrapolated scatter data
- How to become a senior digital IC Design Engineer (1-3) Verilog coding syntax: Verilog behavior level, register transfer level, gate level (abstract level)
- 鸿蒙第四次培训
- VS2015的下载地址和安装教程
- How to make others fear you
- ASP. Net hotel management system
- 外插散点数据
猜你喜欢
Hongmeng third training (project training)
Viewing binary bin files with notepad++ editor
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
How to clean up v$rman_ backup_ job_ Details view reports error ora-02030
活动预告 | 直播行业“内卷”,以产品力拉动新的数据增长点
The uniapp scroll view solves the problems of high adaptability and bullet frame rolling penetration.
Application of high-precision indoor positioning technology in safety management of smart factory
金额计算用 BigDecimal 就万无一失了?看看这五个坑吧~~
ASP. Net hotel management system
Driver development based on I2C protocol
随机推荐
2022年中南大学夏令营面试经验
uniapp实现点击加载更多
AOSP ~ NTP ( 网络时间协议 )
Stm32hal library upgrades firmware based on flash analog U disk (detailed explanation)
STL教程8-map
How to: configure ClickOnce trust prompt behavior
鸿蒙第三次培训(项目实训)
MATLAB提取不規則txt文件中的數值數據(簡單且實用)
P3250 [hnoi2016] Network + [necpc2022] f.tree path tree section + segment tree maintenance heap
一些常用术语
Extrapolated scatter data
Software testing weekly (issue 78): the more confident you are about the future, the more patient you are about the present.
phpcms 提示信息頁面跳轉showmessage
动态规划(区间dp)
How PHP solves the problem of high concurrency
如何将数字字符串转换为整数
[OBS] encapsulate the basic process of OBS acquisition
优化接口性能
The manuscript will be revised for release tonight. But, still stuck here, maybe what you need is a paragraph.
Kubernetes 三打探针及探针方式