Database Installation
Installation of dependency packages
yum install binutils compat-libstdc++-33 elfutils elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel
wget http://mirror.centos.org/centos/5/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
Create the required operating system groups and users
groupadd oinstall groupadd dba useradd -g oinstall -G dba oracle
Setting oracle user password
passwd oracle
Modify the kernel parameters (in the / etc/sysctl.conf file, add or modify the following parameters using a text editor or vi command)
fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 536870912 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
After modification, the settings will take effect.
Modify user restrictions (in the / etc/security/limits.conf file, add or modify the following parameters using a text editor or vi command)/sbin/sysctl -p
In the / etc/pam.d/login file, add or modify the following using a text editor or vi commandoracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240
In the / etc/profile file, add or modify the following using a text editor or vi commandsession required /lib/security/pam_limits.so session required pam_limits.so
Make the setting effectiveif [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -u 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi
Create installation directories (you can choose more space directories to create as appropriate)source /etc/profile
Create / etc/oraInst.loc file, as followsmkdir -p /home/app/ chown -R oracle:oinstall /home/app/ chmod -R 775 /home/app/
Change the permissions of filesnventory_loc=/home/app/oracle/oraInventory inst_group=oinstall
Setting oracle environment variableschown oracle:oinstall /etc/oraInst.loc chmod 664 /etc/oraInst.loc
Add the following at the endsu - oracle vi ~/.bash_profile
Note that no oracle-related environment variables (ORACLE_HOME, PATH,LD_LIBRARY_PATH, etc.) are set except ORACLE_BASE and oracle_SID (in / etc/profile and. bash_profile)export ORACLE_BASE=/u01/app/oracle export ORACLE_SID=orcl
Make the setting effective
Check environmental variablessource /home/oracle/.bash_profile
Unzip the oracle installation fileenv
unzip linux.x64_11gR2_database_1of2.zip unzip linux.x64_11gR2_database_2of2.zip
Document Resources Baidu Network Disk Connection: https://pan.baidu.com/s/1eakhzIhMjwt2HeWJsd_Raw Password: viia
Replication of response file templateSetting response file permissionsmkdir etc cp /home/oracle/database/response/* /home/oracle/etc/
Quietly install Oracle softwaresu - root chmod 700 /home/oracle/etc/*.rsp
Modify the response file/home/oracle/etc/db_install.rsp for installing Oracle softwaresu - oracle
Quietly install Oracle softwareoracle.install.option=INSTALL_DB_SWONLY //29 line installation type ORACLE_HOSTNAME=java-linux-test //37 line host name UNIX_GROUP_NAME=oinstall //42-line Installation Group INVENTORY_LOCATION=/home/app/oracle/oraInventory //47 rows INVENTORY directory SELECTED_LANGUAGES=en,zh_CN,zh_TW //78 Lines Selection Language ORACLE_HOME=/home/app/oracle/product/11.2.0/db_1 //83 rows oracle_home ORACLE_BASE=/home/app/oracle //88 rows oracle_base oracle.install.db.InstallEdition=EE //99-line oracle version oracle.install.db.isCustomInstall=true //108 lines of custom installation oracle.install.db.DBA_GROUP=dba //142 rows dba user group oracle.install.db.OPER_GROUP=oinstall //147 rows oper user group oracle.install.db.config.starterdb.type=GENERAL_PURPOSE //160 rows database type oracle.install.db.config.starterdb.globalDBName=orcl //165 rows globalDBName oracle.install.db.config.starterdb.SID=orcl //170 row SID oracle.install.db.config.starterdb.memoryLimit=512 //Minimum memory (M) for 192 lines of automatic memory management oracle.install.db.config.starterdb.password.ALL=oracle //233 lines set all database users to use the same password DECLINE_SECURITY_UPDATES=true //385 rows set up security update
cd database ./runInstaller -silent -force -ignorePrereq -responseFile /home/oracle/etc/db_install.rsp
Installation, if prompted [WARNING] to ignore, then the installation program is still in progress, if [FATAL], then the installation program has stopped
Check the installation log information for installation progress
The following prompts indicate that the installation is completecd $ORACLE_BASE/oraInventory/logs tail -100f installActions*.log
Use root user to execute root.sh#------------------------------------------------------------------- /home/app/oracle/product/11.2.0/db_1/root.sh To execute the configuration scripts: 1. Open a terminal window 2. Log in as "root" 3. Run the scripts 4. Return to this window and hit "Enter" key to continue Successfully Setup Software. #-------------------------------------------------------------------
su root /home/app/oracle/product/11.2.0/db_1/root.sh
Increase oracle environment variables
Add the following at the endsu - oracle vi ~/.bash_profile
Make the setting effectiveexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 export TNS_ADMIN=$ORACLE_HOME/network/admin export PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/lib export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/JRE export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/JRE/lib export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib export LIBPATH=${CLASSPATH}:$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib export ORACLE_OWNER=oracle export SPFILE_PATH=$ORACLE_HOME/dbs export ORA_NLS10=$ORACLE_HOME/nls/data
Silently configure the networksource /home/oracle/.bash_profile
Quietly install the database and modify the response file/home/oracle/etc/dbca.rsp that only installs the database$ORACLE_HOME/bin/netca /silent /responseFile /home/oracle/etc/netca.rsp
Quietly install the databaseGDBNAME="orcl.java-linux-test" //78 rows global database name = SID + host domain name SID="orcl" //149 row SID CHARACTERSET="ZHS16GBK" //415 line coding NATIONALCHARACTERSET="UTF8" //425 line coding
Examples checking after database construction$ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/etc/dbca.rsp
Monitoring and Inspection after the Construction of the Storehouseps -ef | grep ora_ | grep -v grep | wc -l ps -ef | grep ora_ | grep -v grep
If the following error occurslsnrctl status
Solution: Execute the following commands under root userlsnrctl: error while loading shared libraries: /u01/app/oracle/product/11.2.0/db_1/lib/libclntsh.so.11.1: cannot restore segment prot after reloc: Permission denied
Modify oracle startup profilesu - root setenforce 0
This allows you to start the instance through dbstart, the listenersu - oracle vi /etc/oratab racl:/home/app/oracle/product/11.2.0/db_1:Y //Change "N" to "Y"
At this point, all oracle processes are closed and listeners are stoppeddbstart $ORACLE_HOME
Check the status of the listener againdbshut $ORACLE_HOME
If archive logs are usedlsnrctl status
Default Installation of Database User Checksqlplus / as sysdba SQL> shutdown immediate; SQL> startup mount; SQL> alter database archivelog; SQL> alter database flashback on; (If you want to enable database flashback, execute) SQL> alter database open; SQL> execute utl_recomp.recomp_serial(); (Recompile all potentially invalid objects) SQL> alter system archive log current; (Manual archiving test)
SQL> set lines 256 pages 500 SQL> select USER_ID,USERNAME,ACCOUNT_STATUS,DEFAULT_TABLESPACE from dba_users order by
Database migration
Database export import (exp/imp)
Automatic database backup scriptexp cwapp/cwapp@devel owner=cwapp file=/data/exp_devel.dmp #The parameters are user name, password, database, user, export address. imp cwapp/cwapp@devel file=/data/exp_devel.dmp ignore=y full=y #Parameter Bits: User Name, Password, Database, File Address, Ignore if Table exists, Full Table Import
#!/bin/sh #Backup time BACKUPTIME=$(date +%Y%m%d) #Back up to a stored folder DMPDIR=/app/oracle/admin/orcl/dpdump #Note Name of Backup File DMPNAMEDEMO=FMC-DEMO-$BACKUPTIME.dmp LOGNAMEDEMO=FMC-DEMO-$BACKUPTIME.log ZIPNAMEDEMO=FMC-DEMO-$BACKUPTIME.dmp.zip #Note Name of Backup File DMPNAMEPRD=FMC-PRD-$BACKUPTIME.dmp LOGNAMEPRD=FMC-PRD-$BACKUPTIME.log ZIPNAMEPRD=FMC-PRD-$BACKUPTIME.dmp.zip #Export FMC_DEMO database expdp FMC_DEMO/FMC_DEMO directory=DATA_PUMP_DIR schemas=FMC_DEMO dumpfile=$DMPNAMEDEMO logfile=$LOGNAMEDEMO #Export FMC_PRD database expdp FMC_PRD/FMC_PRD directory=DATA_PUMP_DIR schemas=FMC_PRD dumpfile=$DMPNAMEPRD logfile=$LOGNAMEPRD #Enter the backup storage folder cd $DMPDIR #Compress zip -9 $ZIPNAMEDEMO $DMPNAMEDEMO zip -9 $ZIPNAMEPRD $DMPNAMEPRD #Deleting rm -rf $DMPDIR/$DMPNAMEDEMO rm -rf $DMPDIR/$DMPNAMEPRD