• 17.08.04


    实例管理

    监听

    启动监听:

    $ netstat -tlnp | grep 1521

    $ lsnrctl

    LSNRCTL> help

    $ lsnrctl status

    $ lsnrctl stop

    $ netstat -tln | grep 1521

    快速动态注册:(可选)

    $ sqlplus / as sysdba

    SQL> alter system register;

    $ lsnrctl status

    em

    Emctl start | stop | status dbconsole

    一个监听可以为所有的数据库服务

    Em服务与数据库是一对一的

    启动EM:

    $ netstat -tlnp | grep 1158

    $ echo $ORACLE_SID

    orcl

    $ echo $ORACLE_UNQNAME

    orcl

    如果没有设置ORACLE_UNQNAME:

    $ export ORACLE_UNQNAME=orcl

    $ vi .bash_profile

    export ORACLE_UNQNAME=orcl

    $ . .bash_profile

    确保主机名正常解析:

    $ cat /etc/hosts

    $ emctl status dbconsole

    $ emctl stop dbconsole

    $ emctl start dbconsole

    查看oem的端口:

    $ find /u01 -name portlist.ini

    重新配置em:

    $ emca

    $ emca -deconfig dbcontrol db

    $ emca -config dbcontrol db

    数据库

     

    启动实例:

    $ ls $ORACLE_HOME/dbs/spfileorcl.ora

    SQL> shutdown immediate

    SQL> startup nomount

    SQL> select status from v$instance;

    SQL> select * from v$sgainfo;

    SQL> select * from hr.employees;

    SQL> conn hr/hr

    SQL> startup mount或alter database mount;

    SQL> show parameter control_files

    SQL> select status from v$instance;

    SQL> select * from v$controlfile;

    SQL> select name from v$datafile;

    SQL> select * from hr.employees;

    SQL> conn hr/hr

     

    SQL> startup或alter database open;

    SQL> select status from v$instance;

    SQL> select * from hr.employees;

    SQL> conn hr/hr

    关闭数据库:

    SQL> shutdown normal

    SQL> shutdown transactional     等事物提交之后关闭

    SQL> shutdown immediate     立即关闭

    SQL> shutdown abort        快速关闭

    控制脚本:

    $ vi /etc/oratab

    $ vi $ORACLE_HOME/bin/dbstart

    $ vi $ORACLE_HOME/bin/dbshut

    重启数据库:

    SQL> startup force

    startup force = shutdown abort + startup

    startup force mount = shutdown abort + startup mount

    参数管理

    参数文件:

    $ ls $ORACLE_HOME/dbs/spfileorcl.ora

    预先备份:

    $ cp spfileorcl.ora spfileorcl.ora.bak

    不可以通过vi直接修改!

    查看参数:

    SQL> show parameter

    SQL> select NAME, VALUE from v$parameter;

    修改参数:

    动态参数:

    $ strings $ORACLE_HOME/dbs/spfileorcl.ora|grep reource_limit

    SQL> show parameter RESOURCE_LIMIT

    SQL> alter system set RESOURCE_LIMIT=true;

    SQL> show parameter RESOURCE_LIMIT

    $ strings $ORACLE_HOME/dbs/spfileorcl.ora|grep reource_limit

     

    静态参数:

    $ strings $ORACLE_HOME/dbs/spfileorcl.ora|grep processes

    *.processes=150

    SQL> show parameter processes      值为150

    SQL> alter system set processes=300 scope=spfile;

    SQL> show parameter processes      值为150

    $ cat $ORACLE_HOME/dbs/spfileorcl.ora

    *.processes=300

     

    重启数据库,静态参数修改生效:

    SQL> shutdown immediate

    SQL> startup

    SQL> show parameter processes      值为300

     

    session级别修改参数:

    SQL> select sysdate from dual;

    SQL> alter session set nls_date_format='dd-mon rr';

    SQL> select sysdate from dual;                只影响当前会话,不影响系统

    SQL> conn / as sysdba

    SQL> select sysdate from dual;                恢复默认设置

     

    Pfile(文本格式)/spfile(服务器端的二进制格式)格式转换:

    SQL> create pfile='/home/oracle/initorcl.ora' from spfile;

    $ cat /home/oracle/initorcl.ora

    $ mv $ORACLE_HOME/dbs/spfileorcl.ora $ORACLE_HOME/dbs/spfileorcl.ora.bak

    SQL> shutdown immediate

    SQL> create spfile from pfile='/home/oracle/initorcl.ora';

    $ strings $ORACLE_HOME/dbs/spfileorcl.ora

     

    指定参数文件启动数据库:

    SQL> startup pfile='/home/oracle/initorcl.ora'

    警告日志和后台进程的转储文件

    $ find /u01 -name alert_*.log

    $ vi /u01/app/oracle/diag/rdbms/orcl/orcl/trace/alert_orcl.log

    SQL> show parameter dump

  • 相关阅读:
    联通手机号停机保号了,想恢复要短信验证码登陆但是无法接收短信验证码怎么办
    记卖饭让我先吃
    POJ 3658 Artificial Lake
    POJ 3662 Telephone Lines (dijstra+二分)
    CodeForces 748C Santa Claus and Robot
    CodeForces 748B Santa Claus and Keyboard Check
    POJ 3659 Cell Phone Network(树形dp树的最小点支配集)
    【JZOJ 5455】拆网线 【树形DP】
    【JZOJ 5455】拆网线 【树形DP】
    【JZOJ 5455】拆网线 【树形DP】
  • 原文地址:https://www.cnblogs.com/Zhang-x/p/7395048.html
Copyright © 2020-2023  润新知