您的位置:首页 > 数据库 > Oracle

linux下搭建oracle数据库服务器

2015-10-28 09:26 447 查看
RHEL 5下oracle 11g数据库服务器搭建

1.检查安装所需要的软件包

Oracle 11g要求Red Hat Enterprise Linux 5(32-bit)必须要有的软件包:
binutils-2.17.50.0.6-2.el5  

compat-libstdc++-33-3.2.3-61  

elfutils-libelf-0.125-3.el5  

elfutils-libelf-devel-0.125  

gcc-4.1.1-52  

gcc-c++-4.1.1-52  

glibc-2.5-12  

glibc-common-2.5-12  

glibc-devel-2.5-12

glibc-headers-2.5-12 

libaio-0.3.106  

libaio-devel-0.3.106    

libgcc-4.1.1-52  

libstdc++-4.1.1    

libstdc++-devel-4.1.1-52.e15  

make-3.81-1.1  

sysstat-7.0.0  

unixODBC-2.2.11   


unixODBC-devel-2.2.1

#rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc glibc gcc-c++ glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel
make sysstat unixODBC unixODBC-devel

如出现package unixODBC is not installed

            package unixODBC-devel is not installed

则在系统光盘中找到相应的包上传并安装。

 

2.修改内核参数

#vi /etc/sysctl.conf
kernel.shmall = 2097152 

kernel.shmmax = 4294967295         //默认配置比这里的值大则不需要修改

在文件最后添加以下内容

fs.file-max = 6553600 
kernel.shmmni = 4096 
kernel.sem = 250 32000 100 128  
net.ipv4.ip_local_port_range = 1024 65000  
net.core.rmem_default = 4194304 
net.core.rmem_max = 4194304 
net.core.wmem_default = 262144 
net.core.wmem_max = 262144

修改完后需要使设置生效

#sysctl -p

 

3.创建Oracle用户和组

#groupadd oinstall

#groupadd dba

#useradd -g oinstall -G dba oracle           //创建oracle用户,使其默认组为oinstall,附加组为dba

#passwd oracle

 

4.为Oracle用户设置shell限制

#vi /etc/security/limits.conf

在文件最后添加以下内容:
oracle soft nproc 2047  

oracle hard nproc 16384  

oracle soft nofile 1024  


oracle hard nofile 65536

#vi /etc/pam.d/login

在文件最后添加以下内容:

session required /lib/security/pam_limits.so

#vi /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

所有修改完成后,重启linux系统

#reboot

 

5.为Oracle用户设置环境变量

#vi /home/oracle/.bash_profile

在文件最后添加以下内容:

ORACLE_SID=ixdba 

ORACLE_BASE=/app/oracle  

ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1  

export ORACLE_SID ORACLE_BASE ORACLE_HOME  

export ORA_NLS10=$ORACLE_HOME/nls/data  

PATH=$PATH:/$ORACLE_HOME/bin:$HOME/bin  

export PATH

#source /home/oracle/.bash_profile        //使环境变量设置生效

 

6.创建和授权Oracle安装目录

#mkdir -p /app/oracle                      //-p目录若不存在则新建立目录

#chown -R oracle:oinstall /app

#chown -R oracle:onistall /app/oracle          //-R用于改变目录及目录下文件

 

7.开始安装Oracle

由于Oracle的安装过程需要图形界面的支持,因此安装Oracle必须在Linux的Xwindow界面下完成。
注意 Oracle的安装过程必须在完全的Oracle环境下进行。所谓的"完全Oracle环境"是指,Oracle用户是通过Linux的Xwindow图形登录界面进入的,而不是在root或者其他用户下通过su的方式切换过来的。

#su oracle

$cd /app

$ls

linux_11gR2_database_1of2.zip  linux_11gR2_database_2of2.zip       //zip包最好用FTP工具上传

$unzip linux_11gR2_database_1of2.zip

$unzip linux_11gR2_database_2of2.zip

$ls

database  linux_11gR2_database_1of2.zip  linux_11gR2_database_2of2.zip

$/app/database/runInstaller                   //调用图形界面安装

安装到最后,按要求执行两个脚本

#/app/oracle/oraInventory/orainstRoot.sh

#/app/oracle/product/11.1.0/db_1/root.sh

至此安装完成

 

8.验证是否安装成功

#su oracle

$sqlplus / as sysdba

SQL>select instance_name,status from v$instance;        //能正常执行则说明安装成功

 

9.安装中常见问题

1)./sqlplus: error while loading shared libraries: /app/oracle/product/11.1.0/dbhome_1/lib/libclntsh.so.11.1: cannot restore segment prot after reloc: Permission denied

原因:selinux问题

使用cd命令切换当前目录到 /etc/selinux
使用vim打开config文件
找到里面的SELINUX条目,设置成disabled
重启系统

2)bash: sqlplus: command not found

原因:可能数据库安装好后未启动

#ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
#su - oracle
$ sqlplus /nolog
 
SQL*Plus: Release 10.2.0.1.0 - Production on Mon May 11 12:51:24 2009
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

3)数据库启动时报错could not open parameter file '/app/oracle/product/11.1.0/db_1/dbs/initORCL.ora'

$ORACLE_BASE/admin/(dbname)/pfile目录下的init.ora(.01200923383)文件复制到$ORACLE_HOME/dbs目录下即可
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: