oracle19c静默安装
oracle 19C 静默安装
1、安装环境准备
1、swap内存配置(为内存的2倍)
[root@instance-fx01nq4f ~]# free -m
total used free shared buff/cache available
Mem: 3944 250 3161 0 532 3472
Swap: 0 0 0
##配置虚拟内存
###禁用交换空间: 在进行扩容之前,建议先禁用交换空间,如果是在扩容的前提下
sudo swapoff /swapfile
###更改交换文件大小:
#### 使用dd命令更改交换文件的大小。假设您要将交换空间扩展到8G
sudo dd if=/dev/zero of=/swapfile bs=1G count=8
####设置交换文件格式:
sudo mkswap /swapfile
####启用交换空间
sudo swapon /swapfile
#### 更新fatab文件
echo "/swapfile none swap sw 0 0" >>/etc/fstab
mount -a
####################################################################
[root@instance-fx01nq4f ~]# mkswap /swapfile
Setting up swapspace version 1, size = 8388604 KiB
no label, UUID=5a3d9240-2763-4b85-b951-cdfa0be3742a
[root@instance-fx01nq4f ~]# swapon /swapfile
swapon: /swapfile: insecure permissions 0644, 0600 suggested.
[root@instance-fx01nq4f ~]# echo "/swapfile none swap sw 0 0" >>/etc/fstab
[root@instance-fx01nq4f ~]# mount -a
[root@instance-fx01nq4f ~]# free -m
total used free shared buff/cache available
Mem: 3944 254 1146 0 2543 3434
Swap: 8191 0 8191
[root@instance-fx01nq4f ~]#
####################################################################
2、更改主机名以及添加hosts(db1/110、db2/111)
###设置主机名
hostnamectl set-hostname db1
hostnamectl set-hostname db2
echo "db1" >/etc/hostname
echo "db2" >/etc/hostname
###添加hosts
echo "192.168.0.116 db1">>/etc/hosts
echo "192.168.0.117 db2">>/etc/hosts
3、设置用户打开文件句柄(DB1和DB2都执行):
###编辑 /etc/security/limits.conf 文件
cat >> /etc/security/limits.conf << "EOF"
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
####################################################################
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
4、修改内核参数
cat >> /etc/sysctl.conf << "EOF"
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
EOF
5、创建用户和组
groupadd -g 5001 dba
groupadd -g 5002 asmdba
groupadd -g 5003 backupdba
groupadd -g 5004 dgdba
groupadd -g 5005 kmdba
groupadd -g 5006 racdba
groupadd -g 5007 oper
groupadd -g 5008 oinstall
/usr/sbin/useradd -u 54321 -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,racdba,oper oracle
6、创建ORACLE工作目录
mkdir -p /u01/app/oracle/{oraInventory,product/19.3.0/db}
chown -R oracle:oinstall /u01/
chmod -R 775 /u01
7、配置ORACLE环境变量
#####DB1-MASTER
vi /home/oracle/.bash_profile
###添加下面内容
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0/dbhome_1
export ORACLE_SID=db1
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
source /home/oracle/.bash_profile
#####DB2-DG
vi /home/oracle/.bash_profile
###添加下面内容
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0/dbhome_1
export ORACLE_SID=db2
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
source /home/oracle/.bash_profile
2、安装依赖包
yum install -y oracle-database-preinstall-19c binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libnsl libnsl.i686 libnsl.x86_64 libnsl2 libnsl2.i686 libnsl2.x86_64 libstdc++ libstdc++-devel libXi libXtst make sysstat java-1.8.0-openjdk*
yum update kmod-libs kmod -y
3、解压安装包
cd /u01/app/oracle/product/19.3.0/dbhome_1
unzip LINUX.X64_193000_db_home.zip
chown -R oracle:oinstall ../dbhome_1/
chmod -R +x ../dbhome_1/
4、静默安装
1、编辑rsp文件
cd $ORACLE_HOME/install/response
cp db_install.rsp /tmp
vi /tmp/db_install.rsp
修改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_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=oper
oracle.install.db.OSBACKUPDBA_GROUP=dba
oracle.install.db.OSDGDBA_GROUP=dba
oracle.install.db.OSKMDBA_GROUP=dba
oracle.install.db.OSRACDBA_GROUP=dba
oracle.install.db.config.starterdb.type=DATA_WAREHOUSE
2.静默安装Oracle软件
cd $ORACLE_HOME
./runInstaller -silent -responseFile /tmp/db_install.rsp -ignorePrereq
#########################################################
##以下是安装过程
[oracle@db1 dbhome_1]$ ./runInstaller -silent -responseFile /tmp/db_install.rsp -ignorePrereq
Launching Oracle Database Setup Wizard...
[WARNING] [INS-13014] Target environment does not meet some optional requirements.
CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2023-08-05_04-42-35PM.log
ACTION: Identify the list of failed prerequisite checks from the log: installActions2023-08-05_04-42-35PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
The response file for this session can be found at:
/u01/app/oracle/product/19.3.0/dbhome_1/install/response/db_2023-08-05_04-42-35PM.rsp
You can find the log of this install session at:
/tmp/InstallActions2023-08-05_04-42-35PM/installActions2023-08-05_04-42-35PM.log
As a root user, execute the following script(s):
1. /u01/app/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/19.3.0/dbhome_1/root.sh
Execute /u01/app/oraInventory/orainstRoot.sh on the following nodes:
[db1]
Execute /u01/app/oracle/product/19.3.0/dbhome_1/root.sh on the following nodes:
[db1]
Successfully Setup Software with warning(s).
Moved the install session logs to:
/u01/app/oraInventory/logs/InstallActions2023-08-05_04-42-35PM
################################################
[oracle@db1 dbhome_1]$ exit
logout
[root@db1 dbhome_1]# bash /u01/app/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script is complete.
[root@db1 dbhome_1]# bash /u01/app/oracle/product/19.3.0/dbhome_1/root.sh
#################################################
Check /u01/app/oracle/product/19.3.0/dbhome_1/install/root_db1_2023-08-05_16-45-20-388268452.log for the output of root script
5、配置监听
netca -silent -responseFile $ORACLE_HOME/assistants/netca/netca.rsp
lsnrctl start
lsnrctl status
ss -tnl
LISTEN 0 128 [::]:1521 [::]:*
[oracle@db1 ~]$
6、建库
cd $ORACLE_HOME/assistants/dbca
responseFileVersion=/home/oracle/rspfmt_dbca_response_schema_v19.0.0
gdbName=zhsc
sid=zhsc
databaseConfigType=SI
templateName=General_Purpose.dbc
sysPassword=oracle
oracleHomeUserPassword=oracle
totalMemory=1500
sysPassword=oracle
systemPassword=oracle
datafileDestination=/u01/app/oracle/oradata
characterSet=ZHS16GBK
nationalCharacterSet=AL16UTF16
databaseType=OLTP
执行创建库
dbca -silent -createDatabase -responseFile /tmp/dbca.rsp
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cdb_cluster_name string
cell_offloadgroup_name string
db_file_name_convert string
db_name string zhsc
db_unique_name string zhsc
global_names boolean FALSE
instance_name string zhsc
lock_name_space string
log_file_name_convert string
pdb_file_name_convert string
processor_group_name string
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string zhsc