禁用防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
禁用SELinux
cat /etc/selinux/config
-- 改成SELINUX=disabled
# 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 these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
临时关闭selinux
setenforce 0
vi /etc/sysctl.conf 添加如下内容:
kernel.msgmnb = 65536
fs.file-max = 6815744
kernel.msgmni = 2878
kernel.msgmax = 8192
kernel.msgmnb = 65536
kernel.sem = 250 32000 100 142
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.sysrq = 1
net.core.rmem_default = 1048576
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 3145728
net.ipv4.ip_local_port_range = 9000 65500
vm.min_free_kbytes = 51200
生效:
sysctl -p
vi /etc/security/limits.conf 添加如下内容:
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
vi /etc/pam.d/login
session required pam_limits.so
vi /etc/profile
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
创建组和用户
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -g oinstall -G dba oracle
如果oracle用户已经存在
/usr/sbin/usermod -g oinstall -G dba oracle
echo oracle | passwd --stdin oracle
安装依赖软件包
yum install -y gcc gcc-c++ glibc glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel libXext libXtst libX11 libXau libXi make sysstat unixODBC-devel unixODBC ksh compat-libcap1 compat-libstdc++-33
yum install -y binutils* compat-libcap1* compat-libstdc++* glibc* glibc-devel* ksh* libX11* libXau* libXi* libXtst* libaio* libaio-devel* libgcc* libstdc++* libstdc++-devel* libxcb* make* net-tools* nfs-utils* smartmontools* sysstat* unixODBC* binutils*686* compat-libcap1*686* compat-libstdc++*686* glibc*686* glibc-devel*686* ksh*686* libX11*686* libXau*686* libXi*686* libXtst*686* libaio*686* libaio-devel*686* libgcc*686* libstdc++*686* libstdc++-devel*686* libxcb*686* make*686* net-tools*686* nfs-utils*686* smartmontools*686* sysstat*686* unixODBC*686*
创建目录结构
mkdir -p /data/app/oracle
mkdir -p /data/app/oracle/admin/orcl/adump
mkdir -p /data/app/oracle/admin/orcl/dpdump
mkdir -p /data/app/oracle/admin/orcl/pfile
mkdir -p /data/app/oracle/audit
mkdir -p /data/app/oracle/cfgtoollogs/dbca/orcl
mkdir -p /data/app/oracle/oradata/orcl
mkdir -p /data/app/oracle/product/12.2.0.1/db_1/dbs
chown -R oracle:oinstall /data/app
chmod -R 775 /data/app
创建 SWAP分区
dd if=/dev/zero of=/data/swap bs=1M count=4000
mkswap /data/swap
swapon /data/swap
chmod 0600 /data/swap
设置环境变量
[oracle@ip-10-100-30-250 ~]$ vi /home/oracle/.bash_profile
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export ORACLE_BASE=/data/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0.1/db_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/bin
export PATH
修改 /etc/hosts
[root@ip-10-100-30-250 ~]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.100.30.250 ip-10-100-30-250
chown oracle:oinstall /data/software/database -R
调整应答文件模版
vi my_db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.2.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/app/oraInventory
ORACLE_HOME=/data/app/oracle/product/12.2.0.1/db_1
ORACLE_BASE=/data/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=dba
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.rac.configurationType=
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=false
oracle.install.db.racOneServiceName=
oracle.install.db.rac.serverpoolName=
oracle.install.db.rac.serverpoolCardinality=
oracle.install.db.config.starterdb.type=
oracle.install.db.config.starterdb.globalDBName=
oracle.install.db.config.starterdb.SID=
oracle.install.db.ConfigureAsContainerDB=
oracle.install.db.config.PDBName=
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=
oracle.install.db.config.starterdb.memoryLimit=16384
oracle.install.db.config.starterdb.installExampleSchemas=
oracle.install.db.config.starterdb.password.ALL=
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.password.PDBADMIN=
oracle.install.db.config.starterdb.managementOption=
oracle.install.db.config.starterdb.omsHost=
oracle.install.db.config.starterdb.omsPort=
oracle.install.db.config.starterdb.emAdminUser=
oracle.install.db.config.starterdb.emAdminPassword=
oracle.install.db.config.starterdb.enableRecovery=
oracle.install.db.config.starterdb.storageType=
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
COLLECTOR_SUPPORTHUB_URL=
安装Oracle软件
[oracle@ip-10-100-30-250 response]$ pwd
/data/software/database
chown oracle:oinstall /data/software/database/response/my_db_install.rsp
chmod 700 /data/software/database/response/my_db_install.rsp
[oracle@ip-10-100-30-250 database]$ ./runInstaller -silent -force -ignorePrereq -responseFile /data/software/database/response/my_db_install.rsp
当出现:
As a root user, execute the following script(s):
1. /data/app/oraInventory/orainstRoot.sh
2. /data/app/oracle/product/12.2.0.1/db_1/root.sh
Successfully Setup Software.
切换到root用户执行一下提示的脚本
确认执行
成功。到此已经静默的安装了Oracle软件。
静默配置监听
[oracle@ip-10-100-30-250 database]$ netca -silent -responsefile /data/software/database/response/netca.rsp
静默创建数据库
创建数据文件存放位置
mkdir -p /data/oradata
chown oracle:oinstall /data/oradata
dbca -silent -createDatabase -templateName General_Purpose.dbc
-gdbname orcl -sid orcl
-responseFile NO_VALUE
-sysPassword Oracle12Cr2
-systemPassword Oracle12Cr2
-emConfiguration NONE
-recoveryAreaDestination NONE
-datafileDestination /data/oradata
-redoLogFileSize 200
-sampleSchema false
-automaticMemoryManagement false
-initParams processes=500,audit_trail=NONE
-characterSet AL32UTF8
-nationalCharacterSet AL16UTF16
-memoryPercentage 50
参数说明:
1. gdbname表示全局数据库名称
2. sid表示数据库实例名,单实例环境下sid默认跟service_name一样
3. –responseFile应答文件,这里没有用所以是NO_VALUE
4. SysPassword, systemPassword 分别是sys,system用户的密码
5. –emConfiguration ,recoveryAreaDestination这里是关闭了OEM,闪回区的功能,现网的使用中一般都不会开启这些功能
6. DatafileDestination表示数据文件存放位置
7. redoLogFileSize 重做日志的大小,单位是M,默认只有50M,应该根据实际需要进行调整,这里调整为200M
8. sampleSchema 是否需要创建示例用户(SCOTT,SH,…)
9. automaticMemoryManagement 是否启用内存自动管理
10. initParams后面可以跟多个参数=值的形式,用逗号间隔,这里测试了调整数据库连接数和关闭数据库审计功能两个参数,可以根据需要配置需要的参数。
11. characterSet 设置字符集,数据库创建完成后,就不可以调整了,或者说调整非常困难,因此一定要在执行前确认好使用哪种字符集
12. nationalCharacterSet 设置国家字符集
13. memoryPercentage设置Oracle总共使用服务器的物理内存百分比
登录验证:
set linesize 500
set pagesize 999
col COMP_ID for a20
col comp_name for a40
col VERSION for a20
col STATUS for a20
select comp_id,comp_name,version,status from sys.dba_registry;
COMP_ID COMP_NAME VERSION STATUS
-------------------- ---------------------------------------- -------------------- --------------------
CATALOG Oracle Database Catalog Views 12.2.0.1.0 VALID
CATPROC Oracle Database Packages and Types 12.2.0.1.0 VALID
JAVAVM JServer JAVA Virtual Machine 12.2.0.1.0 VALID
XML Oracle XDK 12.2.0.1.0 VALID
CATJAVA Oracle Database Java Packages 12.2.0.1.0 VALID
APS OLAP Analytic Workspace 12.2.0.1.0 VALID
RAC Oracle Real Application Clusters 12.2.0.1.0 OPTION OFF
XDB Oracle XML Database 12.2.0.1.0 VALID
OWM Oracle Workspace Manager 12.2.0.1.0 VALID
CONTEXT Oracle Text 12.2.0.1.0 VALID
ORDIM Oracle Multimedia 12.2.0.1.0 VALID
SDO Spatial 12.2.0.1.0 VALID
XOQ Oracle OLAP API 12.2.0.1.0 VALID
OLS Oracle Label Security 12.2.0.1.0 VALID
DV Oracle Database Vault 12.2.0.1.0 VALID
15 rows selected.
查看监听状态
[oracle@ip-10-100-30-250 response]$ lsnrctl status