星期四, 4月 11, 2013

Oracle 11g instance auto start for Solaris 10 SMF


1.
修改
$ORACLE_HOME/bin/dbstart
$ORACLE_HOME/bin/dbshut, 第一行改為  ==> #!/usr/bin/bash

2.
寫好以下兩個檔案
File : /etc/oracle11g

#!/usr/bin/bash
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/db112
ORACLE_HOME_LISTENER=$ORACLE_HOME
ORACLE_SID=ilink1
ORACLE_UNQNAME=ilink1
export ORACLE_BASE
export ORACLE_HOME
export ORACLE_HOME_LISTENER
export ORACLE_SID
export ORACLE_UNQNAME 
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]     
then  
           echo "The Oracle Startup file (dbstart) was not found"
           exit   
fi       
if [ ! -f $ORACLE_HOME/bin/emctl -o ! -d $ORACLE_HOME ]       
then
           echo "The Oracle Enterprise Manager Controller (emctl) was not found"
           exit   
fi       
case "$1" in
           'start')
           # start Oracle databases and the enterprise manager console
           su - oracle -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
           #su - oracle -c "$ORACLE_HOME/bin/emctl start dbconsole"
;;
           'stop')
           # stop Oracle enterprise manager first, then the databases
           #su - oracle -c "$ORACLE_HOME/bin/emctl stop dbconsole"
           su - oracle -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
;;
           'restart')
           #su - oracle -c "$ORACLE_HOME/bin/emctl stop dbconsole"        
           su - oracle -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"  
           su - oracle -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"  
           #su - oracle -c "$ORACLE_HOME/bin/emctl start dbconsole"        
;;
esac

File: /tmp/oracle_smf.xml

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="manifest" name="Oracle11g">
    <service name="application/oracle11g" type="service" version="1">
        <!-- Initial setup and configuration of paths -->
        <dependency name="filesystem" grouping="require_all" restart_on="none" type="service">
            <service_fmri value="svc:/system/filesystem/local" />
        </dependency>
        <dependent name="mysql-runlevel" grouping="require_all" restart_on="none">
            <service_fmri value="svc:/milestone/multi-user-server" />
        </dependent>        

        <!-- Execution method for start, stop and restart -->
        <!-- if you need longer time to start, just change the timeout_seconds value -->
        <exec_method type="method" name="start" exec="/etc/oracle11g %m" timeout_seconds="500" />
        <exec_method type="method" name="stop" exec="/etc/oracle11g %m" timeout_seconds="500" />
        <exec_method type="method" name="restart" exec="/etc/oracle11g %m" timeout_seconds="500" />   

        <!-- Other properties and configs -->
        <property_group name="general" type="framework">
            <propval name="action_authorization" type="astring" value="oracle.operator" />
            <propval name="value_authorization" type="astring" value="oracle.administrator" />
        </property_group>
           <instance name="default" enabled="true" />
        <stability value="Unstable" />
        <template>
            <common_name>
                <loctext xml:lang="C">Oracle 11g R2 Database Server</loctext>
            </common_name>
        </template>
    </service>
</service_bundle>

3.註冊至Solaris SMF (Service Management Facility)

cd /tmp

svccfg -v import oracle_smf.xml
svccfg list | grep oracle11g
To enable the service:
# svcadm enable oracle11g
 To disable the service

# svcadm disable oracle11g
 To restart the service

# svcadm restart oracle11g
設定完之後以init 6 指令重開機, 確認已經生效

沒有留言:

LinkWithin-相關文件

Related Posts Plugin for WordPress, Blogger...