1、创建系统和磁盘空间
fdisk /dev/vdb
pvcreate /dev/vdb1
vgcreate datavg /dev/vdb1
lvcreate -n oraclelv -L 500G /dev/datavg
lvcreate -n datalv -l 100%Free /dev/datavg
mkfs.ext4 /dev/datavg/oraclelv
添加交换分区
fdisk /dev/vdc (82 Linux swap / So)
mkswap /dev/vdc1
swapon /dev/vdc1
2、上传安装包和补丁
mkdir -p /oracle/app/product && cd /oracle/app/product
mkdir -p /oracle/soft
scp oracle19c_19.5/LINUX.X64_193000_db_home.zip /oracle/soft/
unzip /oracle/soft/LINUX.X64_193000_db_home.zip -d /oracle/app/product
scp libstdc++33-3.3.3-63.1.x86_64.rpm /oracle/soft/
scp oracle19c_19.5/p30125133_1900000_Linux-x86-64.zip /oracle/soft/
scp oracle19c_19.3/p6880880_190000_Linux-x86-64.zip /oracle/soft/
3、创建用户和配置参数
3.1 创建用户
groupadd oinstall && groupadd dba && useradd -g oinstall -G dba -m oracle && usermod -g oinstall -G dba oracle
passwd oracle
3.2 修改内核参数: 写一个自动修改参数的脚本
cat >> /etc/sysctl.conf <<EOF
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 7549747
kernel.shmmax = 30923764531
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
kernel.panic_on_oops = 1
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
vm.hugetlb_shm_group = 1000
EOF
执行sysctl -p 命令使以上设置生效
--------------------------------------------------------------------------------
#### 说明:
“shmmax”定义单个共享内存段的最大值,单位为字节。
“shmall”定义系统可以使用的共享内存总量,单位为页(一页=4KB),建议配置为单板的总内存大小。如
果“shmall”配置为“4194304”,即4194304*4KB/1024/1024=16GB,则用户创建超过16GB的共享内存会失
败。
shmall=是全部允许使用的共享内存大小,shmmax 是单个段允许使用的大小。这两个可以设置为内存的 90%。
例如 16G 内存,16*1024*1024*1024*90% = 15461882265,shmall 的大小为
15461882265/4k(getconf PAGESIZE可得到) = 3774873
---------------------------------------------------------------------------------
3.3 修改“/etc/sysctl.conf”文件,以分配16G内存为例
# vi /etc/sysctl.conf
在“sysctl.conf”中修改如下参数值为加粗部分。
kernel.shmall = 3774873
kernel.shmmax = 15461882265
fs.file-max = 655350
--16g内存参数
kernel.shmall = 3774873
kernel.shmmax = 15461882265
--32g内存参数
kernel.shmall = 7549747
kernel.shmmax = 30923764531
--64g内存参数
kernel.shmall = 15099494
kernel.shmmax = 61847529062
fs.file-max = 655350
3.4 修改系统参数
cat >> /etc/security/limits.conf <<EOF
oracle soft nproc 4096
oracle hard nproc 16384
oracle soft nofile 2048
oracle hard nofile 65536
oracle soft stack 10240
EOF
3.5 oracle用户配置变量:
#suse
cat >> /home/oracle/.profile <<"EOF"
# Oracle Settings
umask 022
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
export ORACLE_BASE=/oracle/app
export ORACLE_HOME=$ORACLE_BASE/product
export ORACLE_SID=ORCL
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/OPatch:.
export JAVA_HOME=$ORACLE_HOME/jdk
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
EOF
#centos
cat >> /home/oracle/.bash_profile <<"EOF"
export ORACLE_SID=ORCL
export ORACLE_HOME=/oracle/app/product
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/OPatch:.
export JAVA_HOME=$ORACLE_HOME/jdk
set -o vi
EOF
chown oracle.oinstall /home/oracle/.profile
-------------------------------------------------------------
配置客户端图形界面(此IP为安装oracle所用的客户端IP,而不是oracle服务器的IP)
DISPLAY=192.168.1.100:0.0; export DISPLAY
-------------------------------------------------------------
4、配置镜像源
# 配置 suse12 镜像源
cat > /etc/zypp/repos.d/suse12_sp5_x64_dvd1.repo <<EOF
[suse12_sp5_x64_dvd1]
enabled=1
autorefresh=0
baseurl=http://mirrors.com/install/suse/suse12_sp5_x64_dvd1/ (镜像源自行寻找)
type=yast2
gpgcheck=0
EOF
cat > /etc/zypp/repos.d/suse12_sp5_x64_dvd2.repo <<EOF
[suse12_sp5_x64_dvd2]
enabled=1
autorefresh=0
baseurl=http://mirrors.com/install/suse/suse12_sp5_x64_dvd1/ (镜像源自行寻找)
type=yast2
gpgcheck=0
EOF
# centos 镜像源
# mkdir /etc/yum.repos.d/backup
# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup
# cat >> /etc/yum.repos.d/CentOS-Base.repo <<EOF
[base]
enabled=1
baseurl=http://mirrors.com/install/centos/7/os/x86_64/ (镜像源自行寻找)
gpgcheck=0
[update]
baseurl=http://mirrors.com/install/centos/7/extras/x86_64/ (镜像源自行寻找)
enabled=1
gpgcheck=0
[extras]
baseurl=http://mirrors.com/install/centos/7/extras/x86_64/ (镜像源自行寻找)
enabled=1
gpgcheck=0
[centosplus]
baseurl=http://mirrors.com/install/centos/7/centosplus/x86_64/ (镜像源自行寻找)
enabled=1
gpgcheck=0
EOF
5、安装依赖包
zypper install sysstat libstdc* libaio* libcap* libXtst6*
yum install -y sysstat libstdc* libaio* libcap* libXtst6* ksh
# chown oracle.oinstall /oracle/ -R
6、安装oracle
su - oracle
cd /oracle/app/product>
./runInstaller
sys/system Orcl1234
---------------------------------------
# /oracle/oraInventory/orainstRoot.sh
# /oracle/app/product/root.sh
7、安装补丁
停止数据库:
一:升级OPatch:
# unzip p6880880_190000_Linux-x86-64.zip -d p6880880_190000_Linux-x86-64
> mv /oracle/app/product/OPatch /oracle/app/product/OPatch_bak
> cp -rf /oracle/soft/p6880880_190000_Linux-x86-64/OPatch /oracle/app/product/
检查:
:~> cat .profile
export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/OPatch:.
oracle@dggphispra19593:/oracle> /oracle/app/product/OPatch/opatch version
OPatch Version: 12.2.0.1.19
OPatch succeeded.
二:升级补丁
> unzip p30116789_190000_Linux-x86-64.zip -d p30116789_190000_Linux-x86-64
> cd /oracle/soft/p30116789_190000_Linux-x86-64/30116789/30125133
> opatch apply
以下表示升级成功:
......
Patching component oracle.nlsrtl.rsf.core, 19.0.0.0.0...
Patching component oracle.precomp.common, 19.0.0.0.0...
Patching component oracle.precomp.lang, 19.0.0.0.0...
Patch 30125133 successfully applied.
Sub-set patch [29517242] has become inactive due to the application of a super-set patch [30125133].
Please refer to Doc ID 2161861.1 for any possible further required actions.
Log file location: /oracle/app/product/cfgtoollogs/opatch/opatch2020-03-17_19-58-57PM_1.log
注:还要以下两步才正式升级成功
(1)
> sqlplus /nolog
SQL> Connect / as sysdba
SQL> startup
SQL> quit
cd $ORACLE_HOME/OPatch
oracle@dggphispra19593:/oracle/app/product/OPatch> ./datapatch -verbose
(2)
> cd $ORACLE_HOME/rdbms/admin
> sqlplus /nolog
SQL> conn /as sysdba
SQL> @utlrp.sql
检查升级结果:
select * from dba_registry_history;
查出以下内容表示成功
Patch applied from 19.3.0.0.0 to 19.5.0.0.0: Release_Update – 190909180549