热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Linux静默安装Oracle11g教程

准备工作在电脑中下载linux.x64_11gR2_database_1of2.zip和linux.x64_11gR2_database_2of2.ziphttp:download.oracle.comotnlinuxoracle11gR2l

准备工作

在电脑中下载 linux.x64_11gR2_database_1of2.zip 和 linux.x64_11gR2_database_2of2.zip
http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_1of2.zip
http://download.oracle.com/otn/linux/oracle11g/R2/linux.x64_11gR2_database_2of2.zip
复制链接直接用迅雷下载
root用户登录Linux
创建/data/oracle/oraclesetup/目录

[root@lynn-02 ~]# mkdir -p /data/oracle/oraclesetup/

进入/data/oracle/oraclesetup/目录

[root@lynn-02 ~]# cd /data/oracle/oraclesetup/

Ctrl加Alt加F 打开xftp 将下载好的linux.x64_11gR2_database_1of2.zip 和 linux.x64_11gR2_database_2of2.zip上传到Linux下/data/oracle/oraclesetup/目录中
Linux静默安装Oracle 11g教程

查看/data/oracle/oraclesetup/目录下的linux.x64_11gR2_database_1of2.zip 和 linux.x64_11gR2_database_2of2.zip

[root@lynn-02 oraclesetup]# ls
linux.x64_11gR2_database_1of2.zip  linux.x64_11gR2_database_2of2.zip

解压Oracle压缩包

[root@lynn-02 oraclesetup]# unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip

解压Oracle压缩包后会在当前目录下产生一个database目录里面有Oracle安装程序

[root@lynn-02 oraclesetup]# ls
database  linux.x64_11gR2_database_1of2.zip  linux.x64_11gR2_database_2of2.zip
[root@lynn-02 oraclesetup]# cd database
[root@lynn-02 database]# ls
doc  install  response  rpm  runInstaller  sshsetup  stage  welcome.html

在/etc/hosts中添加主机名

[root@lynn-02 database]# vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.130.168 CentOS

关闭SELinux

[root@lynn-02 database]# 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=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@lynn-02 database]# setenforce 0

关闭防火墙

[root@lynn-02 database]# service iptables stop
Redirecting to /bin/systemctl stop iptables.service
[root@lynn-02 database]# systemctl stop firewalld
[root@lynn-02 database]# systemctl disable firewalld

安装Oracle 11g依赖包

[root@lynn-02 database]# yum install -y gcc make binutils gcc-c++ compat-libstdc++-33elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-develnumactl-devel sysstat unixODBC unixODBC-devel pcre-devel

添加安装用户和用户组

[root@lynn-02 database]# groupadd oinstall
[root@lynn-02 database]# groupadd dba
[root@lynn-02 database]# useradd -g oinstall -G dba oracle
[root@lynn-02 database]# passwd oracle
更改用户 oracle 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@lynn-02 database]# id oracle
uid=1000(oracle) gid=1000(oinstall) 组=1000(oinstall),1001(dba)

修改内核参数配置文件/etc/sysctl.conf
添加如下内容
fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2097152

kernel.shmmax = 1073741824

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

其中kernel.shmmax = 1073741824为本机物理内存(2G)的一半,单位为byte。

[root@lynn-02 database]# 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).
fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2097152

kernel.shmmax = 1073741824

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

修改用户的限制文件/etc/security/limits.conf
添加以下内容

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536

oracle soft stack 10240

[root@lynn-02 database]# vim /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:
#
#            
#
#Where:
# 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
#        - 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
#
#                 
#

#*               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

# End of file
oracle           soft    nproc           2047

oracle           hard    nproc           16384

oracle           soft    nofile          1024

oracle           hard    nofile         65536

oracle           soft    stack           10240

修改/etc/pam.d/login文件:
添加以下内容:

session required /lib64/security/pam_limits.so

session required pam_limits.so

[root@lynn-02 database]# 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
session required  /lib64/security/pam_limits.so
session required   pam_limits.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

修改/etc/profile文件:
添加以下内容:

if [ $USER = "oracle" ]; then

if[ $SHELL = "/bin/ksh" ]; then

ulimit -p 16384

ulimit -n 65536

else

ulimit -u 16384 -n 65536

fi

fi

[root@lynn-02 database]# 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

# 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 ; do
    if [ -r "$i" ]; then
        if [ "${-#*i}" != "$-" ]; then
            . "$i"
        else
            . "$i" >/dev/null
        fi
    fi
done

unset i
unset -f pathmunge
if [ $USER = "oracle" ]; then

  if [ $SHELL = "/bin/ksh" ]; then

  ulimit -p 16384

  ulimit -n 65536

 else

  ulimit -u 16384 -n 65536

  fi

fi

创建安装目录和设置文件权限

[root@lynn-02 database]# vim /etc/security/limits.conf
[root@lynn-02 database]# vim /etc/pam.d/login
[root@lynn-02 database]# vim /etc/profile
[root@lynn-02 database]# mkdir -p /data/oracle/product/11.2.0
[root@lynn-02 database]# mkdir /data/oracle/oradata
[root@lynn-02 database]# mkdir /data/oracle/inventory
[root@lynn-02 database]# mkdir /data/oracle/fast_recovery_area
[root@lynn-02 database]# chown -R oracle:oinstall /data/oracle
[root@lynn-02 database]# chmod -R 775 /data/oracle

设置oracle用户环境变量
登陆到oracle用户

[root@lynn-02 ~]# su - oracle
上一次登录:六 4月  7 09:27:52 CST 2018pts/0 上

编辑.bash_profile添加如下内容:

ORACLE_BASE=/data/oracle

ORACLE_HOME=$ORACLE_BASE/product/11.2.0

ORACLE_SID=ora11

PATH=$PATH:$ORACLE_HOME/bin

export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

注意,粗体处必须与创建的数据库实例名称一致,否则数据库启动后无法访问。

[oracle@lynn-02 ~]$ vim .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_BASE=/data/oracle

ORACLE_HOME=$ORACLE_BASE/product/11.2.0

ORACLE_SID=ora11

PATH=$PATH:$ORACLE_HOME/bin

export ORACLE_BASE ORACLE_HOME ORACLE_SIDPATH

编辑/data/oracle/oraclesetup/database/response/db_install.rsp静默安装响应文件

[oracle@lynn-02 ~]$ vim /data/oracle/oraclesetup/database/response/db_install.rsp

需要设置的选项如下:

oracle.install.option=INSTALL_DB_SWONLY

ORACLE_HOSTNAME=CentOS

UNIX_GROUP_NAME=oinstall

INVENTORY_LOCATION=/data/oracle/inventory

SELECTED_LANGUAGES=en,zh_CN

ORACLE_HOME=/data/oracle/product/11.2.0

ORACLE_BASE=/data/oracle

oracle.install.db.InstallEdition=EE

oracle.install.db.DBA_GROUP=dba

oracle.install.db.OPER_GROUP=dba

DECLINE_SECURITY_UPDATES=true

静默安装Oracle11g

[oracle@lynn-02 response]$ cd /data/oracle/oraclesetup/database/
[oracle@lynn-02 database]$ ./runInstaller -silent -responseFile /data/oracle/oraclesetup/database/response/db_install.rsp -ignorePrereq
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 9490 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 4095 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-04-07_11-12-32AM. Please wait ...[oracle@lynn-02 database]$ [WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
   CAUSE: The Central Inventory is located in the Oracle base.
   ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
   CAUSE: The Central Inventory is located in the Oracle base.
   ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
You can find the log of this install session at:
 /data/oracle/inventory/logs/installActions2018-04-07_11-12-32AM.log
The following configuration scripts need to be executed as the "root" user. 
 #!/bin/sh 
 #Root scripts to run

/data/oracle/inventory/orainstRoot.sh
/data/oracle/product/11.2.0/root.sh
To execute the configuration scripts:
     1. Open a terminal window 
     2. Log in as "root" 
     3. Run the scripts 
     4. Return to this window and hit "Enter" key to continue 

Successfully Setup Software.

开始Oracle在后台静默安装。安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止了。
安装到出现Successfully Setup Software 则安装成功

打开终端,以root身份登录,执行脚本:

[root@lynn-02 ~]# sh /data/oracle/inventory/orainstRoot.sh
Changing permissions of /data/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /data/oracle/inventory to oinstall.
The execution of the script is complete.
[root@lynn-02 ~]# sh /data/oracle/product/11.2.0/root.sh
Check /data/oracle/product/11.2.0/install/root_lynn-02_2018-04-07_11-26-59.log for the output of root script

以静默方式配置监听:
重新使用oracle用户登录 执行netca /silent /responseFile /data/oracle/oraclesetup/database/response/netca.rsp

[root@lynn-02 ~]# su - oracle
上一次登录:六 4月  7 10:16:21 CST 2018pts/1 上
[oracle@lynn-02 ~]$ netca /silent /responseFile /data/oracle/oraclesetup/database/response/netca.rsp

正在对命令行参数进行语法分析:
参数"silent" = true
参数"responsefile" = /data/oracle/oraclesetup/database/response/netca.rsp
完成对命令行参数进行语法分析。
Oracle Net Services 配置:
完成概要文件配置。
Oracle Net 监听程序启动:
    正在运行监听程序控制: 
      /data/oracle/product/11.2.0/bin/lsnrctl start LISTENER
    监听程序控制完成。
    监听程序已成功启动。
监听程序配置完成。
成功完成 Oracle Net Services 配置。退出代码是0

成功运行后,在/data/oracle/product/11.2.0/network/admin/中生成listener.ora和sqlnet.ora

[oracle@lynn-02 ~]$ ls /data/oracle/product/11.2.0/network/admin/
listener.ora  samples  shrept.lst  sqlnet.ora

通过netstat命令可以查看1521端口正在监听。

[root@lynn-02 ~]# netstat -tnulp |grep 1521
tcp6       0      0 :::1521                 :::*                    LISTEN      13419/tnslsnr 

以静默方式建立新库,同时也建立一个对应的实例。
编辑/data/oracle/oraclesetup/database/response/dbca.rsp
设置以下参数:

GDBNAME= "ora11"

SID =" ora11"

SYSPASSWORD= " 20180606"

SYSTEMPASSWORD= "20180606"

SYSMANPASSWORD= " 20180606"

DBSNMPPASSWORD= " 20180606"

DATAFILEDESTINATION=/data/oracle/oradata

RECOVERYAREADESTINATION=/data/oracle/fast_recovery_area

CHARACTERSET= "ZHS16GBK"

TOTALMEMORY= "1638"

其中TOTALMEMORY ="1638" 为1638MB,物理内存2G*80%。

[oracle@lynn-02 ~]$ vim /data/oracle/oraclesetup/database/response/dbca.rsp

进行静默配置

[oracle@lynn-02 ~]$ dbca -silent -responseFile /data/oracle/oraclesetup/database/response/dbca.rsp
复制数据库文件
1% 已完成
3% 已完成
11% 已完成
18% 已完成
26% 已完成
37% 已完成
正在创建并启动 Oracle 实例
40% 已完成
45% 已完成
50% 已完成
55% 已完成
56% 已完成
60% 已完成
62% 已完成
正在进行数据库创建
66% 已完成
70% 已完成
73% 已完成
85% 已完成
96% 已完成
100% 已完成
有关详细信息, 请参阅日志文件 "/data/oracle/cfgtoollogs/dbca/ora11/ora11.log"。

建库后进行实例进程检查:

[oracle@lynn-02 ~]$ ps -ef | grep ora_ | grep -v grep
oracle    13850      1  0 14:32 ?        00:00:00 ora_pmon_ora11
oracle    13852      1  0 14:32 ?        00:00:00 ora_vktm_ora11
oracle    13856      1  0 14:32 ?        00:00:00 ora_gen0_ora11
oracle    13858      1  0 14:32 ?        00:00:00 ora_diag_ora11
oracle    13860      1  0 14:32 ?        00:00:00 ora_dbrm_ora11
oracle    13862      1  0 14:32 ?        00:00:00 ora_psp0_ora11
oracle    13864      1  0 14:32 ?        00:00:00 ora_dia0_ora11
oracle    13866      1  0 14:32 ?        00:00:00 ora_mman_ora11
oracle    13868      1  0 14:32 ?        00:00:00 ora_dbw0_ora11
oracle    13870      1  0 14:32 ?        00:00:00 ora_lgwr_ora11
oracle    13872      1  0 14:32 ?        00:00:00 ora_ckpt_ora11
oracle    13874      1  0 14:32 ?        00:00:00 ora_smon_ora11
oracle    13876      1  0 14:32 ?        00:00:00 ora_reco_ora11
oracle    13878      1  0 14:32 ?        00:00:00 ora_mmon_ora11
oracle    13880      1  0 14:32 ?        00:00:00 ora_mmnl_ora11
oracle    13882      1  0 14:32 ?        00:00:00 ora_d000_ora11
oracle    13884      1  0 14:32 ?        00:00:00 ora_s000_ora11
oracle    13898      1  0 14:32 ?        00:00:00 ora_qmnc_ora11
oracle    13913      1  0 14:32 ?        00:00:00 ora_cjq0_ora11
oracle    13915      1  0 14:32 ?        00:00:00 ora_q000_ora11
oracle    13917      1  0 14:32 ?        00:00:00 ora_q001_ora11

查看监听状态:

[oracle@lynn-02 ~]$  lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 07-APR-2018 14:34:17

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                07-APR-2018 14:11:08
Uptime                    0 days 0 hr. 23 min. 13 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /data/oracle/diag/tnslsnr/lynn-02/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lynn-02)(PORT=1521)))
Services Summary...
Service "ora11" has 1 instance(s).
  Instance "ora11", status READY, has 1 handler(s) for this service...
Service "ora11XDB" has 1 instance(s).
  Instance "ora11", status READY, has 1 handler(s) for this service...
The command completed successfully

登录查看实例状态:

[oracle@lynn-02 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat Apr 7 17:28:34 2018

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select status from v$instance;

STATUS
------------
OPEN

SQL> 

Oracle开机自启动设置

修改/data/oracle/product/11.2.0/bin/dbstart

[oracle@lynn-02 ~]$ vim /data/oracle/product/11.2.0/bin/dbstart

将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME
修改/data/oracle/product/11.2.0/bin/dbshut

[oracle@lynn-02 ~]$ vim /data/oracle/product/11.2.0/bin/dbshut

将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME
修改/etc/oratab文件
将orcl:/data/oracle/product/11.2.0:N中最后的N改为Y,成为orcl:/data/oracle/product/11.2.0:Y

[oracle@lynn-02 ~]$ 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::
#
# 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.
#
#
ora11:/data/oracle/product/11.2.0:Y

输入命令dbshut和dbstart测试

[oracle@lynn-02 ~]$ dbshut
Processing Database instance "ora11": log file /data/oracle/product/11.2.0/shutdown.log
[oracle@lynn-02 ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 07-APR-2018 14:52:41

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 2: No such file or directory
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=CentOS)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
[oracle@lynn-02 ~]$ ps -ef |grep ora_ |grep -v grep
[oracle@lynn-02 ~]$ 

Oracle监听停止,进程消失。

[oracle@lynn-02 ~]$ dbstart
Processing Database instance "ora11": log file /data/oracle/product/11.2.0/startup.log
[oracle@lynn-02 ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 07-APR-2018 14:54:27

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                07-APR-2018 14:54:13
Uptime                    0 days 0 hr. 0 min. 19 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /data/oracle/diag/tnslsnr/lynn-02/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lynn-02)(PORT=1521)))
Services Summary...
Service "ora11" has 1 instance(s).
  Instance "ora11", status READY, has 1 handler(s) for this service...
Service "ora11XDB" has 1 instance(s).
  Instance "ora11", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@lynn-02 ~]$ ps -ef |grep ora_ |grep -v grep
oracle    14236      1  0 14:54 ?        00:00:00 ora_pmon_ora11
oracle    14238      1  0 14:54 ?        00:00:00 ora_vktm_ora11
oracle    14242      1  0 14:54 ?        00:00:00 ora_gen0_ora11
oracle    14245      1  0 14:54 ?        00:00:00 ora_diag_ora11
oracle    14247      1  0 14:54 ?        00:00:00 ora_dbrm_ora11
oracle    14249      1  0 14:54 ?        00:00:00 ora_psp0_ora11
oracle    14251      1  0 14:54 ?        00:00:00 ora_dia0_ora11
oracle    14253      1  0 14:54 ?        00:00:00 ora_mman_ora11
oracle    14255      1  0 14:54 ?        00:00:00 ora_dbw0_ora11
oracle    14257      1  0 14:54 ?        00:00:00 ora_lgwr_ora11
oracle    14259      1  0 14:54 ?        00:00:00 ora_ckpt_ora11
oracle    14261      1  0 14:54 ?        00:00:00 ora_smon_ora11
oracle    14264      1  0 14:54 ?        00:00:00 ora_reco_ora11
oracle    14266      1  1 14:54 ?        00:00:00 ora_mmon_ora11
oracle    14268      1  0 14:54 ?        00:00:00 ora_mmnl_ora11
oracle    14270      1  0 14:54 ?        00:00:00 ora_d000_ora11
oracle    14272      1  0 14:54 ?        00:00:00 ora_s000_ora11
oracle    14280      1  0 14:54 ?        00:00:00 ora_qmnc_ora11
oracle    14358      1  0 14:54 ?        00:00:00 ora_cjq0_ora11
oracle    14360      1  0 14:54 ?        00:00:00 ora_j000_ora11
oracle    14362      1  0 14:54 ?        00:00:00 ora_j001_ora11
oracle    14371      1  0 14:54 ?        00:00:00 ora_q000_ora11
oracle    14373      1  0 14:54 ?        00:00:00 ora_q001_ora11

Oracle监听启动,进程启动。
切换到root账户建立自启动脚本

[oracle@lynn-02 ~]$ su -
密码:
上一次登录:六 4月  7 11:21:33 CST 2018pts/0 上
[root@lynn-02 ~]# vim /etc/rc.d/init.d/oracle

添加以下内容(有些值如ORACLE_HOME和ORACLE_USER等根据实际情况可以修改):

#!/bin/bash

#oracle: Start/Stop Oracle Database 11g R2

#chkconfig: 345 90 10

#description: The Oracle Database is an Object-Relational Database ManagementSystem.

#

. /etc/rc.d/init.d/functions

LOCKFILE=/var/lock/subsys/oracle

ORACLE_HOME=/data/oracle/product/11.2.0

ORACLE_USER=oracle

case "$1" in

'start')

         if [ -f $LOCKFILE ]; then

                   echo $0 already running.

         else

                   echo -n $"StartingOracle Database:"

                   su - $ORACLE_USER -c"$ORACLE_HOME/bin/lsnrctl start"

                   su - $ORACLE_USER -c"$ORACLE_HOME/bin/dbstart $ORACLE_HOME"

                   su - $ORACLE_USER -c"$ORACLE_HOME/bin/emctl start dbconsole"

                   touch $LOCKFILE

         fi

   ;;

'stop')

         if [ ! -f $LOCKFILE ]; then

                   echo $0 already stopping.

         else

                   echo -n $"StoppingOracle Database:"

                   su - $ORACLE_USER -c"$ORACLE_HOME/bin/lsnrctl stop"

                   su - $ORACLE_USER -c"$ORACLE_HOME/bin/dbshut"

                   su - $ORACLE_USER -c"$ORACLE_HOME/bin/emctl stop dbconsole"

                   rm -f $LOCKFILE

         fi

   ;;

'restart')

         $0 stop

         sleep 5

         $0 start

   ;;

'status')

         if [ -f $LOCKFILE ]; then

                   echo $0 started.

         else

                   echo $0 stopped.

         fi

   ;;

*)

         echo "Usage: $0[start|stop|status]"

         exit 1

esac

exit 0

修改/etc/init.d/oracle服务文件权限

[root@lynn-02 ~]# chmod 755 /etc/init.d/oracle

设置为开机启动

[root@lynn-02 ~]# chkconfig oracle on
[root@lynn-02 ~]# chkconfig --list oracle

注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。 

      要列出 systemd 服务,请执行 'systemctl list-unit-files'。
      查看在具体 target 启用的服务请执行
      'systemctl list-dependencies [target]'。

oracle          0:关 1:关 2:开 3:开 4:开 5:开 6:关

进行service oracle start/stop/restart测试

[root@lynn-02 ~]# service oracle status
/etc/init.d/oracle stopped.
[root@lynn-02 ~]# service oracle start
Starting oracle (via systemctl):                           [  确定  ]
[root@lynn-02 ~]# service oracle stop
Stopping oracle (via systemctl):                           [  确定  ]
[root@lynn-02 ~]# service oracle restart
Restarting oracle (via systemctl):                         [  确定  ]

Reboot重启查看Oracle监听和实例进程均能自动启动。


推荐阅读
  • Windows7 64位系统安装PLSQL Developer的步骤和注意事项
    本文介绍了在Windows7 64位系统上安装PLSQL Developer的步骤和注意事项。首先下载并安装PLSQL Developer,注意不要安装在默认目录下。然后下载Windows 32位的oracle instant client,并解压到指定路径。最后,按照自己的喜好对解压后的文件进行命名和压缩。 ... [详细]
  • 本文讨论了在Windows 8上安装gvim中插件时出现的错误加载问题。作者将EasyMotion插件放在了正确的位置,但加载时却出现了错误。作者提供了下载链接和之前放置插件的位置,并列出了出现的错误信息。 ... [详细]
  • 本文介绍了在Windows环境下如何配置php+apache环境,包括下载php7和apache2.4、安装vc2015运行时环境、启动php7和apache2.4等步骤。希望对需要搭建php7环境的读者有一定的参考价值。摘要长度为169字。 ... [详细]
  • 【shell】网络处理:判断IP是否在网段、两个ip是否同网段、IP地址范围、网段包含关系
    本文介绍了使用shell脚本判断IP是否在同一网段、判断IP地址是否在某个范围内、计算IP地址范围、判断网段之间的包含关系的方法和原理。通过对IP和掩码进行与计算,可以判断两个IP是否在同一网段。同时,还提供了一段用于验证IP地址的正则表达式和判断特殊IP地址的方法。 ... [详细]
  • 本文介绍了绕过WAF的XSS检测机制的方法,包括确定payload结构、测试和混淆。同时提出了一种构建XSS payload的方法,该payload与安全机制使用的正则表达式不匹配。通过清理用户输入、转义输出、使用文档对象模型(DOM)接收器和源、实施适当的跨域资源共享(CORS)策略和其他安全策略,可以有效阻止XSS漏洞。但是,WAF或自定义过滤器仍然被广泛使用来增加安全性。本文的方法可以绕过这种安全机制,构建与正则表达式不匹配的XSS payload。 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • 基于PgpoolII的PostgreSQL集群安装与配置教程
    本文介绍了基于PgpoolII的PostgreSQL集群的安装与配置教程。Pgpool-II是一个位于PostgreSQL服务器和PostgreSQL数据库客户端之间的中间件,提供了连接池、复制、负载均衡、缓存、看门狗、限制链接等功能,可以用于搭建高可用的PostgreSQL集群。文章详细介绍了通过yum安装Pgpool-II的步骤,并提供了相关的官方参考地址。 ... [详细]
  • EPICS Archiver Appliance存储waveform记录的尝试及资源需求分析
    本文介绍了EPICS Archiver Appliance存储waveform记录的尝试过程,并分析了其所需的资源容量。通过解决错误提示和调整内存大小,成功存储了波形数据。然后,讨论了储存环逐束团信号的意义,以及通过记录多圈的束团信号进行参数分析的可能性。波形数据的存储需求巨大,每天需要近250G,一年需要90T。然而,储存环逐束团信号具有重要意义,可以揭示出每个束团的纵向振荡频率和模式。 ... [详细]
  • 本文介绍了在rhel5.5操作系统下搭建网关+LAMP+postfix+dhcp的步骤和配置方法。通过配置dhcp自动分配ip、实现外网访问公司网站、内网收发邮件、内网上网以及SNAT转换等功能。详细介绍了安装dhcp和配置相关文件的步骤,并提供了相关的命令和配置示例。 ... [详细]
  • 搭建Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境的详细步骤
    本文详细介绍了搭建Windows Server 2012 R2 IIS8.5+PHP(FastCGI)+MySQL环境的步骤,包括环境说明、相关软件下载的地址以及所需的插件下载地址。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • 本文是一位90后程序员分享的职业发展经验,从年薪3w到30w的薪资增长过程。文章回顾了自己的青春时光,包括与朋友一起玩DOTA的回忆,并附上了一段纪念DOTA青春的视频链接。作者还提到了一些与程序员相关的名词和团队,如Pis、蛛丝马迹、B神、LGD、EHOME等。通过分享自己的经验,作者希望能够给其他程序员提供一些职业发展的思路和启示。 ... [详细]
  • Windows下配置PHP5.6的方法及注意事项
    本文介绍了在Windows系统下配置PHP5.6的步骤及注意事项,包括下载PHP5.6、解压并配置IIS、添加模块映射、测试等。同时提供了一些常见问题的解决方法,如下载缺失的msvcr110.dll文件等。通过本文的指导,读者可以轻松地在Windows系统下配置PHP5.6,并解决一些常见的配置问题。 ... [详细]
  • Windows 7 部署工具DISM学习(二)添加补丁的步骤详解
    本文详细介绍了在Windows 7系统中使用部署工具DISM添加补丁的步骤。首先需要将光驱中的安装文件复制到指定文件夹,并进行挂载。然后将需要的MSU补丁解压并集成到系统中。文章给出了具体的命令和操作步骤,帮助读者完成补丁的添加过程。 ... [详细]
  • Android实战——jsoup实现网络爬虫,糗事百科项目的起步
    本文介绍了Android实战中使用jsoup实现网络爬虫的方法,以糗事百科项目为例。对于初学者来说,数据源的缺乏是做项目的最大烦恼之一。本文讲述了如何使用网络爬虫获取数据,并以糗事百科作为练手项目。同时,提到了使用jsoup需要结合前端基础知识,以及如果学过JS的话可以更轻松地使用该框架。 ... [详细]
author-avatar
thofarq
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有