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、网络参数配置
- [root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
- TYPE=Ethernet
- PROXY_METHOD=none
- BROWSER_ONLY=no
- BOOTPROTO=none
- DEFROUTE=yes
- IPV4_FAILURE_FATAL=no
- IPV6INIT=yes
- IPV6_AUTOCONF=yes
- IPV6_DEFROUTE=yes
- IPV6_FAILURE_FATAL=no
- IPV6_ADDR_GEN_MODE=stable-privacy
- NAME=ens33
- UUID=8586e405-4459-42e2-ac9f-def02881736d
- DEVICE=ens33
- ONBOOT=yes
- MACADDR=preserve
- IPADDR=10.10.10.133
- PREFIX=24
- GATEWAY=10.10.10.10
- DNS1=114.114.114.114
- IPV6_PRIVACY=no
- ZONE=public
4、系统软件安装
[root@localhost ~]# yum -y install vim net-tools tree unzip lrzsz
5、系统安全配置
(1)关闭SELINUX安全访问控制
- [root@localhost ~]# vim /etc/selinux/config
- # This file controls the state of SELinux on the system.
- # SELINUX= can take one of these three values:
- # enforcing - SELinux security policy is enforced.
- # permissive - SELinux prints warnings instead of enforcing.
- # disabled - No SELinux policy is loaded.
- # SELINUX=enforcing //注释掉此处
- SELINUX=disabled //新增此处,并将SELINUX状态设置关闭状态disabled
- # SELINUXTYPE= can take one of these two values:
- # targeted - Targeted processes are protected,
- # mls - Multi Level Security protection.
- SELINUXTYPE=targeted
(2)配置防火墙安全规则
- [root@localhost ~]# systemctl status firewalld.service //查看防火墙运行状态
- ● firewalld.service - firewalld - dynamic firewall daemon
- Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
- Active: active (running) since 五 2019-08-30 22:58:53 CST; 8h ago
- Docs: man:firewalld(1)
- Main PID: 841 (firewalld)
- CGroup: /system.slice/firewalld.service
- └─841 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
-
- 8月 30 22:58:52 oracleserver.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
- 8月 30 22:58:53 oracleserver.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
-
- [root@localhost ~]# firewall-cmd --zone=public --add-port=1521/tcp --permanent //开放1521端口
- success
- [root@localhost ~]# firewall-cmd --zone=public --add-port=1158/tcp --permanent //开放1158端口
- success
- [root@localhost ~]# firewall-cmd --zone=public --add-port=22/tcp --permanent //开放22端口
- success
-
- [root@localhost ~]# firewall-cmd --reload //重启载入防火墙配置
- success
-
- [root@localhost ~]# firewall-cmd --zone=public --list-ports //查看已开放端口
- 22/tcp 1158/tcp 1521/tcp
6、安装依赖软件
- 32位依赖软件:
- [root@localhost ~]# yum -y install binutils compat-libcap1 compat-libstdc++-33 \
- compat-libstdc++-33*i686 compat-libstdc++-33*.devel \
- compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ \
- glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio \
- libaio*.i686 libaio-devel libaio-devel*.devel libgcc \
- libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel \
- libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 \
- make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
-
- 64位依赖软件:
- [root@localhost ~]# yum -y install binutils-2.* compat-libstdc++-33* elfutils-libelf-0.* \
- elfutils-libelf-devel-* gcc-4.* gcc-c++-4.* glibc-2.* glibc-common-2.* \
- glibc-devel-2.* glibc-headers-2.* ksh-2* libaio-0.* libaio-devel-0.* \
- libgcc-4.* libstdc++-4.* libstdc++- devel-4.* make-3.* sysstat-7.* \
- unixODBC-2.* unixODBC-devel-2.* pdksh*
-
- 检查依赖软件:
- [root@localhost ~]# rpm -q binutils compat-libcap1 compat-libstdc++-33 \
- compat-libstdc++-33*i686 compat-libstdc++-33*.devel \
- compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ \
- glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio \
- libaio*.i686 libaio-devel libaio-devel*.devel libgcc \
- libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel \
- libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 \
- make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
-
- 执行安装更新:
- [root@localhost ~]# yum update
7、部署用户配置
(1)创建部署用户
- [root@localhost ~]# groupadd oinstall //创建oinstall用户组
- [root@localhost ~]# groupadd dba //创建dba用户组
- [root@localhost ~]# useradd -g oinstall -G dba oracle //创建oracle用户并将用户加入到oinstall、dba两个用户组
- [root@localhost ~]# passwd oracle //设置oracle用户密码
- 更改用户 oracle 的密码 。
- 新的 密码:
- 重新输入新的 密码:
- passwd: 所有的身份验证令牌已经成功更新。
(2)创建部署目录
- [root@localhost ~]# mkdir -p /oracle/app/product/11.2.0/dbhome_1
- [root@localhost ~]# mkdir -p /oracle/app/oradata
- [root@localhost ~]# mkdir -p /oracle/flash_recovery_area
- [root@localhost ~]# mkdir -p /oracle/oraInventory
- [root@localhost ~]# mkdir -p /oracle/response
- [root@localhost ~]# mkdir -p /software
- [root@localhost ~]# chown oracle:oinstall -R /oracle/
- [root@localhost ~]# chown oracle:oinstall -R /software/
- [root@localhost ~]# chmod -R 755 /oracle/
- [root@localhost ~]# chmod -R 755 /software/
8、配置部署参数
(1)配置系统主机参数
- [root@localhost ~]# hostnamectl set-hostname oracleserver.localdomain //修改主机名称
-
- [root@localhost ~]# vim /etc/hosts //配置主机网络地址与主机名称映射记录
- 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
- ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
- 10.10.10.133 oracleserver oracleserver.localdomain
-
- [root@oracleserver ~]# vim /etc/redhat-release //配置系统标识参数
- #CentOS Linux release 7.6.1810 (Core)
- Red Hat Enterprise Linux Server release 7.3 (Maipo)
-
- [root@localhost ~]# reboot //重启操作系统
(2)配置系统内核参数
- [root@oracleserver ~]# vim /etc/sysctl.conf
- # sysctl settings are defined through files in
- # /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
- #
- # Vendors settings live in /usr/lib/sysctl.d/.
- # To override a whole file, create a new file with the same in
- # /etc/sysctl.d/ and put new settings there. To override
- # only specific settings, add a file with a lexically later
- # name in /etc/sysctl.d/ and put new settings there.
- #
- # For more information, see sysctl.conf(5) and sysctl.d(5).
-
- #Oracle Install Parameter //添加下面内核参数
- fs.file-max = 6815744
- fs.aio-max-nr = 1048576
- kernel.shmall = 2097152
- kernel.shmmax = 2147483648
- kernel.shmmni = 4096
- kernel.sem = 250 32000 100 128
- net.ipv4.ip_local_port_range = 9000 65500
- net.core.rmem_default = 4194304
- net.core.rmem_max = 4194304
- net.core.wmem_default = 262144
- net.core.wmem_max = 1048576
-
- [root@oracleserver ~]# /sbin/sysctl -p //更新内核参数,等效命令
- [root@oracleserver ~]# /sysctl -p //更新内核参数,等效命令
- fs.file-max = 6815744
- fs.aio-max-nr = 1048576
- kernel.shmall = 2097152
- kernel.shmmax = 2147483648
- kernel.shmmni = 4096
- kernel.sem = 250 32000 100 128
- net.ipv4.ip_local_port_range = 9000 65500
- net.core.rmem_default = 4194304
- net.core.rmem_max = 4194304
- net.core.wmem_default = 262144
- net.core.wmem_max = 1048576
(3)配置登录身份认证
- [root@oracleserver ~]# vim /etc/pam.d/login
- #%PAM-1.0
- auth [user_unknown=ignore success=ok ignore=ignore default=bad] pam_securetty.so
- auth substack system-auth
- auth include postlogin
- 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 optional pam_keyinit.so force revoke
- session include system-auth
- session include postlogin
- -session optional pam_ck_connector.so
-
- #Oracle Install Parameter //添加下面Oracle安装参数
- session required pam_limits.so
- session required /lib64/security/pam_limits.so
(4)配置资源限制参数
- [root@oracleserver ~]# vim /etc/profile
- # /etc/profile
- # System wide environment and startup programs, for login setup
- # Functions and aliases go in /etc/bashrc
- # It's NOT a good idea to change this file unless you know what you
- # are doing. It's much better to create a custom.sh shell script in
- # /etc/profile.d/ to make custom changes to your environment, as this
- # will prevent the need for merging in future updates.
-
- pathmunge () {
- case ":${PATH}:" in
- *:"$1":*)
- ;;
- *)
- if [ "$2" = "after" ] ; then
- PATH=$PATH:$1
- else
- PATH=$1:$PATH
- fi
- esac
- }
-
- if [ -x /usr/bin/id ]; then
- if [ -z "$EUID" ]; then
- # ksh workaround
- EUID=`/usr/bin/id -u`
- UID=`/usr/bin/id -ru`
- fi
- USER="`/usr/bin/id -un`"
- LOGNAME=$USER
- MAIL="/var/spool/mail/$USER"
- fi
-
- # Path manipulation
- if [ "$EUID" = "0" ]; then
- pathmunge /usr/sbin
- pathmunge /usr/local/sbin
- else
- pathmunge /usr/local/sbin after
- pathmunge /usr/sbin after
- fi
-
- HOSTNAME=`/usr/bin/hostname 2>/dev/null`
- HISTSIZE=1000
- if [ "$HISTCONTROL" = "ignorespace" ] ; then
- export HISTCONTROL=ignoreboth
- else
- export HISTCONTROL=ignoredups
- fi
-
- export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
- # By default, we want umask to get set. This sets it for login shell
- # Current threshold for system reserved uid/gids is 200
- # You could check uidgid reservation validity in
- # /usr/share/doc/setup-*/uidgid file
- if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
- umask 002
- else
- umask 022
- fi
-
- for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
- if [ -r "$i" ]; then
- if [ "${-#*i}" != "$-" ]; then
- . "$i"
- else
- . "$i" >/dev/null
- fi
- fi
- done
- unset i
- unset -f pathmunge
- #Oracle Install Parameter //添加下面Oracle安装参数
- if [ $USER = "oracle" ]; then
- if [ $SHELL = "/bin/ksh" ]; then
- ulimit -p 16384
- ulimit -n 65536
- else
- ulimit -u 16384 -n 65536
- fi
- fi
- [root@oracleserver ~]# source /etc/profile //使参数配置生效
- [root@oracleserver ~]# cat /etc/security/limits.conf
- # /etc/security/limits.conf
- #
- #This file sets the resource limits for the users logged in via PAM.
- #It does not affect resource limits of the system services.
- #
- #Also note that configuration files in /etc/security/limits.d directory,
- #which are read in alphabetical order, override the settings in this
- #file in case the domain is the same or more specific.
- #That means for example that setting a limit for wildcard domain here
- #can be overriden with a wildcard setting in a config file in the
- #subdirectory, but a user specific setting here can be overriden only
- #with a user specific setting in the subdirectory.
- #
- #Each line describes a limit for a user in the form:
- #
- #<domain> <type> <item> <value>
- #
- #Where:
- #<domain> can be:
- # - a user name
- # - a group name, with @group syntax
- # - the wildcard *, for default entry
- # - the wildcard %, can be also used with %group syntax,
- # for maxlogin limit
- #
- #<type> can have the two values:
- # - "soft" for enforcing the soft limits
- # - "hard" for enforcing hard limits
- #
- #<item> can be one of the following:
- # - core - limits the core file size (KB)
- # - data - max data size (KB)
- # - fsize - maximum filesize (KB)
- # - memlock - max locked-in-memory address space (KB)
- # - nofile - max number of open file descriptors
- # - rss - max resident set size (KB)
- # - stack - max stack size (KB)
- # - cpu - max CPU time (MIN)
- # - nproc - max number of processes
- # - as - address space limit (KB)
- # - maxlogins - max number of logins for this user
- # - maxsyslogins - max number of logins on the system
- # - priority - the priority to run user process with
- # - locks - max number of file locks the user can hold
- # - sigpending - max number of pending signals
- # - msgqueue - max memory used by POSIX message queues (bytes)
- # - nice - max nice priority allowed to raise to values: [-20, 19]
- # - rtprio - max realtime priority
- #
- #<domain> <type> <item> <value>
- #
-
- #* soft core 0
- #* hard rss 10000
- #@student hard nproc 20
- #@faculty soft nproc 20
- #@faculty hard nproc 50
- #ftp hard nproc 0
- #@student - maxlogins 4
-
- #Oracle Install Parameter //添加下面Oracle安装参数
- oracle soft nproc 2047
- oracle hard nproc 16384
- oracle soft nofile 1024
- oracle hard nofile 65536
-
- # End of file
(5)配置内存分配参数
- [root@oracleserver ~]# cat /sys/kernel/mm/transparent_hugepage/enabled //查询THP状态
- always
- [root@oracleserver ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled //关闭THP延迟分配内存机制
- [root@oracleserver ~]# cat /sys/kernel/mm/transparent_hugepage/enabled //查询THP状态
- always madvise [never]
(6)配置数据库环境变量
- [root@oracleserver ~]# vim /home/oracle/.bash_profile
- # .bash_profile
- # Get the aliases and functions
- if [ -f ~/.bashrc ]; then
- . ~/.bashrc
- fi
-
- # User specific environment and startup programs
- PATH=$PATH:$HOME/.local/bin:$HOME/bin
- export PATH
-
- #Oracle Install Parameter //添加下面Oracle安装参数
- umask 022
- export ORACLE_BASE=/oracle/app
- export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
- export ORACLE_SID=orcl
- export ORACLE_UNQNAME=orcl
- export NLS_LANG=.AL32UTF8
- export PATH=$ORACLE_HOME/bin:$PATH:$ORACLE_HOME/lib64
- export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
- export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
- export TNS_ADMIN=/oracle/app/product/11.2.0/dbhome_1/network/admin
- export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
-
- [root@oracleserver ~]# source /home/oracle/.bash_profile //使参数配置生效
-
- [root@oracleserver ~]# reboot //重启操作系统
9、上传数据库软件
- [root@oracleserver ~]# cd /software/
- [root@oracleserver software]# rz
- [root@oracleserver software]# ll
- 总用量 2295592
- -rw-r--r-- 1 oracle oinstall 1239269270 8月 29 11:44 Oracle.11g.R2.DataBase.Linux.x64.11.2.0.1.0.1of2.zip
- -rw-r--r-- 1 oracle oinstall 1111416131 8月 29 11:44 Oracle.11g.R2.DataBase.Linux.x64.11.2.0.1.0.2of2.zip
-
- #静默解压文件
- [root@oracleserver software]# unzip -q Oracle.11g.R2.DataBase.Linux.x64.11.2.0.1.0.1of2.zip -d /software
- [root@oracleserver software]# unzip -q Oracle.11g.R2.DataBase.Linux.x64.11.2.0.1.0.2of2.zip -d /software
-
- [root@oracleserver software]# ll
- 总用量 2295592
- drwxr-xr-x 8 oracle oinstall 128 8月 21 2009 database
- -rw-r--r-- 1 oracle oinstall 1239269270 8月 29 11:44 Oracle.11g.R2.DataBase.Linux.x64.11.2.0.1.0.1of2.zip
- -rw-r--r-- 1 oracle oinstall 1111416131 8月 29 11:44 Oracle.11g.R2.DataBase.Linux.x64.11.2.0.1.0.2of2.zip
10、配置数据库响应文件
- [root@oracleserver software]# cp /software/database/response/db_install.rsp /oracle/response/ //等效命令
- [root@oracleserver software]# cp /software/database/response/* /oracle/response/ //等效命令
-
- [root@oracleserver software]# vim /oracle/response/db_install.rsp
- ####################################################################
- ## Copyright(c) Oracle Corporation 1998,2008. All rights reserved.##
- ## ##
- ## Specify values for the variables listed below to customize ##
- ## your installation. ##
- ## ##
- ## Each variable is associated with a comment. The comment ##
- ## can help to populate the variables with the appropriate ##
- ## values. ##
- ## ##
- ## IMPORTANT NOTE: This file contains plain text passwords and ##
- ## should be secured to have read permission only by oracle user ##
- ## or db administrator who owns this installation. ##
- ## ##
- ####################################################################
-
- #------------------------------------------------------------------------------
- # Do not change the following system generated value.
- #------------------------------------------------------------------------------
- #标注响应文件版本
- oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
-
- #------------------------------------------------------------------------------
- # Specify the installation option.
- # It can be one of the following:
- # 1. INSTALL_DB_SWONLY 只装数据库软件
- # 2. INSTALL_DB_AND_CONFIG 安装数据库软件并建库
- # 3. UPGRADE_DB 升级数据库
- #-------------------------------------------------------------------------------
- oracle.install.option=INSTALL_DB_AND_CONFIG
-
- #-------------------------------------------------------------------------------
- # Specify the hostname of the system as set during the install. It can be used
- # to force the installation to use an alternative hostname rather than using the
- # first hostname found on the system. (e.g., for systems with multiple hostnames
- # and network interfaces)
- #-------------------------------------------------------------------------------
- #指定操作系统主机名
- ORACLE_HOSTNAME=oracleserver
-
- #-------------------------------------------------------------------------------
- # Specify the Unix group to be set for the inventory directory.
- #-------------------------------------------------------------------------------
- #指定产品清单oraInventory目录所有者,通常会是oinstall或者dba组
- UNIX_GROUP_NAME=oinstall
-
- #-------------------------------------------------------------------------------
- # Specify the location which holds the inventory files.
- #-------------------------------------------------------------------------------
- #指定产品清单oraInventory目录路径,需要建立在App目录外面
- INVENTORY_LOCATION=/oracle/oraInventory
-
- #-------------------------------------------------------------------------------
- # Specify the languages in which the components will be installed.
- #
- # en : English ja : Japanese
- # fr : French ko : Korean
- # ar : Arabic es : Latin American Spanish
- # bn : Bengali lv : Latvian
- # pt_BR: Brazilian Portuguese lt : Lithuanian
- # bg : Bulgarian ms : Malay
- # fr_CA: Canadian French es_MX: Mexican Spanish
- # ca : Catalan no : Norwegian
- # hr : Croatian pl : Polish
- # cs : Czech pt : Portuguese
- # da : Danish ro : Romanian
- # nl : Dutch ru : Russian
- # ar_EG: Egyptian zh_CN: Simplified Chinese
- # en_GB: English (Great Britain) sk : Slovak
- # et : Estonian sl : Slovenian
- # fi : Finnish es_ES: Spanish
- # de : German sv : Swedish
- # el : Greek th : Thai
- # iw : Hebrew zh_TW: Traditional Chinese
- # hu : Hungarian tr : Turkish
- # is : Icelandic uk : Ukrainian
- # in : Indonesian vi : Vietnamese
- # it : Italian
- #
- # Example : SELECTED_LANGUAGES=en,fr,ja
- #------------------------------------------------------------------------------
- #指定数据库语言,多个直接用逗号隔开
- SELECTED_LANGUAGES=en,zh_CN
-
- #------------------------------------------------------------------------------
- # Specify the complete path of the Oracle Home.
- #------------------------------------------------------------------------------
- #设置ORALCE_HOME的路径
- ORACLE_HOME=/oracle/app/product/11.2.0/dbhome_1
-
- #------------------------------------------------------------------------------
- # Specify the complete path of the Oracle Base.
- #------------------------------------------------------------------------------
- #设置ORACLE_BASE的路径
- ORACLE_BASE=/oracle/app
-
- #------------------------------------------------------------------------------
- # Specify the installation edition of the component.
- #
- # The value should contain only one of these choices.
- # EE : Enterprise Edition 企业版
- # SE : Standard Edition 标准版
- # SEONE : Standard Edition One 标准版1
- # PE : Personal Edition (WINDOWS ONLY) 个人版
- #------------------------------------------------------------------------------
- #指定数据库版本
- oracle.install.db.InstallEdition=EE
-
- #------------------------------------------------------------------------------
- # This variable is used to enable or disable custom install.
- #
- # true : Components mentioned as part of 'customComponents' property
- # are considered for install.
- # false : Value for 'customComponents' is not considered.
- #------------------------------------------------------------------------------
- #是否自定义Oracle的组件,如果选择false,则会使用默认的组件。
- #是否自定义Oracle的组件,如果选择true,则需要自己选择组件。
- oracle.install.db.isCustomInstall=false
-
- #------------------------------------------------------------------------------
- # This variable is considered only if 'IsCustomInstall' is set to true.
- #
- # Description: List of Enterprise Edition Options you would like to install.
- #
- # The following choices are available. You may specify any
- # combination of these choices. The components you choose should
- # be specified in the form "internal-component-name:version"
- # Below is a list of components you may specify to install.
- #
- # oracle.rdbms.partitioning:11.2.0.1.0 - Oracle Partitioning
- # oracle.rdbms.dm:11.2.0.1.0 - Oracle Data Mining
- # oracle.rdbms.dv:11.2.0.1.0 - Oracle Database Vault
- # oracle.rdbms.lbac:11.2.0.1.0 - Oracle Label Security
- # oracle.rdbms.rat:11.2.0.1.0 - Oracle Real Application Testing
- # oracle.oraolap:11.2.0.1.0 - Oracle OLAP
- #------------------------------------------------------------------------------
- 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
-
- ###############################################################################
- # #
- # PRIVILEGED OPERATING SYSTEM GROUPS #
- # ------------------------------------------ #
- # Provide values for the OS groups to which OSDBA and OSOPER privileges #
- # needs to be granted. If the install is being performed as a member of the #
- # group "dba", then that will be used unless specified otherwise below. #
- # #
- ###############################################################################
-
- #------------------------------------------------------------------------------
- # The DBA_GROUP is the OS group which is to be granted OSDBA privileges.
- #------------------------------------------------------------------------------
- #指定拥有OSDBA权限的用户组,通常会是dba组
- oracle.install.db.DBA_GROUP=dba
-
- #------------------------------------------------------------------------------
- # The OPER_GROUP is the OS group which is to be granted OSOPER privileges.
- #------------------------------------------------------------------------------
- 指定拥有OSOPER权限的用户组,通常会是oinstall组
- oracle.install.db.OPER_GROUP=oinstall
-
- #------------------------------------------------------------------------------
- # Specify the cluster node names selected during the installation.
- #------------------------------------------------------------------------------
- #指定RAC安装节点
- oracle.install.db.CLUSTER_NODES=
-
- #------------------------------------------------------------------------------
- # Specify the type of database to create.
- # It can be one of the following:
- # - GENERAL_PURPOSE/TRANSACTION_PROCESSING 一般用途/事物处理
- # - DATA_WAREHOUSE 数据仓库
- #------------------------------------------------------------------------------
- #指定数据库用途类型
- oracle.install.db.config.starterdb.type=DATA_WAREHOUSE
-
- #------------------------------------------------------------------------------
- # Specify the Starter Database Global Database Name.
- #------------------------------------------------------------------------------
- #指定GlobalName
- oracle.install.db.config.starterdb.globalDBName=orcl
-
- #------------------------------------------------------------------------------
- # Specify the Starter Database SID.
- #------------------------------------------------------------------------------
- #指定SIDName
- oracle.install.db.config.starterdb.SID=orcl
-
- #------------------------------------------------------------------------------
- # Specify the Starter Database character set.
- #
- # It can be one of the following:
- # AL32UTF8, WE8ISO8859P15, WE8MSWIN1252, EE8ISO8859P2,
- # EE8MSWIN1250, NE8ISO8859P10, NEE8ISO8859P4, BLT8MSWIN1257,
- # BLT8ISO8859P13, CL8ISO8859P5, CL8MSWIN1251, AR8ISO8859P6,
- # AR8MSWIN1256, EL8ISO8859P7, EL8MSWIN1253, IW8ISO8859P8,
- # IW8MSWIN1255, JA16EUC, JA16EUCTILDE, JA16SJIS, JA16SJISTILDE,
- # KO16MSWIN949, ZHS16GBK, TH8TISASCII, ZHT32EUC, ZHT16MSWIN950,
- # ZHT16HKSCS, WE8ISO8859P9, TR8MSWIN1254, VN8MSWIN1258
- #------------------------------------------------------------------------------
- #指定数据库默认字符集
- oracle.install.db.config.starterdb.characterSet=AL32UTF8
-
- #------------------------------------------------------------------------------
- # This variable should be set to true if Automatic Memory Management
- # in Database is desired.
- # If Automatic Memory Management is not desired, and memory allocation
- # is to be done manually, then set it to false.
- #------------------------------------------------------------------------------
- #开启数据库自动内存管理
- oracle.install.db.config.starterdb.memoryOption=true
-
- #------------------------------------------------------------------------------
- # Specify the total memory allocation for the database. Value(in MB) should be
- # at least 256 MB, and should not exceed the total physical memory available
- # on the system.
- # Example: oracle.install.db.config.starterdb.memoryLimit=512
- #------------------------------------------------------------------------------
- #指定自动内存容量大小
- oracle.install.db.config.starterdb.memoryLimit=512
-
- #------------------------------------------------------------------------------
- # This variable controls whether to load Example Schemas onto the starter
- # database or not.
- #------------------------------------------------------------------------------
- #是否载入模板示例
- oracle.install.db.config.starterdb.installExampleSchemas=false
-
- #------------------------------------------------------------------------------
- # This variable includes enabling audit settings, configuring password profiles
- # and revoking some grants to public. These settings are provided by default.
- # These settings may also be disabled.
- #------------------------------------------------------------------------------
- #是否启用安全设置
- oracle.install.db.config.starterdb.enableSecuritySettings=true
-
- ###############################################################################
- # #
- # Passwords can be supplied for the following four schemas in the #
- # starter database: #
- # SYS #
- # SYSTEM #
- # SYSMAN (used by Enterprise Manager) #
- # DBSNMP (used by Enterprise Manager) #
- # #
- # Same password can be used for all accounts (not recommended) #
- # or different passwords for each account can be provided (recommended) #
- # #
- ###############################################################################
-
- #------------------------------------------------------------------------------
- # This variable holds the password that is to be used for all schemas in the
- # starter database.
- #-------------------------------------------------------------------------------
- #设置数据用所有用户使用同一个密码
- oracle.install.db.config.starterdb.password.ALL=iTouch123
-
- #-------------------------------------------------------------------------------
- # Specify the SYS password for the starter database.
- #-------------------------------------------------------------------------------
- #设置sys用户密码
- oracle.install.db.config.starterdb.password.SYS=
-
- #-------------------------------------------------------------------------------
- # Specify the SYSTEM password for the starter database.
- #-------------------------------------------------------------------------------
- #设置system用户密码
- oracle.install.db.config.starterdb.password.SYSTEM=
-
- #-------------------------------------------------------------------------------
- # Specify the SYSMAN password for the starter database.
- #-------------------------------------------------------------------------------
- #设置sysman用户密码
- oracle.install.db.config.starterdb.password.SYSMAN=
-
- #-------------------------------------------------------------------------------
- # Specify the DBSNMP password for the starter database.
- #-------------------------------------------------------------------------------
- #设置dbsnmp用户密码
- oracle.install.db.config.starterdb.password.DBSNMP=
-
- #-------------------------------------------------------------------------------
- # Specify the management option to be selected for the starter database.
- # It can be one of the following:
- # 1. GRID_CONTROL 远程管理工具
- # 2. DB_CONTROL 本地管理工具
- #-------------------------------------------------------------------------------
- oracle.install.db.config.starterdb.control=DB_CONTROL
-
- #-------------------------------------------------------------------------------
- # Specify the Management Service to use if Grid Control is selected to manage
- # the database.
- #-------------------------------------------------------------------------------
- #GRID_CONTROL需要设定gridcontrol的远程路径URL
- oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
-
- #-------------------------------------------------------------------------------
- # This variable indicates whether to receive email notification for critical
- # alerts when using DB control.
- #-------------------------------------------------------------------------------
- #是否启用Email邮件通知数据库异常警告信息
- oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
-
- #-------------------------------------------------------------------------------
- # Specify the email address to which the notifications are to be sent.
- #-------------------------------------------------------------------------------
- #设置Email邮件通知接收地址
- oracle.install.db.config.starterdb.dbcontrol.emailAddress=
-
- #-------------------------------------------------------------------------------
- # Specify the SMTP server used for email notifications.
- #-------------------------------------------------------------------------------
- #设置Email邮件发送SMTP服务器
- oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
-
-
- ###############################################################################
- # #
- # SPECIFY BACKUP AND RECOVERY OPTIONS #
- # ------------------------------------ #
- # Out-of-box backup and recovery options for the database can be mentioned #
- # using the entries below. #
- # #
- ###############################################################################
-
- #------------------------------------------------------------------------------
- # This variable is to be set to false if automated backup is not required. Else
- # this can be set to true.
- #------------------------------------------------------------------------------
- #是否自动备份数据库
- oracle.install.db.config.starterdb.automatedBackup.enable=false
-
- #------------------------------------------------------------------------------
- # Regardless of the type of storage that is chosen for backup and recovery, if
- # automated backups are enabled, a job will be scheduled to run daily at
- # 2:00 AM to backup the database. This job will run as the operating system
- # user that is specified in this variable.
- #------------------------------------------------------------------------------
- #自动备份会启动一个JOB,指定启动JOB的OSsuer的UID
- oracle.install.db.config.starterdb.automatedBackup.osuid=
-
- #-------------------------------------------------------------------------------
- # Regardless of the type of storage that is chosen for backup and recovery, if
- # automated backups are enabled, a job will be scheduled to run daily at
- # 2:00 AM to backup the database. This job will run as the operating system user
- # specified by the above entry. The following entry stores the password for the
- # above operating system user.
- #-------------------------------------------------------------------------------
- #自动备份会开启一个job,需要指定OSUser的pwd
- oracle.install.db.config.starterdb.automatedBackup.ospwd=
-
- #-------------------------------------------------------------------------------
- # Specify the type of storage to use for the database.
- # It can be one of the following:
- # - FILE_SYSTEM_STORAGE
- # - ASM_STORAGE
- #------------------------------------------------------------------------------
- #自动备份指定使用FILE_SYSTEM_STORAGE存放数据库文件还是使用ASM存放数据库文件
- oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
-
- #-------------------------------------------------------------------------------
- # Specify the database file location which is a directory for datafiles, control
- # files, redo logs.
- #
- # Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM
- #-------------------------------------------------------------------------------
- #使用文件系统存放数据库文件才需要指定数据文件、控制文件、Redo log的存放目录
- oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/oracle/oradata
-
- #-------------------------------------------------------------------------------
- # Specify the backup and recovery location.
- #
- # Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM
- #-------------------------------------------------------------------------------
- #使用文件系统存放数据库文件才需要指定备份恢复目录
- oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/oracle/flash_recovery_area
-
- #-------------------------------------------------------------------------------
- # Specify the existing ASM disk groups to be used for storage.
- #
- # Applicable only when oracle.install.db.config.starterdb.storage=ASM
- #-------------------------------------------------------------------------------
- #使用ASM存放数据库文件才需要指定存放的磁盘组
- oracle.install.db.config.asm.diskGroup=
-
- #-------------------------------------------------------------------------------
- # Specify the password for ASMSNMP user of the ASM instance.
- #
- # Applicable only when oracle.install.db.config.starterdb.storage=ASM_SYSTEM
- #-------------------------------------------------------------------------------
- #使用ASM存放数据库文件才需要指定ASM实例密码
- oracle.install.db.config.asm.ASMSNMPPassword=
-
- #------------------------------------------------------------------------------
- # Specify the My Oracle Support Account Username.
- #
- # Example : MYORACLESUPPORT_USERNAME=metalink
- #------------------------------------------------------------------------------
- #指定metalink账户用户名
- MYORACLESUPPORT_USERNAME=
-
- #------------------------------------------------------------------------------
- # Specify the My Oracle Support Account Username password.
- #
- # Example : MYORACLESUPPORT_PASSWORD=password
- #------------------------------------------------------------------------------
- #指定metalink账户密码
- MYORACLESUPPORT_PASSWORD=
-
- #------------------------------------------------------------------------------
- # Specify whether to enable the user to set the password for
- # My Oracle Support credentials. The value can be either true or false.
- # If left blank it will be assumed to be false.
- #
- # Example : SECURITY_UPDATES_VIA_MYORACLESUPPORT=true
- #------------------------------------------------------------------------------
- #用户是否可以设置metalink密码
- SECURITY_UPDATES_VIA_MYORACLESUPPORT=
-
- #------------------------------------------------------------------------------
- # Specify whether user wants to give any proxy details for connection.
- # The value can be either true or false. If left blank it will be assumed
- # to be false.
- #
- # Example : DECLINE_SECURITY_UPDATES=false
- #------------------------------------------------------------------------------
- # False表示不需要设置安全更新,注意,在11.2的静默安装中疑似有一个BUG
- # Response File中必须指定为true,否则会提示错误,不管是否正确填写了邮件地址
- DECLINE_SECURITY_UPDATES=true
-
- #------------------------------------------------------------------------------
- # Specify the Proxy server name. Length should be greater than zero.
- #
- # Example : PROXY_HOST=proxy.domain.com
- #------------------------------------------------------------------------------
- #代理服务器名
- PROXY_HOST=
-
- #------------------------------------------------------------------------------
- # Specify the proxy port number. Should be Numeric and atleast 2 chars.
- #
- # Example : PROXY_PORT=25
- #------------------------------------------------------------------------------
- #代理服务器端口
- PROXY_PORT=
-
- #------------------------------------------------------------------------------
- # Specify the proxy user name. Leave PROXY_USER and PROXY_PWD
- # blank if your proxy server requires no authentication.
- #
- # Example : PROXY_USER=username
- #------------------------------------------------------------------------------
- #代理服务器用户名
- PROXY_USER=
-
- #------------------------------------------------------------------------------
- # Specify the proxy password. Leave PROXY_USER and PROXY_PWD
- # blank if your proxy server requires no authentication.
- #
- # Example : PROXY_PWD=password
- #------------------------------------------------------------------------------
- #代理服务器密码
- PROXY_PWD=
11、安装数据库软件
- [root@oracleserver ~]# su - oracle
- 上一次登录:六 8月 31 10:40:29 CST 2019pts/1 上
- [oracle@oracleserver ~]$ cd /software/database/
-
- #屏蔽异常信息,无警告信息
- [oracle@oracleserver ~]$ ./runInstaller -silent -ignorePrereq -responseFile /oracle/response/db_install.rsp
-
- #屏蔽部分异常信息,会有警告,可忽略
- [oracle@oracleserver ~]$ ./runInstaller -silent -ignoreSysPrereqs -responseFile /oracle/response/db_install.rsp
- >>>>>>
- 正在启动 Oracle Universal Installer...
- 检查临时空间: 必须大于 120 MB。 实际为 38740 MB 通过
- 检查交换空间: 必须大于 150 MB。 实际为 4095 MB 通过
- 准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2019-04-16_03-41-22PM. 请稍候...[oracle@jetflow136 database]$ 可以在以下位置找到本次安装会话的日志:
- /home/oracle/tools/oraInventory/logs/installActions2019-04-16_03-41-22PM.log
-
- 安装结束后会打印如下信息:
- 以下配置脚本需要以 "root" 用户的身份执行。
- #!/bin/sh
- #要运行的 Root 脚本
- /oracle/oraInventory/orainstRoot.sh
- /oracle/app/product/11.2.0/dbhome_1/root.sh
- 要执行配置脚本, 请执行以下操作:
- 1. 打开一个终端窗口
- 2. 以 "root" 身份登录
- 3. 运行脚本
- 4. 返回此窗口并按 "Enter" 键继续
- Successfully Setup Software.
- <<<<<<
-
- @ 注意:如果需要查询安装过程日志,请重新开个终端,使用命令:tailf /home/oracle/tools/oraInventory/logs/installActions2019-04-16_03-41-22PM.log 打印日志。
- @ 告警:只要不会导致程序退出,即可忽略一些警告异常。
-
- #重新打开一个xshell终端窗口,使用root用户执行脚本
- [root@oracleserver ~]# /oracle/oraInventory/orainstRoot.sh
- [root@oracleserver ~]# /oracle/app/product/11.2.0/dbhome_1/root.sh
12、设置数据库开启启动
- [root@oracleserver ~]# vim /etc/oratab
- #
- # This file is used by ORACLE utilities. It is created by root.sh
- # and updated by the Database Configuration Assistant when creating
- # a database.
- # A colon, ':', is used as the field terminator. A new line terminates
- # the entry. Lines beginning with a pound sign, '#', are comments.
- #
- # Entries are of the form:
- # $ORACLE_SID:$ORACLE_HOME:<N|Y>:
- #
- # The first and second fields are the system identifier and home
- # directory of the database respectively. The third filed indicates
- # to the dbstart utility that the database should , "Y", or should not,
- # "N", be brought up at system boot time.
- #
- # Multiple entries with the same $ORACLE_SID are not allowed.
- #
- #
- #orcl:/oracle/app/product/11.2.0/dbhome_1:N //注释此处
- orcl:/oracle/app/product/11.2.0/dbhome_1:Y //添加此处
- [root@oracleserver ~]# vim /oracle/app/product/11.2.0/dbhome_1/bin/dbstart
- #!/bin/sh
- #
- # $Id: dbstart.sh 22-may-2008.05:05:45 arogers Exp $
- # Copyright (c) 1991, 2008, Oracle. All rights reserved.
- #
- ###################################
- #
- # usage: dbstart $ORACLE_HOME
- #
- # This script is used to start ORACLE from /etc/rc(.local).
- # It should ONLY be executed as part of the system boot procedure.
- #
- # This script will start all databases listed in the oratab file
- # whose third field is a "Y". If the third field is set to "Y" and
- # there is no ORACLE_SID for an entry (the first field is a *),
- # then this script will ignore that entry.
- #
- # This script requires that ASM ORACLE_SID's start with a +, and
- # that non-ASM instance ORACLE_SID's do not start with a +.
- #
- # If ASM instances are to be started with this script, it cannot
- # be used inside an rc*.d directory, and should be invoked from
- # rc.local only. Otherwise, the CSS service may not be available
- # yet, and this script will block init from completing the boot
- # cycle.
- #
- # If you want dbstart to auto-start a single-instance database that uses
- # an ASM server that is auto-started by CRS (this is the default behavior
- # for an ASM cluster), you must change the database's ORATAB entry to use
- # a third field of "W" and the ASM's ORATAB entry to use a third field of "N".
- # These values specify that dbstart auto-starts the database only after
- # the ASM instance is up and running.
- #
- # Note:
- # Use ORACLE_TRACE=T for tracing this script.
- #
- # The progress log for each instance bringup plus Error and Warning message[s]
- # are logged in file $ORACLE_HOME/startup.log. The error messages related to
- # instance bringup are also logged to syslog (system log module).
- # The Listener log is located at $ORACLE_HOME_LISTNER/listener.log
- #
- # On all UNIX platforms except SOLARIS
- # ORATAB=/etc/oratab
- #
- # To configure, update ORATAB with Instances that need to be started up
- # Entries are of the form:
- # $ORACLE_SID:$ORACLE_HOME:<N|Y|W>:
- # An example entry:
- # main:/usr/lib/oracle/emagent_10g:Y
- #
- # Overall algorithm:
- # 1) Bring up all ASM instances with 'Y' entry in status field in oratab entry
- # 2) Bring up all Database instances with 'Y' entry in status field in
- # oratab entry
- # 3) If there are Database instances with 'W' entry in status field
- # then
- # iterate over all ASM instances (irrespective of 'Y' or 'N') AND
- # wait for all of them to be started
- # fi
- # 4) Bring up all Database instances with 'W' entry in status field in
- # oratab entry
- #
- #####################################
- LOGMSG="logger -puser.alert -s "
- trap 'exit' 1 2 3
- # for script tracing
- case $ORACLE_TRACE in
- T) set -x ;;
- esac
-
- # Set path if path not set (if called from /etc/rc)
- SAVE_PATH=/bin:/usr/bin:/etc:${PATH} ; export PATH
- SAVE_LLP=$LD_LIBRARY_PATH
-
- # First argument is used to bring up Oracle Net Listener
- #ORACLE_HOME_LISTNER=$1 //注释此处
- ORACLE_HOME_LISTNER=$ORACLE_HOME //添加此处
- if [ ! $ORACLE_HOME_LISTNER ] ; then
- echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
- echo "Usage: $0 ORACLE_HOME"
- else
- LOG=$ORACLE_HOME_LISTNER/listener.log
-
- # Set the ORACLE_HOME for the Oracle Net Listener, it gets reset to
- # a different ORACLE_HOME for each entry in the oratab.
- export ORACLE_HOME=$ORACLE_HOME_LISTNER
-
- # Start Oracle Net Listener
- if [ -x $ORACLE_HOME_LISTNER/bin/tnslsnr ] ; then
- echo "$0: Starting Oracle Net Listener" >> $LOG 2>&1
- $ORACLE_HOME_LISTNER/bin/lsnrctl start >> $LOG 2>&1 &
- VER10LIST=`$ORACLE_HOME_LISTNER/bin/lsnrctl version | grep "LSNRCTL for " | cut -d' ' -f5 | cut -d'.' -f1`
- export VER10LIST
- else
- echo "Failed to auto-start Oracle Net Listener using $ORACLE_HOME_LISTNER/bin/tnslsnr"
- fi
- fi
-
- # Set this in accordance with the platform
- ORATAB=/etc/oratab
- if [ ! $ORATAB ] ; then
- echo "$ORATAB not found"
- exit 1;
- fi
-
- # Checks Version Mismatch between Listener and Database Instance.
- # A version 10 listener is required for an Oracle Database 10g database.
- # Previous versions of the listener are not supported for use with an Oracle
- # Database 10g database. However, it is possible to use a version 10 listener
- # with previous versions of the Oracle database.
- checkversionmismatch() {
- if [ $VER10LIST ] ; then
- VER10INST=`sqlplus -V | grep "Release " | cut -d' ' -f3 | cut -d'.' -f1`
- if [ $VER10LIST -lt $VER10INST ] ; then
- $LOGMSG "Listener version $VER10LIST NOT supported with Database version $VER10INST"
- $LOGMSG "Restart Oracle Net Listener using an alternate ORACLE_HOME_LISTNER:"
- $LOGMSG "lsnrctl start"
- fi
- fi
- }
-
- # Starts a Database Instance
- startinst() {
- # Called programs use same database ID
- export ORACLE_SID
-
- # Put $ORACLE_HOME/bin into PATH and export.
- PATH=$ORACLE_HOME/bin:${SAVE_PATH} ; export PATH
- # add for bug # 652997
- LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${SAVE_LLP} ; export LD_LIBRARY_PATH
- PFILE=${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora
- SPFILE=${ORACLE_HOME}/dbs/spfile${ORACLE_SID}.ora
- SPFILE1=${ORACLE_HOME}/dbs/spfile.ora
-
- echo ""
- echo "$0: Starting up database \"$ORACLE_SID\""
- date
- echo ""
-
- checkversionmismatch
-
- # See if it is a V6 or V7 database
- VERSION=undef
- if [ -f $ORACLE_HOME/bin/sqldba ] ; then
- SQLDBA=sqldba
- VERSION=`$ORACLE_HOME/bin/sqldba command=exit | awk '
- /SQL\*DBA: (Release|Version)/ {split($3, V, ".") ;
- print V[1]}'`
- case $VERSION in
- "6") ;;
- *) VERSION="internal" ;;
- esac
- else
- if [ -f $ORACLE_HOME/bin/svrmgrl ] ; then
- SQLDBA=svrmgrl
- VERSION="internal"
- else
- SQLDBA="sqlplus /nolog"
- fi
- fi
-
- STATUS=1
- if [ -f $ORACLE_HOME/dbs/sgadef${ORACLE_SID}.dbf ] ; then
- STATUS="-1"
- fi
- if [ -f $ORACLE_HOME/dbs/sgadef${ORACLE_SID}.ora ] ; then
- STATUS="-1"
- fi
- pmon=`ps -ef | grep -w "ora_pmon_$ORACLE_SID" | grep -v grep`
- if [ "$pmon" != "" ] ; then
- STATUS="-1"
- $LOGMSG "Warning: ${INST} \"${ORACLE_SID}\" already started."
- fi
-
- if [ $STATUS -eq -1 ] ; then
- $LOGMSG "Warning: ${INST} \"${ORACLE_SID}\" possibly left running when system went down (system crash?)."
- $LOGMSG "Action: Notify Database Administrator."
- case $VERSION in
- "6") sqldba "command=shutdown abort" ;;
- "internal") $SQLDBA $args <<EOF
- connect internal
- shutdown abort
- EOF
- ;;
- *) $SQLDBA $args <<EOF
- connect / as sysdba
- shutdown abort
- quit
- EOF
- ;;
- esac
-
- if [ $? -eq 0 ] ; then
- STATUS=1
- else
- $LOGMSG "Error: ${INST} \"${ORACLE_SID}\" NOT started."
- fi
- fi
-
- if [ $STATUS -eq 1 ] ; then
- if [ -e $SPFILE -o -e $SPFILE1 -o -e $PFILE ] ; then
- case $VERSION in
- "6") sqldba command=startup ;;
- "internal") $SQLDBA <<EOF
- connect internal
- startup
- EOF
- ;;
- *) $SQLDBA <<EOF
- connect / as sysdba
- startup
- quit
- EOF
- ;;
- esac
-
- if [ $? -eq 0 ] ; then
- echo ""
- echo "$0: ${INST} \"${ORACLE_SID}\" warm started."
- else
- $LOGMSG ""
- $LOGMSG "Error: ${INST} \"${ORACLE_SID}\" NOT started."
- fi
- else
- $LOGMSG ""
- $LOGMSG "No init file found for ${INST} \"${ORACLE_SID}\"."
- $LOGMSG "Error: ${INST} \"${ORACLE_SID}\" NOT started."
- fi
- fi
- }
-
- # Starts an ASM Instance
- startasminst() {
- # Called programs use same database ID
- export ORACLE_SID
- ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
- # Called scripts use same home directory
- export ORACLE_HOME
-
- # For ASM instances, we have a dependency on the CSS service.
- # Wait here for it to become available before instance startup.
-
- # Is the 10g install intact? Are all necessary binaries present?
- if [ ! -x $ORACLE_HOME/bin/crsctl ]; then
- $LOGMSG "$ORACLE_HOME/bin/crsctl not found when attempting to start"
- $LOGMSG " ASM instance $ORACLE_SID."
-
- else
- COUNT=0
- $ORACLE_HOME/bin/crsctl check css
- RC=$?
- while [ "$RC" != "0" ];
- do
- COUNT=`expr $COUNT + 1`
- if [ $COUNT = 15 ] ; then
- # 15 tries with 20 sec interval => 5 minutes timeout
- $LOGMSG "Timed out waiting to start ASM instance $ORACLE_SID"
- $LOGMSG " CSS service is NOT available."
- exit $COUNT
- fi
- $LOGMSG "Waiting for Oracle CSS service to be available before starting "
- $LOGMSG " ASM instance $ORACLE_SID. Wait $COUNT."
- sleep 20
- $ORACLE_HOME/bin/crsctl check css
- RC=$?
- done
- fi
- startinst
- }
-
- # Start of dbstartup script
- #
- # Loop for every entry in oratab file and and try to start
- # that ORACLE.
- #
- # ASM instances need to be started before 'Database instances'
- # ASM instance is identified with '+' prefix in ORACLE_SID
- # Following loop brings up ASM instance[s]
-
- cat $ORATAB | while read LINE
- do
- case $LINE in
- \#*) ;; #comment-line in oratab
- *)
- ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
- if [ "$ORACLE_SID" = '*' ] ; then
- # same as NULL SID - ignore this entry
- ORACLE_SID=""
- continue
- fi
- # Proceed only if last field is 'Y'.
- if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then
- # If ASM instances
- if [ `echo $ORACLE_SID | cut -b 1` = '+' ]; then
- INST="ASM instance"
- ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
- # Called scripts use same home directory
- export ORACLE_HOME
- # file for logging script's output
- LOG=$ORACLE_HOME/startup.log
- touch $LOG
- chmod a+r $LOG
- echo "Processing $INST \"$ORACLE_SID\": log file $ORACLE_HOME/startup.log"
- startasminst >> $LOG 2>&1
- fi
- fi
- ;;
- esac
- done
-
- # exit if there was any trouble bringing up ASM instance[s]
- if [ "$?" != "0" ] ; then
- exit 2
- fi
-
- #
- # Following loop brings up 'Database instances'
- #
- cat $ORATAB | while read LINE
- do
- case $LINE in
- \#*) ;; #comment-line in oratab
- *)
- ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
- if [ "$ORACLE_SID" = '*' ] ; then
- # same as NULL SID - ignore this entry
- ORACLE_SID=""
- continue
- fi
- # Proceed only if last field is 'Y'.
- if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then
- # If non-ASM instances
- if [ `echo $ORACLE_SID | cut -b 1` != '+' ]; then
- INST="Database instance"
- ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
- # Called scripts use same home directory
- export ORACLE_HOME
- # file for logging script's output
- LOG=$ORACLE_HOME/startup.log
- touch $LOG
- chmod a+r $LOG
- echo "Processing $INST \"$ORACLE_SID\": log file $ORACLE_HOME/startup.log"
- startinst >> $LOG 2>&1
- fi
- fi
- ;;
- esac
- done
-
- #
- # Following loop brings up 'Database instances' that have wait state 'W'
- #
- cat $ORATAB | while read LINE
- do
- case $LINE in
- \#*) ;; #comment-line in oratab
- *)
- ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
- if [ "$ORACLE_SID" = '*' ] ; then
- # same as NULL SID - ignore this entry
- ORACLE_SID=""
- continue
- fi
- # Proceed only if last field is 'W'.
- if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "W" ] ; then
- W_ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
- # DB instances with 'W' (wait state) have a dependency on ASM instances via CRS.
- # Wait here for 'all' ASM instances to become available.
- cat $ORATAB | while read LINE
- do
- case $LINE in
- \#*) ;; #comment-line in oratab
- *)
- ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
- if [ "$ORACLE_SID" = '*' ] ; then
- # same as NULL SID - ignore this entry
- ORACLE_SID=""
- continue
- fi
- if [ `echo $ORACLE_SID | cut -b 1` = '+' ]; then
- INST="ASM instance"
- ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
- if [ -x $ORACLE_HOME/bin/srvctl ] ; then
- COUNT=0
- NODE=`olsnodes -l`
- RNODE=`srvctl status asm -n $NODE | grep "$ORACLE_SID is running"`
- RC=$?
- while [ "$RC" != "0" ]; # wait until this comes up!
- do
- COUNT=$((COUNT+1))
- if [ $COUNT = 5 ] ; then
- # 5 tries with 60 sec interval => 5 minutes timeout
- $LOGMSG "Error: Timed out waiting on CRS to start ASM instance $ORACLE_SID"
- exit $COUNT
- fi
- $LOGMSG "Waiting for Oracle CRS service to start ASM instance $ORACLE_SID"
- $LOGMSG "Wait $COUNT."
- sleep 60
- RNODE=`srvctl status asm -n $NODE | grep "$ORACLE_SID is running"`
- RC=$?
- done
- else
- $LOGMSG "Error: \"${W_ORACLE_SID}\" has dependency on ASM instance \"${ORACLE_SID}\""
- $LOGMSG "Error: Need $ORACLE_HOME/bin/srvctl to check this dependency"
- fi
- fi # asm instance
- ;;
- esac
- done # innner while
- fi
- ;;
- esac
- done # outer while
-
- # by now all the ASM instances have come up and we can proceed to bring up
- # DB instance with 'W' wait status
-
- cat $ORATAB | while read LINE
- do
- case $LINE in
- \#*) ;; #comment-line in oratab
- *)
- ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
- if [ "$ORACLE_SID" = '*' ] ; then
- # same as NULL SID - ignore this entry
- ORACLE_SID=""
- continue
- fi
- # Proceed only if last field is 'W'.
- if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "W" ] ; then
- INST="Database instance"
- if [ `echo $ORACLE_SID | cut -b 1` = '+' ]; then
- $LOGMSG "Error: ${INST} \"${ORACLE_SID}\" NOT started"
- $LOGMSG "Error: incorrect usage: 'W' not allowed for ASM instances"
- continue
- fi
- ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
- # Called scripts use same home directory
- export ORACLE_HOME
- # file for logging script's output
- LOG=$ORACLE_HOME/startup.log
- touch $LOG
- chmod a+r $LOG
- echo "Processing $INST \"$ORACLE_SID\": log file $ORACLE_HOME/startup.log"
- startinst >> $LOG 2>&1
- fi
- ;;
- esac
- done
- [root@oracleserver ~]# vim /oracle/app/product/11.2.0/dbhome_1/bin/dbshut
- #!/bin/sh
- #
- # $Id: dbshut.sh 22-may-2008.05:19:31 arogers Exp $
- # Copyright (c) 1991, 2008, Oracle. All rights reserved.
- #
- ###################################
- #
- # usage: dbshut $ORACLE_HOME
- #
- # This script is used to shutdown ORACLE from /etc/rc(.local).
- # It should ONLY be executed as part of the system boot procedure.
- #
- # This script will shutdown all databases listed in the oratab file
- # whose third field is a "Y" or "W". If the third field is set to "Y" and
- # there is no ORACLE_SID for an entry (the first field is a *),
- # then this script will ignore that entry.
- #
- # This script requires that ASM ORACLE_SID's start with a +, and
- # that non-ASM instance ORACLE_SID's do not start with a +.
- #
- # Note:
- # Use ORACLE_TRACE=T for tracing this script.
- # Oracle Net Listener is also shutdown using this script.
- #
- # The progress log for each instance shutdown is logged in file
- # $ORACLE_HOME/shutdown.log.
- #
- # On all UNIX platforms except SOLARIS
- # ORATAB=/etc/oratab
- #
- # To configure, update ORATAB with Instances that need to be shutdown
- # Entries are of the form:
- # $ORACLE_SID:$ORACLE_HOME:<N|Y>:
- # An example entry:
- # main:/usr/lib/oracle/emagent_10g:Y
- #
- #####################################
-
- trap 'exit' 1 2 3
- case $ORACLE_TRACE in
- T) set -x ;;
- esac
-
- # Set path if path not set (if called from /etc/rc)
- SAVE_PATH=/bin:/usr/bin:/etc:${PATH} ; export PATH
- SAVE_LLP=$LD_LIBRARY_PATH
-
- # The this to bring down Oracle Net Listener
- #ORACLE_HOME_LISTNER=$1 //注释此处
- ORACLE_HOME_LISTNER=$ORACLE_HOME //添加此处
- if [ ! $ORACLE_HOME_LISTNER ] ; then
- echo "ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener"
- echo "Usage: $0 ORACLE_HOME"
- else
- LOG=$ORACLE_HOME_LISTNER/listener.log
-
- # Set the ORACLE_HOME for the Oracle Net Listener, it gets reset to
- # a different ORACLE_HOME for each entry in the oratab.
- export ORACLE_HOME=$ORACLE_HOME_LISTNER
-
- # Stop Oracle Net Listener
- if [ -f $ORACLE_HOME_LISTNER/bin/tnslsnr ] ; then
- echo "$0: Stoping Oracle Net Listener" >> $LOG 2>&1
- $ORACLE_HOME_LISTNER/bin/lsnrctl stop >> $LOG 2>&1 &
- else
- echo "Failed to auto-stop Oracle Net Listener using $ORACLE_HOME_LISTNER/bin/tnslsnr"
- fi
- fi
-
- # Set this in accordance with the platform
- ORATAB=/etc/oratab
- if [ ! $ORATAB ] ; then
- echo "$ORATAB not found"
- exit 1;
- fi
-
- # Stops an instance
- stopinst() {
- ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
- if [ "$ORACLE_SID" = '*' ] ; then
- ORACLE_SID=""
- fi
- # Called programs use same database ID
- export ORACLE_SID
- ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
- # Called scripts use same home directory
- export ORACLE_HOME
- # Put $ORACLE_HOME/bin into PATH and export.
- PATH=$ORACLE_HOME/bin:${SAVE_PATH} ; export PATH
- # add for bug 652997
- LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${SAVE_LLP} ; export LD_LIBRARY_PATH
- PFILE=${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora
-
- # See if it is a V6 or V7 database
- VERSION=undef
- if [ -f $ORACLE_HOME/bin/sqldba ] ; then
- SQLDBA=sqldba
- VERSION=`$ORACLE_HOME/bin/sqldba command=exit | awk '
- /SQL\*DBA: (Release|Version)/ {split($3, V, ".") ;
- print V[1]}'`
- case $VERSION in
- "6") ;;
- *) VERSION="internal" ;;
- esac
- else
- if [ -f $ORACLE_HOME/bin/svrmgrl ] ; then
- SQLDBA=svrmgrl
- VERSION="internal"
- else
- SQLDBA="sqlplus /nolog"
- fi
- fi
-
- case $VERSION in
- "6") sqldba command=shutdown ;;
- "internal") $SQLDBA <<EOF
- connect internal
- shutdown immediate
- EOF
- ;;
- *) $SQLDBA <<EOF
- connect / as sysdba
- shutdown immediate
- quit
- EOF
- ;;
- esac
-
- if test $? -eq 0 ; then
- echo "${INST} \"${ORACLE_SID}\" shut down."
- else
- echo "${INST} \"${ORACLE_SID}\" not shut down."
- fi
- }
-
- #
- # Loop for every entry in oratab file and and try to shut down
- # that ORACLE
- #
- # Following loop shuts down 'Database Instance[s]' with 'Y' entry
-
- cat $ORATAB | while read LINE
- do
- case $LINE in
- \#*) ;; #comment-line in oratab
- *)
- ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
- if [ "$ORACLE_SID" = '*' ] ; then
- # NULL SID - ignore
- ORACLE_SID=""
- continue
- fi
- # Proceed only if last field is 'Y' or 'W'
- if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then
- if [ `echo $ORACLE_SID | cut -b 1` != '+' ]; then
- INST="Database instance"
- ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
- LOG=$ORACLE_HOME/shutdown.log
- echo "Processing $INST \"$ORACLE_SID\": log file $LOG"
- stopinst >> $LOG 2>&1
- fi
- fi
- ;;
- esac
- done
-
- #
- # Following loop shuts down 'Database Instance[s]' with 'W' entry
- #
- cat $ORATAB | while read LINE
- do
- case $LINE in
- \#*) ;; #comment-line in oratab
- *)
- ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
- if [ "$ORACLE_SID" = '*' ] ; then
- # NULL SID - ignore
- ORACLE_SID=""
- continue
- fi
- # Proceed only if last field is 'Y' or 'W'
- if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "W" ] ; then
- if [ `echo $ORACLE_SID | cut -b 1` != '+' ]; then
- INST="Database instance"
- ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
- LOG=$ORACLE_HOME/shutdown.log
- echo "Processing $INST \"$ORACLE_SID\": log file $LOG"
- stopinst >> $LOG 2>&1
- fi
- fi
- ;;
- esac
- done
-
- #
- # Following loop shuts down 'ASM Instance[s]'
- #
- cat $ORATAB | while read LINE
- do
- case $LINE in
- \#*) ;; #comment-line in oratab
- *)
- ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
- if [ "$ORACLE_SID" = '*' ] ; then
- # NULL SID - ignore
- ORACLE_SID=""
- continue
- fi
- # Proceed only if last field is 'Y'.
- # Entries whose last field is not Y or N are not DB entry, ignore them.
- if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then
- if [ `echo $ORACLE_SID | cut -b 1` = '+' ]; then
- INST="ASM instance"
- ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
- LOG=$ORACLE_HOME/shutdown.log
- echo "Processing $INST \"$ORACLE_SID\": log file $LOG"
- stopinst >> $LOG 2>&1
- fi
- fi
- ;;
- esac
- done
- [root@oracleserver ~]# vim /etc/rc.d/rc.local
- #!/bin/bash
- # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
- #
- # It is highly advisable to create own systemd services or udev rules
- # to run scripts during boot instead of using this file.
- #
- # In contrast to previous versions due to parallel execution during boot
- # this script will NOT be run after all other services.
- #
- # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
- # that this script will be executed during boot.
-
- touch /var/lock/subsys/local
- su oracle -lc "/oracle/app/product/11.2.0/dbhome_1/bin/lsnrctl start" //添加此处
- su oracle -lc "/oracle/app/product/11.2.0/dbhome_1/bin/dbstart" //添加此处
-
- #开机启动文件执行权限授权
- [root@oracleserver ~]# ls -l /etc/rc.d/rc.local
- -rw-r--r-- 1 775 root 607 8月 31 13:51 /etc/rc.d/rc.local
- [root@oracleserver ~]# chmod +x /etc/rc.d/rc.local
- [root@oracleserver ~]# ls -l /etc/rc.d/rc.local
- -rwxr-xr-x 1 775 root 607 8月 31 13:51 /etc/rc.d/rc.local
13、数据库常用操作
(1)数据库实例启动
- [oracle@oracleserver ~]$ sqlplus /nolog
- SQL> connect / as sysdba
- SQL> startup (默认安装后自启动)
- SQL> startup force (强制启动)
- ORACLE instance started.
-
- Total System Global Area 534462464 bytes
- Fixed Size 2215064 bytes
- Variable Size 360711016 bytes
- Database Buffers 159383552 bytes
- Redo Buffers 12152832 bytes
- Database mounted.
- Database opened.
-
- #查询数据库启动状态
- SQL> select status from v$instance;
- STATUS
- ------------
- OPEN
(2)数据库实例停止
- [oracle@oracleserver ~]$ sqlplus /nolog
- SQL> connect / as sysoper
- SQL> shutdown immediate;
- Database closed.
- Database dismounted.
- ORACLE instance shut down.
(3)配置数据库监听
- #监听配置文件路径设置
- [oracle@oracleserver ~]$ vim /etc/oratab
- #
- # This file is used by ORACLE utilities. It is created by root.sh
- # and updated by the Database Configuration Assistant when creating
- # a database.
-
- # A colon, ':', is used as the field terminator. A new line terminates
- # the entry. Lines beginning with a pound sign, '#', are comments.
- #
- # Entries are of the form:
- # $ORACLE_SID:$ORACLE_HOME:<N|Y>:
- #
- # The first and second fields are the system identifier and home
- # directory of the database respectively. The third filed indicates
- # to the dbstart utility that the database should , "Y", or should not,
- # "N", be brought up at system boot time.
- #
- # Multiple entries with the same $ORACLE_SID are not allowed.
- #
- #
- orcl:/oracle/app/product/11.2.0/dbhome_1:N
-
- #配置数据库监听端口
- [oracle@oracleserver ~]$ cat /oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
- # listener.ora Network Configuration File: /oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
- # Generated by Oracle configuration tools.
-
- LISTENER =
- (DESCRIPTION_LIST =
- (DESCRIPTION =
- (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
- (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
- )
- )
- ADR_BASE_LISTENER = /oracle/app
- [oracle@oracleserver ~]$ lsnrctl stop //停止数据库监听服务
- [oracle@oracleserver ~]$ lsnrctl start //启动数据库监听服务(启动后等待5秒再检查)
- [oracle@oracleserver ~]$ lsnrctl status //查询数据库监听服务状态
- LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 31-AUG-2019 11:02:53
- Copyright (c) 1991, 2009, Oracle. All rights reserved.
- Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
- STATUS of the LISTENER
- ------------------------
- Alias LISTENER
- Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
- Start Date 30-AUG-2019 23:48:25
- Uptime 0 days 11 hr. 14 min. 28 sec
- Trace Level off
- Security ON: Local OS Authentication
- SNMP OFF
- Listener Parameter File /oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
- Listener Log File /oracle/app/diag/tnslsnr/oracleserver/listener/alert/log.xml
- Listening Endpoints Summary...
- (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
- (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
- Services Summary...
- Service "orcl" has 1 instance(s).
- Instance "orcl", status READY, has 1 handler(s) for this service...
- Service "orclXDB" has 1 instance(s).
- Instance "orcl", status READY, has 1 handler(s) for this service...
- The command completed successfully