当前位置:   article > 正文

Linux安装Oracle 11G_oracle11g下载linux

oracle11g下载linux

一、准备工作:

1、CentOS7自行安装(64位),网络自行配置;

2、下载Oracle安装包:linux.x64_11gR2_database_1of2.zip 和 linux.x64_11gR2_database_2of2.zip ;

3、HostName修改:oracle

hostnamectl set-hostname oracle

二、安装过程

1、配置yum源

  1. cd /etc
  2. mv yum.repos.d yum.repos.d.bak
  3. mkdir yum.repos.d
  4. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  5. yum clean all
  6. yum makecache

2、安装依赖包:

  1. yum -y install binutils \
  2. compat-libstdc++-33 \
  3. elfutils-libelf \
  4. elfutils-libelf-devel \
  5. expat \
  6. gcc \
  7. gcc-c++ \
  8. glibc \
  9. glibc-common \
  10. glibc-devel \
  11. glibc-headers \
  12. libaio \
  13. libaio-devel \
  14. libgcc \
  15. libstdc++ \
  16. libstdc++-devel \
  17. make \
  18. pdksh \
  19. sysstat \
  20. unixODBC \
  21. unixODBC-devel

3、检查依赖是否安装完整:

  1. rpm -q \
  2. binutils \
  3. compat-libstdc++-33 \
  4. elfutils-libelf \
  5. elfutils-libelf-devel \
  6. expat \
  7. gcc \
  8. gcc-c++ \
  9. glibc \
  10. glibc-common \
  11. glibc-devel \
  12. glibc-headers \
  13. libaio \
  14. libaio-devel \
  15. libgcc \
  16. libstdc++ \
  17. libstdc++-devel \
  18. make \
  19. pdksh \
  20. sysstat \
  21. unixODBC \
  22. unixODBC-devel | grep "not installed"

4、添加oracle用户组和用户:

  1. groupadd oinstall
  2. groupadd dba
  3. groupadd asmadmin
  4. groupadd asmdba
  5. useradd -g oinstall -G dba,asmdba oracle -d /home/oracle

5、添加完成后,查看oracle用户:

id oracle

6、初始化oracle用户的密码:

passwd oracle

以上部分操作截图:

配置hostname(本机IP映射)

  1. vi /etc/hosts
  2. 192.168.199.110 oracle
  3. # 测试hostname
  4. ping -c 3 oracle

优化OS内核参数

  1. # kernel.shmmax 参数设置为物理内存的一半
  2. vi /etc/sysctl.conf
  3. ## 内容如下:
  4. fs.aio-max-nr=1048576
  5. fs.file-max=6815744
  6. kernel.shmall=2097152
  7. kernel.shmmni=4096
  8. kernel.shmmax = 536870912
  9. kernel.sem=250 32000 100 128
  10. net.ipv4.ip_local_port_range=9000 65500
  11. net.core.rmem_default=262144
  12. net.core.rmem_max=4194304
  13. net.core.wmem_default=262144
  14. net.core.wmem_max=1048586

使参数生效:

sysctl -p

限制oracle用户的shell权限:

  1. vi /etc/security/limits.conf
  2. #在末尾添加
  3. oracle soft nproc 2047
  4. oracle hard nproc 16384
  5. oracle soft nofile 1024
  6. oracle hard nofile 65536
  7. oracle soft stack 10240
  8. oracle hard stack 10240
  9. vi /etc/pam.d/login
  10. session required /lib64/security/pam_limits.so
  11. session required pam_limits.so
  12. vi /etc/profile
  13. if [ $USER = "oracle" ]; then
  14. if [ $SHELL = "/bin/ksh" ]; then
  15. ulimit -p 16384
  16. ulimit -n 65536
  17. else
  18. ulimit -u 16384 -n 65536
  19. fi
  20. fi
  21. --------------------------------------------------------
  22. 使之生效:
  23. source /etc/profile

创建oracle安装目录:

  1. mkdir -p /db/app/oracle/product/11.2.0
  2. mkdir /db/app/oracle/oradata
  3. mkdir /db/app/oracle/oraInventory
  4. mkdir /db/app/oracle/fast_recovery_area
  5. chown -R oracle:oinstall /db/app/oracle
  6. chmod -R 775 /db/app/oracle
创建 vi /etc/oraInst.loc
  1. inventory_loc=/db/app/oracle/oraInventory
  2. inst_group=oinstall
  3. chown oracle:oinstall /etc/oraInst.loc
  4. chmod 664 /etc/oraInst.loc

配置oracle用户环境变量:

  1. su - oracle ## oracle用户登陆
  2. vi .bash_profile
  3. export ORACLE_HOSTNAME=oracle
  4. export ORACLE_BASE=/db/app/oracle
  5. export ORACLE_SID=ORCL
  6. export LC_ALL="en_US"
  7. export LANG="en_US"
  8. export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
  9. export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
  10. ## 以上配置完成后,建议重启系统 或分别执行以下命令:
  11. source /home/oracle/.bash_profile
  12. env

解压oracle压缩文件到 /db:

  1. # 上传linux.x64_11gR2_database_*of2.zip文件至/db/目录;
  2. cd /db/
  3. ls
  4. unzip linux.x64_11gR2_database_1of2.zip -d /db
  5. unzip linux.x64_11gR2_database_2of2.zip -d /db
  6. # 解压完成后:
  7. # 登录Root,复制授权
  8. su - root
  9. mkdir /home/oracle/etc/
  10. cp /db/database/response/* /home/oracle/etc/
  11. chmod 777 /home/oracle/etc/*.rsp
  12. # 登录oracle用户:
  13. su – oracle
  14. vi /home/oracle/etc/db_install.rsp
  15. ## 信息如下:
  16. oracle.install.option=INSTALL_DB_SWONLY
  17. UNIX_GROUP_NAME=oinstall
  18. INVENTORY_LOCATION=/db/app/oracle/oraInventory
  19. SELECTED_LANGUAGES=en,zh_CN
  20. ORACLE_HOSTNAME=oracle
  21. ORACLE_HOME=/db/app/oracle/product/11.2.0/db_1
  22. ORACLE_BASE=/db/app/oracle
  23. oracle.install.db.InstallEdition=EE
  24. oracle.install.db.isCustomInstall=true
  25. oracle.install.db.DBA_GROUP=dba
  26. oracle.install.db.OPER_GROUP=oinstall
  27. oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
  28. oracle.install.db.config.starterdb.globalDBName=orcl
  29. oracle.install.db.config.starterdb.SID=orcl
  30. oracle.install.db.config.starterdb.memoryLimit=512
  31. oracle.install.db.config.starterdb.password.ALL=oracle
  32. DECLINE_SECURITY_UPDATES=true

开始安装:

  1. su - oracle
  2. ./runInstaller -silent -force -responseFile /home/oracle/etc/db_install.rsp -ignorePrereq
  3. ## 安装期间可以使用tail命令监看oracle的安装日志
  4. tail -f /db/app/oracle/oraInventory/logs/installActions2019-05-25_10-38-29AM.log

安装完成,提示Successfully Setup Software.

 使用root用户执行脚本:

  1. su - root
  2. /db/app/oracle/product/11.2.0/db_1/root.sh

增加或修改oracle的环境变量:

  1. su - oracle
  2. vi ~/.bash_profile
  3. export ORACLE_HOME=/db/app/oracle/product/11.2.0/db_1
  4. export TNS_ADMIN=$ORACLE_HOME/network/admin
  5. export PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin
  6. export PATH=${PATH}:/usr/bin:/bin:/usr/local/bin
  7. export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/lib
  8. export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
  9. export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
  10. export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
  11. export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
  12. export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
  13. export LIBPATH=${CLASSPATH}:$ORACLE_HOME/lib:$ORACLE_HOME/ctx/lib
  14. export ORACLE_OWNER=oracle
  15. export SPFILE_PATH=$ORACLE_HOME/dbs
  16. export ORA_NLS10=$ORACLE_HOME/nls/data
  17. #生效
  18. source ~/.bash_profile

配置监听程序:

  1. [oracle@oracle bin]$ pwd
  2. /db/app/oracle/product/11.2.0/db_1/bin
  3. [oracle@oracle bin]$ ./netca /silent /responseFile /home/oracle/etc/netca.rsp

启动监控程序:

  1. [oracle@oracle bin]$ pwd
  2. /db/app/oracle/product/11.2.0/db_1/bin
  3. # 启动监听
  4. [oracle@oracle bin]$ lsnrctl start
  5. # 查看监听状态
  6. [oracle@oracle bin]$ lsnrctl start
  7. LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 25-MAY-2019 00:13:21
  8. Copyright (c) 1991, 2009, Oracle. All rights reserved.
  9. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1522)))
  10. STATUS of the LISTENER
  11. ------------------------
  12. Alias LISTENER
  13. Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
  14. Start Date 25-MAY-2019 00:05:55
  15. Uptime 0 days 0 hr. 7 min. 32 sec
  16. Trace Level off
  17. Security ON: Local OS Authentication
  18. SNMP OFF
  19. Listener Parameter File /db/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
  20. Listener Log File /db/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
  21. Listening Endpoints Summary...
  22. (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
  23. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1522)))
  24. The listener supports no services
  25. The command completed successfully
  26. [oracle@oracle bin]$

静默dbca建库

编辑应答文件:

  1. [oracle@oracle ~]$ vi /etc/dbca.rsp
  2. GDBNAME="orcl.oracle"
  3. SID="orcl"
  4. SYSPASSWORD = "oracle"
  5. SYSTEMPASSWORD = "oracle"
  6. CHARACTERSET="AL32UTF8"
  7. NATIONALCHARACTERSET="UTF8"
  8. # 执行:
  9. $ORACLE_HOME/bin/dbca -silent -responseFile /home/oracle/etc/dbca.rsp

 建库:

  1. [oracle@oracle bin]$ pwd
  2. /db/app/oracle/product/11.2.0/db_1/bin
  3. [oracle@oracle bin]$ dbca -silent -responseFile etc/dbca.rsp

至此完成数据库实例的创建。

删除实例:

[oracle@oracle ~]$ dbca -silent -deleteDatabase -sourcedb orcl

 设置Oracle开机启动

  1. 1.su - oracle
  2. vim $ORACLE_HOME/bin/dbstart
  3. 编辑dbstart,将ORACLE_HOME_LISTER=$1修改成ORACLE_HOME_LISTER=$ORACLE_HOME
  4. vim /etc/oratab
  5. 将“orcl:/db/app/oracle/product/11.2.0/db_1/:N”,
  6. 改为“orcl:/db/app/oracle/product/11.2.0/db_1/:Y"
  7. 2.使用root编辑/etc/rc.d/rc.local启动文件,添加数据库启动脚本dbstart
  8. su oracle -lc "/db/app/oracle/product/11.2.0/db_1/bin/dbstart"
  9. su oracle -lc "/db/app/oracle/product/11.2.0/db_1/bin/lsnrctl start"
  10. 3.为文件/etc/rc.d/rc.local添加执行权限:
  11. chmod +x /etc/rc.d/rc.local
  12. 4.重启主机,查看数据库和监听是自启动
  13. 重启主机 : reboot
  14. 查看监听(oracle用户):lsnrctl status

 登录Oracle

  1. [oracle@oracle bin]$ pwd
  2. /db/app/oracle/product/11.2.0/db_1/bin
  3. [oracle@oracle bin]$ ./sqlplus /nolog
  4. # 进入系统管理用户
  5. SQL> conn / as sysdba
  6. Connected to an idle instance.
  7. # 启动oracle实例
  8. SQL> startup;
解决问题:

(一)、错误信息:ORA-12162: TNS:net service name is incorrectly specified

  1. [oracle@oracle bin]$ ./sqlplus / as sysdba
  2. SQL*Plus: Release 11.2.0.1.0 Production on Sat May 25 00:20:45 2019
  3. Copyright (c) 1982, 2009, Oracle. All rights reserved.
  4. ERROR:
  5. ORA-12162: TNS:net service name is incorrectly specified

解决方式:

1、系统当前的ORACLE_HOME和ORACLE_SID环境变量:

  1. [oracle@oracle bin]$ echo $ORACLE_HOME
  2. /db/app/oracle/product/11.2.0/db_1
  3. [oracle@oracle bin]$ echo $ORACLE_SID
  4. [oracle@oracle bin]$

此时只设置了ORACLE_HOME环境变量,但ORACLE_SID此时为空,这就是该问题的真实原因。

2、给出ORACLE_SID,重新尝试登录:

  1. # 方法(一):
  2. [oracle@oracle bin]$ export ORACLE_SID=ora11g
  3. [oracle@oracle bin]$ echo $ORACLE_SID
  4. ora11g
  5. # 方法(二):
  6. [oracle@oracle bin]$ vi ~/.bash_profile
  7. export ORACLE_SID=ora11g
  8. # 保存退出,使其生效
  9. [oracle@oracle bin]$ source ~/.bash_profile
  10. # 登录oracle
  11. [oracle@oracle bin]$ sqlplus /nolog
  12. SQL*Plus: Release 11.2.0.1.0 Production on Sat May 25 00:37:35 2019
  13. Copyright (c) 1982, 2009, Oracle. All rights reserved.
  14. SQL> conn / as sysdba
  15. Connected to an idle instance.

 ( 二)、错误信息:LRM-00109: could not open parameter file '/db/app/oracle/product/11.2.0/db_1/dbs/initora11g.ora'

  1. SQL> startup
  2. ORA-01078: failure in processing system parameters
  3. LRM-00109: could not open parameter file '/db/app/oracle/product/11.2.0/db_1/dbs/initora11g.ora'

解决方法:

1、查看文件:

  1. cd /db/app/oracle/product/11.2.0/db_1/dbs
  2. ls
  3. # 查看initora11g.ora不存在;

 2、复制文件及改名

  1. [root@oracle admin]# cd /db/app/oracle/admin/orcl/pfile/
  2. [root@oracle pfile]# ls
  3. init.ora.4242019231824
  4. [root@oracle pfile]# cp ./init.ora.4242019231824 /db/app/oracle/product/11.2.0/db_1/dbs/
  5. [root@oracle pfile]# cd /db/app/oracle/product/11.2.0/db_1/dbs/
  6. [root@oracle dbs]# ls
  7. hc_ora11g.dat init.ora init.ora.4242019231824 lkORCL orapworcl
  8. [root@oracle dbs]# mv ./init.ora.4242019231824 initora11g.ora
  9. [root@oracle dbs]# chmod -R 777 /db/app/oracle/product/11.2.0/db_1/dbs/initora11g.ora

 3、登录验证startup命令

  1. [oracle@oracle bin]$ sqlplus "/as sysdba"
  2. SQL*Plus: Release 11.2.0.1.0 Production on Sat May 25 01:33:36 2019
  3. Copyright (c) 1982, 2009, Oracle. All rights reserved.
  4. Connected to an idle instance.
  5. SQL> startup
  6. ORACLE instance started.
  7. Total System Global Area 1586708480 bytes
  8. Fixed Size 2213736 bytes
  9. Variable Size 922749080 bytes
  10. Database Buffers 654311424 bytes
  11. Redo Buffers 7434240 bytes
  12. ORA-00205: error in identifying control file, check alert log for more info
  13. SQL>
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/801217
推荐阅读
相关标签
  

闽ICP备14008679号