参考博客:CentOS7使用命令行安装Oracle11GR2 - 倾听-静轩水月 - 博客园 (cnblogs.com)
1、下载安装文件
这里用XFTP工具将安装包复制到/opt/install目录下
2、关闭防火墙
操作用户:root
systemctl disable firewalld
systemctl stop firewalld
3、安装依赖包
操作用户:root
yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
4、验证依赖包
操作用户:root
rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel
5、创建oracle用户
操作用户:root
groupadd -g 502 oinstall
groupadd -g 503 dba
groupadd -g 504 oper
groupadd -g 505 asmadmin
useradd -u 502 -g oinstall -G oinstall,dba,asmadmin,oper -s /bin/bash -m oracle
passwd oracle
6、创建oradata目录,解压Oracle安装包
将文件解压在根目录下
[root@localhost ~]# mkdir /oradata
将文件复制到oradata目录下
[root@localhost install]# cp p10404530_112030_Linux-x86-64_* /oradata/
修改文件属主和属组
[root@localhost oradata]# chown -R oracle:oinstall /oradata
安装unzip
[root@localhost oradata]# yum install -y unzip
切换为oracle用户
[root@localhost oradata]# su - oracle
[oracle@localhost ~]$ cd /oradata
[oracle@localhost oradata]$ ll
total 2442044
-rw-r--r--. 1 oracle oinstall 1358454646 Dec 12 23:04 p10404530_112030_Linux-x86-64_1of7.zip
-rw-r--r--. 1 oracle oinstall 1142195302 Dec 12 23:04 p10404530_112030_Linux-x86-64_2of7.zip
解压安装包
[oracle@localhost oradata]$ unzip p10404530_112030_Linux-x86-64_1of7.zip
[oracle@localhost oradata]$ unzip p10404530_112030_Linux-x86-64_2of7.zip
全部解压完成后生成database文件夹。
7、修改系统配置
操作用户:root - 编辑配置
[root@localhost ~]# vi /etc/security/limits.conf
添加如下配置:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
8、配置oracle安装目录
操作用户:oracle - 创建oracle11g文件
[root@localhost ~]# su oracle
[oracle@localhost root]$ mkdir -p /oradata/soft/oracle11g
[oracle@localhost root]$ cd /oradata/soft/oracle11g
[oracle@localhost oracle11g]$ pwd
/oradata/soft/oracle11g
返回home目录,修改配置文件
[oracle@localhost oracle11g]$ cd
[oracle@localhost ~]$ pwd
/home/oracle
[oracle@localhost ~]$ vi .bash_profile
打开配置文件,从第13行开始添加如下代码:
export ORACLE_BASE=/oradata/soft/oracle11g
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.3/dbhome_1
export ORACLE_SID=prod
export NLS_LANG=.AL32UTF8
export PATH=${PATH}:${ORACLE_HOME}/bin:$ORACLE_HOME/lib64
将变量配置设置为系统配置
[oracle@localhost /]$ su root
Password:
[root@localhost /]# vi /etc/profile
在系统配置文件中添加配置文件
使环境变量生效
[oracle@localhost ~]$ source .bash_profile
9、修改安装配置文件
[oracle@localhost ~]$ cd oradata/database/response/
[oracle@localhost response]$ ls
dbca.rsp db_install.rsp netca.rsp
[oracle@localhost response]$ cp ./db_install.rsp /oradata/
拷贝安装文件db_install.rsp到/oradata目录下
创建oraInventory文件夹
[root@localhost ~]# cd /oradata/soft
[root@localhost soft]# mkdir oraInventort
[root@localhost oraInventory]# pwd
/oradata/soft/oraInventory
回到oradata文件夹
编辑配置文件db_install.rsp
[oracle@localhost oradata]$ vim db_install.rsp
29 oracle.install.option=INSTALL_DB_AND_CONFIG
37 ORACLE_HOSTNAME=192.168.78.142
42 UNIX_GROUP_NAME=oinstall
49 INVENTORY_LOCATION=/oradata/soft/oraInventory
86 SELECTED_LANGUAGES=en,zh_CN
91 ORACLE_HOME=/oradata/soft/oracle11g/product/11.2.0.3/dbhome_1
96 ORACLE_BASE=/oradata/soft/oracle11g
107 oracle.install.db.InstallEdition=EE
154 oracle.install.db.DBA_GROUP=dba
160 oracle.install.db.OPER_GROUP=oper
189 oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
194 oracle.install.db.config.starterdb.globalDBName=prod
199 oracle.install.db.config.starterdb.SID=prod
213 oracle.install.db.config.starterdb.characterSet=AL32UTF8
221 oracle.install.db.config.starterdb.memoryOption=true
229 oracle.install.db.config.starterdb.memoryLimit=1024
262 oracle.install.db.config.starterdb.password.ALL=oracle
336 oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
344 oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
/oradata/soft/oracle11g/data
351 oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
/oradata/soft/oracle11g/fast_recovery_area
400 DECLINE_SECURITY_UPDATES=true
10、安装数据库
安装前将/oradata文件及目录下的所有文件、文件夹权限属于oracle用户
chown -R oracle:oinstall /oradata/
操作用户oracle - 切换到database下
[oracle@localhost oradata]$ cd ./database/
[oracle@localhost database]$ pwd
/oradata/database
安装文件
[oracle@localhost database]$ ./runInstaller -silent -ignoreSysPrereqs -responseFile /oradata/db_install.rsp -ignorePrereq
可能出现的问题32039:
解决方法:
[root@localhost oradata]# chown -R oracle:oinstall /oradata/
可能出现的问题:
解决方法:
回到第九步,编辑配置文件db_install.rsp
将第229行改为1024改为512
可能出现的问题32035:
解决方法:
[root@localhost oradata]# rm -rf /oradata/soft/oraInventory/*
切换为root用户,删除报错的文件夹。再切换回oracle用户,继续如下操作。
[oracle@localhost database]$ ./runInstaller -silent -ignoreSysPrereqs -responseFile /oradata/db_install.rsp -ignorePrereq
11、登录oracle
[oracle@localhost database]$ sqlplus / as sysdba
SQL> connect /as sysdba
12、启动oracle
打开监听
查看监听器状态
[oracle@localhost ~]$ lsnrctl status
开启监听
[oracle@localhost ~]$ lsnrctl start
登录
启动sqlplus不登陆
[oracle@localhost ~]$ sqlplus /nolog;
SQL> connect system@prod
通过超级管理员以dba的身份登录
[oracle@localhost ~]$ sqlplus / as sysdba