Environment-related:
OS: CentOS release 5.11 IP: 192.168.77.10 MEM: 16G DISK: 50G
1. Brief description
This blog post is actually a silent installation of the CentOS 5 system Oracle 10g in the production environment in use.
This blog includes oracle Software silent installation, software upgrade, playing PSU, manual library building, archiving and backup strategy configuration
If the virtual machine is loaded, because the memory quota of the virtual machine can be adjusted, the partition of SWAP may not be enough, so it needs to be adjusted.
If it is a physical machine library, physical memory of the physical machine is generally determined, so the division of SWAP is generally reasonable unless the physical memory is upgraded.
Official Document Address: https://docs.oracle.com/cd/B19306_01/install.102/b15667/pre_install.htm
Host resource requirements:
At least 1G of physical memory SWAP Size Configuration Requirements: SWAP of 512M MEM 2 times MEM SWAP of 1G~2G MEM 1.5 times MEM SWAP of 2G~8G MEM 1 times MEM SWAP greater than 8 G MEM 0.75 times MEM / The available space of tmp is more than 400M At least 1.5G~3.5G database software installation directory space At least 1.2G data file storage directory space
2. Host Cloning, Basic Environment Deployment
1 Reference to "CentOS 5 Experimental Machine Template Construction and Deployment"
Clone an experimental machine, adjust the memory to 16G, and further configure the host name and hosts file:
hostname oracle10g
sed -i "s/^HOSTNAME=.*$/HOSTNAME=$(hostname)/g" /etc/sysconfig/network
echo "$(grep -E '127|::1' /etc/hosts)">/etc/hosts
echo "$(ifconfig eth0|grep inet|awk -F'[ :]' '{print $13}') $(hostname)">>/etc/hosts
sed -i 's/release 5./release 4./g' /etc/redhat-release
# Configuration files to identify system versions when Oracle software is installed need to be modified
# Oracle 10g supports installation on CentOS 5, which is full of malicious Oracle.
2 degree adjustment of SWAP configuration:
After cloning the experimental machine, the memory is adjusted to 16G, but the SWAP of the template machine is divided into 4G, which does not meet the SWAP partitioning scheme recommended by Oracle.
The suggestions for the division of SWAP are as follows:
Memory resources and hard disk resources are not tight now. If you have a small memory virtual machine, set SWAP to twice the memory directly. For example, 8G virtual machine memory can be set to 16G or even 20G directly, because disk strategy is usually dynamically allocated. If the memory is larger than 16G, it is also possible to set SWAP to 16G directly. Oracle will not report errors or alarm information. Even warnings of insufficient SWAP space can be ignored, because if physical memory bottlenecks exist, SWAP only delays downtime. That is to say, the warning message of insufficient space in SWAP is only a warning message. The problem caused by memory bottleneck cannot be solved by SWAP.
The operation of adjusting the size of virtual machine SWAP space is as follows:
Virtual machine, add a 20G virtual machine disk, boot configuration
grep -v Filename /proc/swaps |awk '{print "SWAP: "$1,$3/1024/1024" GB"}'
# SWAP: /dev/sda2 4.0983 GB
# View the location and capacity of the current SWAP partition
fdisk -l /dev/sdb
# Look at the new disk added. It's a 20G disk without any partitions.
echo -e 'n\np\n1\n\n\nwq\n' |fdisk /dev/sdb
# Non-interactive partitioning, dividing sdb into one main partition, occupying all the space
mkswap /dev/sdb1
# Format partitions into SWAP partitions
swapoff /dev/sda2
swapon /dev/sdb1
# Unload the original SWAP partition and mount the new SWAP partition
grep -v Filename /proc/swaps |awk '{print "SWAP: "$1,$3/1024/1024" GB"}'
# Check SWAP partition information to confirm that the new SWAP mount is OK
sed -i 's/.*swap.*/# &/g' /etc/fstab
echo -e '/dev/sdb1\tswap\tswap\tdefaults\t0 0'>>/etc/fstab
# You need to modify fstab, comment out the original SWAP boot and mount, and configure the new SWAP boot and mount.
init 6
grep -v Filename /proc/swaps |awk '{print "SWAP: "$1,$3/1024/1024" GB"}'
# Restart Virtual Machine Testing
Installation of 3 degree system software package:
#System packages required for silent installation:
yum -y install bc.x86_64 bind-utils.x86_64 compat-db.x86_64 compat-gcc-34.x86_64 \
compat-gcc-34-c++.x86_64 compat-libstdc++-33.i386 compat-libstdc++-33.x86_64 \
elfutils-libelf-devel.i386 elfutils-libelf-devel.x86_64 gcc.x86_64 gcc-c++.x86_64 \
gdb.x86_64 glibc-devel.i386 glibc-devel.x86_64 glibc-headers.x86_64 irqbalance.x86_64 \
ksh.x86_64 libaio.i386 libaio.x86_64 libaio-devel.i386 libaio-devel.x86_64 libICE.i386 \
libSM.i386 libstdc++.i386 libstdc++-devel.x86_64 libXp.i386 libXt.i386 \
libXtst.i386 make.x86_64 sysstat.x86_64 unixODBC-devel.i386 unixODBC-devel.x86_64 \
unixODBC-libs.i386 unixODBC-libs.x86_64 xorg-x11-utils.x86_64 xorg-x11-xinit.x86_64
# yum -y install unixODBC64-devel.i386 unixODBC64-devel.x86_64
# If it's OEL, you can pack these two packages.
yum -y install kernel.x86_64 kernel-headers.x86_64
# yum -y install kernel-uek.x86_64 kernel-uek-headers.x86_64
# If it's OEL, install the kernel package of uek, so-called UEK is Unbreakable Enterprise Kernel
# It's the penguin in the waistcoat. Unbreakable says exactly the same thing.
# There is no graphical component installed in the system. When the graphical component is installed, the system package is also needed.
yum -y groupinstall "X Window System"
#Install graphics components
4 Kernel parameter adjustment and user resource allocation:
Kernel parameter adjustments can be found in CentOS5u11 Oracle 10g Installation and Deployment of Kernel Parameter Settings
Kernel parameter tuning:
echo 'fs.aio-max-nr = 3145728'>>/etc/sysctl.conf
# If the physical memory is greater than 64G, turn it on and use it
# echo 'kernel.shmmax = 137438953472'>>/etc/sysctl.conf
echo 'kernel.sem = 250 32000 100 128'>>/etc/sysctl.conf
echo 'net.ipv4.ip_local_port_range = 1024 65000'>>/etc/sysctl.conf
echo 'net.core.rmem_default = 262144'>>/etc/sysctl.conf
echo 'net.core.rmem_max = 262144'>>/etc/sysctl.conf
echo 'net.core.wmem_default = 262144'>>/etc/sysctl.conf
echo 'net.core.wmem_max = 262144'>>/etc/sysctl.conf
sysctl -p
User resource quota:
echo 'oracle soft nproc 2047'>>/etc/security/limits.conf
echo 'oracle hard nproc 16384'>>/etc/security/limits.conf
echo 'oracle soft nofile 1024'>>/etc/security/limits.conf
echo 'oracle hard nofile 65536'>>/etc/security/limits.conf
echo 'session required pam_limits.so'>>/etc/pam.d/login
cat >>/etc/profile<<EOF
if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
EOF
5 degree Oracle User Creation Configuration and Installation Directory Creation Configuration:
User creation
groupadd -g 1000 oinstall
groupadd -g 1001 dba
useradd -g oinstall -G dba -u 1000 oracle
USERPASS='oracle'
echo "$USERPASS"|passwd --stdin oracle
# Oracle's user password is oracle, which can be changed without affecting the installation and use of Oracle Libraries
User configuration
SID=orcl
NLS=UTF8
# The instance name is orcl, and the character set is UTF8. Change the settings as required
cat >>/home/oracle/.bash_profile<<EOF
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=\$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
ORACLE_SID=$SID; export ORACLE_SID
PATH=/usr/sbin:\$PATH; export PATH
PATH=\$ORACLE_HOME/bin:\$PATH; export PATH
LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib; export CLASSPATH
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
export NLS_LANG=AMERICAN_AMERICA.$NLS
EOF
Installation directory configuration
# If it is a production environment, database file directory, backup file directory and archive file directory need to consider mounting additional storage or special data disk.
mkdir -p /u01/app/oracle/product/10.2.0/db_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01
# Software Installation Directory
mkdir /oradata
chown -R oracle: /oradata
# Database File Directory
mkdir -p /backup
chown -R oracle:oinstall /backup
# Backup File Directory
mkdir -p /arch
chown -R oracle:oinstall /arch
# File catalogue
3. Oracle 10.2.0.1 Software Silent Installation
The host has made many changes and configurations. It is recommended to restart the host once.
reboot
# Restart host
chown oracle: /tmp/10201_database_linux_x86_64.cpio.gz
su - oracle
cd /tmp/
gunzip 10201_database_linux_x86_64.cpio.gz
cpio -idcmv<10201_database_linux_x86_64.cpio
rm -rf 10201_database_linux_x86_64.cpio
# Decompression of database installation media
# Create Response Files for Software Silent Installation
cd /tmp/database/
cat>>/tmp/install_10g.rsp<<EOF
RESPONSEFILE_VERSION=2.2.1.0.0
UNIX_GROUP_NAME="oinstall"
FROM_LOCATION="/tmp/database/stage/products.xml"
FROM_LOCATION_CD_LABEL=<Value Unspecified>
ORACLE_HOME="/u01/app/oracle/product/10.2.0/db_1"
ORACLE_HOME_NAME="OraDb10g_home1"
SHOW_WELCOME_PAGE=true
SHOW_CUSTOM_TREE_PAGE=true
SHOW_COMPONENT_LOCATIONS_PAGE=true
SHOW_SUMMARY_PAGE=true
SHOW_INSTALL_PROGRESS_PAGE=true
SHOW_REQUIRED_CONFIG_TOOL_PAGE=true
SHOW_CONFIG_TOOL_PAGE=true
SHOW_RELEASE_NOTES=true
SHOW_ROOTSH_CONFIRMATION=true
SHOW_END_SESSION_PAGE=true
SHOW_EXIT_CONFIRMATION=true
NEXT_SESSION=false
NEXT_SESSION_ON_FAIL=true
NEXT_SESSION_RESPONSE=<Value Unspecified>
DEINSTALL_LIST={"oracle.server","10.2.0.1.0"}
SHOW_DEINSTALL_CONFIRMATION=true
SHOW_DEINSTALL_PROGRESS=true
CLUSTER_NODES={}
ACCEPT_LICENSE_AGREEMENT=false
TOPLEVEL_COMPONENT={"oracle.server","10.2.0.1.0"}
SHOW_SPLASH_SCREEN=true
SELECTED_LANGUAGES={"en"}
COMPONENT_LANGUAGES={"en"}
INSTALL_TYPE="Enterprise Edition"
sl_superAdminPasswds=<Value Unspecified>
sl_dlgASMCfgSelectableDisks={}
s_superAdminSamePasswd=<Value Unspecified>
s_globalDBName="orcl"
s_dlgASMCfgRedundancyValue="2 (Norm)"
s_dlgASMCfgNewDisksSize="0"
s_dlgASMCfgExistingFreeSpace="0"
s_dlgASMCfgDiskGroupName="DATA"
s_dlgASMCfgDiskDiscoveryString=""
s_dlgASMCfgAdditionalSpaceNeeded=" MB"
s_dbSelectedUsesASM=""
s_dbSIDSelectedForUpgrade=""
s_dbRetChar=""
s_dbOHSelectedForUpgrade=""
s_ASMSYSPassword=<Value Unspecified>
n_performUpgrade=0
n_dlgASMCfgRedundancySelected=2
n_dbType=1
n_dbSelection=0
b_useSamePassword=false
b_useFileSystemForRecovery=false
b_receiveEmailNotification=false
b_loadExampleSchemas=false
b_enableAutoBackup=false
b_dlgASMShowCandidateDisks=true
b_centrallyManageASMInstance=true
sl_dlgASMDskGrpSelectedGroup={" "," "," "," "}
s_dlgRBOUsername=""
s_dlgEMCentralAgentSelected="No Agents Found"
b_useDBControl=true
s_superAdminSamePasswdAgain=<Value Unspecified>
s_dlgEMSMTPServer=""
s_dlgEMEmailAddress=""
s_dlgRBORecoveryLocation="/u01/app/oracle/product/10.2.0/db_1/flash_recovery_area/"
n_upgradeDB=1
n_configurationOption=3
sl_upgradableSIDBInstances={}
n_upgradeASM=0
sl_dlgASMCfgDiskSelections={}
s_ASMSYSPasswordAgain=<Value Unspecified>
n_dbStorageType=0
s_rawDeviceMapFileLocation=""
sl_upgradableRACDBInstances={}
s_dlgRBOPassword=<Value Unspecified>
b_stateOfUpgradeDBCheckbox=false
s_dbSid="orcl"
b_dbSelectedUsesASM=false
sl_superAdminPasswdsAgain=<Value Unspecified>
s_mountPoint="/u01/app/oracle/product/10.2.0/db_1/oradata/"
b_stateOfUpgradeASMCheckbox=false
oracle.assistants.server:OPTIONAL_CONFIG_TOOLS="{}"
oracle.has.common:OPTIONAL_CONFIG_TOOLS="{}"
oracle.network.client:OPTIONAL_CONFIG_TOOLS="{}"
oracle.sqlplus.isqlplus:OPTIONAL_CONFIG_TOOLS="{}"
oracle.sysman.console.db:OPTIONAL_CONFIG_TOOLS="{}"
varSelect=1
s_nameForOPERGrp="dba"
s_nameForDBAGrp="dba"
EOF
./runInstaller -force -silent -responseFile /tmp/install_10g.rsp
# Pass in the response file and install the software silently
# If redhat-release is not modified, the parameter-ignoreSysPrereqs is required
# According to the prompt, you can find the directory of log files for silent installation:
# /u01/app/oracle/oraInventory/logs/
# Screen information analysis for silent installation:
# ...
# ...
# ...
# Installation in progress (Sat Apr 21 11:38:00 CST 2018)
# ............................................................... 14% Done.
# ............................................................... 28% Done.
# ............................................................... 42% Done.
# ............................................................... 56% Done.
# ............................................................... 70% Done.
# ................ 74% Done.
# Install successful
# ...
# Setup in progress (Sat Apr 21 11:39:50 CST 2018)
# .................. 100% Done.
# Setup successful
# End of install phases.(Sat Apr 21 11:39:51 CST 2018)
# Represents successful installation of Library Software
# WARNING:A new inventory has been created in this session. However, it has not yet been registered as the central inventory of this system.
# To register the new inventory please run the script '/u01/app/oracle/oraInventory/orainstRoot.sh' with root privileges.
# If you do not register the inventory, you may not be able to update or patch the products you installed.
# The warning message is that a new inventory was created but not registered in the central inventory of the system.
# Without registration, it is impossible to upgrade or patch the installed product (that is, database software).
# The registration method is: execute script / u01/app/oracle/oraInventory/orainstRoot.sh with root privilege
# The following configuration scripts
# /u01/app/oracle/product/10.2.0/db_1/root.sh
# need to be executed as root for configuring the system. If you skip the execution of the configuration tools, the configuration will not be complete and the product wont function properly. In order to get the product to function properly, you will be required to execute the scripts and the configuration tools after exiting the OUI.
# There is also a configuration script / u01/app/oracle/product/10.2.0/db_1/root.sh that needs to be executed with root privileges.
# The installation of Oracle Database 10g was successful.
# Please check '/u01/app/oracle/oraInventory/logs/silentInstall2018-04-21_11-37-51AM.log' for more details.
# The installation details log is / u01 / APP / Oracle / oraInventory / logs / silent Install 2018-04-21_11-37-51AM. log
# Use root privileges to execute two scripts:
su -
/u01/app/oracle/oraInventory/orainstRoot.sh
/u01/app/oracle/product/10.2.0/db_1/root.sh
# The database software is installed silently.
4. Silent upgrade of database software, installation of final PSU patch
Silent upgrade of database software:
chown oracle: /tmp/p8202632_10205_Linux-x86-64.zip
su - oracle
cd /tmp
unzip p8202632_10205_Linux-x86-64.zip
rm -rf /tmp/p8202632_10205_Linux-x86-64.zip
# Decompression database software upgrade media
# Creating Response Files for Software Silent Upgrade
cd /tmp/Disk1/
cat >>/tmp/Disk1/response/update_10g.rsp<<EOF
RESPONSEFILE_VERSION=2.2.1.0.0
UNIX_GROUP_NAME="oinstall"
FROM_LOCATION="../stage/products.xml"
ORACLE_HOME="/u01/app/oracle/product/10.2.0/db_1"
ORACLE_HOME_NAME="OraDb10g_home1"
TOPLEVEL_COMPONENT={"oracle.patchset.db","10.2.0.5.0"}
SHOW_SPLASH_SCREEN=false
SHOW_WELCOME_PAGE=false
SHOW_COMPONENT_LOCATIONS_PAGE=false
SHOW_CUSTOM_TREE_PAGE=false
SHOW_SUMMARY_PAGE=false
SHOW_INSTALL_PROGRESS_PAGE=true
SHOW_REQUIRED_CONFIG_TOOL_PAGE=false
SHOW_OPTIONAL_CONFIG_TOOL_PAGE=false
SHOW_CONFIG_TOOL_PAGE=false
SHOW_XML_PREREQ_PAGE=false
SHOW_RELEASE_NOTES=false
SHOW_END_OF_INSTALL_MSGS=true
SHOW_ROOTSH_CONFIRMATION=true
SHOW_END_SESSION_PAGE=false
SHOW_EXIT_CONFIRMATION=false
NEXT_SESSION=false
NEXT_SESSION_ON_FAIL=false
SHOW_DEINSTALL_CONFIRMATION=false
SHOW_DEINSTALL_PROGRESS=false
ACCEPT_LICENSE_AGREEMENT=true
RESTART_SYSTEM= false
COMPONENT_LANGUAGES={"en"}
DECLINE_SECURITY_UPDATES=true
EOF
./runInstaller -force -silent -responseFile /tmp/Disk1/response/update_10g.rsp
# Input response file, silently upgrade software
# Screen information analysis for silent installation:
# ...
# ...
# ...
# Deinstall in progress (Saturday, April 21, 2018 11:55:50 AM CST)
# ............................................................... 0% Done.
# ............................................................... 14% Done.
# ............................................................... 28% Done.
# ............................................................... 42% Done.
# ............................................................... 56% Done.
# ............................................................... 70% Done.
# ............................................................... 85% Done.
# ... 100% Done.
# Deinstall successful
#
# Installation in progress (Saturday, April 21, 2018 11:55:50 AM CST)
# ............................................................... 14% Done.
# ............................................................... 28% Done.
# ............................................................... 42% Done.
# ............................................................... 56% Done.
# ............................................................... 70% Done.
# ............................................................... 85% Done.
# ............. 88% Done.
# Install successful
#
# Setup in progress (Saturday, April 21, 2018 11:56:47 AM CST)
# ........... 100% Done.
# Setup successful
# As can be seen from the information, the so-called upgrade is actually the process of uninstalling and installing the new version of the software again.
# But Oracle 10g must install 10.2.0.1 first and then upgrade 10.2.0.5, instead of installing 10.2.0.5 directly.
# End of install phases.(Saturday, April 21, 2018 11:56:49 AM CST)
# WARNING:
# The following configuration scripts need to be executed as the "root" user.
# #!/bin/sh
# #Root script to run
# /u01/app/oracle/product/10.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
# It's still a warning that you need to use root to execute the script. There's only one configuration script to execute here.
# The reason is that the original inventory has been registered, and the upgrade is from the registered inventory, so there is no need to register again.
# The installation of Oracle Database 10g Release 2 Patch Set 4 was successful.
# Please check '/u01/app/oracle/oraInventory/logs/silentInstall2018-04-21_11-55-41AM.log' for more details.
# The installation details log is / u01 / APP / Oracle / oraInventory / logs / silent Install 2018-04-21_11-55-41AM. log
su -
/u01/app/oracle/product/10.2.0/db_1/root.sh
# Execution script
# The silent upgrade of database software is completed.
Install PSU, because Oracle 10g has stopped supporting, there is no corresponding update patch, install the final PSU:
chown oracle: /tmp/p6880880_102000_Linux-x86-64.zip
chown oracle: /tmp/p20299014_10205_Linux-x86-64.zip
su - oracle
cd /tmp
unzip p6880880_102000_Linux-x86-64.zip
cp -av OPatch/* $ORACLE_HOME/OPatch/
$ORACLE_HOME/OPatch/opatch version
# OPatch Version: 10.2.0.5.1
# Upgraded OPatch version
cd /tmp
rm -rf /tmp/p6880880_102000_Linux-x86-64.zip
rm -rf /tmp/OPatch/
unzip p20299014_10205_Linux-x86-64.zip
cd 20299014
$ORACLE_HOME/OPatch/opatch apply
# Email address/User Name:
# Direct carriage return
# Do you wish to remain uninformed of security issues ([Y]es, [N]o) [N]:
# Enter Y to return
# Is the local system ready for patching? [y|n]
# Enter y to return
# Verifying the update...
# Inventory check OK: Patch ID 20299014 is registered in Oracle Home inventory with proper meta-data.
# Files check OK: Files from Patch ID 20299014 are present in Oracle Home.
# Execution of 'sh /tmp/20299014/custom/scripts/post -apply 20299014 ':
# Return Code = 0
# The local system has been patched and can be restarted.
# OPatch succeeded.
# Seeing the above information indicates that the PSU has been installed successfully.
cd /tmp
rm -rf /tmp/p20299014_10205_Linux-x86-64.zip
rm -rf /tmp/20299014/
5. Manual database construction
Instance-related settings:
su - oracle
SID=orcl
NLS=UTF8
# The instance name is orcl, and the character set is UTF8. Change the settings as required
SGA=$(grep 'MemTotal' /proc/meminfo |awk '{printf ("%d\n",$2*1024*0.8*0.8)}')
PGA=$(grep 'MemTotal' /proc/meminfo |awk '{printf ("%d\n",$2*1024*0.8*0.2)}')
# Configure 80% of MEM allocated to Oracle instances
# Configure SGA for 80% and PGA for 20%.
DBPASS=oracle
# Configure database account password to oracle, that is, sys password to Oracle
Configuration monitoring:
cat >$ORACLE_HOME/network/admin/listener.ora<<EOF
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ${SID})
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = ${SID})
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)
(HOST = $(hostname -i))(PORT = 1521))
)
EOF
lsnrctl start
Configure init.ora:
cat >/home/oracle/init.ora<<EOF
db_block_size=8192
# Data block 8K
db_file_multiblock_read_count=16
open_cursors=300
db_domain=""
db_name=${SID}
background_dump_dest=/u01/app/oracle/admin/${SID}/bdump
core_dump_dest=/u01/app/oracle/admin/${SID}/cdump
user_dump_dest=/u01/app/oracle/admin/${SID}/udump
control_files=("/oradata/${SID}/control01.ctl", "/oradata/${SID}/control02.ctl", "/oradata/${SID}/control03.ctl")
# db_recovery_file_dest=/u01/app/oracle/flash_recovery_area
# db_recovery_file_dest_size=2147483648
# Flash Back Zone Not Created
job_queue_processes=100
compatible=10.2.0.5.0
processes=1500
# Total number of processes 1500
sga_target=$SGA
audit_file_dest=/u01/app/oracle/admin/${SID}/adump
remote_login_passwordfile=EXCLUSIVE
pga_aggregate_target=$PGA
undo_management=AUTO
undo_tablespace=UNDOTBS1
EOF
Create instance runtime directory and repository file storage directory:
mkdir -pv /u01/app/oracle/admin/${SID}/{adump,bdump,cdump,dpdump,pfile,udump}
mkdir -pv /u01/app/oracle/product/10.2.0/db_1/cfgtoollogs/dbca/${SID}
mkdir -pv /oradata/${SID}/
chown oracle: -R /oradata/
Library registration:
ORACLE_SID=${SID}; export ORACLE_SID
echo "${SID}:/u01/app/oracle/product/10.2.0/db_1:N">>/etc/oratab
# If the library information is not written to the oratab file, the library cannot be deleted by dbca
Manual database construction:
/u01/app/oracle/product/10.2.0/db_1/bin/sqlplus /nolog<<EOF
host /u01/app/oracle/product/10.2.0/db_1/bin/orapwd file=/u01/app/oracle/product/10.2.0/db_1/dbs/orapw${SID} password=${DBPASS} force=y
-- Create a password file
connect "SYS"/"${DBPASS}" as SYSDBA
set echo on
spool /home/oracle/CreateDB.log
-- Log of database establishment
startup nomount pfile="/home/oracle/init.ora";
-- nomount Example
CREATE DATABASE "${SID}"
MAXINSTANCES 8
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
DATAFILE '/oradata/${SID}/system01.dbf' SIZE 300M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/oradata/${SID}/sysaux01.dbf' SIZE 120M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/oradata/${SID}/temp01.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE '/oradata/${SID}/undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
CHARACTER SET ${NLS}
-- Library Character Set Setting
NATIONAL CHARACTER SET AL16UTF16
LOGFILE
GROUP 1 ('/oradata/${SID}/redo01a.log','/oradata/${SID}/redo01b.log') SIZE 204800K,
GROUP 2 ('/oradata/${SID}/redo02a.log','/oradata/${SID}/redo02b.log') SIZE 204800K,
GROUP 3 ('/oradata/${SID}/redo03a.log','/oradata/${SID}/redo03b.log') SIZE 204800K
-- Three groups of log files, two log members in each group, log file capacity 200 M
USER SYS IDENTIFIED BY "${DBPASS}" USER SYSTEM IDENTIFIED BY "${DBPASS}";
-- Building database
spool off
set echo on
spool /home/oracle/CreateDBFiles.log
-- Establish users Table space logs
CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/oradata/${SID}/users01.dbf' SIZE 5M REUSE
AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
ALTER DATABASE DEFAULT TABLESPACE "USERS";
spool off
-- Establish users Tablespace
set echo on
spool /home/oracle/CreateDBCatalog.log
-- Logging for Creating Performance Views
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catalog.sql;
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catblock.sql;
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catproc.sql;
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/catoctk.sql;
@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/owminst.plb;
connect "SYSTEM"/"${DBPASS}"
@/u01/app/oracle/product/10.2.0/db_1/sqlplus/admin/pupbld.sql;
set echo on
spool /home/oracle/sqlPlusHelp.log
-- Establish sqlplus Help logs
@/u01/app/oracle/product/10.2.0/db_1/sqlplus/admin/help/hlpbld.sql helpus.sql;
spool off
spool off
connect "SYS"/"${DBPASS}" as SYSDBA
set echo on
spool /home/oracle/postDBCreation.log
-- Ending log
set echo on
create spfile='/u01/app/oracle/product/10.2.0/db_1/dbs/spfileorcl.ora' FROM pfile='/home/oracle/init.ora';
-- Establish spfile
shutdown immediate;
-- Guan Chu
connect "SYS"/"${DBPASS}" as SYSDBA
startup ;
-- Restart Library
select 'utl_recomp_begin: ' || to_char(sysdate, 'HH:MI:SS') from dual;
execute utl_recomp.recomp_serial();
select 'utl_recomp_end: ' || to_char(sysdate, 'HH:MI:SS') from dual;
spool off
EOF
# In the / home/oracle directory, the database log can open the terminal, monitor the log and monitor the progress of the database construction.
# If reconstruction is needed, then:
# echo 'shutdown abort'|sqlplus / as sysdba
# rm -rvf cd /oradata/${SID}/*
# rm -rvf /u01/app/oracle/product/10.2.0/db_1/dbs/*${SID}*
# rm -rf /home/oracle/*.log
# Manual database construction
rm -v /home/oracle/{*.log,init.ora}
6. Configuration archiving
sqlplus / as sysdba
define SID=orcl
-- Set up the archive subdirectory to save the archive into and SID In the same subdirectory
host mkdir -pv /arch/&SID
alter system set log_archive_format='arch_%t_%s_%r.arc' scope=spfile;
alter system set log_archive_dest_10='location=/arch/&SID' scope=spfile;
shutdown immediate;
startup mount;
alter database archivelog;
alter database open;
alter system archive log current;
alter system set control_file_record_keep_time=30;
-- Filing retention strategy for 30 days
exit
7. Configure RMAN backup strategy
Directory configuration:
mkdir -pv /backup/rman/script
mkdir -pv /backup/{autobackup,backupset}
mkdir -pv $ORACLE_HOME/block_change_trace
# Create rman script directory, rman automatic backup directory, backup set storage directory
# Create Block Change Tracking Directory
Open Block Change Tracking:
sqlplus / as sysdba
alter system set control_file_record_keep_time=30;
-- Filing retention strategy for 30 days
alter database enable block change tracking using file '/u01/app/oracle/product/10.2.0/db_1/block_change_trace/track.file';
-- Open Block Change Tracking
exit
Set up backup policy:
rman target /
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/backup/autobackup/%F';
exit
# Set up backup retention policy, open control file automatic backup
Create backup scripts:
# Backup script:
cat >/backup/rman/script/rman_inc0.sh<<EOFALL
#!/bin/bash
. ~/.bash_profile
export NLS_LANG=American_America.${NLS}
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
TIME=\$(date "+%Y_%m_%d_%H_%M_%S")
echo ''>>/backup/rman/script/rman_run.log
echo '###########################################################'>>/backup/rman/script/rman_run.log
echo '#######' \$(date '+%F %R:%S') Check and Delete Backup '#######' >>/backup/rman/script/rman_run.log
echo '###########################################################'>>/backup/rman/script/rman_run.log
echo ''>>/backup/rman/script/rman_run.log
rman target / log /backup/rman/script/rman_run.log append<<EOF
allocate channel for maintenance type disk;
crosscheck backup;
crosscheck archivelog all;
delete noprompt archivelog until time 'sysdate-7';
delete noprompt obsolete;
delete noprompt expired backup;
EOF
# Delete archives 7 days ago
echo ''>>/backup/rman/script/rman_run.log
echo '##########################################################'>>/backup/rman/script/rman_run.log
echo '#######' \$(date '+%F %R:%S') Start Rman Inc0 Backup '#######' >>/backup/rman/script/rman_run.log
echo '##########################################################'>>/backup/rman/script/rman_run.log
echo ''>>/backup/rman/script/rman_run.log
rman target / nocatalog log /backup/rman/script/rman_run.log append<<EOF
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
set limit channel c1 readrate=10240;
set limit channel c1 kbytes=4096000;
set limit channel c2 readrate=10240;
set limit channel c2 kbytes=4096000;
backup as compressed backupset filesperset 3 incremental level 0 database format '/backup/backupset/inc0_%d_%T_%s_%p' tag=inc0_\$TIME;
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup as compressed backupset archivelog all not backed up 2 times tag=arch0_\$TIME format '/backup/backupset/arch0_%d_%T_%s_%p';
backup as compressed backupset current controlfile tag=ctl0_\$TIME format '/backup/backupset/ctl0_%d_%T_%s_%p';
backup as compressed backupset spfile tag=spfile0_\$TIME format '/backup/backupset/spfile0_%d_%T_%s_%p';
release channel c1;
release channel c2;
}
EOF
# File and backup twice
EOFALL
Backup tasks:
chmod +x /backup/rman/script/rman_inc0.sh
crontab -l>/tmp/crontab.tmp
echo '# Rman Backup Job'>>/tmp/crontab.tmp
echo '0 0 * * * /bin/bash /backup/rman/script/rman_inc0.sh >/dev/null 2>&1'>>/tmp/crontab.tmp
cat /tmp/crontab.tmp |crontab
rm -rf /tmp/crontab.tmp
Test:
/bin/bash /backup/rman/script/rman_inc0.sh >/dev/null 2>&1
cd /backup/rman/script/
cat rman_run.log
[TOC]