Ubuntu桌面版搭建单机版CloudFoundry

一、简介

想来想去还是写个简介吧…

1.1 CloudFoundry

Cloud Foundry是VMware公司推出的一个开源PaaS云平台,似乎号称业界第一个。它支持多种框架、语言、运行时环境、云平台及应用服务,可以用于应用程序的部署和扩展。

它本身是基于Ruby on Rails编写的,有多个相对独立的子系统。系统之间通过消息机制(nats)通信,使平台在各层级都可水平扩展,既能在大型数据中心里运行,也能运行在一台桌面电脑中,二者使用相同的代码库。

1.2 PaaS

区别语于传统

二、安装

说起来,其实安装很简单,只需要执行一条命令就可以:

bash < <(curl -s -k -B https://raw.githubusercontent.com/yudai/cf_nise_installer/${INSTALLER_BRANCH:-master}/scripts/bootstrap.sh)

但是别高兴的太早,这只是你苦逼路程的开始。好了,咱们从头说。

2.1 系统

我们使用的cf_nise_installer脚本进行安装,该脚本只支持Ubuntu10.04 and 12.04 64bit server。综合大部分资料,目前推荐的系统是Ubuntu 10.04 Server,但是我用的Ubuntu12.04桌面版也安装成功了,并可以正常运行,所有系统方面大家随意。

本文默认使用系统:Ubuntu12.04桌面版

2.2 cf_nise_installer

本文的安装使用的是cf_nise_installer的脚本进行安装,正常情况下,该脚本是全自动与运行的。CloudFoundry所安装过程中涉及的所有安装及环境需要的包他都会下载安装并配置好。

参考:https://github.com/yudai/cf_nise_installer

一定要科学上网,一定要科学上网,一定要科学上网,重要的事情要说三遍,然而并没有卵用……

整个过程中只需要执行两句命令:

sudo apt-get install curl

过程中会各种断,尤其是下载buildpack包的时候,每个包都好几百兆,断了只能从头下载,尤其是buildpack_ruby接近1G的大小,下载过程中自求多福吧,个中辛苦谁下谁知道。

既然说到了cf_nise_installer,就简单分析一下他的脚本,跟句命令来看,我们执行的是工程下scripts文件夹下的bootstrap.sh脚本,其中的内容是:

#!/bin/bash -ex

if [ ! -f /etc/lsb-release ] || \

[ `uname -m` != "x86_64" ]; then

echo "This installer supports only Ubuntu 10.04 and 12.04 64bit server"

exit 1;

fi

# Git bootstrap

if ! (which git); then

sudo apt-get update

sudo apt-get install -y git-core

fi

INSTALLER_URL=${INSTALLER_URL:-https://github.com/yudai/cf_nise_installer.git}

INSTALLER_BRANCH=${INSTALLER_BRANCH:-master}

if [ ! -d cf_nise_installer ]; then

git clone ${INSTALLER_URL} cf_nise_installer

fi

(

cd cf_nise_installer

git checkout ${INSTALLER_BRANCH}

./scripts/install.sh

)

脚本中可以看出,cf_nise_installer只支持Ubuntu10.04 and 12.04 64bit server,所以使用过程中请注意。接下来下载了cf_nise_installer工程之后调用了install.sh脚本,继续查看install.sh脚本:

#!/bin/bash -ex

# Detect RVM

if (rvm >/dev/null 2>&1); then

echo "Found RVM is installed! RVM is not supported by this installer. Remove it and rerun this script."

exit 1

fi

sudo apt-get update

./scripts/install_ruby.sh

source ~/.profile

./scripts/clone_nise_bosh.sh

./scripts/clone_cf_release.sh

./scripts/install_environemnt.sh

./scripts/install_cf_release.sh

set +x

echo "Done!"

echo "You can launch Cloud Foundry with ‘./scripts/start.sh’"

echo "Restart your server before starting processes if you are using Ubuntu 10.04"

看到这脚本估计你会很高兴,因为主要你看到了一下几行字就代表你安装完成了:

set +x

echo "Done!"

echo "You can launch Cloud Foundry with ‘./scripts/start.sh’"

echo "Restart your server before starting processes if you are using Ubuntu 10.04"

然而别高兴的太早,你的安装过程一定对的起苦逼二字的。

言归正传,继续看脚本,脚本先对RVM进行了判断,cf_nise_installer使用的是rbenv这个ruby安装工具,没有选择使用rvm。这个脚本照样没做啥正事,判断了一下rvm,然后又是调用了一堆脚本:

./scripts/install_ruby.sh

source ~/.profile

./scripts/clone_nise_bosh.sh

./scripts/clone_cf_release.sh

./scripts/install_environemnt.sh

./scripts/install_cf_release.sh

别着急,,一个一个的看,./scripts/install_ruby.sh:

#!/bin/bash -ex

if [ ! -d ~/.rbenv ]; then

sudo apt-get -y install build-essential libreadline-dev libssl-dev zlib1g-dev git-core

git clone https://github.com/sstephenson/rbenv.git ~/.rbenv

git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

echo ‘export PATH="$HOME/.rbenv/bin:$PATH"’ >> ~/.profile

echo ‘eval "$(rbenv init -)"’ >> ~/.profile

fi

source ~/.profile

if ! (rbenv versions | grep -q 1.9.3-p484); then

rbenv install 1.9.3-p484

fi

rbenv local 1.9.3-p484

gem install bundler –no-rdoc –no-ri

rbenv rehash

很简单,这个脚本就是在装ruby及相关的包,继续看clone_nise_bosh.sh

#!/bin/bash -ex

if [ ! "$(ls -A nise_bosh)" ]; then

git submodule update –init –recursive nise_bosh

(

cd nise_bosh

if [ "" != "$NISE_BOSH_REV" ]; then

git checkout $NISE_BOSH_REV

fi

echo "Using Nise BOSH revision: `git rev-list –max-count=1 HEAD`"

)

else

echo "’nise_bosh’ directory is not empty. Skipping cloning…"

fi

如果你希望成功,以恒心为良友,以经验为参谋,以小心为兄弟,以希望为哨兵。

Ubuntu桌面版搭建单机版CloudFoundry

相关文章:

你感兴趣的文章:

标签云: