当前位置:   article > 正文

CENTOS 7.5【部署安装ORACLE.11G数据库】

no init file found for database instance "orcl

Oracle Database,又名Oracle RDBMS,或简称Oracle。是甲骨文公司的一款关系数据库管理系统。它是在数据库领域一直处于领先地位的产品。可以说Oracle数据库系统是目前世界上流行的关系数据库管理系统,系统可移植性好、使用方便、功能强,适用于各类大、中、小、微机环境。它是一种高效率、可靠性好的、适应高吞吐量的数据库方案。

1、部署环境要求
(1)操作系统版本:CentOS 7.x(最小化安装)
(2)最小内存容量:4GB
(3)最小CPU核心数:2核心
(4)最小磁盘空间:50GB
(5)磁盘分区建议:500GB磁盘空间为例
           /:50GB(根分区)
           /boot:500MB
           /home:50GB
           swap:物理内存小于4GB时,swap分配值为物理内存2倍,物理内存大于4GB时,swap分配值为物理内存1.5倍
           /data:剩余全部空间

 2、部署软件准备

Oracle Database SoftPack:linux.x64_11gR2_database_1of2.zip
Oracle Database SoftPack:linux.x64_11gR2_database_2of2.zip

 3、网络参数配置

  1. [root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
  2. TYPE=Ethernet
  3. PROXY_METHOD=none
  4. BROWSER_ONLY=no
  5. BOOTPROTO=none
  6. DEFROUTE=yes
  7. IPV4_FAILURE_FATAL=no
  8. IPV6INIT=yes
  9. IPV6_AUTOCONF=yes
  10. IPV6_DEFROUTE=yes
  11. IPV6_FAILURE_FATAL=no
  12. IPV6_ADDR_GEN_MODE=stable-privacy
  13. NAME=ens33
  14. UUID=8586e405-4459-42e2-ac9f-def02881736d
  15. DEVICE=ens33
  16. ONBOOT=yes
  17. MACADDR=preserve
  18. IPADDR=10.10.10.133
  19. PREFIX=24
  20. GATEWAY=10.10.10.10
  21. DNS1=114.114.114.114
  22. IPV6_PRIVACY=no
  23. ZONE=public

 4、系统软件安装

[root@localhost ~]# yum -y install vim net-tools tree unzip lrzsz

5、系统安全配置
(1)关闭SELINUX安全访问控制

  1. [root@localhost ~]# vim /etc/selinux/config
  2. # This file controls the state of SELinux on the system.
  3. # SELINUX= can take one of these three values:
  4. # enforcing - SELinux security policy is enforced.
  5. # permissive - SELinux prints warnings instead of enforcing.
  6. # disabled - No SELinux policy is loaded.
  7. # SELINUX=enforcing //注释掉此处
  8. SELINUX=disabled //新增此处,并将SELINUX状态设置关闭状态disabled
  9. # SELINUXTYPE= can take one of these two values:
  10. # targeted - Targeted processes are protected,
  11. # mls - Multi Level Security protection.
  12. SELINUXTYPE=targeted

(2)配置防火墙安全规则

  1. [root@localhost ~]# systemctl status firewalld.service //查看防火墙运行状态
  2. ● firewalld.service - firewalld - dynamic firewall daemon
  3. Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
  4. Active: active (running) since 五 2019-08-30 22:58:53 CST; 8h ago
  5. Docs: man:firewalld(1)
  6. Main PID: 841 (firewalld)
  7. CGroup: /system.slice/firewalld.service
  8. └─841 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
  9. 830 22:58:52 oracleserver.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
  10. 830 22:58:53 oracleserver.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
  11. [root@localhost ~]# firewall-cmd --zone=public --add-port=1521/tcp --permanent //开放1521端口
  12. success
  13. [root@localhost ~]# firewall-cmd --zone=public --add-port=1158/tcp --permanent //开放1158端口
  14. success
  15. [root@localhost ~]# firewall-cmd --zone=public --add-port=22/tcp --permanent //开放22端口
  16. success
  17. [root@localhost ~]# firewall-cmd --reload //重启载入防火墙配置
  18. success
  19. [root@localhost ~]# firewall-cmd --zone=public --list-ports //查看已开放端口
  20. 22/tcp 1158/tcp 1521/tcp

6、安装依赖软件

  1. 32位依赖软件:
  2. [root@localhost ~]# yum -y install binutils compat-libcap1 compat-libstdc++-33 \
  3. compat-libstdc++-33*i686 compat-libstdc++-33*.devel \
  4. compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ \
  5. glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio \
  6. libaio*.i686 libaio-devel libaio-devel*.devel libgcc \
  7. libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel \
  8. libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 \
  9. make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
  10. 64位依赖软件:
  11. [root@localhost ~]# yum -y install binutils-2.* compat-libstdc++-33* elfutils-libelf-0.* \
  12. elfutils-libelf-devel-* gcc-4.* gcc-c++-4.* glibc-2.* glibc-common-2.* \
  13. glibc-devel-2.* glibc-headers-2.* ksh-2* libaio-0.* libaio-devel-0.* \
  14. libgcc-4.* libstdc++-4.* libstdc++- devel-4.* make-3.* sysstat-7.* \
  15. unixODBC-2.* unixODBC-devel-2.* pdksh*
  16. 检查依赖软件:
  17. [root@localhost ~]# rpm -q binutils compat-libcap1 compat-libstdc++-33 \
  18. compat-libstdc++-33*i686 compat-libstdc++-33*.devel \
  19. compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ \
  20. glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio \
  21. libaio*.i686 libaio-devel libaio-devel*.devel libgcc \
  22. libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel \
  23. libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 \
  24. make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
  25. 执行安装更新:
  26. [root@localhost ~]# yum update

7、部署用户配置
(1)创建部署用户

  1. [root@localhost ~]# groupadd oinstall //创建oinstall用户组
  2. [root@localhost ~]# groupadd dba //创建dba用户组
  3. [root@localhost ~]# useradd -g oinstall -G dba oracle //创建oracle用户并将用户加入到oinstall、dba两个用户组
  4. [root@localhost ~]# passwd oracle //设置oracle用户密码
  5. 更改用户 oracle 的密码 。
  6. 新的 密码:
  7. 重新输入新的 密码:
  8. passwd: 所有的身份验证令牌已经成功更新。

  (2)创建部署目录

  1. [root@localhost ~]# mkdir -p /oracle/app/product/11.2.0/dbhome_1
  2. [root@localhost ~]# mkdir -p /oracle/app/oradata
  3. [root@localhost ~]# mkdir -p /oracle/flash_recovery_area
  4. [root@localhost ~]# mkdir -p /oracle/oraInventory
  5. [root@localhost ~]# mkdir -p /oracle/response
  6. [root@localhost ~]# mkdir -p /software
  7. [root@localhost ~]# chown oracle:oinstall -R /oracle/
  8. [root@localhost ~]# chown oracle:oinstall -R /software/
  9. [root@localhost ~]# chmod -R 755 /oracle/
  10. [root@localhost ~]# chmod -R 755 /software/

8、配置部署参数
(1)配置系统主机参数

  1. [root@localhost ~]# hostnamectl set-hostname oracleserver.localdomain //修改主机名称
  2. [root@localhost ~]# vim /etc/hosts //配置主机网络地址与主机名称映射记录
  3. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  4. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  5. 10.10.10.133 oracleserver oracleserver.localdomain
  6. [root@oracleserver ~]# vim /etc/redhat-release //配置系统标识参数
  7. #CentOS Linux release 7.6.1810 (Core)
  8. Red Hat Enterprise Linux Server release 7.3 (Maipo)
  9. [root@localhost ~]# reboot //重启操作系统

(2)配置系统内核参数

  1. [root@oracleserver ~]# vim /etc/sysctl.conf
  2. # sysctl settings are defined through files in
  3. # /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
  4. #
  5. # Vendors settings live in /usr/lib/sysctl.d/.
  6. # To override a whole file, create a new file with the same in
  7. # /etc/sysctl.d/ and put new settings there. To override
  8. # only specific settings, add a file with a lexically later
  9. # name in /etc/sysctl.d/ and put new settings there.
  10. #
  11. # For more information, see sysctl.conf(5) and sysctl.d(5).
  12. #Oracle Install Parameter //添加下面内核参数
  13. fs.file-max = 6815744
  14. fs.aio-max-nr = 1048576
  15. kernel.shmall = 2097152
  16. kernel.shmmax = 2147483648
  17. kernel.shmmni = 4096
  18. kernel.sem = 250 32000 100 128
  19. net.ipv4.ip_local_port_range = 9000 65500
  20. net.core.rmem_default = 4194304
  21. net.core.rmem_max = 4194304
  22. net.core.wmem_default = 262144
  23. net.core.wmem_max = 1048576
  24. [root@oracleserver ~]# /sbin/sysctl -p //更新内核参数,等效命令
  25. [root@oracleserver ~]# /sysctl -p //更新内核参数,等效命令
  26. fs.file-max = 6815744
  27. fs.aio-max-nr = 1048576
  28. kernel.shmall = 2097152
  29. kernel.shmmax = 2147483648
  30. kernel.shmmni = 4096
  31. kernel.sem = 250 32000 100 128
  32. net.ipv4.ip_local_port_range = 9000 65500
  33. net.core.rmem_default = 4194304
  34. net.core.rmem_max = 4194304
  35. net.core.wmem_default = 262144
  36. net.core.wmem_max = 1048576

(3)配置登录身份认证

  1. [root@oracleserver ~]# vim /etc/pam.d/login
  2. #%PAM-1.0
  3. auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
  4. auth substack system-auth
  5. auth include postlogin
  6. account required pam_nologin.so
  7. account include system-auth
  8. password include system-auth
  9. # pam_selinux.so close should be the first session rule
  10. session required pam_selinux.so close
  11. session required pam_loginuid.so
  12. session optional pam_console.so
  13. # pam_selinux.so open should only be followed by sessions to be executed in the user context
  14. session required pam_selinux.so open
  15. session required pam_namespace.so
  16. session optional pam_keyinit.so force revoke
  17. session include system-auth
  18. session include postlogin
  19. -session optional pam_ck_connector.so
  20. #Oracle Install Parameter //添加下面Oracle安装参数
  21. session required pam_limits.so
  22. session required /lib64/security/pam_limits.so

(4)配置资源限制参数

  1. [root@oracleserver ~]# vim /etc/profile
  2. # /etc/profile
  3. # System wide environment and startup programs, for login setup
  4. # Functions and aliases go in /etc/bashrc
  5. # It's NOT a good idea to change this file unless you know what you
  6. # are doing. It's much better to create a custom.sh shell script in
  7. # /etc/profile.d/ to make custom changes to your environment, as this
  8. # will prevent the need for merging in future updates.
  9. pathmunge () {
  10. case ":${PATH}:" in
  11. *:"$1":*)
  12. ;;
  13. *)
  14. if [ "$2" = "after" ] ; then
  15. PATH=$PATH:$1
  16. else
  17. PATH=$1:$PATH
  18. fi
  19. esac
  20. }
  21. if [ -x /usr/bin/id ]; then
  22. if [ -z "$EUID" ]; then
  23. # ksh workaround
  24. EUID=`/usr/bin/id -u`
  25. UID=`/usr/bin/id -ru`
  26. fi
  27. USER="`/usr/bin/id -un`"
  28. LOGNAME=$USER
  29. MAIL="/var/spool/mail/$USER"
  30. fi
  31. # Path manipulation
  32. if [ "$EUID" = "0" ]; then
  33. pathmunge /usr/sbin
  34. pathmunge /usr/local/sbin
  35. else
  36. pathmunge /usr/local/sbin after
  37. pathmunge /usr/sbin after
  38. fi
  39. HOSTNAME=`/usr/bin/hostname 2>/dev/null`
  40. HISTSIZE=1000
  41. if [ "$HISTCONTROL" = "ignorespace" ] ; then
  42. export HISTCONTROL=ignoreboth
  43. else
  44. export HISTCONTROL=ignoredups
  45. fi
  46. export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
  47. # By default, we want umask to get set. This sets it for login shell
  48. # Current threshold for system reserved uid/gids is 200
  49. # You could check uidgid reservation validity in
  50. # /usr/share/doc/setup-*/uidgid file
  51. if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
  52. umask 002
  53. else
  54. umask 022
  55. fi
  56. for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
  57. if [ -r "$i" ]; then
  58. if [ "${-#*i}" != "$-" ]; then
  59. . "$i"
  60. else
  61. . "$i" >/dev/null
  62. fi
  63. fi
  64. done
  65. unset i
  66. unset -f pathmunge
  67. #Oracle Install Parameter //添加下面Oracle安装参数
  68. if [ $USER = "oracle" ]; then
  69. if [ $SHELL = "/bin/ksh" ]; then
  70. ulimit -p 16384
  71. ulimit -n 65536
  72. else
  73. ulimit -u 16384 -n 65536
  74. fi
  75. fi
  76. [root@oracleserver ~]# source /etc/profile //使参数配置生效

 

  1. [root@oracleserver ~]# cat /etc/security/limits.conf
  2. # /etc/security/limits.conf
  3. #
  4. #This file sets the resource limits for the users logged in via PAM.
  5. #It does not affect resource limits of the system services.
  6. #
  7. #Also note that configuration files in /etc/security/limits.d directory,
  8. #which are read in alphabetical order, override the settings in this
  9. #file in case the domain is the same or more specific.
  10. #That means for example that setting a limit for wildcard domain here
  11. #can be overriden with a wildcard setting in a config file in the
  12. #subdirectory, but a user specific setting here can be overriden only
  13. #with a user specific setting in the subdirectory.
  14. #
  15. #Each line describes a limit for a user in the form:
  16. #
  17. #<domain> <type> <item> <value>
  18. #
  19. #Where:
  20. #<domain> can be:
  21. # - a user name
  22. # - a group name, with @group syntax
  23. # - the wildcard *, for default entry
  24. # - the wildcard %, can be also used with %group syntax,
  25. # for maxlogin limit
  26. #
  27. #<type> can have the two values:
  28. # - "soft" for enforcing the soft limits
  29. # - "hard" for enforcing hard limits
  30. #
  31. #<item> can be one of the following:
  32. # - core - limits the core file size (KB)
  33. # - data - max data size (KB)
  34. # - fsize - maximum filesize (KB)
  35. # - memlock - max locked-in-memory address space (KB)
  36. # - nofile - max number of open file descriptors
  37. # - rss - max resident set size (KB)
  38. # - stack - max stack size (KB)
  39. # - cpu - max CPU time (MIN)
  40. # - nproc - max number of processes
  41. # - as - address space limit (KB)
  42. # - maxlogins - max number of logins for this user
  43. # - maxsyslogins - max number of logins on the system
  44. # - priority - the priority to run user process with
  45. # - locks - max number of file locks the user can hold
  46. # - sigpending - max number of pending signals
  47. # - msgqueue - max memory used by POSIX message queues (bytes)
  48. # - nice - max nice priority allowed to raise to values: [-20, 19]
  49. # - rtprio - max realtime priority
  50. #
  51. #<domain> <type> <item> <value>
  52. #
  53. #* soft core 0
  54. #* hard rss 10000
  55. #@student hard nproc 20
  56. #@faculty soft nproc 20
  57. #@faculty hard nproc 50
  58. #ftp hard nproc 0
  59. #@student - maxlogins 4
  60. #Oracle Install Parameter //添加下面Oracle安装参数
  61. oracle soft nproc 2047
  62. oracle hard nproc 16384
  63. oracle soft nofile 1024
  64. oracle hard nofile 65536
  65. # End of file

 (5)配置内存分配参数

  1. [root@oracleserver ~]# cat /sys/kernel/mm/transparent_hugepage/enabled //查询THP状态
  2. always
  3. [root@oracleserver ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled //关闭THP延迟分配内存机制
  4. [root@oracleserver ~]# cat /sys/kernel/mm/transparent_hugepage/enabled //查询THP状态
  5. always madvise [never]

(6)配置数据库环境变量

  1. [root@oracleserver ~]# vim /home/oracle/.bash_profile
  2. # .bash_profile
  3. # Get the aliases and functions
  4. if [ -f ~/.bashrc ]; then
  5. . ~/.bashrc
  6. fi
  7. # User specific environment and startup programs
  8. PATH=$PATH:$HOME/.local/bin:$HOME/bin
  9. export PATH
  10. #Oracle Install Parameter //添加下面Oracle安装参数
  11. umask 022
  12. export ORACLE_BASE=/oracle/app
  13. export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
  14. export ORACLE_SID=orcl
  15. export ORACLE_UNQNAME=orcl
  16. export NLS_LANG=.AL32UTF8
  17. export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/lib64
  18. export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
  19. export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
  20. export TNS_ADMIN=/oracle/app/product/11.2.0/dbhome_1/network/admin
  21. export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
  22. [root@oracleserver ~]# source /home/oracle/.bash_profile //使参数配置生效
  23. [root@oracleserver ~]# reboot //重启操作系统

9、上传数据库软件

  1. [root@oracleserver ~]# cd /software/
  2. [root@oracleserver software]# rz
  3. [root@oracleserver software]# ll
  4. 总用量 2295592
  5. -rw-r--r-- 1 oracle oinstall 1239269270 829 11:44 Oracle.11g.R2.DataBase.Linux.x64.11.2.0.1.0.1of2.zip
  6. -rw-r--r-- 1 oracle oinstall 1111416131 829 11:44 Oracle.11g.R2.DataBase.Linux.x64.11.2.0.1.0.2of2.zip
  7. #静默解压文件
  8. [root@oracleserver software]# unzip -q Oracle.11g.R2.DataBase.Linux.x64.11.2.0.1.0.1of2.zip -d /software
  9. [root@oracleserver software]# unzip -q Oracle.11g.R2.DataBase.Linux.x64.11.2.0.1.0.2of2.zip -d /software
  10. [root@oracleserver software]# ll
  11. 总用量 2295592
  12. drwxr-xr-x 8 oracle oinstall 128 821 2009 database
  13. -rw-r--r-- 1 oracle oinstall 1239269270 829 11:44 Oracle.11g.R2.DataBase.Linux.x64.11.2.0.1.0.1of2.zip
  14. -rw-r--r-- 1 oracle oinstall 1111416131 829 11:44 Oracle.11g.R2.DataBase.Linux.x64.11.2.0.1.0.2of2.zip

10、配置数据库响应文件

  1. [root@oracleserver software]# cp /software/database/response/db_install.rsp /oracle/response/ //等效命令
  2. [root@oracleserver software]# cp /software/database/response/* /oracle/response/ //等效命令
  3. [root@oracleserver software]# vim /oracle/response/db_install.rsp
  4. ####################################################################
  5. ## Copyright(c) Oracle Corporation 1998,2008. All rights reserved.##
  6. ## ##
  7. ## Specify values for the variables listed below to customize ##
  8. ## your installation. ##
  9. ## ##
  10. ## Each variable is associated with a comment. The comment ##
  11. ## can help to populate the variables with the appropriate ##
  12. ## values. ##
  13. ## ##
  14. ## IMPORTANT NOTE: This file contains plain text passwords and ##
  15. ## should be secured to have read permission only by oracle user ##
  16. ## or db administrator who owns this installation. ##
  17. ## ##
  18. ####################################################################
  19. #------------------------------------------------------------------------------
  20. # Do not change the following system generated value.
  21. #------------------------------------------------------------------------------
  22. #标注响应文件版本
  23. oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
  24. #------------------------------------------------------------------------------
  25. # Specify the installation option.
  26. # It can be one of the following:
  27. # 1. INSTALL_DB_SWONLY 只装数据库软件
  28. # 2. INSTALL_DB_AND_CONFIG 安装数据库软件并建库
  29. # 3. UPGRADE_DB 升级数据库
  30. #-------------------------------------------------------------------------------
  31. oracle.install.option=INSTALL_DB_AND_CONFIG
  32. #-------------------------------------------------------------------------------
  33. # Specify the hostname of the system as set during the install. It can be used
  34. # to force the installation to use an alternative hostname rather than using the
  35. # first hostname found on the system. (e.g., for systems with multiple hostnames
  36. # and network interfaces)
  37. #-------------------------------------------------------------------------------
  38. #指定操作系统主机名
  39. ORACLE_HOSTNAME=oracleserver
  40. #-------------------------------------------------------------------------------
  41. # Specify the Unix group to be set for the inventory directory.
  42. #-------------------------------------------------------------------------------
  43. #指定产品清单oraInventory目录所有者,通常会是oinstall或者dba组
  44. UNIX_GROUP_NAME=oinstall
  45. #-------------------------------------------------------------------------------
  46. # Specify the location which holds the inventory files.
  47. #-------------------------------------------------------------------------------
  48. #指定产品清单oraInventory目录路径,需要建立在App目录外面
  49. INVENTORY_LOCATION=/oracle/oraInventory
  50. #-------------------------------------------------------------------------------
  51. # Specify the languages in which the components will be installed.
  52. #
  53. # en : English ja : Japanese
  54. # fr : French ko : Korean
  55. # ar : Arabic es : Latin American Spanish
  56. # bn : Bengali lv : Latvian
  57. # pt_BR: Brazilian Portuguese lt : Lithuanian
  58. # bg : Bulgarian ms : Malay
  59. # fr_CA: Canadian French es_MX: Mexican Spanish
  60. # ca : Catalan no : Norwegian
  61. # hr : Croatian pl : Polish
  62. # cs : Czech pt : Portuguese
  63. # da : Danish ro : Romanian
  64. # nl : Dutch ru : Russian
  65. # ar_EG: Egyptian zh_CN: Simplified Chinese
  66. # en_GB: English (Great Britain) sk : Slovak
  67. # et : Estonian sl : Slovenian
  68. # fi : Finnish es_ES: Spanish
  69. # de : German sv : Swedish
  70. # el : Greek th : Thai
  71. # iw : Hebrew zh_TW: Traditional Chinese
  72. # hu : Hungarian tr : Turkish
  73. # is : Icelandic uk : Ukrainian
  74. # in : Indonesian vi : Vietnamese
  75. # it : Italian
  76. #
  77. # Example : SELECTED_LANGUAGES=en,fr,ja
  78. #------------------------------------------------------------------------------
  79. #指定数据库语言,多个直接用逗号隔开
  80. SELECTED_LANGUAGES=en,zh_CN
  81. #------------------------------------------------------------------------------
  82. # Specify the complete path of the Oracle Home.
  83. #------------------------------------------------------------------------------
  84. #设置ORALCE_HOME的路径
  85. ORACLE_HOME=/oracle/app/product/11.2.0/dbhome_1
  86. #------------------------------------------------------------------------------
  87. # Specify the complete path of the Oracle Base.
  88. #------------------------------------------------------------------------------
  89. #设置ORACLE_BASE的路径
  90. ORACLE_BASE=/oracle/app
  91. #------------------------------------------------------------------------------
  92. # Specify the installation edition of the component.
  93. #
  94. # The value should contain only one of these choices.
  95. # EE : Enterprise Edition 企业版
  96. # SE : Standard Edition 标准版
  97. # SEONE : Standard Edition One 标准版1
  98. # PE : Personal Edition (WINDOWS ONLY) 个人版
  99. #------------------------------------------------------------------------------
  100. #指定数据库版本
  101. oracle.install.db.InstallEdition=EE
  102. #------------------------------------------------------------------------------
  103. # This variable is used to enable or disable custom install.
  104. #
  105. # true : Components mentioned as part of 'customComponents' property
  106. # are considered for install.
  107. # false : Value for 'customComponents' is not considered.
  108. #------------------------------------------------------------------------------
  109. #是否自定义Oracle的组件,如果选择false,则会使用默认的组件。
  110. #是否自定义Oracle的组件,如果选择true,则需要自己选择组件。
  111. oracle.install.db.isCustomInstall=false
  112. #------------------------------------------------------------------------------
  113. # This variable is considered only if 'IsCustomInstall' is set to true.
  114. #
  115. # Description: List of Enterprise Edition Options you would like to install.
  116. #
  117. # The following choices are available. You may specify any
  118. # combination of these choices. The components you choose should
  119. # be specified in the form "internal-component-name:version"
  120. # Below is a list of components you may specify to install.
  121. #
  122. # oracle.rdbms.partitioning:11.2.0.1.0 - Oracle Partitioning
  123. # oracle.rdbms.dm:11.2.0.1.0 - Oracle Data Mining
  124. # oracle.rdbms.dv:11.2.0.1.0 - Oracle Database Vault
  125. # oracle.rdbms.lbac:11.2.0.1.0 - Oracle Label Security
  126. # oracle.rdbms.rat:11.2.0.1.0 - Oracle Real Application Testing
  127. # oracle.oraolap:11.2.0.1.0 - Oracle OLAP
  128. #------------------------------------------------------------------------------
  129. oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
  130. ###############################################################################
  131. # #
  132. # PRIVILEGED OPERATING SYSTEM GROUPS #
  133. # ------------------------------------------ #
  134. # Provide values for the OS groups to which OSDBA and OSOPER privileges #
  135. # needs to be granted. If the install is being performed as a member of the #
  136. # group "dba", then that will be used unless specified otherwise below. #
  137. # #
  138. ###############################################################################
  139. #------------------------------------------------------------------------------
  140. # The DBA_GROUP is the OS group which is to be granted OSDBA privileges.
  141. #------------------------------------------------------------------------------
  142. #指定拥有OSDBA权限的用户组,通常会是dba组
  143. oracle.install.db.DBA_GROUP=dba
  144. #------------------------------------------------------------------------------
  145. # The OPER_GROUP is the OS group which is to be granted OSOPER privileges.
  146. #------------------------------------------------------------------------------
  147. 指定拥有OSOPER权限的用户组,通常会是oinstall组
  148. oracle.install.db.OPER_GROUP=oinstall
  149. #------------------------------------------------------------------------------
  150. # Specify the cluster node names selected during the installation.
  151. #------------------------------------------------------------------------------
  152. #指定RAC安装节点
  153. oracle.install.db.CLUSTER_NODES=
  154. #------------------------------------------------------------------------------
  155. # Specify the type of database to create.
  156. # It can be one of the following:
  157. # - GENERAL_PURPOSE/TRANSACTION_PROCESSING 一般用途/事物处理
  158. # - DATA_WAREHOUSE 数据仓库
  159. #------------------------------------------------------------------------------
  160. #指定数据库用途类型
  161. oracle.install.db.config.starterdb.type=DATA_WAREHOUSE
  162. #------------------------------------------------------------------------------
  163. # Specify the Starter Database Global Database Name.
  164. #------------------------------------------------------------------------------
  165. #指定GlobalName
  166. oracle.install.db.config.starterdb.globalDBName=orcl
  167. #------------------------------------------------------------------------------
  168. # Specify the Starter Database SID.
  169. #------------------------------------------------------------------------------
  170. #指定SIDName
  171. oracle.install.db.config.starterdb.SID=orcl
  172. #------------------------------------------------------------------------------
  173. # Specify the Starter Database character set.
  174. #
  175. # It can be one of the following:
  176. # AL32UTF8, WE8ISO8859P15, WE8MSWIN1252, EE8ISO8859P2,
  177. # EE8MSWIN1250, NE8ISO8859P10, NEE8ISO8859P4, BLT8MSWIN1257,
  178. # BLT8ISO8859P13, CL8ISO8859P5, CL8MSWIN1251, AR8ISO8859P6,
  179. # AR8MSWIN1256, EL8ISO8859P7, EL8MSWIN1253, IW8ISO8859P8,
  180. # IW8MSWIN1255, JA16EUC, JA16EUCTILDE, JA16SJIS, JA16SJISTILDE,
  181. # KO16MSWIN949, ZHS16GBK, TH8TISASCII, ZHT32EUC, ZHT16MSWIN950,
  182. # ZHT16HKSCS, WE8ISO8859P9, TR8MSWIN1254, VN8MSWIN1258
  183. #------------------------------------------------------------------------------
  184. #指定数据库默认字符集
  185. oracle.install.db.config.starterdb.characterSet=AL32UTF8
  186. #------------------------------------------------------------------------------
  187. # This variable should be set to true if Automatic Memory Management
  188. # in Database is desired.
  189. # If Automatic Memory Management is not desired, and memory allocation
  190. # is to be done manually, then set it to false.
  191. #------------------------------------------------------------------------------
  192. #开启数据库自动内存管理
  193. oracle.install.db.config.starterdb.memoryOption=true
  194. #------------------------------------------------------------------------------
  195. # Specify the total memory allocation for the database. Value(in MB) should be
  196. # at least 256 MB, and should not exceed the total physical memory available
  197. # on the system.
  198. # Example: oracle.install.db.config.starterdb.memoryLimit=512
  199. #------------------------------------------------------------------------------
  200. #指定自动内存容量大小
  201. oracle.install.db.config.starterdb.memoryLimit=512
  202. #------------------------------------------------------------------------------
  203. # This variable controls whether to load Example Schemas onto the starter
  204. # database or not.
  205. #------------------------------------------------------------------------------
  206. #是否载入模板示例
  207. oracle.install.db.config.starterdb.installExampleSchemas=false
  208. #------------------------------------------------------------------------------
  209. # This variable includes enabling audit settings, configuring password profiles
  210. # and revoking some grants to public. These settings are provided by default.
  211. # These settings may also be disabled.
  212. #------------------------------------------------------------------------------
  213. #是否启用安全设置
  214. oracle.install.db.config.starterdb.enableSecuritySettings=true
  215. ###############################################################################
  216. # #
  217. # Passwords can be supplied for the following four schemas in the #
  218. # starter database: #
  219. # SYS #
  220. # SYSTEM #
  221. # SYSMAN (used by Enterprise Manager) #
  222. # DBSNMP (used by Enterprise Manager) #
  223. # #
  224. # Same password can be used for all accounts (not recommended) #
  225. # or different passwords for each account can be provided (recommended) #
  226. # #
  227. ###############################################################################
  228. #------------------------------------------------------------------------------
  229. # This variable holds the password that is to be used for all schemas in the
  230. # starter database.
  231. #-------------------------------------------------------------------------------
  232. #设置数据用所有用户使用同一个密码
  233. oracle.install.db.config.starterdb.password.ALL=iTouch123
  234. #-------------------------------------------------------------------------------
  235. # Specify the SYS password for the starter database.
  236. #-------------------------------------------------------------------------------
  237. #设置sys用户密码
  238. oracle.install.db.config.starterdb.password.SYS=
  239. #-------------------------------------------------------------------------------
  240. # Specify the SYSTEM password for the starter database.
  241. #-------------------------------------------------------------------------------
  242. #设置system用户密码
  243. oracle.install.db.config.starterdb.password.SYSTEM=
  244. #-------------------------------------------------------------------------------
  245. # Specify the SYSMAN password for the starter database.
  246. #-------------------------------------------------------------------------------
  247. #设置sysman用户密码
  248. oracle.install.db.config.starterdb.password.SYSMAN=
  249. #-------------------------------------------------------------------------------
  250. # Specify the DBSNMP password for the starter database.
  251. #-------------------------------------------------------------------------------
  252. #设置dbsnmp用户密码
  253. oracle.install.db.config.starterdb.password.DBSNMP=
  254. #-------------------------------------------------------------------------------
  255. # Specify the management option to be selected for the starter database.
  256. # It can be one of the following:
  257. # 1. GRID_CONTROL 远程管理工具
  258. # 2. DB_CONTROL 本地管理工具
  259. #-------------------------------------------------------------------------------
  260. oracle.install.db.config.starterdb.control=DB_CONTROL
  261. #-------------------------------------------------------------------------------
  262. # Specify the Management Service to use if Grid Control is selected to manage
  263. # the database.
  264. #-------------------------------------------------------------------------------
  265. #GRID_CONTROL需要设定gridcontrol的远程路径URL
  266. oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
  267. #-------------------------------------------------------------------------------
  268. # This variable indicates whether to receive email notification for critical
  269. # alerts when using DB control.
  270. #-------------------------------------------------------------------------------
  271. #是否启用Email邮件通知数据库异常警告信息
  272. oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
  273. #-------------------------------------------------------------------------------
  274. # Specify the email address to which the notifications are to be sent.
  275. #-------------------------------------------------------------------------------
  276. #设置Email邮件通知接收地址
  277. oracle.install.db.config.starterdb.dbcontrol.emailAddress=
  278. #-------------------------------------------------------------------------------
  279. # Specify the SMTP server used for email notifications.
  280. #-------------------------------------------------------------------------------
  281. #设置Email邮件发送SMTP服务器
  282. oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
  283. ###############################################################################
  284. # #
  285. # SPECIFY BACKUP AND RECOVERY OPTIONS #
  286. # ------------------------------------ #
  287. # Out-of-box backup and recovery options for the database can be mentioned #
  288. # using the entries below. #
  289. # #
  290. ###############################################################################
  291. #------------------------------------------------------------------------------
  292. # This variable is to be set to false if automated backup is not required. Else
  293. # this can be set to true.
  294. #------------------------------------------------------------------------------
  295. #是否自动备份数据库
  296. oracle.install.db.config.starterdb.automatedBackup.enable=false
  297. #------------------------------------------------------------------------------
  298. # Regardless of the type of storage that is chosen for backup and recovery, if
  299. # automated backups are enabled, a job will be scheduled to run daily at
  300. # 2:00 AM to backup the database. This job will run as the operating system
  301. # user that is specified in this variable.
  302. #------------------------------------------------------------------------------
  303. #自动备份会启动一个JOB,指定启动JOB的OSsuer的UID
  304. oracle.install.db.config.starterdb.automatedBackup.osuid=
  305. #-------------------------------------------------------------------------------
  306. # Regardless of the type of storage that is chosen for backup and recovery, if
  307. # automated backups are enabled, a job will be scheduled to run daily at
  308. # 2:00 AM to backup the database. This job will run as the operating system user
  309. # specified by the above entry. The following entry stores the password for the
  310. # above operating system user.
  311. #-------------------------------------------------------------------------------
  312. #自动备份会开启一个job,需要指定OSUser的pwd
  313. oracle.install.db.config.starterdb.automatedBackup.ospwd=
  314. #-------------------------------------------------------------------------------
  315. # Specify the type of storage to use for the database.
  316. # It can be one of the following:
  317. # - FILE_SYSTEM_STORAGE
  318. # - ASM_STORAGE
  319. #------------------------------------------------------------------------------
  320. #自动备份指定使用FILE_SYSTEM_STORAGE存放数据库文件还是使用ASM存放数据库文件
  321. oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
  322. #-------------------------------------------------------------------------------
  323. # Specify the database file location which is a directory for datafiles, control
  324. # files, redo logs.
  325. #
  326. # Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM
  327. #-------------------------------------------------------------------------------
  328. #使用文件系统存放数据库文件才需要指定数据文件、控制文件、Redo log的存放目录
  329. oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/oracle/oradata
  330. #-------------------------------------------------------------------------------
  331. # Specify the backup and recovery location.
  332. #
  333. # Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM
  334. #-------------------------------------------------------------------------------
  335. #使用文件系统存放数据库文件才需要指定备份恢复目录
  336. oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/oracle/flash_recovery_area
  337. #-------------------------------------------------------------------------------
  338. # Specify the existing ASM disk groups to be used for storage.
  339. #
  340. # Applicable only when oracle.install.db.config.starterdb.storage=ASM
  341. #-------------------------------------------------------------------------------
  342. #使用ASM存放数据库文件才需要指定存放的磁盘组
  343. oracle.install.db.config.asm.diskGroup=
  344. #-------------------------------------------------------------------------------
  345. # Specify the password for ASMSNMP user of the ASM instance.
  346. #
  347. # Applicable only when oracle.install.db.config.starterdb.storage=ASM_SYSTEM
  348. #-------------------------------------------------------------------------------
  349. #使用ASM存放数据库文件才需要指定ASM实例密码
  350. oracle.install.db.config.asm.ASMSNMPPassword=
  351. #------------------------------------------------------------------------------
  352. # Specify the My Oracle Support Account Username.
  353. #
  354. # Example : MYORACLESUPPORT_USERNAME=metalink
  355. #------------------------------------------------------------------------------
  356. #指定metalink账户用户名
  357. MYORACLESUPPORT_USERNAME=
  358. #------------------------------------------------------------------------------
  359. # Specify the My Oracle Support Account Username password.
  360. #
  361. # Example : MYORACLESUPPORT_PASSWORD=password
  362. #------------------------------------------------------------------------------
  363. #指定metalink账户密码
  364. MYORACLESUPPORT_PASSWORD=
  365. #------------------------------------------------------------------------------
  366. # Specify whether to enable the user to set the password for
  367. # My Oracle Support credentials. The value can be either true or false.
  368. # If left blank it will be assumed to be false.
  369. #
  370. # Example : SECURITY_UPDATES_VIA_MYORACLESUPPORT=true
  371. #------------------------------------------------------------------------------
  372. #用户是否可以设置metalink密码
  373. SECURITY_UPDATES_VIA_MYORACLESUPPORT=
  374. #------------------------------------------------------------------------------
  375. # Specify whether user wants to give any proxy details for connection.
  376. # The value can be either true or false. If left blank it will be assumed
  377. # to be false.
  378. #
  379. # Example : DECLINE_SECURITY_UPDATES=false
  380. #------------------------------------------------------------------------------
  381. # False表示不需要设置安全更新,注意,在11.2的静默安装中疑似有一个BUG
  382. # Response File中必须指定为true,否则会提示错误,不管是否正确填写了邮件地址
  383. DECLINE_SECURITY_UPDATES=true
  384. #------------------------------------------------------------------------------
  385. # Specify the Proxy server name. Length should be greater than zero.
  386. #
  387. # Example : PROXY_HOST=proxy.domain.com
  388. #------------------------------------------------------------------------------
  389. #代理服务器名
  390. PROXY_HOST=
  391. #------------------------------------------------------------------------------
  392. # Specify the proxy port number. Should be Numeric and atleast 2 chars.
  393. #
  394. # Example : PROXY_PORT=25
  395. #------------------------------------------------------------------------------
  396. #代理服务器端口
  397. PROXY_PORT=
  398. #------------------------------------------------------------------------------
  399. # Specify the proxy user name. Leave PROXY_USER and PROXY_PWD
  400. # blank if your proxy server requires no authentication.
  401. #
  402. # Example : PROXY_USER=username
  403. #------------------------------------------------------------------------------
  404. #代理服务器用户名
  405. PROXY_USER=
  406. #------------------------------------------------------------------------------
  407. # Specify the proxy password. Leave PROXY_USER and PROXY_PWD
  408. # blank if your proxy server requires no authentication.
  409. #
  410. # Example : PROXY_PWD=password
  411. #------------------------------------------------------------------------------
  412. #代理服务器密码
  413. PROXY_PWD=

 

11、安装数据库软件

  1. [root@oracleserver ~]# su - oracle
  2. 上一次登录:六 831 10:40:29 CST 2019pts/1
  3. [oracle@oracleserver ~]$ cd /software/database/
  4. #屏蔽异常信息,无警告信息
  5. [oracle@oracleserver ~]$ ./runInstaller -silent -ignorePrereq -responseFile /oracle/response/db_install.rsp
  6. #屏蔽部分异常信息,会有警告,可忽略
  7. [oracle@oracleserver ~]$ ./runInstaller -silent -ignoreSysPrereqs -responseFile /oracle/response/db_install.rsp
  8. >>>>>>
  9. 正在启动 Oracle Universal Installer...
  10. 检查临时空间: 必须大于 120 MB。 实际为 38740 MB 通过
  11. 检查交换空间: 必须大于 150 MB。 实际为 4095 MB 通过
  12. 准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2019-04-16_03-41-22PM. 请稍候...[oracle@jetflow136 database]$ 可以在以下位置找到本次安装会话的日志:
  13. /home/oracle/tools/oraInventory/logs/installActions2019-04-16_03-41-22PM.log
  14. 安装结束后会打印如下信息:
  15. 以下配置脚本需要以 "root" 用户的身份执行。
  16. #!/bin/sh
  17. #要运行的 Root 脚本
  18. /oracle/oraInventory/orainstRoot.sh
  19. /oracle/app/product/11.2.0/dbhome_1/root.sh
  20. 要执行配置脚本, 请执行以下操作:
  21. 1. 打开一个终端窗口
  22. 2."root" 身份登录
  23. 3. 运行脚本
  24. 4. 返回此窗口并按 "Enter" 键继续
  25. Successfully Setup Software.
  26. <<<<<<
  27. @ 注意:如果需要查询安装过程日志,请重新开个终端,使用命令:tailf /home/oracle/tools/oraInventory/logs/installActions2019-04-16_03-41-22PM.log 打印日志。
  28. @ 告警:只要不会导致程序退出,即可忽略一些警告异常。
  29. #重新打开一个xshell终端窗口,使用root用户执行脚本
  30. [root@oracleserver ~]# /oracle/oraInventory/orainstRoot.sh
  31. [root@oracleserver ~]# /oracle/app/product/11.2.0/dbhome_1/root.sh

12、设置数据库开启启动

  1. [root@oracleserver ~]# vim /etc/oratab
  2. #
  3. # This file is used by ORACLE utilities. It is created by root.sh
  4. # and updated by the Database Configuration Assistant when creating
  5. # a database.
  6. # A colon, ':', is used as the field terminator. A new line terminates
  7. # the entry. Lines beginning with a pound sign, '#', are comments.
  8. #
  9. # Entries are of the form:
  10. # $ORACLE_SID:$ORACLE_HOME:<N|Y>:
  11. #
  12. # The first and second fields are the system identifier and home
  13. # directory of the database respectively. The third filed indicates
  14. # to the dbstart utility that the database should , "Y", or should not,
  15. # "N", be brought up at system boot time.
  16. #
  17. # Multiple entries with the same $ORACLE_SID are not allowed.
  18. #
  19. #
  20. #orcl:/oracle/app/product/11.2.0/dbhome_1:N //注释此处
  21. orcl:/oracle/app/product/11.2.0/dbhome_1:Y //添加此处
  1. [root@oracleserver ~]# vim /oracle/app/product/11.2.0/dbhome_1/bin/dbstart
  2. #!/bin/sh
  3. #
  4. # $Id: dbstart.sh 22-may-2008.05:05:45 arogers Exp $
  5. # Copyright (c) 1991, 2008, Oracle. All rights reserved.
  6. #
  7. ###################################
  8. #
  9. # usage: dbstart $ORACLE_HOME
  10. #
  11. # This script is used to start ORACLE from /etc/rc(.local).
  12. # It should ONLY be executed as part of the system boot procedure.
  13. #
  14. # This script will start all databases listed in the oratab file
  15. # whose third field is a "Y". If the third field is set to "Y" and
  16. # there is no ORACLE_SID for an entry (the first field is a *),
  17. # then this script will ignore that entry.
  18. #
  19. # This script requires that ASM ORACLE_SID's start with a +, and
  20. # that non-ASM instance ORACLE_SID's do not start with a +.
  21. #
  22. # If ASM instances are to be started with this script, it cannot
  23. # be used inside an rc*.d directory, and should be invoked from
  24. # rc.local only. Otherwise, the CSS service may not be available
  25. # yet, and this script will block init from completing the boot
  26. # cycle.
  27. #
  28. # If you want dbstart to auto-start a single-instance database that uses
  29. # an ASM server that is auto-started by CRS (this is the default behavior
  30. # for an ASM cluster), you must change the database's ORATAB entry to use
  31. # a third field of "W" and the ASM's ORATAB entry to use a third field of "N".
  32. # These values specify that dbstart auto-starts the database only after
  33. # the ASM instance is up and running.
  34. #
  35. # Note:
  36. # Use ORACLE_TRACE=T for tracing this script.
  37. #
  38. # The progress log for each instance bringup plus Error and Warning message[s]
  39. # are logged in file $ORACLE_HOME/startup.log. The error messages related to
  40. # instance bringup are also logged to syslog (system log module).
  41. # The Listener log is located at $ORACLE_HOME_LISTNER/listener.log
  42. #
  43. # On all UNIX platforms except SOLARIS
  44. # ORATAB=/etc/oratab
  45. #
  46. # To configure, update ORATAB with Instances that need to be started up
  47. # Entries are of the form:
  48. # $ORACLE_SID:$ORACLE_HOME:<N|Y|W>:
  49. # An example entry:
  50. # main:/usr/lib/oracle/emagent_10g:Y
  51. #
  52. # Overall algorithm:
  53. # 1) Bring up all ASM instances with 'Y' entry in status field in oratab entry
  54. # 2) Bring up all Database instances with 'Y' entry in status field in
  55. # oratab entry
  56. # 3) If there are Database instances with 'W' entry in status field
  57. # then
  58. # iterate over all ASM instances (irrespective of 'Y' or 'N') AND
  59. # wait for all of them to be started
  60. # fi
  61. # 4) Bring up all Database instances with 'W' entry in status field in
  62. # oratab entry
  63. #
  64. #####################################
  65. LOGMSG="logger -puser.alert -s "
  66. trap 'exit' 1 2 3
  67. # for script tracing
  68. case $ORACLE_TRACE in
  69. T) set -x ;;
  70. esac
  71. # Set path if path not set (if called from /etc/rc)
  72. SAVE_PATH=/bin:/usr/bin:/etc:${PATH} ; export PATH
  73. SAVE_LLP=$LD_LIBRARY_PATH
  74. # First argument is used to bring up Oracle Net Listener
  75. #ORACLE_HOME_LISTNER=$1 //注释此处
  76. ORACLE_HOME_LISTNER=$ORACLE_HOME //添加此处
  77. if [ ! $ORACLE_HOME_LISTNER ] ; then
  78. echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
  79. echo "Usage: $0 ORACLE_HOME"
  80. else
  81. LOG=$ORACLE_HOME_LISTNER/listener.log
  82. # Set the ORACLE_HOME for the Oracle Net Listener, it gets reset to
  83. # a different ORACLE_HOME for each entry in the oratab.
  84. export ORACLE_HOME=$ORACLE_HOME_LISTNER
  85. # Start Oracle Net Listener
  86. if [ -x $ORACLE_HOME_LISTNER/bin/tnslsnr ] ; then
  87. echo "$0: Starting Oracle Net Listener" >> $LOG 2>&1
  88. $ORACLE_HOME_LISTNER/bin/lsnrctl start >> $LOG 2>&1 &
  89. VER10LIST=`$ORACLE_HOME_LISTNER/bin/lsnrctl version | grep "LSNRCTL for " | cut -d' ' -f5 | cut -d'.' -f1`
  90. export VER10LIST
  91. else
  92. echo "Failed to auto-start Oracle Net Listener using $ORACLE_HOME_LISTNER/bin/tnslsnr"
  93. fi
  94. fi
  95. # Set this in accordance with the platform
  96. ORATAB=/etc/oratab
  97. if [ ! $ORATAB ] ; then
  98. echo "$ORATAB not found"
  99. exit 1;
  100. fi
  101. # Checks Version Mismatch between Listener and Database Instance.
  102. # A version 10 listener is required for an Oracle Database 10g database.
  103. # Previous versions of the listener are not supported for use with an Oracle
  104. # Database 10g database. However, it is possible to use a version 10 listener
  105. # with previous versions of the Oracle database.
  106. checkversionmismatch() {
  107. if [ $VER10LIST ] ; then
  108. VER10INST=`sqlplus -V | grep "Release " | cut -d' ' -f3 | cut -d'.' -f1`
  109. if [ $VER10LIST -lt $VER10INST ] ; then
  110. $LOGMSG "Listener version $VER10LIST NOT supported with Database version $VER10INST"
  111. $LOGMSG "Restart Oracle Net Listener using an alternate ORACLE_HOME_LISTNER:"
  112. $LOGMSG "lsnrctl start"
  113. fi
  114. fi
  115. }
  116. # Starts a Database Instance
  117. startinst() {
  118. # Called programs use same database ID
  119. export ORACLE_SID
  120. # Put $ORACLE_HOME/bin into PATH and export.
  121. PATH=$ORACLE_HOME/bin:${SAVE_PATH} ; export PATH
  122. # add for bug # 652997
  123. LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${SAVE_LLP} ; export LD_LIBRARY_PATH
  124. PFILE=${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora
  125. SPFILE=${ORACLE_HOME}/dbs/spfile${ORACLE_SID}.ora
  126. SPFILE1=${ORACLE_HOME}/dbs/spfile.ora
  127. echo ""
  128. echo "$0: Starting up database \"$ORACLE_SID\""
  129. date
  130. echo ""
  131. checkversionmismatch
  132. # See if it is a V6 or V7 database
  133. VERSION=undef
  134. if [ -f $ORACLE_HOME/bin/sqldba ] ; then
  135. SQLDBA=sqldba
  136. VERSION=`$ORACLE_HOME/bin/sqldba command=exit | awk '
  137. /SQL\*DBA: (Release|Version)/ {split($3, V, ".") ;
  138. print V[1]}'`
  139. case $VERSION in
  140. "6") ;;
  141. *) VERSION="internal" ;;
  142. esac
  143. else
  144. if [ -f $ORACLE_HOME/bin/svrmgrl ] ; then
  145. SQLDBA=svrmgrl
  146. VERSION="internal"
  147. else
  148. SQLDBA="sqlplus /nolog"
  149. fi
  150. fi
  151. STATUS=1
  152. if [ -f $ORACLE_HOME/dbs/sgadef${ORACLE_SID}.dbf ] ; then
  153. STATUS="-1"
  154. fi
  155. if [ -f $ORACLE_HOME/dbs/sgadef${ORACLE_SID}.ora ] ; then
  156. STATUS="-1"
  157. fi
  158. pmon=`ps -ef | grep -w "ora_pmon_$ORACLE_SID" | grep -v grep`
  159. if [ "$pmon" != "" ] ; then
  160. STATUS="-1"
  161. $LOGMSG "Warning: ${INST} \"${ORACLE_SID}\" already started."
  162. fi
  163. if [ $STATUS -eq -1 ] ; then
  164. $LOGMSG "Warning: ${INST} \"${ORACLE_SID}\" possibly left running when system went down (system crash?)."
  165. $LOGMSG "Action: Notify Database Administrator."
  166. case $VERSION in
  167. "6") sqldba "command=shutdown abort" ;;
  168. "internal") $SQLDBA $args <<EOF
  169. connect internal
  170. shutdown abort
  171. EOF
  172. ;;
  173. *) $SQLDBA $args <<EOF
  174. connect / as sysdba
  175. shutdown abort
  176. quit
  177. EOF
  178. ;;
  179. esac
  180. if [ $? -eq 0 ] ; then
  181. STATUS=1
  182. else
  183. $LOGMSG "Error: ${INST} \"${ORACLE_SID}\" NOT started."
  184. fi
  185. fi
  186. if [ $STATUS -eq 1 ] ; then
  187. if [ -e $SPFILE -o -e $SPFILE1 -o -e $PFILE ] ; then
  188. case $VERSION in
  189. "6") sqldba command=startup ;;
  190. "internal") $SQLDBA <<EOF
  191. connect internal
  192. startup
  193. EOF
  194. ;;
  195. *) $SQLDBA <<EOF
  196. connect / as sysdba
  197. startup
  198. quit
  199. EOF
  200. ;;
  201. esac
  202. if [ $? -eq 0 ] ; then
  203. echo ""
  204. echo "$0: ${INST} \"${ORACLE_SID}\" warm started."
  205. else
  206. $LOGMSG ""
  207. $LOGMSG "Error: ${INST} \"${ORACLE_SID}\" NOT started."
  208. fi
  209. else
  210. $LOGMSG ""
  211. $LOGMSG "No init file found for ${INST} \"${ORACLE_SID}\"."
  212. $LOGMSG "Error: ${INST} \"${ORACLE_SID}\" NOT started."
  213. fi
  214. fi
  215. }
  216. # Starts an ASM Instance
  217. startasminst() {
  218. # Called programs use same database ID
  219. export ORACLE_SID
  220. ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
  221. # Called scripts use same home directory
  222. export ORACLE_HOME
  223. # For ASM instances, we have a dependency on the CSS service.
  224. # Wait here for it to become available before instance startup.
  225. # Is the 10g install intact? Are all necessary binaries present?
  226. if [ ! -x $ORACLE_HOME/bin/crsctl ]; then
  227. $LOGMSG "$ORACLE_HOME/bin/crsctl not found when attempting to start"
  228. $LOGMSG " ASM instance $ORACLE_SID."
  229. else
  230. COUNT=0
  231. $ORACLE_HOME/bin/crsctl check css
  232. RC=$?
  233. while [ "$RC" != "0" ];
  234. do
  235. COUNT=`expr $COUNT + 1`
  236. if [ $COUNT = 15 ] ; then
  237. # 15 tries with 20 sec interval => 5 minutes timeout
  238. $LOGMSG "Timed out waiting to start ASM instance $ORACLE_SID"
  239. $LOGMSG " CSS service is NOT available."
  240. exit $COUNT
  241. fi
  242. $LOGMSG "Waiting for Oracle CSS service to be available before starting "
  243. $LOGMSG " ASM instance $ORACLE_SID. Wait $COUNT."
  244. sleep 20
  245. $ORACLE_HOME/bin/crsctl check css
  246. RC=$?
  247. done
  248. fi
  249. startinst
  250. }
  251. # Start of dbstartup script
  252. #
  253. # Loop for every entry in oratab file and and try to start
  254. # that ORACLE.
  255. #
  256. # ASM instances need to be started before 'Database instances'
  257. # ASM instance is identified with '+' prefix in ORACLE_SID
  258. # Following loop brings up ASM instance[s]
  259. cat $ORATAB | while read LINE
  260. do
  261. case $LINE in
  262. \#*) ;; #comment-line in oratab
  263. *)
  264. ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
  265. if [ "$ORACLE_SID" = '*' ] ; then
  266. # same as NULL SID - ignore this entry
  267. ORACLE_SID=""
  268. continue
  269. fi
  270. # Proceed only if last field is 'Y'.
  271. if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then
  272. # If ASM instances
  273. if [ `echo $ORACLE_SID | cut -b 1` = '+' ]; then
  274. INST="ASM instance"
  275. ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
  276. # Called scripts use same home directory
  277. export ORACLE_HOME
  278. # file for logging script's output
  279. LOG=$ORACLE_HOME/startup.log
  280. touch $LOG
  281. chmod a+r $LOG
  282. echo "Processing $INST \"$ORACLE_SID\": log file $ORACLE_HOME/startup.log"
  283. startasminst >> $LOG 2>&1
  284. fi
  285. fi
  286. ;;
  287. esac
  288. done
  289. # exit if there was any trouble bringing up ASM instance[s]
  290. if [ "$?" != "0" ] ; then
  291. exit 2
  292. fi
  293. #
  294. # Following loop brings up 'Database instances'
  295. #
  296. cat $ORATAB | while read LINE
  297. do
  298. case $LINE in
  299. \#*) ;; #comment-line in oratab
  300. *)
  301. ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
  302. if [ "$ORACLE_SID" = '*' ] ; then
  303. # same as NULL SID - ignore this entry
  304. ORACLE_SID=""
  305. continue
  306. fi
  307. # Proceed only if last field is 'Y'.
  308. if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then
  309. # If non-ASM instances
  310. if [ `echo $ORACLE_SID | cut -b 1` != '+' ]; then
  311. INST="Database instance"
  312. ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
  313. # Called scripts use same home directory
  314. export ORACLE_HOME
  315. # file for logging script's output
  316. LOG=$ORACLE_HOME/startup.log
  317. touch $LOG
  318. chmod a+r $LOG
  319. echo "Processing $INST \"$ORACLE_SID\": log file $ORACLE_HOME/startup.log"
  320. startinst >> $LOG 2>&1
  321. fi
  322. fi
  323. ;;
  324. esac
  325. done
  326. #
  327. # Following loop brings up 'Database instances' that have wait state 'W'
  328. #
  329. cat $ORATAB | while read LINE
  330. do
  331. case $LINE in
  332. \#*) ;; #comment-line in oratab
  333. *)
  334. ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
  335. if [ "$ORACLE_SID" = '*' ] ; then
  336. # same as NULL SID - ignore this entry
  337. ORACLE_SID=""
  338. continue
  339. fi
  340. # Proceed only if last field is 'W'.
  341. if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "W" ] ; then
  342. W_ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
  343. # DB instances with 'W' (wait state) have a dependency on ASM instances via CRS.
  344. # Wait here for 'all' ASM instances to become available.
  345. cat $ORATAB | while read LINE
  346. do
  347. case $LINE in
  348. \#*) ;; #comment-line in oratab
  349. *)
  350. ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
  351. if [ "$ORACLE_SID" = '*' ] ; then
  352. # same as NULL SID - ignore this entry
  353. ORACLE_SID=""
  354. continue
  355. fi
  356. if [ `echo $ORACLE_SID | cut -b 1` = '+' ]; then
  357. INST="ASM instance"
  358. ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
  359. if [ -x $ORACLE_HOME/bin/srvctl ] ; then
  360. COUNT=0
  361. NODE=`olsnodes -l`
  362. RNODE=`srvctl status asm -n $NODE | grep "$ORACLE_SID is running"`
  363. RC=$?
  364. while [ "$RC" != "0" ]; # wait until this comes up!
  365. do
  366. COUNT=$((COUNT+1))
  367. if [ $COUNT = 5 ] ; then
  368. # 5 tries with 60 sec interval => 5 minutes timeout
  369. $LOGMSG "Error: Timed out waiting on CRS to start ASM instance $ORACLE_SID"
  370. exit $COUNT
  371. fi
  372. $LOGMSG "Waiting for Oracle CRS service to start ASM instance $ORACLE_SID"
  373. $LOGMSG "Wait $COUNT."
  374. sleep 60
  375. RNODE=`srvctl status asm -n $NODE | grep "$ORACLE_SID is running"`
  376. RC=$?
  377. done
  378. else
  379. $LOGMSG "Error: \"${W_ORACLE_SID}\" has dependency on ASM instance \"${ORACLE_SID}\""
  380. $LOGMSG "Error: Need $ORACLE_HOME/bin/srvctl to check this dependency"
  381. fi
  382. fi # asm instance
  383. ;;
  384. esac
  385. done # innner while
  386. fi
  387. ;;
  388. esac
  389. done # outer while
  390. # by now all the ASM instances have come up and we can proceed to bring up
  391. # DB instance with 'W' wait status
  392. cat $ORATAB | while read LINE
  393. do
  394. case $LINE in
  395. \#*) ;; #comment-line in oratab
  396. *)
  397. ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
  398. if [ "$ORACLE_SID" = '*' ] ; then
  399. # same as NULL SID - ignore this entry
  400. ORACLE_SID=""
  401. continue
  402. fi
  403. # Proceed only if last field is 'W'.
  404. if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "W" ] ; then
  405. INST="Database instance"
  406. if [ `echo $ORACLE_SID | cut -b 1` = '+' ]; then
  407. $LOGMSG "Error: ${INST} \"${ORACLE_SID}\" NOT started"
  408. $LOGMSG "Error: incorrect usage: 'W' not allowed for ASM instances"
  409. continue
  410. fi
  411. ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
  412. # Called scripts use same home directory
  413. export ORACLE_HOME
  414. # file for logging script's output
  415. LOG=$ORACLE_HOME/startup.log
  416. touch $LOG
  417. chmod a+r $LOG
  418. echo "Processing $INST \"$ORACLE_SID\": log file $ORACLE_HOME/startup.log"
  419. startinst >> $LOG 2>&1
  420. fi
  421. ;;
  422. esac
  423. done
  1. [root@oracleserver ~]# vim /oracle/app/product/11.2.0/dbhome_1/bin/dbshut
  2. #!/bin/sh
  3. #
  4. # $Id: dbshut.sh 22-may-2008.05:19:31 arogers Exp $
  5. # Copyright (c) 1991, 2008, Oracle. All rights reserved.
  6. #
  7. ###################################
  8. #
  9. # usage: dbshut $ORACLE_HOME
  10. #
  11. # This script is used to shutdown ORACLE from /etc/rc(.local).
  12. # It should ONLY be executed as part of the system boot procedure.
  13. #
  14. # This script will shutdown all databases listed in the oratab file
  15. # whose third field is a "Y" or "W". If the third field is set to "Y" and
  16. # there is no ORACLE_SID for an entry (the first field is a *),
  17. # then this script will ignore that entry.
  18. #
  19. # This script requires that ASM ORACLE_SID's start with a +, and
  20. # that non-ASM instance ORACLE_SID's do not start with a +.
  21. #
  22. # Note:
  23. # Use ORACLE_TRACE=T for tracing this script.
  24. # Oracle Net Listener is also shutdown using this script.
  25. #
  26. # The progress log for each instance shutdown is logged in file
  27. # $ORACLE_HOME/shutdown.log.
  28. #
  29. # On all UNIX platforms except SOLARIS
  30. # ORATAB=/etc/oratab
  31. #
  32. # To configure, update ORATAB with Instances that need to be shutdown
  33. # Entries are of the form:
  34. # $ORACLE_SID:$ORACLE_HOME:<N|Y>:
  35. # An example entry:
  36. # main:/usr/lib/oracle/emagent_10g:Y
  37. #
  38. #####################################
  39. trap 'exit' 1 2 3
  40. case $ORACLE_TRACE in
  41. T) set -x ;;
  42. esac
  43. # Set path if path not set (if called from /etc/rc)
  44. SAVE_PATH=/bin:/usr/bin:/etc:${PATH} ; export PATH
  45. SAVE_LLP=$LD_LIBRARY_PATH
  46. # The this to bring down Oracle Net Listener
  47. #ORACLE_HOME_LISTNER=$1 //注释此处
  48. ORACLE_HOME_LISTNER=$ORACLE_HOME //添加此处
  49. if [ ! $ORACLE_HOME_LISTNER ] ; then
  50. echo "ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener"
  51. echo "Usage: $0 ORACLE_HOME"
  52. else
  53. LOG=$ORACLE_HOME_LISTNER/listener.log
  54. # Set the ORACLE_HOME for the Oracle Net Listener, it gets reset to
  55. # a different ORACLE_HOME for each entry in the oratab.
  56. export ORACLE_HOME=$ORACLE_HOME_LISTNER
  57. # Stop Oracle Net Listener
  58. if [ -f $ORACLE_HOME_LISTNER/bin/tnslsnr ] ; then
  59. echo "$0: Stoping Oracle Net Listener" >> $LOG 2>&1
  60. $ORACLE_HOME_LISTNER/bin/lsnrctl stop >> $LOG 2>&1 &
  61. else
  62. echo "Failed to auto-stop Oracle Net Listener using $ORACLE_HOME_LISTNER/bin/tnslsnr"
  63. fi
  64. fi
  65. # Set this in accordance with the platform
  66. ORATAB=/etc/oratab
  67. if [ ! $ORATAB ] ; then
  68. echo "$ORATAB not found"
  69. exit 1;
  70. fi
  71. # Stops an instance
  72. stopinst() {
  73. ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
  74. if [ "$ORACLE_SID" = '*' ] ; then
  75. ORACLE_SID=""
  76. fi
  77. # Called programs use same database ID
  78. export ORACLE_SID
  79. ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
  80. # Called scripts use same home directory
  81. export ORACLE_HOME
  82. # Put $ORACLE_HOME/bin into PATH and export.
  83. PATH=$ORACLE_HOME/bin:${SAVE_PATH} ; export PATH
  84. # add for bug 652997
  85. LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${SAVE_LLP} ; export LD_LIBRARY_PATH
  86. PFILE=${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora
  87. # See if it is a V6 or V7 database
  88. VERSION=undef
  89. if [ -f $ORACLE_HOME/bin/sqldba ] ; then
  90. SQLDBA=sqldba
  91. VERSION=`$ORACLE_HOME/bin/sqldba command=exit | awk '
  92. /SQL\*DBA: (Release|Version)/ {split($3, V, ".") ;
  93. print V[1]}'`
  94. case $VERSION in
  95. "6") ;;
  96. *) VERSION="internal" ;;
  97. esac
  98. else
  99. if [ -f $ORACLE_HOME/bin/svrmgrl ] ; then
  100. SQLDBA=svrmgrl
  101. VERSION="internal"
  102. else
  103. SQLDBA="sqlplus /nolog"
  104. fi
  105. fi
  106. case $VERSION in
  107. "6") sqldba command=shutdown ;;
  108. "internal") $SQLDBA <<EOF
  109. connect internal
  110. shutdown immediate
  111. EOF
  112. ;;
  113. *) $SQLDBA <<EOF
  114. connect / as sysdba
  115. shutdown immediate
  116. quit
  117. EOF
  118. ;;
  119. esac
  120. if test $? -eq 0 ; then
  121. echo "${INST} \"${ORACLE_SID}\" shut down."
  122. else
  123. echo "${INST} \"${ORACLE_SID}\" not shut down."
  124. fi
  125. }
  126. #
  127. # Loop for every entry in oratab file and and try to shut down
  128. # that ORACLE
  129. #
  130. # Following loop shuts down 'Database Instance[s]' with 'Y' entry
  131. cat $ORATAB | while read LINE
  132. do
  133. case $LINE in
  134. \#*) ;; #comment-line in oratab
  135. *)
  136. ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
  137. if [ "$ORACLE_SID" = '*' ] ; then
  138. # NULL SID - ignore
  139. ORACLE_SID=""
  140. continue
  141. fi
  142. # Proceed only if last field is 'Y' or 'W'
  143. if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then
  144. if [ `echo $ORACLE_SID | cut -b 1` != '+' ]; then
  145. INST="Database instance"
  146. ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
  147. LOG=$ORACLE_HOME/shutdown.log
  148. echo "Processing $INST \"$ORACLE_SID\": log file $LOG"
  149. stopinst >> $LOG 2>&1
  150. fi
  151. fi
  152. ;;
  153. esac
  154. done
  155. #
  156. # Following loop shuts down 'Database Instance[s]' with 'W' entry
  157. #
  158. cat $ORATAB | while read LINE
  159. do
  160. case $LINE in
  161. \#*) ;; #comment-line in oratab
  162. *)
  163. ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
  164. if [ "$ORACLE_SID" = '*' ] ; then
  165. # NULL SID - ignore
  166. ORACLE_SID=""
  167. continue
  168. fi
  169. # Proceed only if last field is 'Y' or 'W'
  170. if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "W" ] ; then
  171. if [ `echo $ORACLE_SID | cut -b 1` != '+' ]; then
  172. INST="Database instance"
  173. ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
  174. LOG=$ORACLE_HOME/shutdown.log
  175. echo "Processing $INST \"$ORACLE_SID\": log file $LOG"
  176. stopinst >> $LOG 2>&1
  177. fi
  178. fi
  179. ;;
  180. esac
  181. done
  182. #
  183. # Following loop shuts down 'ASM Instance[s]'
  184. #
  185. cat $ORATAB | while read LINE
  186. do
  187. case $LINE in
  188. \#*) ;; #comment-line in oratab
  189. *)
  190. ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
  191. if [ "$ORACLE_SID" = '*' ] ; then
  192. # NULL SID - ignore
  193. ORACLE_SID=""
  194. continue
  195. fi
  196. # Proceed only if last field is 'Y'.
  197. # Entries whose last field is not Y or N are not DB entry, ignore them.
  198. if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then
  199. if [ `echo $ORACLE_SID | cut -b 1` = '+' ]; then
  200. INST="ASM instance"
  201. ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
  202. LOG=$ORACLE_HOME/shutdown.log
  203. echo "Processing $INST \"$ORACLE_SID\": log file $LOG"
  204. stopinst >> $LOG 2>&1
  205. fi
  206. fi
  207. ;;
  208. esac
  209. done
  1. [root@oracleserver ~]# vim /etc/rc.d/rc.local
  2. #!/bin/bash
  3. # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
  4. #
  5. # It is highly advisable to create own systemd services or udev rules
  6. # to run scripts during boot instead of using this file.
  7. #
  8. # In contrast to previous versions due to parallel execution during boot
  9. # this script will NOT be run after all other services.
  10. #
  11. # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
  12. # that this script will be executed during boot.
  13. touch /var/lock/subsys/local
  14. su oracle -lc "/oracle/app/product/11.2.0/dbhome_1/bin/lsnrctl start" //添加此处
  15. su oracle -lc "/oracle/app/product/11.2.0/dbhome_1/bin/dbstart" //添加此处
  16. #开机启动文件执行权限授权
  17. [root@oracleserver ~]# ls -l /etc/rc.d/rc.local
  18. -rw-r--r-- 1 775 root 607 831 13:51 /etc/rc.d/rc.local
  19. [root@oracleserver ~]# chmod +x /etc/rc.d/rc.local
  20. [root@oracleserver ~]# ls -l /etc/rc.d/rc.local
  21. -rwxr-xr-x 1 775 root 607 831 13:51 /etc/rc.d/rc.local

13、数据库常用操作
(1)数据库实例启动

  1. [oracle@oracleserver ~]$ sqlplus /nolog
  2. SQL> connect / as sysdba
  3. SQL> startup (默认安装后自启动)
  4. SQL> startup force (强制启动)
  5. ORACLE instance started.
  6. Total System Global Area 534462464 bytes
  7. Fixed Size 2215064 bytes
  8. Variable Size 360711016 bytes
  9. Database Buffers 159383552 bytes
  10. Redo Buffers 12152832 bytes
  11. Database mounted.
  12. Database opened.
  13. #查询数据库启动状态
  14. SQL> select status from v$instance;
  15. STATUS
  16. ------------
  17. OPEN

(2)数据库实例停止

  1. [oracle@oracleserver ~]$ sqlplus /nolog
  2. SQL> connect / as sysoper
  3. SQL> shutdown immediate;
  4. Database closed.
  5. Database dismounted.
  6. ORACLE instance shut down.

(3)配置数据库监听

  1. #监听配置文件路径设置
  2. [oracle@oracleserver ~]$ vim /etc/oratab
  3. #
  4. # This file is used by ORACLE utilities. It is created by root.sh
  5. # and updated by the Database Configuration Assistant when creating
  6. # a database.
  7. # A colon, ':', is used as the field terminator. A new line terminates
  8. # the entry. Lines beginning with a pound sign, '#', are comments.
  9. #
  10. # Entries are of the form:
  11. # $ORACLE_SID:$ORACLE_HOME:<N|Y>:
  12. #
  13. # The first and second fields are the system identifier and home
  14. # directory of the database respectively. The third filed indicates
  15. # to the dbstart utility that the database should , "Y", or should not,
  16. # "N", be brought up at system boot time.
  17. #
  18. # Multiple entries with the same $ORACLE_SID are not allowed.
  19. #
  20. #
  21. orcl:/oracle/app/product/11.2.0/dbhome_1:N
  22. #配置数据库监听端口
  23. [oracle@oracleserver ~]$ cat /oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
  24. # listener.ora Network Configuration File: /oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
  25. # Generated by Oracle configuration tools.
  26. LISTENER =
  27. (DESCRIPTION_LIST =
  28. (DESCRIPTION =
  29. (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
  30. (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
  31. )
  32. )
  33. ADR_BASE_LISTENER = /oracle/app
  1. [oracle@oracleserver ~]$ lsnrctl stop //停止数据库监听服务
  2. [oracle@oracleserver ~]$ lsnrctl start //启动数据库监听服务(启动后等待5秒再检查)
  3. [oracle@oracleserver ~]$ lsnrctl status //查询数据库监听服务状态
  4. LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 31-AUG-2019 11:02:53
  5. Copyright (c) 1991, 2009, Oracle. All rights reserved.
  6. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
  7. STATUS of the LISTENER
  8. ------------------------
  9. Alias LISTENER
  10. Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
  11. Start Date 30-AUG-2019 23:48:25
  12. Uptime 0 days 11 hr. 14 min. 28 sec
  13. Trace Level off
  14. Security ON: Local OS Authentication
  15. SNMP OFF
  16. Listener Parameter File /oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
  17. Listener Log File /oracle/app/diag/tnslsnr/oracleserver/listener/alert/log.xml
  18. Listening Endpoints Summary...
  19. (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  20. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
  21. Services Summary...
  22. Service "orcl" has 1 instance(s).
  23. Instance "orcl", status READY, has 1 handler(s) for this service...
  24. Service "orclXDB" has 1 instance(s).
  25. Instance "orcl", status READY, has 1 handler(s) for this service...
  26. The command completed successfully

 

转载于:https://www.cnblogs.com/usxiao/p/Oracle.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/865864
推荐阅读
相关标签
  

闽ICP备14008679号