我会编辑原帖,因为现在我们打破了原来的问题,我甚至不得不扭曲原来的问题。至于那些现在加入的人。配置多个oracle实例/侦听器以在Oracle EL6中自动启动时遇到问题。 我正在使用以下脚本来处理初创公司:
#!/bin/sh
# chkconfig 345 99 10
export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
export ORACLE_OWNER=oracle
if [ ! -f $ORACLE_HOME/bin/dbstart ]
then
echo "Oracle startup: cannot start"
exit
fi
case "$1" in
'start')
# Start the Oracle databases:
su $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" &
su $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start TEST.LOCALHOST" &
su $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start CAPEX" &
touch /var/lock/subsys/dbora
;;
'stop')
# Stop the Oracle databases:
su $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
su $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop TEST.LOCAHOST"
su $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop CAPEX"
rm -f /var/lock/subsys/dbora
;;
esac
此文件位于/etc/init.d/文件夹下。该文件本身称为dbora。我还用chkconfig --add将它添加到启动中。它的状态又是chkconfig --list的输出如下:
[root@localhost ~]# chkconfig --list
NetworkManager 0:off 1:off 2:on 3:on 4:on 5:on 6:off
abrt-ccpp 0:off 1:off 2:off 3:on 4:off 5:on 6:off
abrt-oops 0:off 1:off 2:off 3:on 4:off 5:on 6:off
abrtd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
acpid 0:off 1:off 2:on 3:on 4:on 5:on 6:off
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
autofs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
blk-availability 0:off 1:on 2:on 3:on 4:on 5:on 6:off
bluetooth 0:off 1:off 2:off 3:on 4:on 5:on 6:off
certmonger 0:off 1:off 2:off 3:on 4:on 5:on 6:off
cgconfig 0:off 1:off 2:off 3:off 4:off 5:off 6:off
cgred 0:off 1:off 2:off 3:off 4:off 5:off 6:off
cpuspeed 0:off 1:on 2:on 3:on 4:on 5:on 6:off
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off
dbora 0:off 1:off 2:off 3:on 4:on 5:on 6:off
dnsmasq 0:off 1:off 2:off 3:off 4:off 5:off 6:off
firstboot 0:off 1:off 2:off 3:off 4:off 5:off 6:off
haldaemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off
htcacheclean 0:off 1:off 2:off 3:off 4:off 5:off 6:off
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
irqbalance 0:off 1:off 2:off 3:on 4:on 5:on 6:off
kdump 0:off 1:off 2:off 3:off 4:off 5:off 6:off
lvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:off
mcelogd 0:off 1:off 2:off 3:on 4:off 5:off 6:off
mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off
messagebus 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
nfslock 0:off 1:off 2:off 3:on 4:on 5:on 6:off
ntpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
ntpdate 0:off 1:off 2:off 3:off 4:off 5:off 6:off
numad 0:off 1:off 2:off 3:off 4:off 5:off 6:off
oddjobd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
portreserve 0:off 1:off 2:on 3:on 4:on 5:on 6:off
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
psacct 0:off 1:off 2:off 3:off 4:off 5:off 6:off
quota_nld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rdisc 0:off 1:off 2:off 3:off 4:off 5:off 6:off
restorecond 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rhnsd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
rngd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
rpcgssd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
rpcsvcgssd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
saslauthd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
smartd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
spice-vdagentd 0:off 1:off 2:off 3:off 4:off 5:on 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sssd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
svnserve 0:off 1:off 2:off 3:off 4:off 5:off 6:off
sysstat 0:off 1:on 2:on 3:on 4:on 5:on 6:off
udev-post 0:off 1:on 2:on 3:on 4:on 5:on 6:off
vmware-tools 0:off 1:off 2:on 3:on 4:on 5:on 6:off
vmware-tools-thinprint 0:off 1:off 2:on 3:on 4:on 5:on 6:off
wdaemon 0:off 1:off 2:off 3:off 4:off 5:off 6:off
winbind 0:off 1:off 2:off 3:off 4:off 5:off 6:off
wpa_supplicant 0:off 1:off 2:off 3:off 4:off 5:off 6:off
xinetd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
ypbind 0:off 1:off 2:off 3:off 4:off 5:off 6:off
xinetd based services:
chargen-dgram: off
chargen-stream: off
daytime-dgram: off
daytime-stream: off
discard-dgram: off
discard-stream: off
echo-dgram: off
echo-stream: off
rsync: off
tcpmux-server: off
time-dgram: off
time-stream: off
重新启动系统后,我检查了两个监听器的日志文件,这些文件现在包含以下条目:
For CAPEX listener:
<msg time='2013-12-17T14:16:44.440+01:00' org_id='oracle' comp_id='tnslsnr'
type='UNKNOWN' level='16' host_id='localhost.localdomain'
host_addr='::1'>
<txt>17-DEC-2013 14:16:44 * service_update * CAPEX * 0</txt>
</msg>
For TEST.LOCALOHOST listener:
<msg time='2013-12-17T14:16:46.880+01:00' org_id='oracle' comp_id='tnslsnr'
type='UNKNOWN' level='16' host_id='localhost.localdomain'
host_addr='::1'>
<txt>17-DEC-2013 14:16:46 * service_update * TEST * 0</txt>
</msg>
我还尝试通过执行以下命令检查侦听器是否正在运行(因为我发现它们都没有正在运行):
[root@localhost ~]# ps -ef | grep tnslsnr | grep -v grep
[root@localhost ~]#
由于我还试图检查实际的数据库实例是否正在运行,我还发现它们处于空闲状态,这对我来说意味着没有运行。也许现在你已经知道发生了什么,我搞砸了什么。
谢谢, 乔
答案 0 :(得分:2)
ORACLE_HOME
未在su
环境中设置。正在提供lsnrctl
二进制文件的完整路径,因为在$ORACLE_HOME
被调用之前su
正在展开,所以您真的在做:
su oracle -c "/u01/app/oracle/product/12.1.0/dbhome_1/bin/lsnrctl start CAPEX" &
手动运行时ORACLE_HOME
已设置,因此可以正常运行。在su
运行时,它不是,但它仍然找到二进制文件,因为它具有完整路径。 dbstart
有效,因为它在处理ORACLE_HOME
条目时会从oratab
条目重置ORACLE_HOME
。没有消息文件&#39;错误通常是listener.ora
未设置的指示符,代码引用的权限错误表明它在错误的位置寻找su $ORACLE_OWNER -c "ORACLE_HOME is: \$ORACLE_HOME`"
,可能是在根目录下。
您可以通过让脚本尝试显示值来证明这一点:
ORACLE_HOME
您可以在通过su
运行的命令中设置su $ORACLE_OWNER -c "ORACLE_HOME=$ORACLE_HOME;$ORACLE_HOME/bin/lsnrctl start CAPEX" &
,如下所示:
export
但是su
脚本中的变量会更简单,这会使export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
export ORACLE_OWNER=oracle
显示变量:
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
ORACLE_OWNER=oracle
export ORACLE_HOME ORACLE_OWNER
或
{{1}}
......取决于你的shell。