安装Oracle18c内核最低为
3.10.0-123.el7.x86_64
通过命令查看 uname -a
3.10.0-123.el7.x86_64
安装依赖包
yum install bc ,binutils-2.23.52.0.1-12.el7.x86_64 ,compat-libcap1-1.10-3.el7.x86_64,compat-libstdc++-33-3.2.3-71.el7.i686,compat-libstdc++-33-3.2.3-71.el7.x86_64,glibc-2.17-36.el7.i686,glibc-2.17-36.el7.x86_64,glibc-devel-2.17-36.el7.i686,glibc-devel-2.17-36.el7.x86_64,ksh,libaio-0.3.109-9.el7.i686,libaio-0.3.109-9.el7.x86_64,libaio-devel-0.3.109-9.el7.i686,libaio-devel-0.3.109-9.el7.x86_64,libX11-1.6.0-2.1.el7.i686,libX11-1.6.0-2.1.el7.x86_64,libXau-1.0.8-2.1.el7.i686,libXau-1.0.8-2.1.el7.x86_64,libXi-1.7.2-1.el7.i686,libXi-1.7.2-1.el7.x86_64,libXtst-1.2.2-1.el7.i686,libXtst-1.2.2-1.el7.x86_64,libXrender-devel-0.9.10-1.el7.i686,libXrender-devel-0.9.10-1.el7.x86_64,libXrender-0.9.10-1.el7.i686,libXrender-0.9.10-1.el7.x86_64,libgcc-4.8.2-3.el7.i686,libgcc-4.8.2-3.el7.x86_64,libstdc++-4.8.2-3.el7.i686,libstdc++-4.8.2-3.el7.x86_64,libstdc++-devel-4.8.2-3.el7.i686,libstdc++-devel-4.8.2-3.el7.x86_64,libxcb-1.9-5.el7.i686,libxcb-1.9-5.el7.x86_64,make-3.82-19.el7.x86_64 make-3.82-19.el7.x86_64,nfs-utils-1.3.0-0.21.el7.x86_64,net-tools-2.0-0.17.20131004git.el7 ,python-2.7.5-34.0.1.el7 ,python-configshell-1.1.fb18-1.el7.noarch,python-rtslib-2.1.fb57-3.el7.noarch ,python-six-1.9.0-2.el7.noarch,smartmontools-6.2-4.el7.x86_64,sysstat-10.1.5-1.el7.x86_64,targetcli-2.1.fb41-3.el7.noarch
创建Oracle用户和组
groupadd -g 12345 oinstall
groupadd -g 12346 dba
# /usr/sbin/useradd -u 12345 -g oinstall -G dba oracle # GID
如果已经创建的Oracle用户使用加入组
usermod -a -G oinstall,dba oracle
将oinstall设为主组
usermod -g oinstall oracle
passwd oracle
关闭seLinux和防火墙
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
修改内核参数
echo ' kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 fs.file-max = 6815744 fs.aio-max-nr = 1048576 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.swappiness = 0 vm.dirty_background_ratio = 3 vm.dirty_ratio = 80 vm.dirty_expire_centisecs = 500 vm.dirty_writeback_centisecs = 100 vm.min_free_kbytes=262144 ' >> /etc/sysctl.conf
修改Linux限制
echo 'oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536' >>/etc/security/limits.conf
vim /etc/pam.d/login 找到这一行:session required pam_namespace.so ,在其下一行添加一条pam_limits.so
session required pam_limits.so
创建Oracle_home和Oracle_base路径
mkdir -p /u01/app/oracle/product/18c
chown -R oracle.oinstall /u01
$su - oracle //进入oracle用户模式下
设置Oracle环境变量
echo "ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/18c
ORACLE_SID=bbll
PATH=$ORACLE_HOME/bin:$PATH" >>.bash_profile
环境变量生效
source .bash_profile
上传安装包
unzip -d /u01/app/oracle/product/18c
chown -R oracle.oinstall /u01
修改db_install.rsp文件,安装Oracle软件
/u01/app/oracle/product/18c/runInstaller -silent -responseFile /u01/app/oracle/product/18c/install/response/db_install.rsp
创建监听
netca /silent /responseFile /u01/app/oracle/product/18c/assistants/netca/netca.rsp
创建数据库
dbca -silent -createDatabase -responseFile /u01/app/oracle/product/18c/assistants/dbca/dbca.rsp
修改当前环境变量
. oraenv
1.创建实例配置文件
$cd $ORACLE_HOME/dbs
$cp initorcl.ora initbbll.ora
$vi initbbll.ora
db_name='bbll'
vcenter.__java_pool_size=402653184
vcenter.__large_pool_size=134217728
vcenter.__oracle_base='/opt/11g/oracle'
vcenter.__pga_aggregate_target=11341398016
vcenter.__sga_target=34024194048
vcenter.__shared_io_pool_size=0
vcenter.__shared_pool_size=7985954816
vcenter.__streams_pool_size=67108864
*.audit_file_dest='/opt/11g/oracle/admin/bbll/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files = (ora_control3, ora_control4)
*.db_block_size=8192
*.db_domain=''
*.db_name='bbll'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=YFZD2XDB)'
*.local_listener=''
*.open_cursors=300
*.pga_aggregate_target=11333009408
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=34001125376
*.undo_tablespace='UNDOTBS1'
2.创建实例相关目录
$cd $ORACLE_BASE
$cd admin
$mkdir bbll
$cd bbll
$mkdir adump bdump cdump pfile udump
$mkdir -p /u01/app/oracle/fast_recovery_area/BBLL
3.创建vcenter数据文件
cd /u01/app/oracle/oradata
mkdir BBLL
4.启动实例
$ . oraenv
ORACLE_SID = [cdb] ? bbll
ORACLE_HOME = [/home/oracle] ? /u01/app/oracle/product/18c
The Oracle base remains unchanged with value /u01/app/oracle
$sqlplus /nolog
sql>conn /as sysdba;
sql>startup nomount;
sql>select instance_name from v$instance; //正常启动后执行语句可以看到运行的实例
sql>exit
5.创建密码文件
$$ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapwbbll password=yourpassword force=y //文件生成在$ORACLE_HOME/dbs目录下
6.创建数据库脚本如下,进入到sql界面执行下面语句
sql>
CREATE DATABASE bbll
USER SYS IDENTIFIED BY sys
USER SYSTEM IDENTIFIED BY manager
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/bbll/redo01.log') SIZE 100M,
GROUP 2 ('/u01/app/oracle/oradata/bbll/redo02.log') SIZE 100M,
GROUP 3 ('/u01/app/oracle/oradata/bbll/redo03.log') SIZE 100M
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
MAXINSTANCES 1
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
DATAFILE '/u01/app/oracle/oradata/bbll/system01.dbf' SIZE 325M REUSE
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/app/oracle/oradata/bbll/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE tbs_1 datafile '/u01/app/oracle/oradata/bbll/tbs_1.dbf' size 50m
DEFAULT TEMPORARY TABLESPACE temp
TEMPFILE '/u01/app/oracle/oradata/bbll/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/bbll/undotbs1.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
//其中UNDO TABLESPACE undotbs1必须与实例配置文件中的名字完全一样
sql>select status from v$instance;
//status为open表示成功
//运行后续脚本,创建数据字典及相关视图
SQL>conn sys as sysdba
SQL>@?/rdbms/admin/catalog.sql;
//此过程可能需要10分钟左右
SQL>@?/rdbms/admin/catproc.sql;
/此过程可能需要15分钟左右
SQL>@?/rdbms/admin/catblock.sql;
SQL>@?/rdbms/admin/catoctk.sql;
SQL>@?/rdbms/admin/owminst.plb;
SQL>conn system/ manager
SQL>@?/sqlplus/admin/pupbld.sql;
SQL>@?/sqlplus/admin/help/hlpbld.sql helpus.sql
//配置listener.ora和tnsnames.ora,这两个文件在$ORACLE_HOME/network/admin目录下
listener.ora
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME = bbll)
(ORACLE_HOME = /u01/app/oracle/product/18c)
(SID_NAME = bbll)
)
)
tnsnames.ora
vcenter =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bbll)
)
)
配置安装EM express
SQL> exec dbms_xdb_config.sethttpport(5500);
安装rlwrap命令,使Oracle中可以上下切换命令行
wget http://rpmfind.net/linux/epel/7/x86_64/Packages/r/rlwrap-0.43-2.el7.x86_64.rpm
rpm -ivh rlwrap-0.43-2.el7.x86_64.rpm
rlwrap sqlplus / as sysdba