Pular para o conteúdo
Visualizando 1 post (de 1 do total)
  • Autor
    Posts
  • #96831
    thisombra
    Participante

      Galera,

      Sou novo aqui e criei um script para colocar uma base oracle para Startar (Iniciar) automaticamente. A base deverá ser criada antes de tudo, utilizando o DBCA da oracle ou até manualmente.

      Automatizar o Startup do Oracle 11g R2 – 1 base
      Nome da Base: TESTE

      Criando o arquivo que chamará o arquivo de inicialização TESTE

      Usuário Root
      # vi /etc/init.d/initora

      #!/bin/sh
      # chkconfig: 345 99 10
      # description: Oracle auto start-stop script.
      #
      # Set ORA_HOME to be equivalent to the $ORACLE_HOME
      # from which you wish to execute dbstart and dbshut;
      #
      # Set ORA_OWNER to the user id of the owner of the
      # Oracle database in ORA_HOME.

      ORA_HOME=/u01/app/oracle/product/11.2.0/db_home1
      ORA_OWNER=oracle

      if [ ! -f $ORA_HOME/bin/dbstart ]
      then
      echo “Oracle startup: cannot start”
      exit

      fi
      case “$1” in
      ‘start’)
      # Start the Oracle databases:
      # The following command assumes that the oracle login
      # will not prompt the user for any values
      su – $ORA_OWNER -c “$ORA_HOME/bin/emctl start dbconsole”
      su – $ORA_OWNER -c “$ORA_HOME/bin/lsnrctl start”
      su – $ORA_OWNER -c $ORA_HOME/bin/dbstart
      ;;

      ‘stop’)
      # Stop the Oracle databases:
      # The following command assumes that the oracle login
      # will not prompt the user for any values
      su – $ORA_OWNER -c “$ORA_HOME/bin/emctl stop dbconsole”
      su – $ORA_OWNER -c “$ORA_HOME/bin/lsnrctl stop”
      su – $ORA_OWNER -c $ORA_HOME/bin/dbshut
      ;;
      esac

      Setando as variáveis de ambiente da base TESTE
      # vi /usr/local/sbin/initora

      #!/bin/bash
      #
      # network Bring up/down networking
      #
      # chkconfig: 345 20 80
      # description: Starts and stops Oracle processes
      # Set ORACLE_HOME to be equivalent to the $ORACLE_HOME
      # from which you wish to execute dbstart and dbshut;
      #
      # Set ORACLE_OWNER to the user id of the owner of the
      # Oracle database in ORACLE_HOME.
      #

      ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_home1
      ORACLE_OWNER=oracle
      ORACLE_SID=TESTE

      case “$1″ in
      ‘start”reload”restart’ )

      su – $ORACLE_OWNER -c $ORACLE_HOME/bin/dbstart
      su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/lsnrctl start”
      su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/emctl start dbconsole sysman /”

      touch /var/lock/subsys/initora
      ;;
      ‘stop’)

      su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/emctl stop dbconsole sysman /”
      su – $ORACLE_OWNER -c “$ORACLE_HOME/bin/lsnrctl stop”
      su – $ORACLE_OWNER -c $ORACLE_HOME/bin/dbshut
      rm -f /var/lock/subsys/initora
      ;;

      esac

      # End of script iniTora

      Ao final é importante liberar o BD no /etc/oratab, senão não inicia o BD automaticamente. Ao final da linha mudamos de “N” no para “Y” yes.

      # vi /etc/oratab

      TESTE:/u01/app/oracle/product/11.2.0/oracle/db_home1:Y

      Alterar permissão de execução e colocar no grupo DBA

      # cd /usr/local/sbin/
      # ll
      chmod +x /usr/local/sbin/initora
      chown oracle:dba /usr/local/sbin/initora

      Colocando para iniciar automaticamente nas variáveis de inicialização
      # vi /etc/rc.local

      /usr/local/sbin/initora
      /etc/init.d/initora start

      Permissão para o dono:
      # chmod 755 /usr/local/sbin/initora

      # cd /etc/init.d/
      # chmod 750 /etc/init.d/initora

      Checar a configuração dos arquivos
      # chkconfig –add initora –level 0356

      Adicionando nos arquivos de inicialização do Sistema Operacional:
      # chgrp dba initora

      Criando o Atalho para inicializar automaticamente da base
      # ln -s /etc/init.d/initora /etc/rc.d/rc0.d/K01dbora

      Checar a configuração dos arquivos
      # chkconfig –level 345 initora on

      Fim!! Reinicie a máquina e o banco fará o Startup automaticamente!

      Valeu pelo Espaço aqui. Grande abraço a todos. Qualquer dúvida ou sugestão, utilizar os comentários![/i]

      _________________
      Atenciosamente,
      Thiago Victor P. Lima

    Visualizando 1 post (de 1 do total)
    • Você deve fazer login para responder a este tópico.