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.
- Run the following command under an oracle user:
- Go to sqlplus
- $ Sqlplus/nolog
- Connect to the database as sysdba and start the Oracle Database Engine
- SQL> conn/as sysdba
- SQL> startup
- Exit sqlplus and run Listener.
- SQL> exit
- $ 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:
- $ 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.
- ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
- 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.
- More/home/oracle_11/app/oracle/product/11.2/db/bin/dbstart
Some content is as follows:
- # First argument is used to bring up Oracle Net Listener
- ORACLE_HOME_LISTNER = $1
- If [! $ ORACLE_HOME_LISTNER]; then
- Echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
- Echo "Usage: $0 ORACLE_HOME"
- Else
- LOG = $ ORACLE_HOME_LISTNER/listener. log
- # Set the ORACLE_HOME for the Oracle Net Listener, it gets reset
- # A different ORACLE_HOME for each entry in the oratab.
- 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:
- 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:
- 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:
- #! /Bin/bash
- # Chkconfig: 2345 90 10
- Export ORACLE_BASE =/home/oracle_11/app/
- Export ORACLE_HOME = $ ORACLE_BASE/oracle/product/11.2.0/db_1
- Export ORACLE_SID = orcl
- Export PATH = $ PATH: $ ORACLE_HOME/bin
- ORCL_OWN = "oracle"
- # If the executables do not exist -- display error
- If [! -F $ ORACLE_HOME/bin/dbstart-o! -D $ ORACLE_HOME]
- Then
- Echo "Oracle startup: cannot start"
- Exit 1
- Fi
- # Depending on parameter -- start, stop, restart
- # Of the instance and listener or usage display
- Case "$1" in
- Start)
- # Oracle listener and instance startup
- Echo-n "Starting Oracle :"
- Su-$ ORCL_OWN-c "$ ORACLE_HOME/bin/dbstart"
- Touch/var/lock/subsys/oradb
- Su-$ ORCL_OWN-c "$ ORACLE_HOME/bin/emctl start dbconsole"
- Echo "OK"
- ;;
- Stop)
- # Oracle listener and instance shutdown
- Echo-n "Shutdown Oracle :"
- Su-$ ORCL_OWN-c "$ ORACLE_HOME/bin/emctl stop dbconsole"
- Su-$ ORCL_OWN-c "$ ORACLE_HOME/bin/dbshut"
- Rm-f/var/lock/subsys/oradb
- Echo "OK"
- ;;
- Reload | restart)
- $0 stop
- $1 start
- ;;
- *)
- Echo "Usage: 'basename $ 0' start | stop | restart | reload"
- Exit 1
- Esac
- Exit 0
Add this file to start
- # Chmod 755/etc/rc. d/init. d/oradb
- # Chkconfig -- add oradb
Restart service
- # Service oradb stop
- # 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