• centos7 下安装oracle 11g笔记


    安装关键步骤:

    [sonny@localhost ~]$ su root  #切换到root
    Password: 
    [root@localhost sonny]# groupadd oinstall  #创建用户组oinstall
    [root@localhost sonny]# groupadd dba  #创建用户组dba
    [root@localhost sonny]# useradd -g oinstall -g dba -m oracle  #创建oracle用户,并加入到oinstall和dba用户组
    [root@localhost sonny]# passwd oracle  #设置用户oracle的登陆密码,不设置密码,在CentOS的图形登陆界面没法登陆
    Changing password for user oracle.
    New password:   # 密码
    BAD PASSWORD: The password is shorter than 8 characters
    Retype new password:   # 确认密码
    passwd: all authentication tokens updated successfully.
    [root@localhost sonny]# id oracle # 查看新建的oracle用户
    uid=1001(oracle) gid=1002(dba) groups=1002(dba)
    [root@localhost sonny]# 
    
    
    [sonny@localhost ~]$ su root
    Password: 
    [root@localhost sonny]# mkdir -p /data/oracle  #oracle数据库安装目录
    [root@localhost sonny]# mkdir -p /data/oraInventory  #oracle数据库配置文件目录
    [root@localhost sonny]# mkdir -p /data/database  #oracle数据库软件包解压目录
    [root@localhost sonny]# cd /data
    [root@localhost data]# ls  #创建完毕检查一下(强迫症)
    database  oracle  oraInventory
    [root@localhost data]# chown -R oracle:oinstall /data/oracle  #设置目录所有者为oinstall用户组的oracle用户
    [root@localhost data]# chown -R oracle:oinstall /data/oraInventory
    [root@localhost data]# chown -R oracle:oinstall /data/database
    [root@localhost data]#  
    
    
    
    [sonny@localhost data]$ su root
    Password: 
    [root@localhost data]# cat /proc/version 
    Linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015
    [root@localhost data]# cat /etc/redhat-release  
    CentOS Linux release 7.2.1511 (Core) 
    [root@localhost data]# vi /etc/redhat-release
    [root@localhost data]# cat /etc/redhat-release 
    redhat-7 
    [root@localhost data]#  
    
    
    yum install gcc gcc-c++ glibc glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel zlib-devel unzip compat-libcap1 compat-libstdc++-33
    
    
    
    [root@localhost /]# vi /etc/selinux/config
    [root@localhost /]# cat /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   #此处修改为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@localhost /]# 

    终于在vmare的centos7下将oracle11g安装成功了,不容易,将结果记录如下

    启动oracle监听及服务的步骤,使用oracle用户登录,执行以下命令

    登录到CentOS,切换到oracle用户权限
    #  su – oracle
    接着输入:
    $  sqlplus "/as sysdba"
    原本的画面会变为
    SQL>
    接着请输入
    SQL>  startup
    就可以正常的启动数据库了。

    检查Oracle DB监听器是否正常

    回到终端机模式,输入:
    SQL>  exit
    $  lsnrctl status
    检查看看监听器是否有启动
    如果没有启动,可以输入:
    $  lsnrctl start
    启动监听器

     使用plsql查看服务器版本信息

     CentOS设置Oracle开机自动启动

     1 在Windows下安装完成Oracle 11gR2后,默认就开机自启动Oracle相关服务,但Linux下安装完后每次都得手动启动和关闭数据库(dbstart | dbshut)、监听器(lsnrctl)、控制台(emtcl)。如何把Oracle添加到Linux系统服务里开机自启动呢?下面以CentOS 6.3为例详解,其他发行版一样通用!
     2  
     3 1、Redhat init简介:
     4 Linux启动时,会运行一个init程序,然后由init来启动后面的任务,包括多用户环境(inittab中设定)和网络等。运行级就是当前程序运行的功能级别,这个级别从1到6,具有不同的功能。这些级别在/etc/inittab(其他发行版这个文件位置不同)中指定,该文件就是init程序寻找的主要文件。最先运行的服务放在/etc/rc.d目录下。
     5 文件以S开头,代表start(启动),后面的数字是启动顺序;文件以K开头,代表kill(结束),同样,后面的数字代表结束顺序。例如:/etc/rc3.d/S55sshd表示它与运行级别3有关,55就是它的启动顺序;/etc/rc3.d/K15nginx表示它与运行级别3有关,15就是它的关闭顺序。
     6 init.d
     7 这个目录中存放了一些服务启动脚本,系统安装时的多个rpm包,这些脚本在执行时可以用来启动,停止和重启这些服务。
     8 rcx.d(x为0~6 9 这个目录是启动级别的执行程序链接目录,里面的文件都是指向init.d目录中文件的一些软连接。
    10 2、修改dbstart和dbshut启动关闭脚本,使其启动数据库的同时也自动启动监听器(即启动数据库时启动监听器,停止数据库时停止监听器):
    11 # vim /u01/app/oracle/product/11.2.0/db_1/bin/dbstart
    12 找到下面的代码,在实际脚本代码的前面
    13 
    14 # First argument is used to bring up Oracle Net Listener
    15 ORACLE_HOME_LISTNER=$1
    16 # 将此处的 ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
    17 if [ ! $ORACLE_HOME_LISTNER ] ; then
    18 echo "ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener"
    19 echo "Usage: $0 ORACLE_HOME"
    20 else
    21 LOG=$ORACLE_HOME_LISTNER/listener.log
    22 同样也修改dbshut脚本:
    23 # vim /u01/app/oracle/product/11.2.0/db_1/bin/dbshut
    24 
    25 # The this to bring down Oracle Net Listener
    26 ORACLE_HOME_LISTNER=$1
    27 # 将此处的 ORACLE_HOME_LISTNER=$1 修改为 ORACLE_HOME_LISTNER=$ORACLE_HOME
    28 if [ ! $ORACLE_HOME_LISTNER ] ; then
    29 echo "ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener"
    30 echo "Usage: $0 ORACLE_HOME"
    31 else
    32 LOG=$ORACLE_HOME_LISTNER/listener.log
    33 3、新建Oracle服务启动脚本:
    34 # vim /etc/init.d/oracle
    35 新建一个以oracle命名的文件(也可以命名为oracle11g等,自己喜欢啥名改啥名。),并将以下脚本代码复制到文件里(里面的oracle目录路径根据自己的实际安装路径修改):
    36 
    37 #!/bin/sh
    38 # chkconfig: 345 61 61
    39 # description: Oracle 11g R2 AutoRun Servimces
    40 # /etc/init.d/oracle
    41 #
    42 # Run-level Startup script for the Oracle Instance, Listener, and
    43 # Web Interface
    44 export ORACLE_BASE=/u01/app/oracle
    45 export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
    46 export ORACLE_SID=ORCL
    47 export PATH=$PATH:$ORACLE_HOME/bin
    48 ORA_OWNR="oracle"
    49 # if the executables do not exist -- display error
    50 if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
    51 then
    52 echo "Oracle startup: cannot start"
    53 exit 1
    54 fi
    55 # depending on parameter -- startup, shutdown, restart
    56 # of the instance and listener or usage display
    57 case "$1" in
    58 start)
    59 # Oracle listener and instance startup
    60 su $ORA_OWNR -lc $ORACLE_HOME/bin/dbstart
    61 echo "Oracle Start Succesful!OK."
    62 ;;
    63 stop)
    64 # Oracle listener and instance shutdown
    65 su $ORA_OWNR -lc $ORACLE_HOME/bin/dbshut
    66 echo "Oracle Stop Succesful!OK."
    67 ;;
    68 reload|restart)
    69 $0 stop
    70 $0 start
    71 ;;
    72 *)
    73 echo $"Usage: `basename $0` {start|stop|reload|reload}"
    74 exit 1
    75 esac
    76 exit 0
    77 
    78 保存退出!
    79 4、赋予启动脚本执行权限并链接好:
    80 # chmod 750 /etc/init.d/oracle # ln -s /etc/init.d/oracle /etc/rc1.d/K61oracle # ln -s /etc/init.d/oracle /etc/rc3.d/S61oracle
    81 5、把oracle启动脚本添加到系统服务里并设置自启动:
    82 # chkconfig --add oracle # chkconfig --level 345 oracle on
    83 reboot重启系统看看效果吧
    Oracle自启动

    export NLS_LANG="AMERICAN_AMERICA.UTF8"

    参考:

    http://www.linuxidc.com/Linux/2016-04/130559p2.htm#0-tsina-1-45959-397232819ff9a47a7b7e80a40613cfe1

    http://www.jianshu.com/p/36a78274a00e

    http://blog.sina.com.cn/s/blog_4af62a6501018xfj.html

  • 相关阅读:
    对文本抽取词袋模型特征
    jieba分词
    家用电器用户行为分析与事件识别
    Linux系统调用:创建和终止进程
    Linux系统调用:获取进程PID
    使用函数指针解决函数重载二义性调用问题
    C++ string基本操作
    有界深度优先搜索-八数码问题
    数据传送指令
    x86-64数据格式、通用寄存器与操作数格式
  • 原文地址:https://www.cnblogs.com/weiweictgu/p/5548485.html
Copyright © 2020-2023  润新知