ITPub博客

首页 > 数据库 > Oracle > AutoInstallSoftware【ORACLE】

AutoInstallSoftware【ORACLE】

原创 Oracle 作者:ygzhou518 时间:2016-06-07 13:19:04 0 删除 编辑
# -*- coding:utf-8 -*-
require 'chef/log'
require 'socket'
hostname = Socket.gethostname
include_recipe "oracle::softcheckenv"

dbver = "#{node['oracle']['S_ora_version']}"
case dbver
##############add by ygzhou(Zhou) 2016-06-03
  when "11.2.0.3.15" then
    Chef::Log.info "*"*100
    Chef::Log.info "*"*10+"第三部分:软件版本安装"

    ruby_block 'clone_install_software' do
      block do
        Chef::Log.info "*"*100
        Chef::Log.info "*" * 20 + "  clone_install_software ! "+"*" * 20+"\n"
        install = `su - oracle -c ' source /tmp/#{node['oracle']['S_ora_version']}/install/oracle_env.sh ;#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/oui/bin/runInstaller -ignoreSysPreReqs -invPtrLoc #{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/oraInst.loc -silent -clone ORACLE_BASE="#{node['oracle']['S_ora_base']}" ORACLE_HOME="#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}" ORACLE_HOME_NAME="oracle_home_11203015" '`.chomp
        sleep 5;
      end
      action :run
    end
    ruby_block 'execute_root_scripts' do
      block do
        Chef::Log.info "*"*100
        Chef::Log.info "*" * 20 + "  execute root scritps ! "+"*" * 20+"\n"
        roots = `#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/root.sh`.chomp
        sleep 5;
      end
      action :run
    end

###########################################
  when "11.2.0.3.0" then
    Chef::Log.info "*"*100
    Chef::Log.info "*"*10+"第三部分:软件版本安装"

    ruby_block 'clone_install_software' do
      block do
        Chef::Log.info "*"*100
        Chef::Log.info "*" * 20 + "  clone_install_software ! "+"*" * 20+"\n"
        install = `su - oracle -c ' source /tmp/#{node['oracle']['S_ora_version']}/install/oracle_env.sh ;#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/oui/bin/runInstaller -ignoreSysPreReqs -invPtrLoc #{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/oraInst.loc -silent -clone ORACLE_BASE="#{node['oracle']['S_ora_base']}" ORACLE_HOME="#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}" ORACLE_HOME_NAME="oracle_home_11203002" '`.chomp
        sleep 5;
      end
      action :run
    end
    ruby_block 'execute_root_scripts' do
      block do
        Chef::Log.info "*"*100
        Chef::Log.info "*" * 20 + "  execute root scritps ! "+"*" * 20+"\n"
        roots = `#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/root.sh`.chomp
        sleep 5;
      end
      action :run
    end
  when "11.2.0.2.0" then
    Chef::Log.info "*"*100
    Chef::Log.info "*"*10+"第三部分:软件版本安装"

    ruby_block 'clone_software' do
      block do
        Chef::Log.info "*"*100
        Chef::Log.info "*" * 20 + "  clone_install_software ! "+"*" * 20+"\n"
        install = `su - oracle -c ' source /tmp/#{node['oracle']['S_ora_version']}/install/oracle_env.sh ;#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/oui/bin/runInstaller -ignoreSysPreReqs -invPtrLoc #{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/oraInst.loc -silent -clone ORACLE_BASE="#{node['oracle']['S_ora_base']}" ORACLE_HOME="#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}" ORACLE_HOME_NAME="oracle_home_11202002" '`.chomp
        sleep 5;
      end
      action :run
    end
    ruby_block 'execute_root_scripts' do
      block do
        Chef::Log.info "*"*100
        Chef::Log.info "*" * 20 + "  execute root scritps ! "+"*" * 20+"\n"
        roots = `#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/root.sh`.chomp
        sleep 5;
      end
      action :run
    end
  when "10.2.0.5.6" then
    Chef::Log.info "*"*100
    Chef::Log.info "*"*10+"第三部分:软件版本安装"
    puts "*"*10+"第三部分:软件版本安装"


    ruby_block 'clone_install_software' do
      block do
        Chef::Log.info "*"*100
        Chef::Log.info "*" * 20 + "  clone_software ! "+"*" * 20+"\n"
        install = `su - oracle -c ' source /tmp/#{node['oracle']['S_ora_version']}/install/oracle_env.sh ;#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/oui/bin/runInstaller -ignoreSysPreReqs -invPtrLoc #{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/oraInst.loc -silent -clone ORACLE_BASE="#{node['oracle']['S_ora_base']}" ORACLE_HOME="#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}" ORACLE_HOME_NAME="oracle_home_10205002" '`.chomp
        sleep 5;
      end
      action :run
    end
    ruby_block 'execute_root_scripts' do
      block do
        Chef::Log.info "*"*100
        Chef::Log.info "*" * 20 + "  execute root scritps ! "+"*" * 20+"\n"
        roots = `#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/root.sh`.chomp
        sleep 5;
      end
      action :run
    end
    ruby_block 'execute_asm_pin' do
      block do
        Chef::Log.info "*"*100
        Chef::Log.info "*" * 20 + "  execute asm pin ! "+"*" * 20+"\n"
        asmpins = `/dba/app/product/11.2.0/grid/bin/crsctl pin css -n #{hostname}`.chomp
        sleep 5;
      end
      action :run
    end
  when "10.2.0.4.0" then
    Chef::Log.info "*"*100
    Chef::Log.info "*"*10+"第三部分:软件版本安装"

    ruby_block 'clone_install_software' do
      block do
        Chef::Log.info "*"*100
        Chef::Log.info "*" * 20 + "  clone_software ! "+"*" * 20+"\n"
        install = `su - oracle -c ' source /tmp/#{node['oracle']['S_ora_version']}/install/oracle_env.sh ;#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/oui/bin/runInstaller -ignoreSysPreReqs -invPtrLoc #{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/oraInst.loc -silent -clone ORACLE_BASE="#{node['oracle']['S_ora_base']}" ORACLE_HOME="#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}" ORACLE_HOME_NAME="oracle_home_10204002" '`.chomp
        sleep 5;
      end
      action :run
    end
    ruby_block 'execute_root_scripts' do
      block do
        Chef::Log.info "*"*100
        Chef::Log.info "*" * 20 + "  execute root scritps ! "+"*" * 20+"\n"
        roots = `#{node['oracle']['S_ora_home']}/#{node['oracle']['S_ora_version']}/root.sh`.chomp
        sleep 5;
      end
      action :run
    end
    ruby_block 'execute_asm_pin' do
      block do
        Chef::Log.info "*"*100
        Chef::Log.info "*" * 20 + "  execute asm pin ! "+"*" * 20+"\n"
        asmpins = `/dba/app/product/11.2.0/grid/bin/crsctl pin css -n #{hostname}`.chomp
        sleep 5;
      end
      action :run
    end
  else
    Chef::Log.error "*"*100
    raise  "*" * 20 +" Oracle version is wrong !"+"*" * 20 +"\n" 
end

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24867586/viewspace-2116783/,如需转载,请注明出处,否则将追究法律责任。

上一篇: Oracle DgFailOver
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2011-02-11

  • 博文量
    167
  • 访问量
    365023