1.安装环境---
- 操作系统:CentOS release 6.8 (Final)
- oracle:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
-
【1】安装依赖包:
yum -y install binutils compat-libcap1 compat-libstdc++.i686 compat-libstdc++.x86_64 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc.i686 glibc.x86_64 glibc-devel.i686 glibc-devel.x86_64 ksh libgcc.i686 libgcc.x86_64 libstdc++.i686 libstdc++.x86_64 libstdc++-devel.i686 libstdc++-devel.x86_64 libaio.i686 libaio.x86_64 libaio-devel.i686 libaio-devel.x86_64 libXext libXtst libX11 libXau libxcb libXi make sysstat unixODBC-devel.i686 unixODBC-devel.x86_64 unixODBC.i686 unixODBC.x86_64 compat-libstdc++-33.i686 compat-libstdc++-33.x86_64
-
【2】修改hosts文件:
vi /etc/hosts 写入以下内容: 127.0.0.1 SVR-28-137 //实际的服务器名称
-
【3】更改kernel参数:
在文件结尾追加以下内容:
[root@localhost var]# vi /etc/sysctl.conf # 安装oracle 时添加以下选项 net.ipv4.ip_local_port_range = 9000 65500 fs.file-max = 6815744 kernel.shmall = 10523004 kernel.shmmax = 6465333657 kernel.shmmni = 4096 kernel.sem = 250 32000 100 128 net.core.rmem_default=262144 net.core.wmem_default=262144 net.core.rmem_max=4194304 net.core.wmem_max=1048576 fs.aio-max-nr = 1048576
执行以下命令使更改生效:
sysctl -p
-
【4】创建安装oracle所需用户与用户组:
[root@localhost var]# groupadd -g 200 oinstall [root@localhost var]# groupadd -g 201 dba [root@localhost var]# useradd -u 440 -g oinstall -G dba -d /usr/oracle oracle [root@localhost var]# passwd oracle
修改login(黄色部分为添加的选项):
[root@localhost var]# vi /etc/pam.d/login #%PAM-1.0 auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so auth include system-auth account required pam_nologin.so account include system-auth password include system-auth # pam_selinux.so close should be the first session rule session required pam_selinux.so close session required pam_loginuid.so session optional pam_console.so # pam_selinux.so open should only be followed by sessions to be executed in the user context session required pam_selinux.so open session required pam_namespace.so session required pam_limits.so session optional pam_keyinit.so force revoke session include system-auth -session optional pam_ck_connector.so
修改limits.conf,在文件尾添加以下内容(黄色部分)
[root@localhost var]# vi /etc/security/limits.conf
# 安装oracle时 设置以下参数 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536
修改profile
[root@localhost var]# vi /etc/profile # 安装oracle时添加以下内容 if [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi
-
【5】创建安装目录和设置权限
[root@localhost ~]#mkdir -p /usr/local/oracle/product/11.2.0/dbhome_1 //创建安装目录
[root@localhost ~]#chown -R oracle:oinstall /usr/local/oracle
[root@localhost ~]#mkdir -p /data/oracle/oradata //数据文件存放目录
[root@localhost ~]#mkdir -p /data/oracle/recovery_area //数据恢复目录
[root@localhost ~]#mkdir -p /data/oracle/oraInventory //数据库创建及使用过程中的日志目录
[root@localhost ~]#chown -R oracle:oinstall /data/oracle //修改安装目录权限
[root@localhost ~]#chmod -R 775 /data/oracle //修改安装目录权限
[root@localhost ~]#su - oracle //登录oracle用户,设置环境变量
[oracle@localhost ~]#vi .bash_profile //修改配置文件
# 在文件末尾添加
export ORACLE_BASE=/usr/local/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64
export ORACLE_SID=orcl
umask 022
[oracle@localhost ~]$source .bash_profile //使设置生效
2. 安装oracle database
-
[1] 下载oracle安装文件(for linux x86),并上传到CentOS上
下载地址:http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
文件存放目录:/usr/local/src
-
[2] 解压安装文件
[root@localhost src]# unzip -o -d ./oracle linux.x64_11gR2_database_1of2.zip [root@localhost src]# unzip -o -d ./oracle linux.x64_11gR2_database_2of2.zip
-
[3]修改配置文件db_install.rsp,并安装
[root@localhost src]#cd /usr/local/src/oracle/database/response
[root@localhost src]#cp db_install.rsp db_install.rsp.bak
[root@localhost src]#vi db_install.rsp
下面把主要修改的地方贴出来
oracle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=DB_m2 //当前主机名,必须要修改一致 UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/data/oracle/oraInventory SELECTED_LANGUAGES=en,zh_CN ORACLE_HOME=/usr/local/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/usr/local/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/data/oracle/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/data/oracle/recovery_area
DECLINE_SECURITY_UPDATES=true //一定要设为true
登录oracle用户,执行安装
[root@localhost database]# su oracle [oracle@localhost database]$ ./runInstaller -silent -responseFile /usr/local/src/oracle/database/response/db_install.rsp
安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在进行,如果出现[FATAL],则安装程序已经停止了
直到出现以下提示则安装成功:
我在安装时遇到一些问题:
1. [INS-06101] IP address of localhost could not be determined([INS-06101] 无法确定本地主机的 IP 地址) 出现这种错误是因为主机名和/etc/hosts 文件不一致,只需要把主机名和其IP 写入/etc/hosts 文件,就ok了。 2.[INS-32033]central inventory location is not writable 主产品清单位置不可写 这是因为之前没有将/data/oracle 目录给予权限
3.[INS-32012]无法创建目录
将安装目录:/usr/local/oracle(在上面的配置文件中设定的) 的所有者改为oracle chown -R oracle:oinstall /usr/local/oracle
-
[4] 配置监听配置文件response/netca.rsp
netca /silent /responsefile /usr/local/src/oracle/database/response/netca.rsp
-
[5]修改配置文件response/dbca.rsp,静默建立新库
vi /usr/local/src/oracle/database/response/dbca.rsp
RESPONSEFILE_VERSION = "11.2.0" //不能更改 OPERATION_TYPE = "createDatabase" GDBNAME = "orcl.us.oracle.com" //全局数据库的名字=SID+主机域名 SID = "orcl" //对应的实例名字 TEMPLATENAME = "General_Purpose.dbc" //建库用的模板文件 DATAFILEDESTINATION = /data/oracle/oradata //数据文件存放目录 RECOVERYAREADESTINATION=/data/oracle/recovery_data //恢复数据存放目录 CHARACTERSET = "AL32UTF8" //字符集,重要!!! 建库后一般不能更改,所以建库前要确定清楚。 TOTALMEMORY = "5120" //oracle内存5120MB
配置完之后,执行安装命令:
dbca -silent -responseFile /usr/local/src/oracle/database/response/dbca.rsp
输入后会提示输入sys 和 system的密码,输入后出现安装进度: