1. 说明

Oracle 18c已经出来一段时间了,现在官网可以下载Client,但是还没有Database和Grid的下载链接。不过可以通过​​https://edelivery.oracle.com来下载​​​

Oracle 18c单实例安装_linux

2. 内存要求

Database:最少1G,推荐大小8G。

Grid:最少8G。—要求更高了

Oracle 18c单实例安装_linux_02

3. 配置操作系统参数

任选其一操作即可

3.1. 通过Oracle的RPM包来配置操作系统

如果你的操作系统是Oracle Linux或者RedHat Linux,那么你可以通过Oracle RPM包来完成绝大部分的操作系统的配置。Oracle Linux5.2及以上版本有该RPM包。

RPM包干的事情:

    Automatically downloads and installs any additional RPM packages needed for installing Oracle Grid Infrastructure and Oracle Database, and resolves any dependencies
 Creates an oracle user, and creates the oraInventory (oinstall) and OSDBA (dba) groups for that user
 As needed, sets sysctl.conf settings, system startup parameters, and driver parameters to values based on recommendations from the Oracle RDBMS Pre-Install program
 Sets hard and soft resource limits
 Sets other recommended parameters, depending on your kernel version

—安装RPM包


# yum install oracle-database-server-18c-preinstall

注:官方还没放出18c的RPM包,不过可以使用12cR2的RPM。


3.2. 手动配置

3.2.1. 配置/etc/hosts

[root@18c software]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain

192.168.1.178 18c

3.2.2. 添加用户和组

/usr/sbin/groupadd -g 54321 oinstall
/usr/sbin/groupadd -g 54322 dba
/usr/sbin/groupadd -g 54323 oper
/usr/sbin/useradd -u 54321 -g oinstall -G dba,oper oracle

3.2.3. 关闭防火墙/SELINUX

—关闭防火墙


[root@18c software]# systemctl stop firewalld
[root@18c software]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

—关闭SELINUX(需重启)

[root@18c software]# vi /etc/selinux/config
[root@18c software]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

临时:

[root@18c software]# setenforce 0
[root@18c software]# getenforce
Permissive

3.2.4. 创建目录

mkdir -p /u01/app/oracle/product/18.1.0/dbhome_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01/

3.2.5. 配置ORACLE用户环境变量

ORACLE_SID=lei;export ORACLE_SID  
ORACLE_UNQNAME=zqlei;export ORACLE_UNQNAME
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/18.1.0/dbhome_1; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="YYYY:MM:DDHH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=american_america.ZHS16GBK; export NLS_LANG
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin:$ORA_CRS_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
umask 022

3.2.6. 配置资源限制

—limit

[root@18c ~]# vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle soft memlock 3145728
oracle hard memlock 3145728

—sysctl

[root@rac1 ~]# vim /etc/sysctl.conf 
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

3.2.7. 安装必要的包

yum install binutils gcc gcc-c++  compat-libstdc++-33 glibc  glibc.i686  glibc-devel  ksh libgcc.i686   libstdc++-devel  libaio  libaio.i686  libaio-devel  libaio-devel.i686  libXtst  libXtst.i686  libX11  libX11.i686 libXau  libXau.i686  libxcb  libxcb.i686  libXi  libXi.i686  make  sysstat  compat-libcap1 –y

compat-libstdc++-33这个包镜像里可能没有,需要单独下载

​http://www.rpmfind.net/linux/centos/7.5.1804/os/x86_64/Packages/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm​​​

  1. 安装

和12c一样,直接解压到ORACLE_HOME下,然后运行runinstaller安装即可

4.1. 解压

[oracle@18c software]$ unzip -d /u01/app/oracle/product/18.1.0/dbhome_1/ 
OracleDatabase18.0.0.0.0LinuxX86_64.zip

4.2. 运行Runinstaller

[oracle@18c dbhome_1]$ ./runInstaller

Oracle 18c单实例安装_sql_03

略…

Oracle 18c单实例安装_linux_04

4.3. DBCA建库

和12c没有区别

注意:​ 由于当前限制只能在Exdata上安装,所以会报错ORA-12754

Oracle 18c单实例安装_oracle_05

解决方法:

解决Oracle 18c无法安装实例的方法—ORA-12754:如下

1. 说明

由于当前18c仅支持安装在Exdata环境下,无法通过DBCA来创建数据库。所以可以通过手动创建,然后修改参数文件。

2. 创建初始化参数文件

一定要添加这个参数*._exadata_feature_on=true


[oracle@18c dbs]$ vi initlei.ora
lei.__data_transfer_cache_size=0
lei.__db_cache_size=385875968
lei.__inmemory_ext_roarea=0
lei.__inmemory_ext_rwarea=0
lei.__java_pool_size=16777216
lei.__large_pool_size=33554432
lei.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
lei.__pga_aggregate_target=822083584
lei.__sga_target=2449473536
lei.__shared_io_pool_size=117440512
lei.__shared_pool_size=486539264
lei.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/lei/adump'
*.audit_trail='db'
*.compatible='18.1.0'
*.control_files='/u01/app/oracle/oradata/lei/control01.ctl','/u01/app/oracle/oradata/lei/control02.ctl'
*.db_block_size=8192
*.db_name='lei'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=leiXDB)'
*.enable_pluggable_database=true
*.local_listener='LISTENER'
*.nls_language='SIMPLIFIED CHINESE'
*.nls_territory='CHINA'
*.open_cursors=300
*.pga_aggregate_target=314572800
*.processes=320
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_max_size=1048576000
*.sga_target=1048576000
*.undo_tablespace='UNDOTBS1'
*._exadata_feature_on=true --主要是加这个参数

3. 创建必要的目录

[oracle@18c ~]$ mkdir -p /u01/app/oracle/admin/lei/adump
[oracle@18c ~]$ mkdir -p /u01/app/oracle/oradata/lei/
[oracle@18c ~]$ mkdir -p /u01/app/oracle/oradata/pdbseed/

4. 启动到nomount

SQL> startup nomount
ORACLE instance started.

Total System Global Area 1048575224 bytes
Fixed Size 8903928 bytes
Variable Size 377487360 bytes
Database Buffers 658505728 bytes
Redo Buffers 3678208 bytes

5. 创建CDB数据库

CREATE DATABASE lei
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/lei/redo01.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/app/oracle/oradata/lei/redo02.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/app/oracle/oradata/lei/redo03.log') SIZE 100M BLOCKSIZE 512
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/lei/system01.dbf' SIZE 700M
SYSAUX DATAFILE '/u01/app/oracle/oradata/lei/sysaux01.dbf' SIZE 550M
DEFAULT TABLESPACE users
DATAFILE '/u01/app/oracle/oradata/lei/users01.dbf' SIZE 500M
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/lei/temp01.dbf' SIZE 20M
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/lei/undotbs01.dbf' SIZE 200M
ENABLE PLUGGABLE DATABASE
SEED
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/lei/', '/u01/app/oracle/oradata/pdbseed/')
SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
SYSAUX DATAFILES SIZE 100M
USER_DATA TABLESPACE usertbs
DATAFILE '/u01/app/oracle/oradata/pdbseed/usertbs01.dbf' SIZE 200M;

6. 执行脚本

如果创建了PDB,需要切换到PDB中再执行一遍,要不会造成一些数据字典无法访问的情况:

​https://www.cndba.cn/Expect-le/article/2875​​​


SQL> @?/rdbms/admin/catalog.sql    --数据库字典,动态视图创建等
SQL> @?/rdbms/admin/catproc.sql --PL/SQL存过过程相关代码
SQL> @?/rdbms/admin/utlrp.sql --编译

—使用SYSTEM用户执行以下脚本

SQL> @?/sqlplus/admin/pupbld.sql   #SQL*Plus相关

7. 验证

SQL> select open_mode from v$database;

OPEN_MODE
----------------------------------------
READ WRITE

SQL> show pdbs;

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
BANNER_FULL
--------------------------------------------------------------------------------
BANNER_LEGACY
--------------------------------------------------------------------------------
CON_ID
----------
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.1.0.0.0
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
0


1 row selected.