ORACLE:【1】32位Linux系统图形界面安装Oracle

创建oracle用户与相关用户组及Oracl用户环境变量和安装路径

# 添加组和用户
[root@oracle11g ~]# groupadd oinstall
[root@oracle11g ~]# groupadd dba
[root@oracle11g ~]# useradd -g oinstall -G dba oracle
[root@oracle11g ~]# passwd oracle
[root@oracle11g ~]# 设置你的密码
# 查看创建好的oralce用户组
[root@oracle11g ~]# id oracle
uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba)
[root@oracle11g ~]# 
# 创建文件夹并修改组和用户所属关系和相关权限(命令格式:chown -R 用户:用户组 文件夹)
[root@oracle11g ~]# mkdir -p /opt/oracle
[root@oracle11g ~]# chown -R oracle:oinstall /opt/oracle(使得/opt/oracle文件夹输入oracle用户和oinstall组)
[root@oracle11g ~]# chmod -R 775 /opt/oracle(修改u01文件夹访问权限)—可选(最好执行下)
# 添加/etc/hosts中dns解析信息
192.168.1.102             oracle11g
# 配置oracle用户环境变量:
[root@oracle11g ~]# su - oracle
[oracle@oracle11g ~]$ vi .bash_profile

# Oracle setting
ORACLE_BASE=/opt/oracle
ORACLE_HOME=$ORACLE_BASE/oracle
ORACLE_SID=demo
PATH=$ORACLE_HOME/bin:$PATH
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
LANG=en_US.UTF-8
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH NLS_LANG LANG

下载安装包

软件包官网下载链接如下:

Database Software Downloads | Oracle

官方提供的文档链接如下:

Database 19c and 21c | Oracle

注意一定要选择平台相同的安装包

我这里选用的是x86的安装包,使用unzip命令将其解压(直接解压就行),解压完成后会生成一个database文件夹:

硬件检查

1. 内存要求

  • 至少1GB的RAM,可以使用以下命令:
[root@oracle11g ~]# grep MemTotal /proc/meminfo
MemTotal:        1938868 kB
[root@oracle11g ~]# 
  • 检查RAM与交换分区之间的要求,使用一下命令查看交换分区大小:
[root@oracle11g ~]# grep SwapTotal /proc/meminfo 
SwapTotal:       2097144 kB
[root@oracle11g ~]# 
RAM需要交换空间的大小
1 GB和2 GB之间RAM大小的1.5倍
2 GB和16 GB之间等于RAM的大小
超过16 GB16 GB

2. 硬盘要求

  • 保证/tmp目录只要有1GB可用空间
[root@oracle11g ~]# df -h /tmp
Filesystem                        Size  Used Avail Use% Mounted on
/dev/mapper/vg_oracle11g-lv_root   18G   12G  5.0G  70% /
[root@oracle11g ~]# 
  • 可使用以下命令你给查看你系统可用硬盘空间:
[root@oracle11g ~]# df -h
Filesystem                        Size  Used Avail Use% Mounted on
/dev/mapper/vg_oracle11g-lv_root   18G   12G  5.0G  70% /
tmpfs                             947M  456M  492M  49% /dev/shm
/dev/sda1                         485M   31M  430M   7% /boot
[root@oracle11g ~]# 

软件检查

1. 操作系统要求

官方文档中说11g版本Oracle安装包支持以下操作Linux发行版:

  • Asianux 2.0
  • Asianux 3.0
  • Oracle Enterprise Linux 4.0 Update 7 或更新版本
  • Oracle Enterprise Linux 5.0
  • Red Hat Enterprise Linux 4.0 Update 7 或更新版本
  • Red Hat Enterprise Linux 5.0
  • SUSE Linux Enterprise Server 10.0
  • SUSE Linux Enterprise Server 11.0

CentOS应该和RHEL一样对待,所以说这里要求并没有那么严格

2. 软件包依赖

  • 官方文档中对于RHEL5及以上版本的Linux发行版,要求需要以下的软件包(更高版本也行)
binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
elfutils-libelf-devel-static-0.125
gcc-4.1.2
gcc-c++-4.1.2
glibc-2.5-24
glibc-common-2.5
glibc-devel-2.5
glibc-headers-2.5
kernel-headers-2.6.18
ksh-20060214
libaio-0.3.106
libaio-devel-0.3.106
libgcc-4.1.2
libgomp-4.1.2
libstdc++-4.1.2
libstdc++-devel-4.1.2
make-3.81
sysstat-7.0.2
unixODBC-2.2.11
unixODBC-devel-2.2.11

  • 你可以使用以下命令查看上面这些软件包的版本是否大于等于上面的要求:
[root@oracle11g ~]# rpm -q binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel
binutils-2.20.51.0.2-5.48.el6.i686
package compat-libstdc++ is not installed
elfutils-libelf-0.164-2.el6.i686
elfutils-libelf-devel-0.164-2.el6.i686
elfutils-libelf-devel-static-0.164-2.el6.i686
gcc-4.4.7-23.el6.i686
gcc-c++-4.4.7-23.el6.i686
glibc-2.12-1.212.el6.i686
glibc-common-2.12-1.212.el6.i686
glibc-devel-2.12-1.212.el6.i686
glibc-headers-2.12-1.212.el6.i686
kernel-headers-2.6.32-754.6.3.el6.i686
ksh-20120801-37.el6_9.i686
libaio-0.3.107-10.el6.i686
libaio-devel-0.3.107-10.el6.i686
libgcc-4.4.7-23.el6.i686
libgomp-4.4.7-23.el6.i686
libstdc++-4.4.7-23.el6.i686
libstdc++-devel-4.4.7-23.el6.i686
make-3.81-23.el6.i686
sysstat-9.0.4-33.el6_9.1.i686
unixODBC-2.2.14-14.el6.i686
unixODBC-devel-2.2.14-14.el6.i686
[root@oracle11g ~]# 
  • 如果有未安装的使用以下命令下载更新:
[root@oracle11g ~]# yum install binutils compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.cn99.com
 * updates: centos.ustc.edu.cn
Setting up Install Process
Package binutils-2.20.51.0.2-5.48.el6.i686 already installed and latest version
No package compat-libstdc++ available.
Package elfutils-libelf-0.164-2.el6.i686 already installed and latest version
Package elfutils-libelf-devel-0.164-2.el6.i686 already installed and latest version
Package elfutils-libelf-devel-static-0.164-2.el6.i686 already installed and latest version
Package gcc-4.4.7-23.el6.i686 already installed and latest version
Package gcc-c++-4.4.7-23.el6.i686 already installed and latest version
Package glibc-2.12-1.212.el6.i686 already installed and latest version
Package glibc-common-2.12-1.212.el6.i686 already installed and latest version
Package glibc-devel-2.12-1.212.el6.i686 already installed and latest version
Package glibc-headers-2.12-1.212.el6.i686 already installed and latest version
Package kernel-headers-2.6.32-754.6.3.el6.i686 already installed and latest version
Package ksh-20120801-37.el6_9.i686 already installed and latest version
Package libaio-0.3.107-10.el6.i686 already installed and latest version
Package libaio-devel-0.3.107-10.el6.i686 already installed and latest version
Package libgcc-4.4.7-23.el6.i686 already installed and latest version
Package libgomp-4.4.7-23.el6.i686 already installed and latest version
Package libstdc++-4.4.7-23.el6.i686 already installed and latest version
Package libstdc++-devel-4.4.7-23.el6.i686 already installed and latest version
Package 1:make-3.81-23.el6.i686 already installed and latest version
Package sysstat-9.0.4-33.el6_9.1.i686 already installed and latest version
Package unixODBC-2.2.14-14.el6.i686 already installed and latest version
Package unixODBC-devel-2.2.14-14.el6.i686 already installed and latest version
Nothing to do
[root@oracle11g ~]# 

配置内核参数(以下命令都需要root用户权限执行)

1.修改/etc/sysctl.conf文件,我直接替换

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 1048576
kernel.shmmax = 536870912
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 = 1048586
net.ipv4.tcp_wmem = 262144 262144 262144
net.ipv4.tcp_rmem = 4194304 4194304 4194304
---------------------------------------------------------------------------
为使上述配置生效而不重启系统,执行如下命令
[root@oracle11g ~]# /sbin/sysctl -p

2.为oracle用户添加shell配置

为了提高Oracle软件性能,需要为Oracle用户添加以下shell配置:

Shell Limit在limits.conf中的项硬限制
打开文件描述符的最大数量nofile65536
单个用户可用的最大进程数nproc16384
进程堆栈段的最大大小stack10240

步骤如下:

  • /etc/security/limits.conf文件,添加以下参数:
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
  • /etc/pam.d/login文件中添加一行:
session    required     pam_limits.so
  • /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

开始正式安装

进入到之前解压的安装包,运行runInstaller脚本开始安装;注意:一定要使用oracle用户登录图形界面,否则运行runInstaller会报错显示错误(因为后面使用图形化界面安装的,需要权限去运行图形界面程序)。

后续安装参考Windows系统安装步骤,检查失败的忽略就行,此处就不列举了。。。

Windows客户端链接Oracle时,将Oracle服务器防火墙关闭或者开放指定端口。。。
 

****************重要说明:踩过的坑****************

此处没有设置开机自启动,需要自己配置;

linux重启后开启数据库,先启动数据库,后开启监听;
# 启动数据库服务
[oracle@oracle11g ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Nov 18 23:17:46 2018

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

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  795127808 bytes
Fixed Size                  1339456 bytes
Variable Size             473960384 bytes
Database Buffers          314572800 bytes
Redo Buffers                5255168 bytes
Database mounted.
Database opened.
SQL> conn scott/scott
Connected.
SQL> select * from tab;
TNAME                                                        TABTYPE
------------------------------------------------------------ --------------
 CLUSTERID
----------
BONUS                                                        TABLE
DEPT                                                         TABLE
EMP                                                          TABLE
TNAME                                                        TABTYPE
------------------------------------------------------------ --------------
 CLUSTERID
----------
SALGRADE                                                     TABLE
SQL> quit
# 启动监听
[oracle@oracle11g ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 18-NOV-2018 23:19:39

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

Starting /opt/oracle/oracle/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /opt/oracle/oracle/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/oracle11g/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11g)(PORT=1521)))

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                18-NOV-2018 23:19:39
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/oracle/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/oracle11g/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11g)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@oracle11g ~]$  
# 查看监听状态
[oracle@oracle11g ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 18-NOV-2018 23:20:23

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                18-NOV-2018 23:19:39
Uptime                    0 days 0 hr. 0 min. 44 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/oracle/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/oracle11g/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11g)(PORT=1521)))
Services Summary...
Service "demoXDB" has 1 instance(s).
  Instance "demo", status READY, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
  Instance "demo", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@oracle11g ~]$ 
# 关闭oracle顺序及命令
[oracle@oracle11g ~]$ lsnrctl stop

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 18-NOV-2018 23:21:16

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
[oracle@oracle11g ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Nov 18 23:21:28 2018

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> quit

****************重要说明:踩过的坑****************