oracle19c数据库安装相对于oracle12c安装还是有些不一样的,所以今天再来记录一下安装过程,本次安装仍然是基于Oracle linux7.6环境来安装,仅供参考
(1)关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
(2)禁用SElinux
执行vim /etc/selinux/config修改编辑config文件,将SELINUX设置成disabled,如下所示
(3)编辑hosts和hostname文件
执行vim /etc/hostname,添加如下内容
jamysong
执行vim /etc/hosts,添加如下内容,这里192.168.227.75地址可以通过执行ifconfig查询到
192.168.227.75 jamysong
然后执行init 6重启后,可以看到修改已经生效
然后执行init 6重启oracle linux,可以看到如下所示
(4)禁用透明 HugePages
vim /etc/default/grub,在GRUB_CMDLINE_LINUX参数的末尾添加transparent_hugepage=never。编辑如下所示
使用修改后的配置生成/boot/grub2/grub.cfg文件,执行grub2-mkconfig -o /boot/grub2/grub.cfg
执行init 6重启 oracle linux以使更改生效
执行cat /sys/kernel/mm/transparent_hugepage/enabled查看,如下图所示说明已经禁用HugePages
(5)安装依赖包
yum install -y \
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
yum install -y \
net-tools \
gcc \
gcc-c++ \
gcc-info \
gcc-locale \
gcc48 \
gcc48-info \
gcc48-locale \
gcc48-c++
(6)创建用户和用户组
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
echo "oracle" | passwd oracle --stdin
(7)为 Oracle 用户设置安全限制
执行以下命令编辑30-oracle.conf文件,设置oracle用户的安全限制
cat >/etc/security/limits.d/30-oracle.conf<<EOF
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
oracle hard memlock 134217728
oracle soft memlock 134217728
EOF
(8)修改linux内核参数
执行以下命令编辑98-oracle.conf文件
cat >/etc/sysctl.d/98-oracle.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
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
EOF
然后执行sysctl --system命令重新加载内核参数
(9)为 Oracle Database 19c 创建目录
mkdir -p /u01/app/oracle/product/19.3.0/dbhome_1
mkdir -p /u01/oradata
chown -R oracle:oinstall /u01
chmod -R 775 /u01
(10)为 Oracle 用户配置 Linux 环境变量
执行su oracle切换到oracle用户下,然后执行vim ~/.bash_profile命令设置环境变量
# Oracle Settings
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=jamysong
export ORACLE_UNQNAME=cdb1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0/dbhome_1
export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_SID=orcl
export PDB_NAME=pdb1
export DATA_DIR=/u01/oradata
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
编辑完成后,执行source ~/.bash_profile,使oracle用户环境变量生效。
(11)上传oracle19c二进制安装文件
将oracle19c二进制安装文件上传至/usr/local/src目录下并执行以下命令解压文件至安装目录
unzip LINUX.X64_193000_db_home.zip -d $ORACLE_HOME
在oracle用户下,执行cd $ORACLE_HOME命令切换到oracle安装目录下,然后执行数据库安装命令
./runInstaller -ignorePrereq -waitforcompletion -silent \
oracle.install.option=INSTALL_DB_SWONLY \
ORACLE_HOSTNAME=${ORACLE_HOSTNAME} \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=${ORA_INVENTORY} \
ORACLE_HOME=${ORACLE_HOME} \
ORACLE_BASE=${ORACLE_BASE} \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSBACKUPDBA_GROUP=backupdba \
oracle.install.db.OSDGDBA_GROUP=dgdba \
oracle.install.db.OSKMDBA_GROUP=kmdba \
oracle.install.db.OSRACDBA_GROUP=racdba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true
如下图所示表示安装数据库软件成功
然后切换到root用户下,执行以下两个脚本
sh /u01/app/oraInventory/orainstRoot.sh
sh /u01/app/oracle/product/19.3.0/dbhome_1/root.sh
执行su oracle命令切换到oracle用户,使用以下命令启动监听
lsnrctl start //启动oracle数据库监听
lsnrctl status //查看oracle数据库监听状态
lsnrctl stop //停用oracle数据库监听
执行以下命令创建数据库
dbca -silent -createDatabase \
-templateName General_Purpose.dbc \
-gdbname ${ORACLE_SID} -sid ${ORACLE_SID} \
-responseFile NO_VALUE \
-characterSet AL32UTF8 \
-sysPassword 123456 \
-systemPassword 123456 \
-createAsContainerDatabase true \
-numberOfPDBs 1 \
-pdbName ${PDB_NAME} \
-pdbAdminPassword 123456 \
-databaseType MULTIPURPOSE \
-automaticMemoryManagement false \
-totalMemory 800 \
-storageType FS \
-datafileDestination "${DATA_DIR}" \
-redoLogFileSize 50 \
-emConfiguration NONE \
-ignorePreReqs
创建数据库过程如下:
[oracle@jamysong dbhome_1]$ dbca -silent -createDatabase \
> -templateName General_Purpose.dbc \
> -gdbname ${ORACLE_SID} -sid ${ORACLE_SID} \
> -responseFile NO_VALUE \
> -characterSet AL32UTF8 \
> -sysPassword 123456 \
> -systemPassword 123456 \
> -createAsContainerDatabase true \
> -numberOfPDBs 1 \
> -pdbName ${PDB_NAME} \
> -pdbAdminPassword 123456 \
> -databaseType MULTIPURPOSE \
> -automaticMemoryManagement false \
> -totalMemory 800 \
> -storageType FS \
> -datafileDestination "${DATA_DIR}" \
> -redoLogFileSize 50 \
> -emConfiguration NONE \
> -ignorePreReqs
[WARNING] [DBT-06208] The 'SYS' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'SYSTEM' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'PDBADMIN' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
53% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/orcl.
Database Information:
Global Database Name:orcl
System Identifier(SID):orcl
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
然后使用sqlplus / as sysdba登录数据库
创建用户
create user c##jamy identified by 123456;
给用户授权
grant connect, resource,dba to c##jamy;
可以登录服务器端执行如下命令:
查看数据库监听
lsnrctl status
如果没有开启监听,需要执行 lsnrctl start 开启监听
如下图所示表示已开启监听
开启监听以后执行 sqlplus / as sysdba
最后执行startup 来启动数据库实例,然后用数据库客户端就可以连接了