【问题标题】:Starting Multiple Oracle 12c Listeners on Startup在启动时启动多个 Oracle 12c 侦听器
【发布时间】:2014-01-03 17:40:18
【问题描述】:

我将编辑原始帖子,因为现在我们正在分解原始问题,我什至也不得不扭曲原始问题。至于现在加入的人。在 Oracle EL6 中配置多个 oracle 实例/侦听器以自动启动时遇到问题。 我正在使用以下脚本来处理启动:

#!/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 ~]#

当我还尝试检查实际的数据库实例是否正在运行时,我还发现它们处于空闲状态,这对我来说意味着没有运行。也许现在你知道发生了什么,我搞砸了什么。

谢谢, 乔

【问题讨论】:

    标签: oracle oracle12c


    【解决方案1】:

    ORACLE_HOME 未在 su 环境中设置。提供了 lsnrctl 二进制文件的完整路径,因为在调用 su 之前正在扩展 $ORACLE_HOME,所以你真的在做:

    su oracle -c "/u01/app/oracle/product/12.1.0/dbhome_1/bin/lsnrctl start CAPEX" &
    

    当您手动运行它时,ORACLE_HOME 已设置,所以它可以工作。当通过su 运行时,它不是,但它仍然可以找到二进制文件,因为它具有完整路径。 dbstart 之所以有效,是因为它在处理 oratab 条目时会重置 ORACLE_HOME。 “无消息文件”错误通常表明未设置 ORACLE_HOME,代码引用的权限错误表明它在错误的位置查找 listener.ora,可能是在根目录下。

    您可以通过让脚本尝试显示值来证明这一点:

    su $ORACLE_OWNER -c "ORACLE_HOME is: \$ORACLE_HOME`"
    

    您可以在通过su 运行的命令中将ORACLE_HOME 设置为:

    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
    

    ...取决于你的外壳。

    【讨论】:

    • 感谢您的回答。我根据您的回答修改了 bash 脚本。现在我在启动时没有收到错误消息,但监听器和数据库都没有启动。
    • 您是否从命令中获得了您正在回显的消息以及任何横幅等?您可以添加更多调试以在失败时进行精确定位吗?你还说这是一个 bash 脚本 - 你还没有展示它,你有 #!/bin/bash 在顶部吗?想知道该导出表单是否在引导过程中混淆了 root 的默认 shell。如果您以 root 身份手动运行脚本会发生什么?
    • 你应该检查 alert.log 和 listener.log 文件。
    • 根据新信息更新了原问题。
    • @Joey - 您编辑的版本看起来不应该做任何事情,因为您的第一个测试现在指的是$ORA_HOME,它没有设置。侦听器日志消息虽然令人困惑,除非您稍后手动启动它们。将$ORACLE_HOME 传递给dbstart 应该只是意味着它启动了默认侦听器,并且您没有默认值......但是目前它不应该走那么远。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多