CloudFoundry部署之BOSH_CLI(BOSH管理控制台)和MicroBosh(微BOSH)部署
- Ruby环境准备
- BOSH_CLI安装
- MicroBosh部署
由于CloudFoundry&BOSH是基于Ruby和Go语言开发的
所以要事先准备Ruby环境,这里我们使用NFS服务器同时作为我们的BOSHCLI管理控制台BOSHCLI同时允许安装在物理机及虚拟机中,采用Ubuntu12.04操作系统
- 安装Ruby所需依赖包
libyaml-dev因为版本号为1.9.3的ruby源码包中并没有集成libyaml-dev所以要事先准备该环境否则ruby运行缺少关键类库sudo apt-get install git-core build-essential libsqlite3-dev curl libmysqlclient-dev libxml2-dev libxslt1-dev libpq-dev genisoimage libyaml-dev zlib1g zlib1g-dev openssl libssl-dev libssl0.9.8 openssh-server
- 下载ruby源码包
这里使用的是ruby-1.9.3-p484,CloudFoundry-164版本目前支持ruby1.9.3和ruby2.0.0这两个版本,其他版本部署会出现各种错误 - 解压ruby源码包
sudo tar zxvf ruby-1.9.3-p484
- 编译安装ruby源码包
sudo chmod 777 -R ruby-1.9.3-p484 cd ruby-1.9.3-p484 sudo ./configure --prefix=/usr/local/ruby sudo make sudo make install
- 设置环境变量及软连接
sudo vi /etc/environment PATH="/usr/local/ruby/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" sudo ln -s /usr/local/ruby/bin/ruby /usr/bin/ruby sudo ln -s /usr/local/ruby/bin/gem /usr/bin/gem ruby -v && sudo ruby -v
- 安裝bundler
gem install bundle sudo ln -s /usr/local/ruby/bin/bundle /usr/bin/bundle sudo ln -s /usr/local/ruby/bin/bundler /usr/bin/bundler
- 安裝BOSHCLI
sudo gem install bosh_cli
- 安装MicroBosh部署器,否则bosh中没有micro相关的命令行
sudo gem install bosh_cli_plugin_micro
三、MicroBosh部署
- 下载stemcells,这里使用bosh-stemcell-2375-vsphere-esxi-ubuntu.tgz
- 创建目录
sudo mkdir -p ~/deployments/micro01 sudo chmod 777 -R ~/deployments cd ~/deployments/micro01
- 创建并编辑micro01.yml,保存至~/deployments/micro01目录下
sudo vi micro01.yml --- name: MicroBOSH01 # # Change network settings to match your environment. # network: ip: 192.168.2.20 # The IP address of your soon-to-be-deployed Micro BOSH netmask: 255.255.255.0 gateway: 192.168.2.1 dns: # The micro-bosh VM has the following DNS entries in its /etc/resolv.com, allowing it to resolve, for example, IaaS FQDNs. - 192.168.2.2 # You can also include a second DNS server underneath this line. cloud_properties: name: "VM Network" resources: persistent_disk: 16384 cloud_properties: ram: 4096 disk: 16384 cpu: 2 cloud: plugin: vsphere properties: agent: ntp: - ntp.sjtu.edu.cn # Specify any NTP server vcenters: - host: 192.168.2.2 # Your vCenter server IP user: WIN-0HB5C2E36RV\Administrator # The vCenter user for login password: kingdee$2012 # The vCenter user password datacenters: - name: CF-Zone01 vm_folder: vm_folder template_folder: template_folder disk_path: cf_folder datastore_pattern: NFSDataStore persistent_datastore_pattern: NFSDataStore allow_mixed_datastores: true clusters: - CF-Cluster01: # The Cluster name resource_pool: MICROBOSH apply_spec: properties: vcenter: host: 192.168.2.2 user: WIN-0HB5C2E36RV\Administrator # Your vCenter username password: kingdee$2012 # Your vCenter password datacenters: - name: CF-Zone01 vm_folder: vm_folder # Create this folder manually in vCenter template_folder: template_folder # Ditto. disk_path: cf_folder # Create this path manually in your datastore datastore_pattern: NFSDataStore # See documentation.md (official doc) for more on the datastore pattern persistent_datastore_pattern: NFSDataStore allow_mixed_datastores: true clusters: - CF-Cluster01: resource_pool: MICROBOSH # dns: # The BOSH powerDNS contacts the following DNS server for serving DNS entries from other domains. # recursor: <ip_for_dns> logging: # If needed increase the default logging level to trace RES
3.设置MicroBosh部署目标(也就是通常说的设置target)
bosh micro deployment micro01.yml
4.通过上面下载好的stemcell部署MicroBosh
bosh micro deploy ~/stemcells/bosh-stemcell-2375-vsphere-esxi-ubuntu.tgz
5.验证部署环境
bosh status bosh micro agent ping
若cf出现问题需要重新部署整个cf的话,bosh delete deployment不好用的情况下,则手动删除所有虚拟机,然后需要删除config目录下的所有.bosh_*和.bosh*和.cf*,然后重新部署即可