CentOS 7 静默安装Oracle数据库 21C —— 筑梦之路

oracle数据库下载地址:

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

1. 修改主机名

hostnamectl set-hostname oracledb

2. 关闭selinux和防火墙

systemctl disable firewalld.service --now

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

3. 检查依赖包


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. 安装依赖包

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. 创建所需的用户和用户组

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. 配置linux内核参数

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. 配置用户资源

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. 修改/etc/pam.d/login文件

vim /etc/pam.d/login

session required /lib/security/pam_limits.so

9. 修改/etc/profile文件

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. 创建安装目录

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. 配置oracle用户环境变量

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. 文件解压

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. 配置安装引导文件

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. 执行安装

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

15. 以root执行脚本

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

16. 创建监听

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

17. 创建数据库

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. 检查验证

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


#  登陆

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

你可能感兴趣的:(数据库技术,linux系统运维,数据库,centos,服务器)