CloudFoundry部署(二):BOSH_CLI&MicroBosh部署

本文详细介绍了如何准备Ruby环境以安装BOSH_CLI,并利用BOSH_CLI部署MicroBosh的过程。从Ruby环境搭建到BOSH_CLI的安装,再到具体的MicroBosh配置与部署步骤,帮助读者掌握Cloud Foundry的部署流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CloudFoundry部署之BOSH_CLI(BOSH管理控制台)和MicroBosh(微BOSH)部署

  • Ruby环境准备
  • BOSH_CLI安装
  • MicroBosh部署
一、Ruby环境准备

由于CloudFoundry&BOSH是基于Ruby和Go语言开发的
所以要事先准备Ruby环境,这里我们使用NFS服务器同时作为我们的BOSHCLI管理控制台

BOSHCLI同时允许安装在物理机及虚拟机中,采用Ubuntu12.04操作系统

  1. 安装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
    libyaml-dev因为版本号为1.9.3的ruby源码包中并没有集成libyaml-dev所以要事先准备该环境否则ruby运行缺少关键类库
  2. 下载ruby源码包
    这里使用的是ruby-1.9.3-p484,CloudFoundry-164版本目前支持ruby1.9.3和ruby2.0.0这两个版本,其他版本部署会出现各种错误
  3. 解压ruby源码包
    sudo tar zxvf ruby-1.9.3-p484
  4. 编译安装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
  5. 设置环境变量及软连接
    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
  6. 安裝bundler
    gem install bundle
  7. 
    sudo ln -s /usr/local/ruby/bin/bundle /usr/bin/bundle
    sudo ln -s /usr/local/ruby/bin/bundler /usr/bin/bundler
    
    
二、BOSH_CLI安装
  1. 安裝BOSHCLI
    sudo gem install bosh_cli
  2. 安装MicroBosh部署器,否则bosh中没有micro相关的命令行
    sudo gem install bosh_cli_plugin_micro

三、MicroBosh部署

  1. 下载stemcells,这里使用bosh-stemcell-2375-vsphere-esxi-ubuntu.tgz
  2. 创建目录
    sudo mkdir -p ~/deployments/micro01
    sudo chmod 777 -R ~/deployments
    cd ~/deployments/micro01
  3. 创建并编辑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*,然后重新部署即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值