linux(centos6.8)安装oracle11g

来源:互联网 发布:php嵌入html页面 编辑:程序博客网 时间:2024/05/20 04:12
  1. 安装前准备
    • 下载oracle版本
      • 地址:http://docs.oracle.com/cd/E21901_01/index.html ,下载2个文件分别是 linux.x64_11gR2_database_1of2.zip,linux.x64_11gR2_database_2of2.zip
    • 安装前须知:

      • 内存(RAM)的最小要求是 1GB,建议 2GB 及以上。
      • 虚拟内存 swap 建议:内存为 1GB~2GB 时建议swap大小为内存大小的 1.5 倍;内存为 2GB~16GB 时建议swap大小为内存的大小;内存超过 16GB 时swap保持16GB。
      • 要求临时文件目录,如 /tmp 的磁盘空间至少 1GB。
      • 磁盘空间要求:企业版为4.35GB的安装空间和1.7GB以上的数据文件空间;标准版为4.22GB的安装空间和1.5GB以上的数据文件空间。
      • 需要 X window 图形界面。
      • 需要 root 用户权限
    • 本文安装环境:

      • 操作系统 CentOS 6.4 2.6.32-358.el6.x86_64(desktop),2GB RAM,80GB 硬盘空间(4GB swap、100MB /boot、40GB /)
      • 主机名 mophee, IP 192.168.80.19(静态)
      • 环境:VMware Workstation 9.0
    • 必要安装包的安装
      • centos root下执行以下脚本
      • yum install -y binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel make numactl sysstat libXp unixODBC unixODBC-devel
      • 或以下(推荐)
      • #提前安装好需要的rpm包yum install gcc libaio libaio-devel libstdc++ libstdc++-devel libgcc elfutils-libelf-devel glibc-devel glibc-devel gcc-c++ compat-libstdc++-33 unixODBC unixODBC-devel

        有一个rpm包需要独立下载pdksh-5.2.14-37.el5_8.1.x86_64,然后rpm -ivh安装即可。

        创建oinstall组
        groupadd oinstall

        创建dba组 
        groupadd dba

        创建oracle用户
        useradd -g oinstall -G dba oracle

        修改oracle用户的密码
        passwd oracle

        技术分享
        vi /etc/sysctl.conf#在文件末尾添加以下内容fs.aio-max-nr = 1048576fs.file-max = 6815744kernel.shmall = 2097152kernel.shmmax = 536870912kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048586 #刷新参数sysctl -p vi /etc/security/limits.conf  #在文件末尾添加以下内容oracle              soft    nproc   2047  oracle              hard    nproc   16384  oracle              soft    nofile  1024  oracle              hard    nofile  65536  oracle              soft    stack   10240 #创建安装Oracle软件所需要的目录mkdir -p /u01/oracle_11g_r2chown -R oracle:oinstall /u01/oracle_11g_r2chmod -R 775 /u01/oracle_11g_r2 #日志目录mkdir /u01/oralnventorychown -R oracle:oinstall /u01/oralnventory/chmod -R 775 /u01/oralnventory/ vi /home/oracle/.bash_profile  #在文件末尾添加以下内容umask 022export ORACLE_BASE=/u01/oracle_11g_r2export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/db_1export ORACLE_SID=orclexport PATH=$PATH:HOME/bin:$ORACLE_HOME/bin vi /etc/pam.d/login#在文件末尾添加以下内容session required /lib/security/pam_limits.sosession required 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   fifi #刷新参数source /etc/profile
        View Code
  1. 安装

        关闭SELinux(在root帐号下操作):

         编辑SELinux配置文件 vi /etc/selinux/config,将SELINUX的值设为 disabled,如下:

1
SELINUX=disabled;

        修改该文件可使重启系统后不启动SELinux。关闭当前已开启的SELinux使用如下命令:

1
setenforce 0

修改/etc/hosts文件(在root帐号下操作):

编辑文件 vi /etc/hosts,添加一行:

1
192.168.80.19 mophee

若不进行此操作会在安装时弹出警告,并且可能影响监听程序的正常运行,所以建议做这个修改。

创建所需的目录(在root帐号下操作):

把oracle安装在 /opt/oracle 目录下,所以需创建该目录:

1
2
3
mkdir/opt/oracle;
chownoracle:oinstall /opt/oracle;
chmod755 /opt/oracle;

安装时还需要设置 Inventory 目录,所以需创建该目录:

1
2
3
mkdir/opt/oraInventory;
chownoracle:oinstall /opt/oraInventory;
chmod755 /opt/oraInventory;

安装包相关:

Oracle 11g R2的安装包被压缩成两个文件:linux.x64_11gR2_database_1of2.zip、linux.x64_11gR2_database_2of2.zip,将它们上传到安装机器上,并使用 unzip linux.x64_11gR2_database_1of2.zip; unzip linux.x64_11gR2_database_2of2.zip; 进行解压缩,将得到一个名称为 database 的目录。我把它放在 /home/oracle/database 中。

由于安装过程是以 oracle 身份进行的,所以需确保oracle帐号对 /home/oracle/database 有执行权限,可使用如下命令将该目录赋予oracle帐号所有,并拥有执行权限:

1
2
chmod-R 700 /home/oracle/database;
chown-R oracle:oinstall /home/oracle/database;

————————退出 root,以 oracle 身份登录———————————-

设置oracle帐号登录时环境(以oracle身份登录):

编辑文件 vi /home/oracle/.bash_profile,添加如下行:

1
2
3
4
5
6
ORACLE_BASE=/opt/oracle#安装目录
ORACLE_HOME=$ORACLE_BASE/11g#oracle家目录
ORACLE_SID=orcl; #实例名
LD_LIBRARY_PATH=$ORACLE_HOME/lib;
PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin;
exportORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH;

保存退出后执行如下命令使以上设置立即生效:

1
source/home/oracle/.bash_profile

开始安装(以oracle身份登录):

1
2
exportLANG=en_US; ##
/home/oracle/database/runInstaller##执行该程序开始安装
  1. 安装收尾

  

最后的完善工作

vi /etc/oratab
orcl:/u01/oracle_11g_r2/oracle/product/11.2.0/db_1:Y(把N改成Y)

分别编辑以下两个文件
vi /u01/oracle_11g_r2/oracle/product/11.2.0/db_1/bin/dbstart
vi /u01/oracle_11g_r2/oracle/product/11.2.0/db_1/bin/dbshut

找到 ORACLE_HOME_LISTNER=$1
改成 ORACLE_HOME_LISTNER=$ORACLE_HOME

启动脚本如下

  1. #!/bin/bash
  2. # chkconfig: 2345 90 10
  3. export ORACLE_BASE=/u01/oracle_11g_r2
  4. export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/db_1
  5. export ORACLE_SID=orcl
  6. export PATH=$PATH:$ORACLE_HOME/bin
  7. ORCL_OWN="oracle"
  8. # if the executables do not exist -- display error
  9. if [ ! -f $ORACLE_HOME/bin/dbstart -! -d $ORACLE_HOME ]
  10. then
  11. echo "Oracle startup: cannot start"
  12. exit 1
  13. fi
  14. # depending on parameter -- start, stop, restart
  15. # of the instance and listener or usage display
  16. case "$1" in
  17. start)
  18. # Oracle listener and instance startup
  19. echo -"Starting Oracle: "
  20. su - $ORCL_OWN -"$ORACLE_HOME/bin/dbstart"
  21. touch /var/lock/subsys/oradb
  22. su - $ORCL_OWN -"$ORACLE_HOME/bin/emctl start dbconsole"
  23. echo "OK"
  24. ;;
  25. stop)
  26. # Oracle listener and instance shutdown
  27. echo -"Shutdown Oracle: "
  28. su - $ORCL_OWN -"$ORACLE_HOME/bin/emctl stop dbconsole"
  29. su - $ORCL_OWN -"$ORACLE_HOME/bin/dbshut"
  30. rm -/var/lock/subsys/oradb
  31. echo "OK"
  32. ;;
  33. reload|restart)
  34. $0 stop
  35. $1 start
  36. ;;
  37. *)
  38. echo "Usage: ‘basename $0‘ start|stop|restart|reload"
  39. exit 1
  40. esac
  41. exit 0
原创粉丝点击