0x00 Preparations Before Installation
-
A CentOS 7.+ machine with the YUM environment configured.
-
You have downloaded the Oracle11gR2 database installation file, Linux.x64_11GR2_database_1of2.ziplinux.x64_11GR2_database_2of2.zip. Upload the file to the TMP directory. You can also download directly to the machine through baidu cloud disk by bypy.
File sharing address: pan.baidu.com/s/12MV-Dq8z… (s5i7)
0x01 Operating System Preparations
1. Add a host address
#Oracledb# 01 is a custom value and can be changed as required[root@centos7] $echo "192.168.0.111 oracledb" > /etc/hosts#You can also give the server a name [optional]. After the operation, you need to log in again and centos7 will be changed to OracleDB
[root@centos7] $ hostnamectl set-hostname oracledb
Copy the code
2. Install the Unzip software and common software
[root@oracledb] $ yum install unzip net-tools vim -y
Copy the code
3. Decompress the Oracle installation program
#Create '/data/oracle/oraclesetup' to store installation files
[root@oracledb] $ mkdir -p /data/oracle/oraclesetup
#Unzip the installation file to /data/oracle/ Oraclesetup
[root@oracledb] $ unzip linux.x64_11gR2_database_1of2.zip -d /data/oracle/oraclesetup
[root@oracledb] $ unzip linux.x64_11gR2_database_2of2.zip -d /data/oracle/oraclesetup
Copy the code
4. Close the Selinux
## temporarily shut down Selinux without restarting the server
[root@oracledb] $ setenforce 0
## Modify the configuration file to permanently disable Selinux[root@oracledb] $ vim /etc/selinux/config ... Change the value SELINUX=disabledCopy the code
5. Configure the firewall
## firewalld Firewall allows port 1521
[root@oracledb] $ firewall-cmd --zone=public --add-port=1521/tcp --permanent
#Reload the firewall configuration
[root@oracledb] $ firewall-cmd --reload
## [Optional] If the test environment can directly turn off the firewall[root@oracledb] $systemctl stop firewalld [root@oracledb] $systemctl disable firewalld // Disable automatic firewall startupCopy the code
6. Install a database-dependent environment
Online environments can be installed by ‘yum install’
[root@oracledb] $ yum install gcc make binutils gcc-c++ compat-libstdc++-33elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-develnumactl-devel sysstat unixODBC unixODBC-devel pcre-devel –y
Copy the code
In an offline environment, you can download an offline RPM package and use RPM to install it
#Download dependent zip packages in advance. CentOS7.4
## link: https://pan.baidu.com/s/1TVrQDBjU2tzDHU1yZRooxw extraction code: i8oo
[root@oracledb] $ rpm -Uvh --force --nodeps *.rpm
Copy the code
7. Add users and user groups required by the Oracle database
[root@oracledb] $ groupadd oinstall
[root@oracledb] $ groupadd dba
[root@oracledb] $ useradd -g oinstall -G dba oracle
#Set password for oracle user.
[root@oracledb] $ passwd oracle
[root@oracledb] $ id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba),1004(asmdba)
Copy the code
8. Modify the kernel parameter configuration file
-
Example Modify the kernel parameter configuration file /etc/sysctl.conf
#Kernel. shmmax = 1073741824 Is half of the 2 GB physical memory, expressed in bytes[root@oracledb] $ vim /etc/sysctl.conf ... Add the following information: fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 1073741824 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 ## Check the configuration [root@oracledb] $ sysctl -p Copy the code
-
Modify the user’s restricted file
[root@oracledb] # vim /etc/security/limits.conf ... Oracle soft nproc 2047 Oracle Hard nproc 16384 Oracle soft nofile 1024 Oracle hard nofile 65536 [root@oracledb] # vim /etc/pam.d/login ... Session required /lib64/security/pam_limits.so session required pam_limits.so [root@oracledb] # vim /etc/profile . Add the following##oracle if [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi Copy the code
0x02 Silently Installing the Oracle Server
1. Create an installation directory and set file permissions
[root @ oracledb] $mkdir -p/data/oracle/product / 11.2.0 [root @ oracledb] $mkdir -p/data/oracle/oradata [root @ oracledb] $ mkdir -p /data/oracle/inventory [root@oracledb] $ mkdir -p /data/oracle/fast_recovery_area [root@oracledb] $ chown -R oracle:oinstall /data/oracle [root@oracledb] $ chmod -R 775 /data/oracleCopy the code
2. Set environment variables for oracle users
#Switch to the Oracle user. Note The su username user cannot change the environment variable. Run the su - username command[root@oracledb] $ su - oracle [oracle@oracledb] $ vim ~/.bash_profile ... Add the following## oracleORACLE_HOME=$ORACLE_BASE/product/11.2.0 ORACLE_SID=ora11 Set NLS_LANG= american_America.al32UTF8 # as required. Set this parameter as required. This parameter must be exported to system variables. Otherwise, garbled characters will be displayed during data import. PATH=$PATH:$ORACLE_HOME/bin export NLS_LANG ORACLE_BASE ORACLE_HOME ORACLE_SID PATHCopy the code
3. Edit the static installation file
#Place the installation configuration file under /home/oracle for easy use[oracle@oracledb] $ cp -R /data/oracle/oraclesetup/database/response/ ~/ [oracle@oracledb] $ vim ~/response/db_install.rsp ... Oracle.install. option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=oracledb UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION = / data/oracle/inventory SELECTED_LANGUAGES = en, zh_CN ORACLE_HOME = / data/oracle/product / 11.2.0 ORACLE_BASE=/data/oracle oracle.install.db.InstallEdition=EE oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=dba DECLINE_SECURITY_UPDATES=trueCopy the code
4. Use db_install. RSP to silently install the database
[oracle@oracledb] $ ./data/oracle/oraclesetup/database/runInstaller -silent -responseFile ~/response/db_install.rsp -ignorePrereq
...
/u01/app/oracle/inventory/logs/*.log
Copy the code
Oracle starts silent installation in the background. If [WARNING] is displayed during the installation process, ignore it. If [FATAL] is displayed, the installation process is still running in the background. The log of the installation session can be found by executing the input.
5. Wait until the installation is complete and use the software as promptedroot
User Configuration
#Switching to user root
[oracle@oracledb] $ su - root
#Execute the script[root @ oracledb] $sh/data/oracle/product / 11.2.0 / root. ShCopy the code
0x03 Silently configuring database listening
#Switching oracle Users
[root@oracledb] $ su - oracle
#Configured to monitor
[oracle@oracledb] $ netca /silent /responseFile ~/response/netca.rsp
Copy the code
After run successfully, in/data/oracle/product / 11.2.0 / network/admin generated in the listener. Ora and sqlnet. Ora
#The root user can use netstat to view that port 1521 is occupied
[root@oracledb] $ netstat -tnulp | grep 1521
tcp6 0 0 :::1521 :::* LISTEN 87283/tnslsnr
Copy the code
0x04 Silently Creating a Database instance
1. Modify the dbca. RSP file
#Switching oracle Users
[root@oracledb] $ su - oracle
#Modify the dbca. RSP file[oracle@oracledb] $vim ~ /response/dbca.rsp... GDBNAME= "ora11" SID ="ora11" # change SYSPASSWORD= "dbpassword" # change SYSTEMPASSWORD= "dbpassword" # Change your password SYSMANPASSWORD= "dbPassword" # Change your password DBSNMPPASSWORD= "dbPassword" # Change your password DATAFILEDESTINATION=/data/oracle/oradata RECOVERYAREADESTINATION=/data/oracle/fast_recovery_area CHARACTERSET= "American_america.al32utf8" # alter character set TOTALMEMORY= "1638" # alter character set TOTALMEMORY= "1638" # alter character set TOTALMEMORY= "1638" # alter character set TOTALMEMORY= "1638"Copy the code
2. Create a database instance silently
#The system starts to silently create a database instance[oracle@oracledb] $dbca-silent-responseFile ~ /response/dbca.rspCopy the code
3. Check the instance process
#After the library is built, the instance process is checked
[oracle@oracledb] $ ps -ef | grep ora_ | grep -v grep
Copy the code
4. Check the listening status
#Viewing listening Status
[oracle@oracledb] $ lsnrctl status
Copy the code
5. Log in to the database to check the instance status
[oracle@oracledb] $ sqlplus / as sysdba
...
SQL> select status from v$instance;
STATUS
------------
OPEN
Copy the code
0x05 Oracle Automatically Starts upon Startup
1. Modifydbstart
configuration
[oracle @ oracledb] $vim/data/oracle/product / 11.2.0 / bin/dbstart... ORACLE_HOME_LISTNER=$ORACLE_HOME # Change ORACLE_HOME_LISTNER=$1 to $ORACLE_HOMECopy the code
2. Modifydbshut
configuration
[oracle @ oracledb] $vim/data/oracle/product / 11.2.0 / bin/dbshut... ORACLE_HOME_LISTNER=$ORACLE_HOME # Change ORACLE_HOME_LISTNER=$1 to $ORACLE_HOMECopy the code
3. Modify/etc/oratab
configuration
[oracle@oracledb] $ vim /etc/oratab ... Change the following configuration ora11: / data/oracle/product / 11.2.0: Y # will be former: / data/oracle/product / 11.2.0: last N Y instead of NCopy the code
4. Test the dbshut and distart commands
#Test closed
[oracle@oracledb] $ dbshut
#The instance process disappears after closing
[oracle@oracledb] $ ps -ef | grep ora_ | grep -v grep
Copy the code
#Open test
[oracle@oracledb] $ dbstart
#The instance process will appear when enabled
[oracle@oracledb] $ ps -ef | grep ora_ | grep -v grep
Copy the code
5. Write the startup script
#Switch to user root
[oracle@oracledb] $ su - root
#Modify ORACLE_BASE, ORACLE_HOME, and ORACLE_SID according to your own configuration
[root@oracledb] $ vim /etc/rc.d/init.d/oracle
#! /bin/sh
# chkconfig: 345 61 61
# description: Oracle 11g R2 AutoRun Servimces
# /etc/init.d/oracle
#
# Run-level Startup script for the Oracle Instance, Listener, and
# Web InterfaceExport ORACLE_BASE=/data/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/ export ORACLE_SID= ORA11 export PATH=$PATH:$ORACLE_HOME/bin ORA_OWNR="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 -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startupsu $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart echo "Oracle Start Succesful! OK." ;; stop) # Oracle listener and instance shutdownsu $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut echo "Oracle Stop Succesful! OK." ;; reload | restart) $0 stop
$0 start
;;
*)
echo $"Usage: $(basename $0) {start|stop|reload|reload}"
exit 1
;;
esac
exit 0
Copy the code
6. Configure the self-start script
#Example Change the permission of the /etc/init.d/oracle service file
[root@oracledb] $ chmod 755 /etc/init.d/oracle
#Set automatic startup upon startup
[root@oracledb] $ chkconfig oracle on
Copy the code
7. Useservice
Testing oracle services
#Restarting the Oracle Service
[root@oracledb] $ service oracle restart
#Check the Oracle service status
[root@oracledb] $ service oracle status
#Closing the Oracle Service
[root@oracledb] $ service oracle stop
#Starting the Oracle Service
[root@oracledb] $ service oracle start
Copy the code