系统 : CentOS 7.9
硬件:虚拟机处理器2核 内存 4g 硬盘1:40g 硬盘2:20g
[root@localhost ~]# yum -y update
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
yum install -y binutils*
yum install -y compat-libcap1*
yum install -y compat-libstdc++*
yum install -y elfutils-libelf* elfutils-libelf-devel*
yum install -y glibc* glibc-devel*
yum install -y gcc*
yum install -y gcc-c++*
yum install -y libaio* libaio-devel*
yum install -y libgcc*
yum install -y libstdc++ libstdc++-devel*
yum install -y ksh*
yum install -y libXp* libXp-devel*
yum install -y libxt* libxt-devel*
yum install -y make*
yum install -y sysstat*
yum install -y unixODBC*
yum install -y unixODBC-devel*
yum install -y smartmontools
groupadd oinstall
groupadd dba
groupadd oper
useradd -g oinstall -G dba,oper oracle
mkdir -p /u01/software
mkdir -p /u01/app/oracle/product
mkdir -p /u01/app/oracle/oradata
mkdir -p /u01/app/oraInventory
mkdir -p /u01/app/oracle/flash_recovery_area/
mkdir -p /u01/app/oracle/product/19.3/dbhome_1
赋予权限
chown -R oracle:oinstall /u01/app/oracle/
chown -R oracle:oinstall /u01/software
chown -R oracle:oinstall /u01/app/oraInventory
设置oraarp用户密码
passwd oracle
fs.suid_dumpable = 1
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 8388608
kernel.shmmax = 68719476735
kernel.shmmni = 4096
# semaphores: semmsl, semmns, semopm, semmni
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=1048586
要使 /etc/sysctl.conf 更改立即生效,执行以下命令
/sbin/sysctl -p
ps:kernel.shmall 和 kernel.shmmax 根据实际物理内存修改,保证oracle数据库SGA 小于系统上的 shmmax,具体如下
1. kernel.shmall :
当内存为 12G 时, kernel.shmall = 3145728
当内存为 16G 时, kernel.shmall = 4194304
当内次为 32G 时, kernel.shmall = 8388608
当内存为 64G 时, kernel.shmall = 16777216
当内存为 128G 时, kernel.shmall = 33554432
2. kernel.shmmax :
内存为 12G 时,该值为 12*1024*1024*1024-1 = 12884901887
内存为 16G 时,该值为 16*1024*1024*1024-1 = 17179869183
内存为 32G 时,该值为 32*1024*1024*1024-1 = 34359738367
内存为 64G 时,该值为 64*1024*1024*1024-1 = 68719476735
内存为 128G 时,该值为 128*1024*1024*1024-1 = 137438953471
vi /etc/security/limits.conf
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 4096
oracle hard nofile 65536
oracle soft stack 10240
#su - oracle
vi .bash_profile
增加如下几行:
# added by oracle
export ORACLE_BASE=/u01/app/oracle
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
export ORACLE_HOME=$ORACLE_BASE/product/19.3/dbhome_1
export ORACLE_SID=oradb
export LANG="en_US.UTF-8"
#export LANG="en_US"
export NLS_LANG="american_AMERICA.UTF8"
#export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/usr/X11R6/lib64/
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
source /etc/profile
解压Oracle 19c安装介质文件。
注意:这次安装介质需要放置在ORACLE_HOME的目录中
[root@localhost software]# cd /u01/app/oracle/product/19.3/dbhome_1/
[root@localhost dbhome_1]# chown -R oracle.oinstall LINUX.X64_193000_db_home.zip
[root@localhost dbhome_1]# su - oracle
[oracle@localhost ~]$ cd $ORACLE_HOME
[oracle@localhost ~]$ unzip LINUX.X64_193000_db_home.zip
su - oracle
unzip LINUX.X64_193000_db_home.zip
vi ~oracle/db_install.rsp
vi $ORACLE_HOME/install/response/db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/19.3/dbhome_1
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=oinstall
oracle.install.db.OSBACKUPDBA_GROUP=oinstall
oracle.install.db.OSDGDBA_GROUP=oinstall
oracle.install.db.OSKMDBA_GROUP=oinstall
oracle.install.db.OSRACDBA_GROUP=oinstall
oracle.install.db.rootconfig.executeRootScript=true
oracle.install.db.rootconfig.configMethod=ROOT
/u01/app/oracle/product/19.3/dbhome_1/
./runInstaller -force -silent -noconfig -ignorePrereq -responseFile /u01/app/oracle/product/19.3/dbhome_1/install/response/db_install.rsp
一边安装一边查看日志(日志文件是installActions+日期AM.log)
tail -200f /u01/app/oraInventory/logs/InstallActions2022-03-02_02-44-45PM/installActions2022-03-02_02-44-45PM.log
安装完切换到root用户执行脚本
exit
/u01/app/oracle/product/19.3/dbhome_1/root.sh
su - oracle
netca -silent -responsefile /u01/app/oracle/product/19.3/dbhome_1/assistants/netca/netca.rsp
查看监听: lsnrctl status
启动监听:lsnrctl start
netstat -tlnp
vi $ORACLE_HOME/assistants/dbca/dbca.rsp
responseFileVersion=/u01/app/oracle/assistants/rspfmt_dbca_response_schema_v19.0.0
gdbName=esdb
sid=esdb
databaseConfigType=SI
createAsContainerDatabase=true
numberOfPDBs=1
pdbName=orcl
pdbAdminPassword=ORACLE19C
templateName=General_Purpose.dbc
sysPassword=ORACLE19C
systemPassword=ORACLE19C
dbsnmpPassword=ORACLE19C
datafileDestination=/u01/app/oracle/oradata
recoveryAreaDestination=/u01/app/oracle/flash_recovery_area
characterSet=ZHS16GBK
totalMemory=2048
listeners=LISTENER
sampleSchema=true
databaseType=OLTP
ps:只有红色是容器数据库 只有蓝色是单实例数据库
绿色修改物理内存值
开始安装数据库
$ORACLE_HOME/bin/dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile $ORACLE_HOME/assistants/dbca/dbca.rsp
startup;
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/19.3/dbhome_1/dbs/initoradb.ora'
ALTER SYSTEM SET MEMORY_TARGET=32767M SCOPE=SPFILE;
ALTER SYSTEM SET MEMORY_MAX_TARGET=32767M SCOPE=SPFILE;
ALTER SYSTEM SET PGA_AGGREGATE_TARGET=7436M SCOPE=SPFILE;
ALTER SYSTEM SET SGA_TARGET=22575M SCOPE=SPFILE;
ALTER SYSTEM SET SGA_MAX_SIZE=22575M SCOPE=SPFILE;
重启数据库服务
shutdown immediate;
startup;
alter database open;
alter pluggable database pdb1 open; 打开容器
说明Oracle被异常关闭时,有资源没有被释放,一般有以下几种可能,
1) Oracle的共享内存段或信号量没有被释放;
2) Oracle的后台进程(如SMON、PMON、DBWn等)没有被关闭;
3)用于锁内存的文件lk和sgadef.dbf文件没有被删除。
cd $ORACLE_HOME/dbs
ls lk*
lksid文件没有被删除。将它删除掉
rm lk*
再次启动数据库提示:ORA-00205: error in identifying control file, check alert log for more info
查看共享内存段
ipcs -map
根据ID号清除共享内存段
ipcrm -m 32768
ipcrm -m 65537
ipcrm -m 98306
ipcrm -m 393222
ipcrm -m 425991
ipcrm -m 458760
查看信号量
ipcs -s
根据semid清除信号量
ipcrm -s 229378
ipcrm -s 491523
最后重启数据库 startup;
show parameter spfile;
如果VALUE字段为空就需要创建SPFILE;
create spfile from pfile='/u01/app/oracle/admin/esdb/pfile/init.ora.4222023184649';
创建pfile:create pfile='/u01/app/oracle/pfile522.ora' from spfile;