Auto-start Oracle 11gR2 in Linux

Source: Internet
Author: User

Auto-start Oracle 11gR2 in Linux

Oracle in Linux is running after installation. After the machine is restarted, Oracle does not add Oracle to the Windows service as in Windows. In linux, You need to manually start the Orcle service.

  1. Run the following command under an oracle user:
  2. Go to sqlplus
  3. $ Sqlplus/nolog
  4. Connect to the database as sysdba and start the Oracle Database Engine
  5. SQL> conn/as sysdba
  6. SQL> startup
  7. Exit sqlplus and run Listener.
  8. SQL> exit
  9. $ Lsnrctl start

In this way, you can connect to the Oracle database. To use the EM provided by Oracle to manage Oracle, you also need to start the EM console and run the following command:

  1. $ Emctl start dbconsole

In this way, you can access the em console through http: // localhost: 1158/EM.

Use dbstart and dbstop to start Oracle services

Problems encountered during installation:

1. garbled characters during installation:

This is because oracle does not support Chinese characters. You can first use the command export LANG = en to temporarily change the environment to English, and then install. The modification of this environment variable is temporary. It will be changed after restart or when you log on to oracle.

2. If the following error occurs during installation:

[INS-32031] Invalid inventory location

[INS-32033] Central Inventory location is not vritable

Solution: Modify the/home/oracle_11 permission

Chown-R oracle: oinstall/home/oracle_11

 

It may be easier to use the dbstart command to start the database, but this error will be reported when you use the dbstart command after installing oracle for the first time.

  1. ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
  2. Usage:/u01/app/oracle/product/11.2/db/bin/dbstart ORACLE_HOME

The cause of this error is that ORACLE_HOME_LISTNER is not set. Let's take a look at the dbstart file.

  1. More/home/oracle_11/app/oracle/product/11.2/db/bin/dbstart

Some content is as follows:

  1. # First argument is used to bring up Oracle Net Listener
  2. ORACLE_HOME_LISTNER = $1
  3. If [! $ ORACLE_HOME_LISTNER]; then
  4. Echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
  5. Echo "Usage: $0 ORACLE_HOME"
  6. Else
  7. LOG = $ ORACLE_HOME_LISTNER/listener. log
  8. # Set the ORACLE_HOME for the Oracle Net Listener, it gets reset
  9. # A different ORACLE_HOME for each entry in the oratab.
  10. Export ORACLE_HOME = $ ORACLE_HOME_LISTNER

Solution: assign $ ORACLE_HOME to $ oracle_home_lin.pdf, save, and exit

Execute dbstart again, but it does not reflect that there is no error. If we need to use dbstart, we need to change the last N of the instance in the/etc/oratab file to Y, as shown below:

  1. Orcl:/home/oracle_11/app/oracle/product/11.2/db: Y

OK. Save and try the dbstart command again. The returned result is as follows:

  1. Processing Database instance "orcl": log file/home/oracle_11/app/oracle/product/11.2.0/db_1/startup. log

Dbshut makes the same settings. In this way, you can use the dbstart and dbshut commands to start and close the data after the listener is started.

Add the Oracle service to the Linux boot start item and use the root user to create the/etc/rc. d/init. d/oradb script file. The file content is as follows:

  1. #! /Bin/bash
  2. # Chkconfig: 2345 90 10
  3. Export ORACLE_BASE =/home/oracle_11/app/
  4. Export ORACLE_HOME = $ ORACLE_BASE/oracle/product/11.2.0/db_1
  5. Export ORACLE_SID = orcl
  6. Export PATH = $ PATH: $ ORACLE_HOME/bin
  7. ORCL_OWN = "oracle"
  8. # If the executables do not exist -- display error
  9. If [! -F $ ORACLE_HOME/bin/dbstart-o! -D $ ORACLE_HOME]
  10. Then
  11. Echo "Oracle startup: cannot start"
  12. Exit 1
  13. Fi
  14. # Depending on parameter -- start, stop, restart
  15. # Of the instance and listener or usage display
  16. Case "$1" in
  17. Start)
  18. # Oracle listener and instance startup
  19. Echo-n "Starting Oracle :"
  20. Su-$ ORCL_OWN-c "$ ORACLE_HOME/bin/dbstart"
  21. Touch/var/lock/subsys/oradb
  22. Su-$ ORCL_OWN-c "$ ORACLE_HOME/bin/emctl start dbconsole"
  23. Echo "OK"
  24. ;;
  25. Stop)
  26. # Oracle listener and instance shutdown
  27. Echo-n "Shutdown Oracle :"
  28. Su-$ ORCL_OWN-c "$ ORACLE_HOME/bin/emctl stop dbconsole"
  29. Su-$ ORCL_OWN-c "$ ORACLE_HOME/bin/dbshut"
  30. Rm-f/var/lock/subsys/oradb
  31. Echo "OK"
  32. ;;
  33. Reload | restart)
  34. $0 stop
  35. $1 start
  36. ;;
  37. *)
  38. Echo "Usage: 'basename $ 0' start | stop | restart | reload"
  39. Exit 1
  40. Esac
  41. Exit 0

Add this file to start

 

  1. # Chmod 755/etc/rc. d/init. d/oradb
  2. # Chkconfig -- add oradb

Restart service

 

  1. # Service oradb stop
  2. # Service oradb start

The next time you start the machine, the Oracle service will start with a random machine.

The Oracle database has been installed and configured.

Tip: the default port number of the Oracle database: 1521. The default port number of the EM manager provided by Oracle is 1158.

Uninstall:

It is cumbersome to install oracle in linux, but it is very simple to uninstall. You only need to delete the relevant files !!!

Oracle11g comes with an unmount batch processing home/oracle/product/11.2.0/dbhome_1/deinstall

Run the processing file to automatically uninstall oracle and manually delete the \ app folder.

You may need to fill in the following items during the running process:

All single-instance listeners to cancel configuration [LISTENER]: LISTENER

List of database names configured in the oracle Home Directory [MYDATA, ORCL]: MYDATA, ORACL

Do you still want to modify the details of MYDATA and l databases? [N]: n

CCR check is finished

Continue [y-yes, n-no]? [N]: y

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.