Database Chapter (Oracle) - - Installation of Non-Graphic Interface and Database Migration in Linux System

Keywords: Oracle Database SQL Linux

Installation of non-graphical interface and database migration for Linux system

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.

/sbin/sysctl -p
Modify user restrictions (in the / etc/security/limits.conf file, add or modify the following parameters using a text editor or vi command)

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
In the / etc/pam.d/login file, add or modify the following using a text editor or vi command
session required /lib/security/pam_limits.so
session required pam_limits.so
In the / etc/profile file, add or modify the following using a text editor or vi command
if [ $USER = "oracle" ]; then
    if [ $SHELL = "/bin/ksh" ]; then
       ulimit -u 16384
       ulimit -n 65536
    else
       ulimit -u 16384 -n 65536
    fi
fi
Make the setting effective
source /etc/profile
Create installation directories (you can choose more space directories to create as appropriate)
mkdir -p /home/app/
chown -R oracle:oinstall /home/app/
chmod -R 775 /home/app/
Create / etc/oraInst.loc file, as follows
nventory_loc=/home/app/oracle/oraInventory
inst_group=oinstall
Change the permissions of files
chown oracle:oinstall /etc/oraInst.loc
chmod 664 /etc/oraInst.loc
Setting oracle environment variables
su - oracle
vi ~/.bash_profile
Add the following at the end
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=orcl
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)
    

Make the setting effective

source /home/oracle/.bash_profile
Check environmental variables
env
Unzip the oracle installation file
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 template
mkdir etc
cp /home/oracle/database/response/* /home/oracle/etc/
Setting response file permissions
su - root
chmod 700 /home/oracle/etc/*.rsp
Quietly install Oracle software
su - oracle
Modify the response file/home/oracle/etc/db_install.rsp for installing Oracle software
oracle.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
Quietly install Oracle software
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

cd $ORACLE_BASE/oraInventory/logs
tail -100f installActions*.log
The following prompts indicate that the installation is complete
#-------------------------------------------------------------------
/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.
#------------------------------------------------------------------- 
Use root user to execute root.sh
su root
/home/app/oracle/product/11.2.0/db_1/root.sh

Increase oracle environment variables

su - oracle 
vi ~/.bash_profile
Add the following at the end
export 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
Make the setting effective
source /home/oracle/.bash_profile
Silently configure the network
$ORACLE_HOME/bin/netca /silent /responseFile /home/oracle/etc/netca.rsp
Quietly install the database and modify the response file/home/oracle/etc/dbca.rsp that only installs the database
GDBNAME="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
Quietly install the database
$ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/etc/dbca.rsp
Examples checking after database construction
ps -ef | grep ora_ | grep -v grep | wc -l
ps -ef | grep ora_ | grep -v grep
Monitoring and Inspection after the Construction of the Storehouse
lsnrctl status
If the following error occurs
lsnrctl: 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
Solution: Execute the following commands under root user
su - root
setenforce 0
Modify oracle startup profile
su - oracle
vi /etc/oratab 
racl:/home/app/oracle/product/11.2.0/db_1:Y //Change "N" to "Y"
This allows you to start the instance through dbstart, the listener
dbstart $ORACLE_HOME
At this point, all oracle processes are closed and listeners are stopped
dbshut $ORACLE_HOME
Check the status of the listener again
lsnrctl status
If archive logs are used
sqlplus / 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) 
Default Installation of Database User Check
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)

exp 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
Automatic database backup script
#!/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




Posted by pontiac007 on Thu, 16 May 2019 02:36:37 -0700