日期:2014-05-16  浏览次数:20628 次

实现用response文件静态安装Oracle

首先得有一个response文件,这个文件可能从/staging/response中得到。当然还得做必要的修改。

可以根据需要做一些修改:

RESPONSEFILE_VERSION=2.2.1.0.0
FROM_LOCATION="../stage/products.xml"
ORACLE_HOME="/u01/app/oracle/product/10.1.0/db_1"
ORACLE_HOME_NAME="OUIHome1"
TOPLEVEL_COMPONENT={"oracle.server","10.1.0.3.0"}
DEINSTALL_LIST={"oracle.server","10.1.0.3.0"}

。。。

s_superAdminPasswdType="N"
b_useSamePassword=false
s_superAdminSamePasswd="oracle"
s_superAdminSamePasswdAgain="oracle"
sl_superAdminPasswds={"sys","system","oracle","oracle"}
sl_superAdminPasswdsAgain={"sys","system","oracle","oracle"}

?


接着在linux环境中还得做不好工作,当然这些都可以放到一个shell脚本中一次做完:

  • ?创建oraInst.loc文件,对于第一次安装,这是必要的

????? #if oracle was never installed in this machine, it is must
function create_oraInst_file()
{
?? #create file /etc/oraInst.loc
?? echo "Create oracle location file /etc/oraInst.loc"
?? echo
?? rm -f /etc/oraInst.loc
?? touch oraInst.loc
?? cat >> oraInst.loc << EOF
inventory_loc=${ORACLE_BASE}/oraInventory
inst_group=oinstall
EOF
?? cp oraInst.loc /etc/oraInst.loc
?? chown oracle:oinstall /etc/oraInst.loc
?? chmod 664 /etc/oraInst.loc
?? mkdir ${ORACLE_BASE}/oraInventory
?? chown oracle:oinstall ${ORACLE_BASE}/oraInventory

?? rm -f oraInst.loc
}

  • 增加必要的用户和组

???? create user and group
#include groups: osinstall, dba, oper
#include use: oracle
function add_groups_and_user()
{
?? #add groups for installing oracle
?? echo
?? echo "check or add the groups for installing ORACLE "
?? echo
?? [ "`grep oinstall: /etc/group`" = "" ] && sudo /usr/sbin/groupadd oinstall
?? [ "`grep dba: /etc/group`" = "" ] && sudo /usr/sbin/groupadd dba
?? [ "`grep oper /etc/group`" = "" ] && sudo /usr/sbin/groupadd oper
?? ! id oracle >&/dev/null && useradd oracle
?? usermod -g oinstall -G dba oracle

?? ORACLE_USER_DIR=$(get_user_directory oracle)
?? echo "User oracle directory: $ORACLE_USER_DIR"

?? cp /etc/sudoers /etc/sudoers.bak
?? sed '/.*/{/^( )*oracle/d}' /etc/sudoers > sudoers
?? cat >> sudoers <<EOF
oracle ALL=(ALL) NOPASSWD: ALL
EOF
?? cp -f sudoers /etc/
?? rm -f sudoers
}

  • 创建必要的目录

#create oracle directory
function create_directory()
{
?? #make oracle_base
?? echo "make ORACLE_BASE:${ORACLE_BASE}"
?? echo
?? rm -rfv ${ORACLE_BASE}
?? mkdir -pv ${ORACLE_BASE}
?? mkdir -pv ${ORACLE_BASE}/oradata
?? chown -R oracle:oinstall ${ORACLE_BASE}
?? chmod -R 775 ${ORACLE_BASE}

?? #make directory /var/opt/oracle to contain files that describe various components of the
?? #Oracle server software installation
?? echo "make directory /var/opt/oracle to contain files that describe various components"
?? echo "of the Oracle server software installation"
?? echo
?? mkdir -pv /var/opt/oracle
?? chown oracle:dba /var/opt/oracle
?? chmod 755 /var/opt/oracle
}

  • 更改操作系统的参数配置

#config system
function config_system_parameters()
{
?? echo "Config system parameters."
?? echo
?? cp /etc/sysctl.conf /etc/sysctl.conf.bak
?? sed '/.*/{/^kernel.shmall/d;/^kernel.shmmax/d;/^kernel.shmmni/d;/kernel.sem /d;/^fs.file-max/d;/^net.ipv4.ip_local_port_range/d}' /etc/sysctl.conf > sysctl.conf
?? cat >> sysctl.conf <<EOF
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
EOF
?? cp -f sysctl.conf /etc/
?? rm -f sysctl.conf
}

#need to change /etc/redhat-release
function config_release()
{
?? echo "Config OS release