该文档描述如何使用 Tsuru 和 Docker 构建自己的私有 PaaS 服务。
文档假设你已经在64位的 Ubuntu 12.04 LTS 上安装了 Tsuru。
开源项目Docker,Red Hat新的虚拟化选择
安装之前开始安装之前,需要先安装 curl 和 Python-software-properties 两个软件包,这两个软件包用来安装额外的资源库。
sudo apt-get update
sudo apt-get install curl python-software-properties -qqy
添加资源库
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9echo "deb docker main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-add-repository ppa:tsuru/lvm2 -y
sudo apt-add-repository ppa:tsuru/ppa -y
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10echo "deb dist 10gen" | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
安装 beanstalkd
sudo apt-get install beanstalkd -qqy
cat > /tmp/default-beanstalkd <<EOFBEANSTALKD_LISTEN_ADDR=127.0.0.1BEANSTALKD_LISTEN_PORT=11300DAEMON_OPTS="-l \$BEANSTALKD_LISTEN_ADDR -p \$BEANSTALKD_LISTEN_PORT -b /var/lib/beanstalkd"START=yesEOFsudo mv /tmp/default-beanstalkd /etc/default/beanstalkd
sudo service beanstalkd start
安装 redis
sudo apt-get install redis-server -qqy
安装 hipache
sudo apt-get install node-hipache -qqy
sudo start hipache
安装 docker
sudo apt-get install lxc-docker -qqyecho export DOCKER_OPTS=\"-H 127.0.0.1:4243\" | sudo tee -a /etc/default/dockerecho export DOCKER_HOST=127.0.0.1:4243 >> ~/.bashrc
sudo stop docker
sudo start docker
安装 gandalf
sudo apt-get install gandalf-server -qqyhook_dir=/home/git/bare-template/hooks
sudo mkdir -p $hook_dirsudo curl https://raw.githubusercontent.com/tsuru/tsuru/master/misc/git-hooks/post-receive -o ${hook_dir}/post-receive
sudo chmod +x ${hook_dir}/post-receive
sudo chown -R git:git /home/git/bare-template# make sure you write the public IP of the machine in the "host" parameter# in the /etc/gandalf.conf filesudo start gandalf-server
sudo start git-daemon
安装 tsuru API server
sudo apt-get install tsuru-server -qqy
sudo curl -o /etc/tsuru/tsuru.conf# make sure you replace all occurrences of {{{HOST_IP}}} with the machine's# public IP in the /etc/tsuru/tsuru.conf filesudo sed -i -e 's/=no/=yes/' /etc/default/tsuru-server
sudo start tsuru-ssh-agent
sudo start tsuru-server-api
sudo start tsuru-server-collector
平台安装
curl https://raw.githubusercontent.com/tsuru/tsuru/master/misc/platforms-setup.js | mongo tsuru
这样它们就从 basebuilder 被安装到你指定的系统中,例如 Python:
docker build --no-cache -t tsuru/python https://raw.githubusercontent.com/flaviamissi/basebuilder/master/python/Dockerfile
将 Python 替换成其他平台(你可以检查 basebuilder 来获取支持的平台列表).
使用 tsuru 客户端恭喜你,现在你已经有一个可以运行的 tsuru 服务器了,你可以参考 tsuru client usage guide 来开始构建你的应用程序。
添加服务这里有一份完整的关于如何一步步的安装 MySQL 服务的文档:Install and configure a MySQL service.
DNS 服务器你也可以给 Tsuru 集成一个 DNS 服务器,可参考 Here you can find an example of using bind as a DNS forwarder, 与 Tsuru 进行集成。
Docker 的详细介绍:请点这里
Docker 的下载地址:请点这里