CentOS 7 silently installs Oracle database 21C - the road to dream building

Oracle database download address:

https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/index.html

1. Modify the hostname

hostnamectl set-hostname oracledb

2. Turn off selinux and firewall

systemctl disable firewalld.service --now

sed -i.bak 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

3. Check dependencies


rpm --query --queryformat "%{NAME}-%{VERSION}.%{RELEASE} (%{ARCH})\n" bc binutils compat-libcap1 compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh libaio libaio-devel libX11 libXau libXi libXtst libXrender libXrender-devel libgcc libstdc++ libstdc++-devel libxcb make smartmontools sysstat

4. Install dependent packages

yum -y install compat-libcap1 compat-libstdc++-33 elfutils-libelf-devel fontconfig-devel glibc-devel ksh libaio-devel libX11 libXau libXi libXtst libXrender libXrender-devel libstdc++-devel libxcb smartmontools sysstat

5. Create the required users and user groups

groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper
groupadd -g 54324 backupdba
groupadd -g 54325 dgdba
groupadd -g 54326 kmdba
groupadd -g 54330 racdba
useradd -u 54321 -g oinstall -G dba,oper,backupdba,dgdba,kmdba,racdba oracle

6. Configure linux kernel parameters

vim /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 16451328
kernel.shmmax = 33692319744
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

# 立即生效

sysctl -p

7. Configure user resources

vim /etc/security/limits.conf
oracle soft nofile 1024
oracle hard nofile 65536
oracle hard nproc 16384
oracle soft nproc 2047
oracle soft stack 10240
oracle hard stack 32768
oracle hard memlock 3145728

8. Modify the /etc/pam.d/login file

vim /etc/pam.d/login

session required /lib/security/pam_limits.so

9. Modify the /etc/profile file

vim /etc/profile
if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
   ulimit -p 16384
   ulimit -n 65536
  else
   ulimit -u 16384 -n 65536
  fi
fi

#  

source /etc/profile

10. Create the installation directory

mkdir -p /home/oracle/app/oracle/product/21.3.0
mkdir -p /home/oracle/app/oracle/oradata
mkdir -p /home/oracle/app/oracle/inventory
mkdir -p /home/oracle/app/oraInventory
mkdir -p /home/oracle/app/oracle/fast_recovery_area
chown -R oracle:oinstall /home/oracle/app
chmod -R 775 /home/oracle/app

11. Configure oracle user environment variables

su - oracle
vim .bash_profile
source /home/oracle/.bash_profile
export LANG=en_US
export NSL_LANG=american_america.ZHS16GBK
export ORACLE_BASE=/home/oracle
export ORACLE_HOME=$ORACLE_BASE/app/oracle/product/21.3.0
export ORACLE_SID=YXPCDB
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export CLASSPATH=$CLASSPATH:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/jlib:$ORACLE_HOME/network/lib

12. File decompression

exit # 退到root用户下
chown oracle:oinstall /Tools/LINUX.X64_213000_db_home.zip   
chmod 755 /Tools/LINUX.X64_213000_db_home.zip 
su - oracle 
unzip /Tools/LINUX.X64_213000_db_home.zip -d $ORACLE_HOME

13. Configure the installation boot file

cd $ORACLE_HOME/install/response
cp db_install.rsp db_install.rsp.bak
vim db_install.rsp
# 主要修改以下参数
oracle.install.option=INSTALL_DB_SWONLY        
UNIX_GROUP_NAME=oinstall              
INVENTORY_LOCATION=/home/oracle/app/oraInventory  
ORACLE_HOME=/home/oracle/app/oracle/product/21.3.0  
ORACLE_BASE=/home/oracle/app/oracle          
oracle.install.db.InstallEdition=EE          
oracle.install.db.OSDBA_GROUP=dba          
oracle.install.db.OSOPER_GROUP=oper          
oracle.install.db.OSBACKUPDBA_GROUP=backupdba    
oracle.install.db.OSDGDBA_GROUP=dgdba        
oracle.install.db.OSKMDBA_GROUP=kmdba        
oracle.install.db.OSRACDBA_GROUP=racdba        
oracle.install.db.rootconfig.executeRootScript=false

14. Execute the installation

cd $ORACLE_HOME
./runInstaller -silent -responseFile $ORACLE_HOME/install/response/db_install.rsp

15. Execute the script as root

su root
sh /home/oracle/app/oraInventory/orainstRoot.sh
sh /home/oracle/app/oracle/product/21.3.0/root.sh

16. Create listeners

su - oracle # 在oracle的用户下
cd assistants/netca
cp netca.rsp netca.rsp.bak
netca /silent /responseFile $ORACLE_HOME/assistants/netca/netca.rsp

17. Create database

cd $ORACLE_HOME/assistants/dbca
dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE -gdbname YXPCDB  -sid YXPCDB -createAsContainerDatabase TRUE -numberOfPDBs 1 -pdbName pdbYXP -pdbAdminPassword Yangxiaopeng214 -sysPassword Yangxiaopeng214 -systemPassword Yangxiaopeng214 -datafileDestination '/home/oracle/app/oracle/oradata' -recoveryAreaDestination '/home/oracle/flash_recovery_area' -redoLogFileSize 50 -storageType FS -characterset ZHS16GBK -nationalCharacterSet AL16UTF16 -totalMemory 2048 -databaseType OLTP  -emConfiguration NONE
# 主要参数
gdbName=YXPCDBsid=YXPCDBdatabaseConfigType=SIcreateAsContainerDatabase=truenumberOfPDBs=1pdbName=pdbYXPpdbAdminPassword=Yangxiaopeng214templateName=General_Purpose.dbcsysPassword=Yangxiaopeng214systemPassword=Yangxiaopeng214emConfiguration=NONEdbsnmpPassword=Yangxiaopeng214datafileDestination=/home/oracle/app/oracle/oradatarecoveryAreaDestination=/home/oracle/flash_recovery_areastorageType=FScharacterSet=ZHS16GBKnationalCharacterSet=AL16UTF16sampleSchema=truetotalMemory=2048redoLogFileSize=50

18. Check Validation

lsnrctl status   # 查看监听状态
lsnrctl restart  # 重启监听
lsnrctl stop     # 停止监听
lsnrctl start    # 启动监听


#  登陆

sqlplus
输入用户名和密码(system/Yangxiaopeng214)
select sysdate from dual;

Guess you like

Origin blog.csdn.net/qq_34777982/article/details/130951397