Oracle 监听处理脚本

前端之家收集整理的这篇文章主要介绍了Oracle 监听处理脚本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
---------Oracle 自动修改主机及监听地址 --------
[root@limin-test ~]# cat 2.sh
#!/bin/bash
#Program:
# 修改/etc/hosts下IP及主机名地址


#定义的一些常量
log_file=/tmp/log_
HOSTNAME=`hostname`
ORACLE_TNS='/u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin'
ORACLE_SID=cpdb
HOST_IP=`ifconfig eth0 | grep "inet addr" | awk '{ print $2}' | awk -F: '{print $2}'`

echo "修改/etc/hosts下配置信息..."
#修改IP及主机名地址
cat > /etc/hosts << EOF
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6


# --- Oracle configure --- #
$HOST_IP $HOSTNAME
EOF

echo "修改了Oracle监听文件及备份原有信息..."

#备份原监听文件,并创建touch空的文件.
echo "备份原监听listener.ora及tnsnames.ora文件... "
cp $ORACLE_TNS/listener.ora -f $ORACLE_TNS/`date +%F`_listener.ora.bak
cp $ORACLE_TNS/tnsnames.ora -f $ORACLE_TNS/`date +%F`_tnsnames.ora.bak

#touch $ORACLE_TNS/listener.ora
#touch $ORACLE_TNS/tnsnames.ora

cat > $ORACLE_TNS/listener.ora << EOF
# listener.ora Network Configuration File: /u01/app/11.2.0.4/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = $HOSTNAME)(PORT = 1521))
)
)

ADR_BASE_LISTENER = /u01/app/oracle

EOF

echo "准备修改tnsnames.ora 文件..."

cat > $ORACLE_TNS/tnsnames.ora << EOF
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

$(echo $ORACLE_SID | tr '[a-z]' '[A-Z]') =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = $HOSTNAME)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = $ORACLE_SID )
)
)

EOF

echo "修改监听文件文件权限属组..."
chown -R oracle:oinstall $ORACLE_TNS/listener.ora
chown -R oracle:oinstall $ORACLE_TNS/tnsnames.ora

echo " .........."
echo " ..........."
echo " ............."
echo " ...修改完成..."
echo " ....GoodBye...."

猜你在找的Oracle相关文章