2MUCH

Linux-安装Oracle

2022-08-02


Linux-安装Oracle数据库

安装【失败】,可能因为我的服务器空间不足。。。罢了,先放着吧

背景:我的阿里云linux服务器(CentOS 7.8 64位)之前在宝塔已懒人安装了mysql,现需要在服务器上学习Oracle,所以先记录安装过程(静默安装)。

正式安装之前,可以先检测下是否已有安装Oracle程序。若已有安装oracle,应能看到oracle进程,且一般都会有oracle用户。我在本机上验证如下,是没有安装过的,

[cindy@iZbp15qc4wmx335c268l5mZ ~]$ ps -ef | grep oracle
cindy    26709 26624  0 20:22 pts/0    00:00:00 grep --color=auto oracle
[cindy@iZbp15qc4wmx335c268l5mZ ~]$ id oracle
id: oracle: no such user
[cindy@iZbp15qc4wmx335c268l5mZ ~]$ rpm -qa | grep oracle # 查看以rpm包安装的软件列表
[cindy@iZbp15qc4wmx335c268l5mZ ~]$ yum list installed | grep oracle  # 查看以yum安装的软件列表

步骤概览

参考 http://www.javashuo.com/article/p-sbcnrnqx-gr.html

安装swap分区

oracle安装需要swap分区,所以先检查下是否已有swap分区。

[root@iZbp15qc4wmx335c268l5mZ ~]# free
              total        used        free      shared  buff/cache   available
Mem:         964136      425288      172940         304      365908      366360
Swap:       1049596      303616      745980
[root@iZbp15qc4wmx335c268l5mZ ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Mon Sep 14 07:14:22 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=9f2d3e15-a78a-4f3d-8385-0165b4b67864 /                       ext4    defaults        1 1
/www/swap    swap    swap    defaults    0 0

看起来是已有的,如果没有,可参考链接的方式创建。

安装依赖包

[root@iZbp15qc4wmx335c268l5mZ ~]# yum -y install  gcc gcc-c++ make binutils compat-libstdc++-33 glibc glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel sysstat ksh
... # 安装细节省略

Installed:
  compat-libstdc++-33.x86_64 0:3.2.3-72.el7          ksh.x86_64 0:20120801-143.el7_9          unixODBC.x86_64 0:2.3.1-14.el7         
  unixODBC-devel.x86_64 0:2.3.1-14.el7              

Updated:
  binutils.x86_64 0:2.27-44.base.el7_9.1          glibc.x86_64 0:2.17-326.el7_9          glibc-devel.x86_64 0:2.17-326.el7_9         

Dependency Updated:
  glibc.i686 0:2.17-326.el7_9 glibc-common.x86_64 0:2.17-326.el7_9 glibc-headers.x86_64 0:2.17-326.el7_9 nscd.x86_64 0:2.17-326.el7_9

Complete!

root用户执行。最后会列出Installed,Updated,Dependency Updated。

创建用户/组

首先看下已有的用户和组,以免出现重复。没有与要创建的用户/组重名的,so放心安装。

cat /etc/passwd  # 查看所有用户
cat /etc/group  # 查看所有组

创建用户组oinstall,dba,创建用户oracle

[root@iZbp15qc4wmx335c268l5mZ ~]# groupadd -g 200 oinstall  # 组id设为200
[root@iZbp15qc4wmx335c268l5mZ ~]# groupadd -g 201 dba
[root@iZbp15qc4wmx335c268l5mZ ~]# useradd -u 440 -g oinstall -G dba oracle  # 创建oracle用户,指定uid为400
[root@iZbp15qc4wmx335c268l5mZ ~]# passwd oracle  # 设置oracle密码
Changing password for user oracle.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@iZbp15qc4wmx335c268l5mZ ~]# id oracle
uid=440(oracle) gid=200(oinstall) groups=200(oinstall),201(dba)

关闭SELINUX

oracle是需要关闭SELINUX的,至于为什么要关闭,或者说能否不要关闭,只需合适的设置即可,这部分后面有空了再说。先查看目前是否是关闭的(以下给了三种方法):

[root@iZbp15qc4wmx335c268l5mZ ~]# cat /etc/selinux/config

# 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 three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


[root@iZbp15qc4wmx335c268l5mZ ~]# /usr/sbin/sestatus -v
SELinux status:                 disabled
[root@iZbp15qc4wmx335c268l5mZ ~]# getenforce
Disabled

若当前是开启的,则需要关闭

setenforce 0 

下载oralce包并解压

官网只能看到最新版的下载包,我想安装的11g版本的不好找。。。于是找到网盘资源( https://blog.csdn.net/m0_53166211/article/details/121524069 )来下载

安装oracle的目录磁盘空间要充足,否则会安装oracle失败(大于4G)

例如,可以新建目录/app/oracle并把压缩包放入并解压

[root@iZbp15qc4wmx335c268l5mZ home]# ls -l /app/oracle
total 2295600
-rw-r--r-- 1 root root 1239269270 Aug  6 11:34 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 root root 1111416131 Aug  6 11:36 linux.x64_11gR2_database_2of2.zip
[root@iZbp15qc4wmx335c268l5mZ home]# cd /app/oracle
[root@iZbp15qc4wmx335c268l5mZ oracle]# unzip linux.x64_11gR2_database_1of2.zip
[root@iZbp15qc4wmx335c268l5mZ oracle]# unzip linux.x64_11gR2_database_2of2.zip
[root@iZbp15qc4wmx335c268l5mZ oracle]# ls -l
total 2295604
drwxr-xr-x 8 root root       4096 Aug 21  2009 database  # 解压内容在这
-rw-r--r-- 1 root root 1239269270 Aug  6 11:34 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 root root 1111416131 Aug  6 11:36 linux.x64_11gR2_database_2of2.zip
[root@iZbp15qc4wmx335c268l5mZ oracle]# cd database
[root@iZbp15qc4wmx335c268l5mZ database]# ls -l
total 36
drwxr-xr-x 12 root root 4096 Aug 17  2009 doc
drwxr-xr-x  4 root root 4096 Aug 15  2009 install
drwxrwxr-x  2 root root 4096 Aug 15  2009 response
drwxr-xr-x  2 root root 4096 Aug 15  2009 rpm
-rwxr-xr-x  1 root root 3226 Aug 15  2009 runInstaller
drwxrwxr-x  2 root root 4096 Aug 15  2009 sshsetup
drwxr-xr-x 14 root root 4096 Aug 15  2009 stage
-rw-r--r--  1 root root 5402 Aug 18  2009 welcome.html

oracle安装

在此之前,还需要修改下/app/oracle/database/response/db_install.rsp`文件。修改内容参考 https://blog.csdn.net/csd_nuser/article/details/110089960http://www.javashuo.com/article/p-sbcnrnqx-gr.html

vim db_install.rsp # 以下为可参考的【http://www.javashuo.com/article/p-sbcnrnqx-gr.html】的修改内容,修改内容以具体情况和需求为准
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=能够写本机地址
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/app/oracle/oraInventory
SELECTED_LANGUAGES=zh_CN,en
ORACLE_HOME=/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=512
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle2018
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.automatedBackup.enable=false
DECLINE_SECURITY_UPDATES=true
[root@iZbp15qc4wmx335c268l5mZ response]# vim /app/oracle/database/response/db_install.rsp
# 参考修改参数

登陆oracle用户,进行正式安装:

[oracle@iZbp15qc4wmx335c268l5mZ ~]$ cd /app/oracle/database
[oracle@iZbp15qc4wmx335c268l5mZ database]$ ./runInstaller -silent -responseFile /app/oracle/database/response/db_install.rsp

安装过程杯具了,记录报错:

1、Unable to create directory.等报错

[oracle@iZbp15qc4wmx335c268l5mZ database]$ ./runInstaller -silent -responseFile /app/oracle/database/response/db_install.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 19429 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 729 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2022-08-06_11-53-42AM. Please wait ...[oracle@iZbp15qc4wmx335c268l5mZ database]$ [FATAL] [INS-32012] Unable to create directory.
   CAUSE: Either proper permissions were not granted to create the directory or there was no space left in the volume.
   ACTION: Check your permission on the selected directory or choose another directory.
[FATAL] [INS-32021] Insufficient disk space on this volume for the selected Oracle home.
   CAUSE: The selected Oracle home was on a volume without enough disk space.
   ACTION: Choose a location for Oracle home that has enough space (minimum of 4,397MB) or free up space on the existing volume.
A log of this session is currently saved as: /tmp/OraInstall2022-08-06_11-53-42AM/installActions2022-08-06_11-53-42AM.log. Oracle recommends that if you want to keep this log, you should move it from the temporary location to a more permanent location.

# 根据提示查看 /tmp/OraInstall2022-08-06_11-53-42AM 下面的日志

可能是空间不足。。。先放着,后面有缘再解决

参考链接

http://www.javashuo.com/article/p-sbcnrnqx-gr.html

https://blog.csdn.net/csd_nuser/article/details/110089960