CentOS 7.4安装Oracle 11g

1. 从官网下载Oracle安装包到CentOS中, 共有两个压缩包:

linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip

2. 添加用户组和用户

groupadd -g oinstall                            #添加oinstall组
groupadd -g dba                                 #添加dba组
useradd -g oinstall -G dba oracle       #添加用户oracle
passwd oracle                                    #输入oracle用户的密码

3. 在/etc/hosts文件中添加主机IP跟主机名

192.168.1.1  gongxm

4.关闭selinux ,编辑 /etc/selinux/config文件,设置SELINUX= enforcing 为SELINUX=disabled

5.关闭防火墙

查看防火墙状态:systemctl status firewalld
停止防火墙:systemctl stop firewalld
关闭自启动防火墙服务:systemctl disable firewalld

6. 修改内核参数

编辑 /etc/sysctl.conf
添加以下设置:

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
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

再执行下面的命令使参数生效:

sysctl -p

7.修改用户的限制文件

编辑 /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.修改/etc/pam.d/login文件

添加以下内容:

session  required   /lib64/security/pam_limits.so
session  required   pam_limits.so

9.修改/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

10.创建安装目录、修改文件权限

mkdir -p /app/oracle/product/11.2.0
mkdir /app/oracle/oradata
mkdir /app/oracle/inventory
mkdir /app/oracle/fast_recovery_area
chown -R oracle:oinstall /app/oracle
chmod -R 775 /app/oracle

11.安装Oracle 11g依赖包

yum -y install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static elfutils-libelf-devel ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel

12.安装unzip命令

yum -y unzip

13.解压两个文件:

unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip

14.切换到oracle账号登陆, 设置环境变量

编辑.bash_profile文件:

vim .bash_profile

添加:
ORACLE_BASE=/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

15.切换到root账号, 编辑静默安装响应文件

进入oracle安装包解压后的目录,编辑 .../database/response/db_install.rsp文件:

vim db_install.rsp
修改以下参数:
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=gongxm
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/app/oracle/product/11.2.0
ORACLE_BASE=/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true

16.根据响应文件安装oracle 11g

./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /home/oracle/database/response/db_install.rsp

开始Oracle在后台静默安装。安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止了。

此时再打开另外一个终端选项卡,输入提示的会话日志目录:

tail –f /app/oracle/inventory/logs/installActions2018-05-18_11-27-36PM.log

看到日志文件会持续输出安装信息没有输入异常信息,则表明安装过程正常。

17. 如果提示以下内容, 说明需要分配交换空间

swap space: 0 MB available, 150 MB required.

可以参考: 这里

18.提示安装完成后, 切换到root账号

执行以下命令:

sh /app/oracle/inventory/orainstRoot.sh
sh /app/oracle/product/11.2.0/root.sh

注意:
执行第一个命令时, 会提示:

Changing permissions of /app/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /app/oracle/inventory to oinstall.

这是正常的!!!

19.用oracle用户登录配置监听

netca -silent -responseFile /home/oracle/database/response/netca.rsp

需要配置DISPLAY变量,配完之后重新netca:

export DISPLAY=localhost:0.0

成功运行后,会在/app/oracle/product/11.2.0/network/admin/ 中生成listener.ora和sqlnet.ora两个文件

20.如果出现以下异常:

Exception in thread "main" java.lang.UnsatisfiedLinkError: 
/app/oracle/product/11.2.0/jdk/jre/lib/amd64/xawt/libmawt.so: 
libXext.so.6: cannot open shared object file: No such file or directory

解决方案:
安装以下内容:

#yum install libXp
#yum install libXt
#yum install libXtst

21.切换到root用户,编辑 /home/oracle/database/response/dbca.rsp

修改以下参数:
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/app/oracle/oradata
RECOVERYAREADESTINATION=/app/oracle/fast_recovery_area
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "1638"

22.切换到oracle账号进行静默配置

dbca -silent -responseFile /home/oracle/database/response/dbca.rsp

这时会开始生成数据, 稍等几分钟,会有进度的提示

23.完成建库后,检查安装是否成功

[oracle@gongxm database]$ sqlplus / as sysdba  //以SYSDBA这个角色登陆SQLPLUS

SQL> startup                      //启动数据库
SQL> select count(*) from tabs;   //查询tabs表的字段数量,
                                  // 如果有内容,表示连接数据库正常

24.查看监听状态

lsnrctl status

如果提示以下内容:

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 19-MAY-2018 09:03:40

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                19-MAY-2018 08:36:13
Uptime                    0 days 0 hr. 27 min. 27 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /app/oracle/diag/tnslsnr/gongxm/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=gongxm)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully

表示监听正常!

25.到这里, oracle安装完成!

你可能感兴趣的:(CentOS 7.4安装Oracle 11g)