阿里云ECS CentOS7安装oracle11gR2

2018-01-09 10:19:20来源:oschina作者:郑加威人点击

分享
环境

1、阿里云ECS centos7


2、oracle11gR2安装包:linux.x64_11gR2_database_1of2.zip、linux.x64_11gR2_database_2of2.zip


[root@iZ23zw1ss97Z ~]# ll /data/oracle
total 2295600
-rw-r--r-- 1 root root 1239269270 Jan8 15:36 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 root root 1111416131 Jan8 15:36 linux.x64_11gR2_database_2of2.zip
[root@iZ23zw1ss97Z ~]#
分配虚拟内存

如果是阿里云ECS只有1g内存,那么就需要创建swap分区,弥补物理内存的不足,也就是虚拟内存的概念,把硬盘的一部分划分作为虚拟内存,但这个空间不是越大越好,硬盘的速度远低于内存,设置不当反而拖慢系统的速度。


阿里云的主机默认没有swap分区,可以使用free命令查看:


[root@iZ23zw1ss97Z ~]# free -m
total used freesharedbuff/cache available
Mem:7567 1473 1071216 5021 5611
Swap:000
[root@iZ23zw1ss97Z ~]#

下面记录在阿里云CentOS 7上创建swap分区的步骤:


①使用dd命令创建一个swap分区


[root@iZ23zw1ss97Z ~]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000
1024000+0 records in
1024000+0 records out
1048576000 bytes (1.0 GB) copied, 3.30162 s, 318 MB/s
[root@iZ23zw1ss97Z ~]#

count的值是:size(多少M)* 1024,我这里设置的1G虚拟内存,也就是count=1024000.


②格式化swap分区


[root@iZ23zw1ss97Z ~]# mkswap /home/swap
Setting up swapspace version 1, size = 1023996 KiB
no label, UUID=f404a256-960b-492b-8648-94ef6f75cd92
[root@iZ23zw1ss97Z ~]#

③把格式化后的文件分区设置为swap分区


[root@iZ23zw1ss97Z ~]# swapon /home/swap
swapon: /home/swap: insecure permissions 0644, 0600 suggested.
[root@iZ23zw1ss97Z ~]#

(关闭SWAP分区命令为:[root@iZ23zw1ss97Z ~]# swapoff /home/swap)


此时,swap分区已经创建好了,使用free命令查看,可见多了一个挂载分区。


④swap分区自动挂载


[root@iZ23zw1ss97Z ~]# vi /etc/fstab

在文件末尾加上


/home/swapswapswapdefault0 0

⑤查看是否成功


[root@iZ23zw1ss97Z ~]# free -m
total used freesharedbuff/cache available
Mem:7567 1474236216 5856 5610
Swap:9990999
[root@iZ23zw1ss97Z ~]#
查看有无ifconfig命令
[root@iZ23zw1ss97Z ~]# ls /sbin|grep ifconfig
ifconfig
[root@iZ23zw1ss97Z ~]#

如果没有,执行yum安装一下


yum install net-tools.x86_64
安装Oracle所需的依赖包
[root@iZ23zw1ss97Z ~]# yum -y installgcc gcc-c++ make binutils compat-libstdc++-33 glibc glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel unixODBC unixODBC-devel sysstat ksh
创建用户和组
[root@iZ23zw1ss97Z ~]# groupadd -g 200 oinstall#添加oinstall组,组的id为200
[root@iZ23zw1ss97Z ~]# groupadd -g 201 dba#添加dba组,组的id为201
[root@iZ23zw1ss97Z ~]# useradd -u 440 -g oinstall -G dba oracle#添加用户oracle,并specified它的id为440
[root@iZ23zw1ss97Z ~]# passwd oracle #设置oracle用户的密码
Changing password for user oracle.
New password:
BAD PASSWORD: The password contains the user name in some form
Retype new password:
passwd: all authentication tokens updated successfully.
[root@iZ23zw1ss97Z ~]# id oracle #查看用户id和所属组
uid=440(oracle) gid=200(oinstall) groups=200(oinstall),201(dba)
[root@iZ23zw1ss97Z ~]#

对oracle的操作,要使用oracle账号。


关闭SELINUX

阿里云缺省关闭


[root@iZ23zw1ss97Z ~]# 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 these two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted #注释掉
[root@iZ23zw1ss97Z ~]#
目录授权
[root@iZ23zw1ss97Z ~]# chown -R oracle:oinstall /data/oracle/
[root@iZ23zw1ss97Z ~]# cd /data/oracle/
[root@iZ23zw1ss97Z oracle]$ ll
total 2295604
-rw-r--r-- 1 oracle oinstall 1239269270 Jan8 15:36 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 oracle oinstall 1111416131 Jan8 15:36 linux.x64_11gR2_database_2of2.zip
[root@iZ23zw1ss97Z oracle]$
切换到oracle用户下

解压服务器的/data/oracle/目录下 linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip


解压缩到/data/oracle/目录下,执行命令:


[root@iZ23zw1ss97Z ~]$ su - oracle
[oracle@iZ23zw1ss97Z ~]$ unzip linux.x64_11gR2_database_1of2.zip -d /data/oracle
...
[oracle@iZ23zw1ss97Z ~]$ unzip linux.x64_11gR2_database_2of2.zip -d /data/oracle
...
[oracle@iZ23zw1ss97Z ~]$ cd /data/oracle/
[oracle@iZ23zw1ss97Z oracle]$ ll
total 2295604
drwxr-xr-x 8 oracle oinstall4096 Aug 212009 database
-rw-r--r-- 1 oracle oinstall 1239269270 Jan8 15:36 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 oracle oinstall 1111416131 Jan8 15:36 linux.x64_11gR2_database_2of2.zip
[oracle@iZ23zw1ss97Z oracle]$

配置安装参数


“vi/data/oracle/database/response/db_install.rsp”命令配置安装参数 修改后的db_install.rsp文件内容如下:


[oracle@iZ23zw1ss97Z response]$ cat db_install.rsp
####################################################################
## Copyright(c) Oracle Corporation 1998,2008. All rights reserved.##
## ##
## Specify values for the variables listed below to customize ##
## your installation. ##
## ##
## Each variable is associated with a comment. The comment ##
## can help to populate the variables with the appropriate ##
## values. ##
## ##
## IMPORTANT NOTE: This file contains plain text passwords and##
## should be secured to have read permission only by oracle user##
## or db administrator who owns this installation.##
## ##
####################################################################
#------------------------------------------------------------------------------
# Do not change the following system generated value.
#------------------------------------------------------------------------------
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
#------------------------------------------------------------------------------
# Specify the installation option.
# It can be one of the following:
# 1. INSTALL_DB_SWONLY
# 2. INSTALL_DB_AND_CONFIG
# 3. UPGRADE_DB
#选择安装类型:1.只装数据库软件 2.安装数据库软件并建库 3.升级数据库
#-------------------------------------------------------------------------------
oracle.install.option=INSTALL_DB_SWONLY
#-------------------------------------------------------------------------------
# Specify the hostname of the system as set during the install. It can be used
# to force the installation to use an alternative hostname rather than using the
# first hostname found on the system. (e.g., for systems with multiple hostnames
# and network interfaces)
# 指定操作系统主机名,通过/etc/hosts命令获得
#-------------------------------------------------------------------------------
ORACLE_HOSTNAME=iZ23zw1ss97Z
#-------------------------------------------------------------------------------
# Specify the Unix group to be set for the inventory directory.
# 指定oracle inventory目录的所有者,通常会是oinstall或者dba
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=oinstall
#-------------------------------------------------------------------------------
# Specify the location which holds the inventory files.
# 指定产品清单oracle inventory目录的路径
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=/data/oraInventory
#-------------------------------------------------------------------------------
# Specify the languages in which the components will be installed.
#
# en : Englishja : Japanese
# fr : French ko : Korean
# ar : Arabic es : Latin American Spanish
# bn : Bengalilv : Latvian
# pt_BR: Brazilian Portuguese lt : Lithuanian
# bg : Bulgarianms : Malay
# fr_CA: Canadian French es_MX: Mexican Spanish
# ca : Catalanno : Norwegian
# hr : Croatian pl : Polish
# cs : Czechpt : Portuguese
# da : Danish ro : Romanian
# nl : Dutchr