Install oracle 11g r2 silently in Centos 7 64-bit minimal minimal installation system (no graphical installation)

1. Installation and operation environment (operating system environment)

1. Minimize the installation of linux CentOS7

The image package I use: CentOS-7-x86_64-Minimal-1708.iso

Operating system installation steps: https://blog.51cto.com/mflag/2300359

2. Turn off selinux and firewalld

[[email protected] ~]# sed -i's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

[[email protected] ~]# systemctl disable firewalld.service

Two install dependent packages

1. There is no problem to solve the YUM source before installing the dependencies:

依赖1: yum -y install gcc gcc-c++ make binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static glibc glibc-common glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel numactl-devel sysstat unixODBC unixODBC-devel kernelheaders pdksh pcre-devel readline 依赖2:yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel 依赖3:yum -y install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel   

2. Check the dependency installation

rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel | grep "not installed"

3. Found no pdksh package

Download the rpm package of pdksh directly through the wget command

wget -O /tmp/pdksh-5.2.14-37.el5_8.1.x86_64.rpm http://vault.centos.org/5.11/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm

4. Check the dependencies again

rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel | grep "not installed"

The dependence is completely resolved, and proceed to the next step.

Three create users and groups, install directories, and set permissions

1. Create users and groups

Create a user group: groupadd oinstall
Create a user group: groupadd dba
create a user and add to the user group: useradd -g oinstall -G dba oracle

Set password: echo "123456" | passwd --stdin oracle

2. Create the installation directory and permissions (   according to the situation, choose a directory with more space to create )
mkdir -p /data/u01/app/oracle/product/11.2.0/dbhome_1
mkdir /data/u01/app/oracle/{ oradata,inventory,fast_recovery_area}
chown -R oracle:oinstall /data/u01/app/oracle
chmod -R 775 /data/u01/app/oracle

chown -R oracle.oinstall /data/u01/ #Authorize the installation directory

[[email protected] software]# ll总用量 3664204drwxr-xr-x  7 oracle oinstall        136 6月   3 11:26 databasedrwxr-xr-x  7 oracle oinstall        156 6月   3 11:27 grid-rw-r--r--. 1 oracle oinstall 1395582860 6月   2 14:40 p13390677_112040_Linux-x86-64_1of7.zip-rw-r--r--. 1 oracle oinstall 1151304589 6月   2 14:40 p13390677_112040_Linux-x86-64_2of7.zip-rw-r--r--. 1 oracle oinstall 1205251894 6月   2 14:41 p13390677_112040_Linux-x86-64_3of7.zip

Four modify the configuration file

1. Modify the kernel file: vim /etc/sysctl.conf

fs.aio-max-nr = 1048576fs.file-max = 6815744kernel.shmall = 2097152kernel.shmmax = 1073741824kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576

Execute: sysctl -p #make the configuration file take effect;

2. Modify user limits: vim /etc/security/limits.conf

oracle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536oracle soft stack 10240

3. Modify the /etc/pam.d/login file: vim /etc/pam.d/login

(Restrict the shell permissions of the oracle user)

session required /lib64/security/pam_limits.sosession required pam_limits.so

4. Modify the /etc/profile file: vim /etc/profile

(Restrict the shell permissions of the oracle user)

if [ $USER = "oracle" ]; thenif [ $SHELL = "/bin/ksh" ]; thenulimit -p 16384ulimit -n 65536elseulimit -u 16384 -n 65536fifi

5. Set the oracle user environment variable

First switch to the oracle user: su-oracle
edit: vim .bash_profile

[[email protected] ~]$ vim ~/.bash_profile

export ORACLE_BASE=/data/u01/app/oracleexport ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1export ORACLE_SID=orclexport ORACLE_UNQNAME=$ORACLE_SIDexport PATH=$ORACLE_HOME/bin:$PATHexport NLS_LANG=american_america.AL32UTF8alias sqlplus='rlwrap sqlplus'alias rman='rlwrap rman'

***: Modify according to your own installation environment.

[[email protected] ~]$ source .bash_profile #Make the variable effective immediately;

Five, upload the database installation package and unzip

1. Upload the installation package to the server

Search for command line upload tool and install

 yum search rz  yum install lrzsz

[[email protected] database]$ ls
install readme.html response rpm runInstaller sshsetup stage welcome.html


2. Create a directory to store the installation package;
mkdir -p /data/u01/software
move the installation package to decompress

mv linux.x64_11gR2database /data/u01/software/cd /data/u01/software unzip linux.x64_11gR2_database_1of2.zipunzip linux.x64_11gR2_database_2of2.zip

3. Confirm the installation directory permissions

chown -R oracle.oinstall /u01/ #Authorize the installation directory

Six modify the silent installation response file


1. Copy and back up a response file: cp -R /data/u01/software/database/response/.
Cd response/

2. Modify the /data/u01/software/database/response/db_install.rsp file

vim db_install.rsp

oracle.install.option=INSTALL_DB_SWONLYORACLE_HOSTNAME=自己的主机名UNIX_GROUP_NAME=oinstallINVENTORY_LOCATION=/data/u01/app/oracle/inventorySELECTED_LANGUAGES=en,zh_CNORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1ORACLE_BASE=/data/u01/app/oracleoracle.install.db.InstallEdition=EEoracle.install.db.DBA_GROUP=dbaoracle.install.db.OPER_GROUP=dbaDECLINE_SECURITY_UPDATES=true

Execution: vim db_install.rsp

Modified content:
1, oracle.install.option=INSTALL_DB_SWONLY

2. ORACLE_HOSTNAME=own host name

3.

UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/u01/app/oracle/inventory

4.

SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/data/u01/app/oracle
oracle.install.db.InstallEdition=EE

5.

oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba

6, DECLINE_SECURITY_UPDATES=true

Seven perform silent installation

1. Switch to the unzipped installation package directory: cd /data/u01/software/database/
execution: ./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq

The installation is complete, prompt    Successfully Setup Software.

2. After the installation is successful, there are two scripts that need to be executed as root, just follow the prompts to execute;

Open a new terminal and use root login to execute the above script:

[[email protected] ~]# /data/oracle/inventory/orainstRoot.sh
[[email protected] ~]# /data/oracle/product/11.2.0/db_1/root.sh

***Common errors

Common mistakes:
Prepare to start Oracle Universal Installer from the following address /tmp/OraInstall2018-07-11_08-41-22PM. Please wait...[[email protected] database]$ [FATAL] [INS-32012] Unable to create directory.
Reason: The correct permissions to create the directory are not granted, or there is no free space in the volume.
Action: Please check your permissions on the selected directory or choose another directory.
[FATAL] [INS-32012] Unable to create directory.
Reason: The correct permissions to create the directory are not granted, or there is no free space in the volume.
Action: Please check your permissions on the selected directory or choose another directory.
The log of this session is currently saved as: /tmp/OraInstall2018-07-11_08-41-22PM/installActions2018-07-11_08-41-22PM.log. If you want to keep this log, Oracle recommends moving it from a temporary location to a more permanent location.
Solution:
chown -R oracle.oinstall /u01/ #Authorize the installation directory

Eight configure monitoring in silent mode

1. Re-use oracle user login

su - oraclenetca /silent /responsefile /home/oracle/response/netca.rsp

[[email protected] ~]$ netca -silent -responsefile /home/oracle/response/netca.rsp

The command line parameters are being parsed:
Parameter "silent" = true
Parameter "responsefile" = /home/oracle/response/netca.rsp
Complete the syntax analysis of the command line parameters.
Oracle Net Services configuration:
Complete the profile configuration.
The Oracle Net listener starts:
Listener control is running:
/u01/app/oracle/product/11.2.0/bin/lsnrctl start LISTENER
The listener control is complete.
The listener has started successfully.
The listener configuration is complete.
The Oracle Net Services configuration was successfully completed. Exit code is 0
Through the netstat command, you can check that port 1521 is listening.

[[email protected] ~]$ netstat -tnlp

(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN-
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN-
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN-
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN-
tcp6 0 0 :::1521:::* LISTEN 2624/tnslsnr
tcp6 0 0 :::22 :::* LISTEN-
tcp6 0 0 ::1:25 :::* LISTEN-
tcp6 0 0 ::1:6010 :::* LISTEN-
tcp6 0 0 ::1:6011 :::* LISTEN-

After successful operation, listener.ora and sqlnet.ora are generated in /u01/app/oracle/product/11.2.0/network/admin/

2. View monitor

netstat -tnulp | grep 1521

Nine create a database silently

1. Configure the response file: vim /home/oracle/response/dbca.rsp

TOTALMEMORY is set to 80% of the total memory

vim /home/oracle/response/dbca.rsp
GDBNAME = "orcl"SID = "orcl"SYSPASSWORD = "oracle"SYSTEMPASSWORD = "oracle"SYSMANPASSWORD = "oracle"DBSNMPPASSWORD = "oracle"DATAFILEDESTINATION =/data/u01/app/oracle/oradataRECOVERYAREADESTINATION=/data/u01/app/oracle/fast_recovery_areaCHARACTERSET = "AL32UTF8"TOTALMEMORY = "2048"


Increase the memory, generally 1.5-2 times the physical memory size TOTALMEMORY = "2048"

The # in front is to be deleted, and the password is set corresponding to the user;

2. Check and modify the configuration content
egrep -v "(^#|^$)" /home/oracle/response/dbca.rsp

3. Installation and creation:
dbca -silent -responseFile /home/oracle/response/dbca.rsp

Perform silent library building

4. Check the instance process after the database is built:

[[email protected] ~]$ ps -ef | grep ora_ | grep -v grep

ps -ef | grep ora_ | grep -v grep

View monitoring status

lsnrctl status

5. Log in to sqlplus to view the status of the instance

You can view the default instance
env|grep ORACLE_UNQNAME and
enter sqlplus to start the instance

sqlplus / as sysdbaselect status from v$instance;
In the following situations, the solution is as follows: input startup, according to the prompt information, copy the file $ORACLE_BASE/admin/数据库名称/pfilein the init.ora.xxxform of the $ORACLE_HOME/dbsdirectory to the directory initoracle.ora(according to the startup prompt).

Ten connection test

1, sqlplus connection test

View the current SID: echo $ORACLE_SID

#登录sqlplus,查看实例状态[[email protected] ~]$ sqlplus / as sysdbaSQL> select status from v$instance; STATUS------------OPEN  #查看数据库编码select userenv('language') from dual;  #查看数据库版本信息select * from v$version;  #激活scott用户alter user scott account unlock;alter user scott identified by tiger;select username,account_status from all_users;

2, Navicat connect to Oracle remotely

Open port 1521

firewall-cmd --zone=public --add-port=1521/tcp --permanentfirewall-cmd --reload

IP is the IP address of the Oracle server, and the service name is the instance name of Oracle. The case can be ignored

select instance_name from v$instance;

Open Navicat, Tools→Options

Open the OCI interface, select oci.dll in the instantclient-basic decompression directory in the OCI library column on the right, and then click OK

Restart Navicat, click connect, select Oracle

The startup and shutdown of oracle multi-instance

Oracle /oracle login

1. Start the listener

lsnrctl start

The monitor generally does not need to be activated, and the monitor needs to be activated if the machine is restarted.

View the current SID: echo $ORACLE_SID

2. Start the database instance :

Set the instance that needs to be operated: export ORACLE_SID=a (instance 1 that needs to be started)

Enter sqlplus0: sqlplus/nolog

DBA login: conn /as sysdba

Startup: startup

Exit sqlplus: quit

Set the instance that needs to be operated: export ORACLE_SID=b (instance 2 that needs to be started)

Enter sqlplus: sqlplus /nolog

DBA login: conn /as sysdba

Startup: startup

Exit sqlplus: quit

3. Close the database instance:

Set the instance that needs to be operated: export ORACLE_SID=a (the instance that needs to be started)

Enter sqlplus: sqlplus /nolog

DBA login: conn /as sysdba

Shutdown: shutdown immediate

Exit sqlplus: quit

Set the instance that needs to be operated: export ORACLE_SID=b (the instance that needs to be started)

Enter sqlplus: sqlplus /nolog

DBA login: conn /as sysdba

Shutdown: shutdown immediate

Exit sqlplus: quit

Eleven set up Oracle to boot up

1. Set according to your actual situation

方法 (一) service服务类型 service服务这样是centos6之前的版本的,在centos7中也可以用,只不过centos7采用systemctl这种方式管理服务,性能更高效,如果两种方式都有,systemctl的优先级更高。 1.修改/u01/app/oracle/product/11.2.0/bin/dbstart[[email protected] ~]$ vim /u01/app/oracle/product/11.2.0/bin/dbstart将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME 2.修改/u01/app/oracle/product/11.2.0/bin/dbshut[[email protected] ~]$ vim /u01/app/oracle/product/11.2.0/bin/dbshut将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME 3.修改/etc/oratab文件[[email protected] ~]$ vim /etc/oratab将orcl:/u01/app/oracle/product/11.2.0:N中最后的N改为Y,成为orcl:/u01/app/oracle/product/11.2.0:Y4.输入命令dbshut和dbstart测试[[email protected] ~]$ dbshut Oracle监听停止,进程消失。 [[email protected] ~]$ dbstart Oracle监听启动,进程启动。 5.切换到root账户建立自启动脚本[[email protected] ~]$ su -[[email protected] ~]# vim /etc/rc.d/init.d/oracle添加以下内容(有些值如ORACLE_HOME和ORACLE_USER等根据实际情况可以修改): #!/bin/sh#chkconfig: 2345 20 80#description: Oracle dbstart / dbshut#以上两行为chkconfig所需ORA_HOME=/u01/app/oracle/product/11.2.0ORA_OWNER=oracleLOGFILE=/var/log/oracle.logecho "#################################" >> ${LOGFILE}date +"### %T %a %D: Run Oracle" >> ${LOGFILE}if [ ! -f ${ORA_HOME}/bin/dbstart ] || [ ! -f ${ORA_HOME}/bin/dbshut ]; then    echo "Error: Missing the script file ${ORA_HOME}/bin/dbstart or ${ORA_HOME}/bin/dbshut!" >> ${LOGFILE}    echo "#################################" >> ${LOGFILE}    exitfistart(){    echo "###Startup Database..."    su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbstart ${ORA_HOME}"    echo "###Done."    echo "###Run database control..."    su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl start dbconsole"    echo "###Done."}stop(){    echo "###Stop database control..."    su - ${ORA_OWNER} -c "${ORA_HOME}/bin/emctl stop dbconsole"    echo "###Done."    echo "###Shutdown Database..."    su - ${ORA_OWNER} -c "${ORA_HOME}/bin/dbshut ${ORA_HOME}"    echo "###Done."}case "$1" in    'start')        start >> ${LOGFILE}    ;;    'stop')        stop >> ${LOGFILE}    ;;    'restart')        stop >> ${LOGFILE}        start >> ${LOGFILE}    ;;esacdate +"### %T %a %D: Finished." >> ${LOGFILE}echo "#################################" >> ${LOGFILE}echo ""   6.修改/etc/init.d/oracle服务文件权限 [[email protected] ~]# vim /etc/rc.d/init.d/oracle[[email protected] ~]# chmod +x /etc/rc.d/init.d/oracle [[email protected] ~]# service oracle stopReloading systemd:                                         [  确定  ]Stopping oracle (via systemctl):                           [  确定  ] 7.设置为开机启动[[email protected] ~]# chkconfig oracle on 8.进行service oracle start/stop测试 9.Reboot重启查看Oracle监听和实例进程均能自动启动。 方法 (二)systemctl 服务类型 注意:采用systemctl服务启动oracle,启动监听的参数要配置成绝对路径,不然1521端口可能无法启动。vim /u01/app/oracle/product/11.2.0/bin/dbstart#ORACLE_HOME_LISTNER=$ORACLE_HOMEORACLE_HOME_LISTNER=/u01/app/oracle/product/11.2.0 1、添加脚本[[email protected] ~]# vim /usr/lib/systemd/system/oracle.service [Unit]Description=The oracle11g databaseAfter=network.target remote-fs.target  [Service]User=oracleType=forking# oracle will fail to start if /run/oralce.pid already exists but has the wrong# SELinux context. This might happen when running `oralce -t` from the cmdline.#ExecStart=/bin/bash /home/oracle/start.sh#ExecStartPre=/home/oracle/.bash_profileExecStart=/u01/app/oracle/product/11.2.0/bin/dbstartExecStop=/u01/app/oracle/product/11.2.0/bin/dbshutRestartSec=2s [Install]WantedBy=multi-user.target  [[email protected] ~]# systemctl daemon-reload #重新加载启动脚本,否则可能无效。[[email protected] ~]# systemctl start oracle[[email protected] ~]# systemctl status oracle #查看启动状态● oracle.service - The oracle11g database   Loaded: loaded (/usr/lib/systemd/system/oracle.service; enabled; vendor preset: disabled)   Active: active (running) since 六 2018-07-14 16:29:12 CST; 4s ago  Process: 2154 ExecStop=/u01/app/oracle/product/11.2.0/bin/dbshut (code=exited, status=0/SUCCESS)  Process: 2314 ExecStart=/u01/app/oracle/product/11.2.0/bin/dbstart (code=exited, status=0/SUCCESS)   CGroup: /system.slice/oracle.service           ├─2322 /u01/app/oracle/product/11.2.0/bin/tnslsnr LISTENER -inherit           ├─2480 ora_pmon_orcl           ├─2482 ora_vktm_orcl           ├─2486 ora_gen0_orcl           ├─2488 ora_diag_orcl           ├─2490 ora_dbrm_orcl           ├─2492 ora_psp0_orcl           ├─2494 ora_dia0_orcl           ├─2496 ora_mman_orcl           ├─2498 ora_dbw0_orcl           ├─2500 ora_lgwr_orcl           ├─2502 ora_ckpt_orcl           ├─2504 ora_smon_orcl           ├─2506 ora_reco_orcl           ├─2508 ora_mmon_orcl           ├─2510 ora_mmnl_orcl           ├─2512 ora_d000_orcl           ├─2514 ora_s000_orcl           ├─2573 ora_qmnc_orcl           └─2651 ora_cjq0_orcl 7月 14 16:29:05 oracle11 systemd[1]: Starting The oracle11g database...7月 14 16:29:07 oracle11 dbstart[2314]: Processing Database instance "orcl": log file /u01/app/oracle/product/11.2.0/startup.log7月 14 16:29:12 oracle11 systemd[1]: Started The oracle11g database.[[email protected] ~]# netstat -tnlp|grep 1521tcp6       0      0 :::1521                 :::*                    LISTEN      2322/tnslsnr         [[email protected] ~]# systemctl enable oracle #使oracle服务开机自启动Created symlink from /etc/systemd/system/multi-user.target.wants/oracle.service to /usr/lib/systemd/system/oracle.service. [[email protected] system]# systemctl is-enabled oracle #查看oracle是否开机启动enabled