3.安装Oracle Database
1.安装规划
oracle10G
数据库版本:
10201_database_linux_x86_64.cpio.gz
p8202632_10205_Linux-x86-64.zip
p8350262_10205_Generic.zip
数据库安装规划:
ORACLE_BASE=/u01/app/ora10g
ORACLE_HOME=/u01/app/ora10g/product/10.2.0/db_1
ORACLE_SID=orcl10g
-----------------------------------------------------
oracle11g
数据库版本:
p13390677_112040_Linux-x86-64_1of7.zip
p13390677_112040_Linux-x86-64_2of7.zip
p6880880_112000_Linux-x86-64.zip
p31537677_112040_Linux-x86-64.zip
数据库安装规划:
ORACLE_BASE=/u01/app/ora11g
ORACLE_HOME=/u01/app/ora11g/product/11.2.0/db_1
ORACLE_SID=orcl11g
2.安装过程(略)
#1.Oracle10g监听端口配置1521
[oracle@yuanzj.com:/home/oracle]$ cat /u01/app/ora10g/product/10.2.0/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/ora10g/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/ora10g/product/10.2.0/db_1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = yuanzj.com)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
#2.Oracle11g监听端口配置1522
[oracle@yuanzj.com:/home/oracle]$ cat /u01/app/ora11g/product/11.2.0/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/ora11g/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = yuanzj.com)(PORT = 1522))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
)
)
ADR_BASE_LISTENER = /u01/app/ora11g
3.配置自启服务
3.1.修改/etc/oratab
[root@yuanzj ~]# cat /etc/oratab
#
# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.
# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:<N|Y>:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
orcl10g:/u01/app/ora10g/product/10.2.0/db_1:Y
orcl11g:/u01/app/ora11g/product/11.2.0/db_1:Y
3.2.修改$ORACLE_HOME/bin/路径下的oracle自带的启动与关闭脚本,dbstart和dbshut.(oracle10g和oracle11g都需要修改)
#su -oracle
$cd $ORACLE_HOME/bin
$vi dbstart
找到ORACLE_HOME_LISTNER=$1这一行
改为:ORACLE_HOME_LISTNER=$ORACLE_HOME
$vi dbshut
找到ORACLE_HOME_LISTNER=$1这一行
改为:ORACLE_HOME_LISTNER=$ORACLE_HOME
3.3.新建启动服务脚本,并授予执行权限
[root@yuanzj ~]# ls -lh /etc/init.d/ora1*
-rwxrwxr-x 1 root root 1.7K Feb 13 12:04 /etc/init.d/ora10g
-rwxrwxr-x 1 root root 1.7K Feb 13 12:04 /etc/init.d/ora11g
[root@yuanzj ~]#
[root@yuanzj ~]# cat /etc/init.d/ora10g
#!/bin/bash
# chkconfig: 2345 10 90
# /etc/init.d/ora10g
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface
export ORACLE_HOME=/u01/app/ora10g/product/10.2.0/db_1
export ORACLE_SID=orcl10g
export PATH=$ORACLE_HOME/bin:$PATH
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: " >> /var/log/oracle10g
echo "-------------------------------------------------" >> /var/log/oracle10g
su - $ORA_OWNR -c "source /home/oracle/.db10g;lsnrctl start" >> /var/log/oracle10g
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart" /var/log/oracle10g
touch /var/lock/subsys/oracle10g
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
echo "Oracle Start Successfull!!!" /var/log/oracle10g
echo "-------------------------------------------------" >> /var/log/oracle10g
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: " >> /var/log/oracle10g
su - $ORA_OWNR -c "source /home/oracle/.db10g;lsnrctl stop" >> /var/log/oracle10g
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut" >> /var/log/oracle10g
rm -f /var/lock/subsys/oracle10g
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole" >> /var/lock/subsys/oracle10g
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0
[root@yuanzj ~]# cat /etc/init.d/ora11g
#!/bin/bash
# chkconfig: 2345 10 90
# /etc/init.d/ora11g
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web Interface
export ORACLE_HOME=/u01/app/ora11g/product/11.2.0/db_1
export ORACLE_SID=orcl11g
export PATH=$ORACLE_HOME/bin:$PATH
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: " >> /var/log/oracle11g
echo "-------------------------------------------------" >> /var/log/oracle11g
su - $ORA_OWNR -c "source /home/oracle/.db11g;lsnrctl start" >> /var/log/oracle11g
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart" /var/log/oracle11g
touch /var/lock/subsys/oracle11g
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"
echo "Oracle Start Successfull!!!" /var/log/oracle11g
echo "-------------------------------------------------" >> /var/log/oracle11g
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: " >> /var/log/oracle11g
su - $ORA_OWNR -c "source /home/oracle/.db11g;lsnrctl stop" >> /var/log/oracle11g
su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut" >> /var/log/oracle11g
rm -f /var/lock/subsys/oracle11g
su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole" >> /var/lock/subsys/oracle11g
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0
3.4.注册开机服务
chkconfig --add ora10g
chkconfig ora10g on
chkconfig --add ora11g
chkconfig ora11g on
4.重启验证数据和监听启动结果
[oracle@yuanzj.com:/home/oracle]$ 10g
[oracle@yuanzj.com:/home/oracle]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 18-FEB-2023 18:11:42
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=yuanzj.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date 18-FEB-2023 17:09:01
Uptime 0 days 1 hr. 2 min. 40 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/ora10g/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/ora10g/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=yuanzj.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "orcl10g" has 1 instance(s).
Instance "orcl10g", status READY, has 1 handler(s) for this service...
Service "orcl10gXDB" has 1 instance(s).
Instance "orcl10g", status READY, has 1 handler(s) for this service...
Service "orcl10g_XPT" has 1 instance(s).
Instance "orcl10g", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@yuanzj.com:/home/oracle]$ 11g
[oracle@yuanzj.com:/home/oracle]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-FEB-2023 18:11:46
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=yuanzj.com)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 18-FEB-2023 17:09:20
Uptime 0 days 1 hr. 2 min. 26 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/ora11g/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/ora11g/diag/tnslsnr/yuanzj/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=yuanzj.com)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
Services Summary...
Service "orcl11g" has 1 instance(s).
Instance "orcl11g", status READY, has 1 handler(s) for this service...
Service "orcl11gXDB" has 1 instance(s).
Instance "orcl11g", status READY, has 1 handler(s) for this service...
The command completed successfully