十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Pivotal Web Service主管工程师 产品经理 吴疆
创新互联建站是一家集网站建设,栖霞企业网站建设,栖霞品牌网站建设,网站定制,栖霞网站建设报价,网络营销,网络优化,栖霞网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。
在《CloudFoundry in 1 Box简介:Bosh-lite篇》我们介绍了Bosh-lite的架构和部署。在本篇中,我们将详细描述另一个CloudFoundry in 1 Box解决方案PCF-Dev。
1. PCF-dev简介
PCF是Pivotal发行的Cloud Foundry商业版,PCF-Dev原名MicroPCF,是Pivotal为PCF的应用开发人员准备的一款App单虚拟机版的CloudFoundry。但是,麻雀虽小,五脏俱全。PCF-Dev虽然可以在仅仅一台虚拟式上即可运行,但是却包含了cloud foundry完整的技术栈。下图展示了PCF-Dev的架构
在PCF-Dev中,除了包含了完整的Cloud Foundry,还包含了下列Cloud Foundry Service
MySQL
redis
RabbitMQ
和一系列Buildpack
Java
Ruby
Python
Golang
Static file
Binary
PCF-Dev不仅功能强大,使用起来却是异常简便。下面我们就来一步一步搭建一个PCF-Dev环境。
2. 环境准备
笔者采用的事Cent OS 7.2作为宿主机的操作系统,VirtualBox为虚拟机平台
2.1 安装以来的软件包
# rpm -Uvh http://mirror.pnl.gov/epel/7/x86_64/e/epel-release-7-5.noarch.rpm # yum install -y vim git screen kernel* libX11 qt SDL SDL-devel libxml2-devel \ libvpx libpng libXt libXmu libxslt libxslt-devel openssl \ openssl-devel libXcursor libXinerama qt qt-devel wget gcc unzip ntpdate net-tools
2.2 安装Ruby环境
笔者使用rbenv来安装和管理ruby
# git clone git://github.com/sstephenson/rbenv.git $HOME/.rbenv # git clone https://github.com/sstephenson/ruby-build.git $HOME/.rbenv/plugins/ruby-build # echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile # echo 'eval "$(rbenv init -)"' >> ~/.bash_profile # source ~/.bash_profile # rbenv install 2.3.0 # rbenv global 2.1.3 # gem install bundle # gem install nokogiri — --use-system-libraries
2.3安装Vagrant
# wget https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.rpm # rpm -Uvh vagrant_1.8.1_x86_64.rpm
验证vagrant
# vagrant --version Vagrant 1.8.1
2.4 安装VirtualBox
# wget http://download.virtualbox.org/virtualbox/5.0.16/VirtualBox-5.0-5.0.16_105871_el7-1.x86_64.rpm # #安装virtualbox时需要linux kernel的源代码,设置KERN_DIR环境变量指示kernel源代码路径 # export KERN_DIR=/usr/src/kernels/# rpm -Uvh VirtualBox-5.0-5.0.16_105871_el7-1.x86_64.rpm
验证virtualbox是否安装成功
# VBoxManage --version 5.0.16r105871
3. 部署PCF-Dev
3.1 从pivotal network下载PcF-dev
Pivotal Network地址:http://network.pivotal.io
3.2 解压pcf-dev
3.3 启动pcf-dev
# cd# ./start-osx #在linux也可以正常工作
3.4 查看PCF-dev component
# cd# vagrant ssh ##登陆pcf-dev虚拟机 # 登陆之后的pcf-dev虚拟机 $ sudo -i # monit summary root@agent-id-pcfdev-0:~# monit summary The Monit daemon 5.2.5 uptime: 14m Process 'consul_agent' running Process 'cloud_controller_clock' running Process 'cloud_controller_ng' running Process 'cloud_controller_worker_local_1' running Process 'cloud_controller_worker_local_2' running Process 'nginx_cc' running Process 'cloud_controller_migration' running Process 'cloud_controller_worker_1' running Process 'doppler' running Process 'gorouter' running Process 'loggregator_trafficcontroller' running Process 'metron_agent' running Process 'nats' running Process 'postgres' running Process 'route_registrar' running Process 'routing-api' running Process 'uaa' running Process 'etcd' running Process 'garden' running Process 'auctioneer' running Process 'bbs' running Process 'cc_uploader' running Process 'converger' running Process 'file_server' running Process 'nsync_listener' running Process 'nsync_bulker' running Process 'rep' running Process 'route_emitter' running Process 'ssh_proxy' running Process 'stager' running Process 'tps_listener' running Process 'tps_watcher' running Process 'syslog-configurator' running Process 'process-watcher' running Process 'cf-redis-broker' running Process 'broker-nginx' running Process 'cf-redis-route-registrar' running Process 'cf-mysql-broker' running Process 'cf-mysql-route-registrar' running Process 'quota-enforcer' running Process 'mariadb_ctrl' running Process 'galera-healthcheck' running Process 'gra-log-purger-executable' running Process 'rabbitmq-broker' running Process 'rabbitmq-broker-route-registrar' running Process 'rabbitmq-management-route-registrar' running Process 'rabbitmq-server' running System 'system_localhost' running
启动后的PCF-Dev虚拟机配置了两块网卡,一块用来连接CloudFoundry网络,使用10.0.2.15/24;一块用来和宿主机通信,使用IP 192.168.11.11
如果设有http https proxy,需要执行如下步骤
export no_proxy=192.168.11.11,local.pcfdev.io
至此,PCF-Dev环境准备完毕。
4. 部署app到PCF-Dev
4.1 安装CF CLI
#rpm -Uvh https://s3.amazonaws.com/go-cli/releases/v6.16.1/cf-cli-installer_6.16.1_x86-64.rpm
4.2 cf target
PCF-Dev默认的域名为local.pcfdev.io, *.local.pcfdev.io会被解析到192.168.11.11
# ping xyz.local.pcfdev.io PING xyz.local.pcfdev.io (192.168.11.11) 56(84) bytes of data. 64 bytes from 192.168.11.11: icmp_seq=1 ttl=64 time=0.818 ms 64 bytes from 192.168.11.11: icmp_seq=2 ttl=64 time=1.45 ms 64 bytes from 192.168.11.11: icmp_seq=3 ttl=64 time=1.33 ms 64 bytes from 192.168.11.11: icmp_seq=4 ttl=64 time=1.69 ms 64 bytes from 192.168.11.11: icmp_seq=5 ttl=64 time=1.25 ms ^C --- xyz.local.pcfdev.io ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4006ms rtt min/avg/max/mdev = 0.818/1.311/1.696/0.292 ms
# cf api https://api.local.pcfdev.io --skip-ssl-validation Setting api endpoint to api.local.pcfdev.io... OK API endpoint: https://api.local.pcfdev.io (API version: 2.51.0) Not logged in. Use 'cf login' to log in. # cf login ##username/password are admin/admin API endpoint: https://api.local.pcfdev.io Email> admin Password> Authenticating... OK Targeted org pcfdev-org Targeted space pcfdev-space API endpoint: https://api.local.pcfdev.io (API version: 2.51.0) User: admin Org: pcfdev-org Space: pcfdev-space
4.3 部署App
# cd# cf push