cloudfoundry 2 on apache cloudstack 4.2.1

Download CloudFoundry 2 on Apache CloudStack 4.2.1

Post on 07-Aug-2015

100 views

Category:

Software

0 download

Embed Size (px)

TRANSCRIPT

  1. 1. i COPYRIGHT FUJITSU LIMITED 2014 CloudStack Advent Calendar 2014 16 CloudFoundry 2 on Apache CloudStack 4.2.1 Powered by OSS Apache CloudStack 4.2.1 CloudFoundry 2 Cloudstack Ver4.2.1 VM Ubuntu 12.04 350GB 150GB (root)
  2. 2. 1 COPYRIGHT FUJITSU LIMITED 2014 1. CloudFoundry CloudStack KVM UbuntuOS Ver12.04 CPU m1.small 1core 500MB m1.medium2 1core 2GB m1.large 2core 2GB m1.large2 2core 4GB disk2gb 2GB disk10gb 10GB disk20gb 20GB
  3. 3. 2 COPYRIGHT FUJITSU LIMITED 2014 2. CloudFoundry BOSH BOSHMicro BOSH Cloudstack UbuntuVM 2.1. Ubuntu Cloudstack Ubuntu12 Ubuntu VM m1.small 2.2. Ubuntu VM 2.2.1.root root root (1)root $ sudo su # passwd (2)root ssh sshd_config # vi /etc/ssh/sshd_config PermitRootLogin without-password PermitRootLogin yes ----- #PasswordAuthentication yes PasswordAuthentication yes (3) # initctl restart ssh
  4. 4. 3 COPYRIGHT FUJITSU LIMITED 2014 2.2.2. /tmp Cloudstack (1) 20GB GUI (2) /tmp # mount /dev/vdb /tmp /dev/vdb 2.2.3. http_proxyhttps_proxy export http_proxy=http://{Proxy Server}:{Port} export https_proxy=http:// {Proxy Server}:{Port} 2.3. 2.3.1. upgrade apt-get Japanese Team # wget -q https://www.ubuntulinux.jp/ubuntu-ja-archive-keyring.gpg -O- | sudo apt-key add - # wget -q https://www.ubuntulinux.jp/ubuntu-jp-ppa-keyring.gpg -O- | sudo apt- key add - # wget https://www.ubuntulinux.jp/sources.list.d/precise.list -O /etc/apt/sou rces.list.d/ubuntu-ja.list # apt-get update
  5. 5. 4 COPYRIGHT FUJITSU LIMITED 2014 upgrade # apt-get upgrade 2.3.2.acpiphp acpiphp # modprobe acpiphp # sh -c "echo acpiphp >> /etc/modules" 2.3.3. (1)git # apt-add-repository ppa:git-core/ppa # apt-get update # sudo apt-get install git-core (2)RubyGems # apt-get install g++ make libxslt-dev libxml2-dev libsqlite3-dev zlib1g-dev l ibreadline-dev libssl-dev libcurl4-openssl-dev (3)stemcell # apt-get install libsqlite3-dev genisoimage libmysqlclient-dev libpq-dev debo otstrap kpartx 2.3.4.Ruby (1) git git config # git config --global http.proxy http://mp067159:8160584683@rep.proxy.nic.fuj itsu.com:8080/ # git config --global https.proxy http://mp067159:8160584683@rep.proxy.nic.fu jitsu.com:8080/
  6. 6. 5 COPYRIGHT FUJITSU LIMITED 2014 (2)rbenv rbenv # apt-get install build-essential bison libreadline6-dev curl git-core zlib1g- dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev aut oconf libncurses5-dev # git clone http://github.com/sstephenson/rbenv.git .rbenv # git clone http://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/rub y-build (3)profile rbenv ~/.bash_profile $ vi ~/.bash_profile export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" $ source ~/.bash_profile (4)Ruby rbenv Ruby # rbenv install --list Ruby # rbenv install 1.9.3-p547 # rbenv global 1.9.3-p547 # ruby --version ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-linux]
  7. 7. 6 COPYRIGHT FUJITSU LIMITED 2014 3. BOSH 3.1. BOSH MicroBOSH 3.1.1.BOSH git Bosh # git clone https://github.com/cloudfoundry-community/bosh-cloudstack-cpi.git ~/bosh # cd ~/bosh 3.1.2. gem gem # gem install bundler # bundle 3.1.3.stemcell stemcell VM AWS Hper-V Openstak stemcell Cloustack 2 stemcellOpenstack (1) Bosh VM stemcell # bundle exec rake stemcell:build_os_image[ubuntu,precise,/tmp/ubuntu_base_im age.tgz] ubuntu OS precise OS ubuntu precise lucid /tmp/ubuntu_base_image.tgz (2)bosh-stemcell /mnt/stemcells/null/null/ ubuntu/work/work/chroot/boot
  8. 8. 7 COPYRIGHT FUJITSU LIMITED 2014 initrd.img-xxx-virtualvmlinuz-xxx-virtual/root/ bosh/bosh-stemcell/spec/stemcells/ubuntu_precise_spec.rb 3 14 desc ribe end # ls /mnt/stemcells/null/null/ubuntu/work/work/chroot/boot System.map-3.2.0-70-virtual config-3.2.0-70-virtual initrd.img-3.2.0-70-vir tual abi-3.2.0-70-virtual grub vmlinuz-3.2.0-70-virtual ubuntu 3.2.0-70 # vi /root/bosh/bosh-stemcell/spec/stemcells/ubuntu_precise_spec.rb describe 'Ubuntu 12.04 stemcell', stemcell_image: true do context 'installed by image_install_grub' do describe file('/boot/grub/grub.conf') do it { should be_file } it { should contain 'default=0' } it { should contain 'timeout=1' } it { should contain 'title Ubuntu 12.04.5 LTS (3.2.0-68-virtual)' } it { should contain ' root (hd0,0)' } it { should contain ' kernel /boot/vmlinuz-3.2.0-68-virtual ro root=UUI D=' } it { should contain ' selinux=0' } it { should contain ' initrd /boot/initrd.img-3.2.0-68-virtual' } end describe 'Ubuntu 12.04 stemcell', stemcell_image: true do context 'installed by image_install_grub' do describe file('/boot/grub/grub.conf') do it { should be_file } it { should contain 'default=0' } it { should contain 'timeout=1' } it { should contain 'title Ubuntu 12.04.5 LTS (3.2.0-70-virtual)' } it { should contain ' root (hd0,0)' }
  9. 9. 8 COPYRIGHT FUJITSU LIMITED 2014 it { should contain ' kernel /boot/vmlinuz-3.2.0-70-virtual ro root=UUI D=' } it { should contain ' selinux=0' } it { should contain ' initrd /boot/initrd.img-3.2.0-70-virtual' } end (3)stemcell (1) stemcell # bundle exec rake stemcell:build_with_local_os_image[cloudstack,ubuntu,preci se,ruby,/tmp/ubuntu_base_image.tgz] 3.1.4.Proxy Firstbosh Proxy no_proxy # export no_proxy=172.16.10.224,172.16.10.227,172.16.10.228 IP VM IP IP 3.1.5. (1) Cloudstack API SSH # cat kick_api.sh ----------------------------------------- #!/bin/bash # # kick_api.sh # # please set your host address="http://172.16.10.224:8080" # Cloudstack URL # please set your api key CloudStackGUI
  10. 10. 9 COPYRIGHT FUJITSU LIMITED 2014 api_key="QBbqiA_mGMp23w8lX1zadH_PCruxaqj55iTtQgCQst5Pd5aJ1TrXKErTX3UKIvmx4Ok5 WaJZNPwY0o1Y_ORP2A" # please set your secret keyCloudStackGUI secret_key="oN5z4NafX9OrwknE39f9sT_rhSrfdCa1CRuoCjO3iD214wzM4JGLIT2TjwmvBerWL uM9OOdnCEtyVpPy02rOkg" api_path="/client/api?" if [ $# -lt 1 ]; then echo "usage: $0 command=... paramter=... parameter=..."; exit; elif [[ $1 != "command="* ]]; then echo "usage: $0 command=... paramter=... parameter=..."; exit; elif [ $1 == "command=" ]; then echo "usage: $0 command=... paramter=... parameter=..."; exit; fi data_array=("$@" "apikey=${api_key}") temp1=$(echo -n ${data_array[@]} | tr " " "n" | sort -fd -t'=' | perl -pe's/([^-_.~A-Za-z0-9=s])/sprintf("%%%02X", ord($1))/seg'| tr "A-Z" "a-z" | tr "n" "&" ) signature=$(echo -n ${temp1[@]}) signature=${signature%&} signature=$(echo -n $signature | openssl sha1 -binary -hmac $secret_key | openssl base64 ) signature=$(echo -n $signature | perl -pe's/([^-_.~A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg') url=${address}${api_path}$(echo -n $@ | tr " " "&")"&"apikey=$api_key"&"signat ure=$signature echo " SEND URL: $url" curl ${url} (2) name= ./kick_api.sh command=createSSHKeyPair name=
  11. 11. 10 COPYRIGHT FUJITSU LIMITED 2014 # ./kick_api.sh command=createSSHKeyPair name=cfmykey SEND URL: http://172.16.10.224:8080/client/api?command=createSSHKeyPair&name =cfmykey&apikey=QBbqiA_mGMp23w8lX1zadH_PCruxaqj55iTtQgCQst5Pd5aJ1TrXKErTX3UKI vmx4Ok5WaJZNPwY0o1Y_ORP2A&signature=gPmSPYqd2fIaSf5%2BX2K%2FvEdgaD8%3D -----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQCqPLtCyjC3GeLwJODEI9eJLnaanRzxpvU2BWfuUTMem5/s8hwe FN2cr7ZC5deW9cR1P394OFtWVarOdvDymHntUsZeJMxGY3ad5WlNL5OBLy1aqSIk T7p7S7ZHfFpEZ8Qx6M13E3xc27T9o+DJMPV300vjSL3sJy+vAcrIGyusQQIDAQAB AoGAE/mwV3P2J2YINPl+zkUOY3BqRlYtMUXP/BjCSzqH7w1/xIPcPMNiBaKwlkT1 +Sa5eLCMuoSSYx0GP9fBChZOKBPScMrC/77s03U8lLDSaDPid45st8U9dQy6Id97 ny1D3+hU2NNvaVPCZYqtvsGhhLhQ3Hj7YnmbqEJN7I8pTUkCQQDRXknbOkjjm1uX rqter6jU8r1TS9a3HpJIgbxWD+9qNZmBDJJIb7dB+6NXg3/oljJynB48LRgDlU5Y cfwCAGlTAkEA0CdGyBRFNWaqKpLR1wugN0CPDrh4AkwSOCne64ReJiLDaLohcCjr ASHF/ShwyQ/lX/fZfo4u/Nld3c5IO9ydmwJBAK024Muq8Nq9kY1wSP9RPNDQ8qmT ONTPSh8KlpJtJJouNg16JRwgsPC6C20/sfbvLFV9q9YFSLTONb8ermvJg1kCQCsw WxFck1eXK6uVtxBliyKrtIMbZ1siqY0ZsvUvC9Hh2KW8KP/6nXgop8n1QCGXuMIG zQvjOICiIUXKbVZuWg0CQEqhaJ1xWZkxd2EuDcPr+JPBJSS/DyOOtdqNQBTpoJLz fVkHNwwStJIU4x9/CULbRtvqedyTsIYmnfSKWZtoVJ0= -----END RSA PRIVATE KEY----- cfmykeydb:12:1e:5c:79:0c:ba:06:35:51:7 e:4c:21:a9:c9:94root@ubunt u14:~# (3) -----BEGIN RSA PRIVATE KEY----------END RSA PRIVATE KEY- ---- # vi /root/cfmykey -----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQCqPLtCyjC3GeLwJODEI9eJLnaanRzxpvU2BWfuUTMem5/s8hwe FN2cr7ZC5deW9cR1P394OFtWVarOdvDymHntUsZeJMxGY3ad5WlNL5OBLy1aqSIk T7p7S7ZHfFpEZ8Qx6M13E3xc27T9o+DJMPV300vjSL3sJy+vAcrIGyusQQIDAQAB AoGAE/mwV3P2J2YINPl+zkUOY3BqRlYtMUXP/BjCSzqH7w1/xIPcPMNiBaKwlkT1 +Sa5eLCMuoSSYx0GP9fBChZOKBPScMrC/77s03U8lLDSaDPid45st8U9dQy6Id97 ny1D3+hU2NNvaVPCZYqtvsGhhLhQ3Hj7YnmbqEJN7I8pTUkCQQDRXknbOkjjm1uX rqter6jU8r1TS9a3HpJIgbxWD+9qNZmBDJJIb7dB+6NXg3/oljJynB48LRgDlU5Y
  12. 12. 11 COPYRIGHT FUJITSU LIMITED 2014 cfwCAGlTAkEA0CdGyBRFNWaqKpLR1wugN0CPDrh4AkwSOCne64ReJiLDaLohcCjr ASHF/ShwyQ/lX/fZfo4u/Nld3c5IO9ydmwJBAK024Muq8Nq9kY1wSP9RPNDQ8qmT ONTPSh8KlpJtJJouNg16JRwgsPC6C20/sfbvLFV9q9YFSLTONb8ermvJg1kCQCsw WxFck1eXK6uVtxBliyKrtIMbZ1siqY0ZsvUvC9Hh2KW8KP/6nXgop8n1QCGXuMIG zQvjOICiIUXKbVZuWg0CQEqhaJ1xWZkxd2EuDcPr+JPBJSS/DyOOtdqNQBTpoJLz fVkHNwwStJIU4x9/CULbRtvqedyTsIYmnfSKWZtoVJ0= -----END RSA PRIVATE KEY----- 3.1.6. BOSH firstbosh micro_bosh.yml micro_bosh.yml # mkdir -p ~/deployments/firstbosh # vi ~/deployments/firstbosh/micro_bosh.yml network ip ip endpoint URL /client/api default_security_groups [""] TCPUDP Openstack name: firstbosh logging: level: DEBUG network: type: dynamic ip: 172.16.10.227 # IP
  13. 13. 12 COPYRIGHT FUJITSU LIMITED 2014 resources: persistent_disk: 20512 cloud_properties: instance_type: m1.large2 # VM cloud: plugin: cloudstack properties: cloudstack: endpoint: http://172.16.10.224:8080/client/api # Cloudstack /client/api api_key: QBbqiA_mGMp23w8lX1zadH_PCruxaqj55iTtQgCQst5Pd5aJ1TrXKErTX3UKIvmx 4Ok5WaJZNPwY0o1Y_ORP2A # secret_access_key: oN5z4NafX9OrwknE39f9sT_rhSrfdCa1CRuoCjO3iD214wzM4JGLIT 2TjwmvBerWLuM9OOdnCEtyVpPy02rOkg # default_key_na