Recently, I had a hard time installing the Oracle environment in Linux. I encountered a lot of problems and finally got it done. So I wrote this article to record the installation process for future use.
1. Preparations for configuration in Linux
Environment: Linux: Redhat Enterprise 5.4, DB: Oracle 11g R2 X64, Oracle installed in the/home/oralce_11 directory.
The configuration process is as follows: (most of the content is online, and individuals follow the online steps)
1) Check the basic requirements (this must meet the requirements for the awesome server and can be skipped)
Memory size
Grep MemTotal/proc/meminfo
Swap partition size
Grep SwapTotal/proc/meminfo
Add swap Partition
Create a partition file such as/home/swap. The file size is 5120000 blocks. Generally, 1 block is 1 K, so the space here is 5 GB.
Dd if =/dev/zero of =/home/swap bs = 1024 count = 5120000
Then convert the partition into a swap partition.
Mkswap/home/swap
Then add it to fstab.
Echo "/home/swap defaults 0 0">/etc/fstab
2) Check the software requirements and install the software without yum install.
Rpm-q binutils compat-libstdc ++-33 elfutils-libelf-devel glibc-common glibc-devel gcc-c ++ libaio-devel libaliblibgcc libstdc + + libstdc ++-devel make sysstat unixODBC-devel pdksh
(If there is no installation, put the Linux CD into the Server folder, find the corresponding RPM package, and run the RPM command for installation. If you like the GUI, you can also double-click the corresponding RPM package on the image interface to install the package. Note that when the libaio-devel unixODBC-devel software package is installed, in addition to the X64 package, the i386 package should also be installed, not because it is an X64 system, I will not install the i386 package. )
3) configure the kernel.
Edit/etc/sysctl. conf.
Add the following content to the file
# Kernel paramaters required by Oracle 11gR1
Fs. file-max = 6815744
Fs. aio-max-nr = 1048576
Kernel. shmall = 2097152
Kernel. shmmax = 2147483648
Kernel. shmmni = 4096
Kernel. sem = 250 32000 100 128
Net. ipv4.ip _ local_port_range = 9000 65500
Net. core. rmem_default = 4194304
Net. core. rmem_max = 4194304
Net. core. wmem_default = 262144
Net. core. wmem_max = 1048576
4) to make the/etc/sysctl. conf change take effect immediately, run the following command.
Sysctl-p
5) edit/etc/security/limits. conf.
Add the following lines:
Oracle soft nproc 2047
Hard nproc 16384
Oracle soft nofile 1024
Oracle hard nofile 65536
6) edit/etc/pam. d/login.
Add the following lines:
Session required/lib/security/pam_limits.so
Session required pam_limits.so
[Note: For X64 systems, use/lib64/security/pam_limits.so. Otherwise, the system may not be able to log on to the server !]
7) edit/etc/profile.
Add the following lines:
If [$ USER = "oracle"]; then
If [$ SHELL = "/bin/ksh"]; then
Ulimit-p 16384
Ulimit-n 65536
Else
Ulimit-u 16384-n 65536
Fi
Fi
8) Create an operating system user as the owner of the software installation and support group.
Groupadd oinstall
Groupadd dba
Useradd-g oinstall-G dba oracle
Passwd oracle
9) create a software installation directory.
Mkdir-p/home/oracle_11/app/
Chown-R oracle. oinstall/home/oracle_11/
Chmod-R 755/home/oracle_11/
10) edit/home/oracle/. bash_profile.
Add the following lines:
Umask 022
ORACLE_BASE =/home/oracle_11/app
ORACLE_HOME = $ ORACLE_BASE/oracle/product/11.2.0/db_1
ORACLE_SID = MYTEST -- Instance name, which can be modified as needed
PATH = $ PATH: $ HOME/bin: $ ORACLE_HOME/bin
LD_LIBRARY_PATH = $ ORACLE_HOME/lib:/usr/lib
LANG = C -- set this parameter to avoid garbled characters during installation.
Export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH LD_LIBRARY_PATH LANG
11) open another terminal window as root in the GUI (local operation or remote operation through VNC)
-- This step is critical. If you do not run this step, the graph-based installation interface cannot be started when the oracle user runs #./runInstaller.
# Xhost +
# Xhost + localhost
12) decompress the downloaded Oracle Installation File to Linux, and then install the database.
# Su-oracle
Cd database/
./RunInstaller
13) Next, a graphical Installation Wizard will appear. Follow the wizard step by step, which is the same as the wizard for installing Oracle in Windows. There is no big difference until the installation is complete.
2. confirm that the installation is successful.
Oracle in Linux is running after installation. Run top-u oracle to view the processes run as Oracle users. On the graphic interface, run $ ORACLE_HOME/sqldeveloper. sh to display the free Oracle management client SQL Developer that comes with Oracle. Connect to the just-installed Oracle. The connection is successful.
In this case, restart the server to check whether Oracle can be started properly after the server is restarted. Run the reboot command as the Root user to restart Linux. After the restart is complete, Oracle is not registered as a service like Oracle in Windows by default, therefore, you need to manually enter the command to start. Startup method: log on to oracle and run the following statement:
1. Go to sqlplus:
Sqlplus/nolog
2. Connect to the database as sysdba and start the Oracle database engine:
SQL> conn/as sysdba
SQL> startup
3. Exit sqlplus and run Listener.
SQL> exit
$ Lsnrctl start
In this way, the TNS of the database is started and the database can be connected through the network. Generally, it is enough to start these two instances. If you want to use 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 https: // servername: 1158/EM/console.
Here, I encountered an error in running sqlplus in actual operations, which is roughly as follows:
Sqlplus/as sysdba
Sqlplus: error while loading shared libraries:/u01/app/oracle/product/11.1.0/db_1/lib/libnnz11.so: cannot restore segment prot after reloc: Permission denied
Many people have encountered this problem on the Internet. It turns out that SELinux is playing a strange role. My solution is to disable SELinux:
Change the content of the/etc/sysconfig/selinux file to SELINUX = disabled, and then restart the server.
It seems that this method is not very good, and the solution is to use the chcon command.
Example: chcon-t texrel_shlib_t/usr/local/rsi/idl_6.1/bin. linux. x86/*. so
In addition, I also reported the TNS-12555: TNS: permission denied error when starting Listener.
Later, I searched the internet and found that oracle users could not access the/var/tmp/. oracle folder. The method was very simple. After running: chmod 777/var/tmp/. oracle, it would be OK.
Also, when I started the EM console, I encountered an error: Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name.
After this variable is set (run the export ORACLE_UNQNAME = xxxx Instance name), start the EM console, and a new error is displayed, that is, the Enter command is used to configure the issue. /u01/app/oracle/product/11.2.0/db_1/Solaris/j2ee/OC4J_DBConsole_xxxx not found. no such file? I checked it and found that such a file does not exist. What should I do? In fact, it is very simple to run:
Emca-config dbcontrol db
You can reconfigure it according to the wizard.
3. Configure Oracle as auto-start
Although Oracle does not often shut down as a server, it is too troublesome to manually start Oracle every time when it is restarted occasionally, hoping that it will be the same as in Windows, oracle is automatically started every time it is started. You only need to configure Oracle as a Linux service. The procedure is as follows:
1. Create the/etc/rc. d/init. d/oracle11g script file as the root user. The content is as follows (the environment variable settings are modified according to the actual situation ):
#! /Bin/bash
#
# Chkconfig: 35 95 1
# Description: init script to start/stop oracle database 11g, TNS listener, EM
#
#
#
# Match these values to your environment:
ORACLE_BASE =/home/oracle_11/app
ORACLE_HOME = $ ORACLE_BASE/oracle/product/11.2.0/db_1
ORACLE_SID = BRDWDEV
ORACLE_UNQNAME = BRDWDEV
PATH = $ PATH: $ HOME/bin: $ ORACLE_HOME/bin
LD_LIBRARY_PATH = $ ORACLE_HOME/lib:/usr/lib
LANG = C
Export ORACLE_BASE ORACLE_HOME ORACLE_SID ORACLE_UNQNAME PATH LD_LIBRARY_PATH LANG
# See how we are called:
Case $1 in
Start)
Su-oracle <EOO
Lsnrctl start
Sqlplus/nolog <EOS
Connect/as sysdba
Startup
EOS
Emctl start dbconsole
EOO
;;
Stop)
Su-oracle <EOO
Lsnrctl stop
Sqlplus/nolog <EOS
Connect/as sysdba
Shutdown immediate
EOS
Emctl stop dbconsole
EOO
;;
*)
Echo "Usage: $0 {start | stop }"
;;
Esac
2. Run the following command as the root user:
Chmod 755/etc/rc. d/init. d/oracle11g
Chkconfig -- add oracle11g
3. Restart the service.
Service oracle11g stop
Service oracle11g start
In this way, oracle automatically starts and stops when the host is switched on and off.
In addition, you need to modify the/etc/oratab file and change the last N to Y, as shown below:
XxxxTEST:/home/oracle_11/app/oracle/product/11.2.0/db_1: Y
Finally, we need to test whether the Automatic startup is effective. Restart the server. After a few minutes, we can see that the client can connect to Oracle normally. The Oracle environment is configured successfully!