Open Oracle Manual ,Search Key Word : AUDIT And U got what you want

解决方案 »

  1.   

    你是 DBA吗? 如果是的话,你也太不细心了。  给几个建议:
        1. 修改用户 sys/system/scott/sys_man(oem使用)的密码;    2. 进入dba studio看看系统有多少个用户,有没有可疑用户    3. 不用随便给普通用户赋予DBA角色,普通用户赋予CONNECT或
           RESOURCE角色或者根据需要赋予相关的权限。    4. 8i以上使用LogMiner工具,关于此工具的使用查阅精华区或faqs    5. 经常查看Alert<SID>.log文件,该文件路径: $ORACLE_HOME\admin\sid\bdump.
           
        
      

  2.   

    用LogMiner包看一下,可以看到他是用的那个用户修改的那些表修改了什么。
    Example of Using LogMiner
    Assume that the data dictionary extract was taken to a flat file named
    '/usr/oracle/dbs/dict.txt'
    The DBA first specifies five redo logs to be analyzed
    execute dbms_logmnr.add_logfile (filename => '/usr/oracle/dbs/arch123.dbf',
    options => dbms_logmnr.NEW);
    -- identifying this file starts a new list of files to analyze
    execute dbms_logmnr.add_logfile (filename => '/usr/oracle/dbs/arch124.dbf',
    options => dbms_logmnr.ADDFILE);
    execute dbms_logmnr.add_logfile (filename => '/usr/oracle/dbs/arch125.dbf',
    options => dbms_logmnr.ADDFILE);
    execute dbms_logmnr.add_logfile (filename => '/usr/oracle/dbs/arch126.dbf',
    options => dbms_logmnr.ADDFILE);
    execute dbms_logmnr.add_logfile (filename => '/usr/oracle/dbs/arch127.dbf',
    options => dbms_logmnr.ADDFILE);
    The DBA then specifies the location of the dictionary with,
    execute dbms_logmnr.start_logmnr( dictfilename => '/usr/oracle/dbs/dict.txt' );
    The DBA is now ready to issue a select against the v$logmnr_contents view
    select operation, sql_redo, sql_undo
    from v$logmnr_contents
    where seg_owner = 'SCOTT' and seg_name = 'ORDERS' and
    operation = 'DELETE' and username = 'RON';
      

  3.   

    listner.log里面会有你想要的证据
      

  4.   

    shahand你好谢谢你,我查看了这个文件,我发现是我的哪个同事了,谢谢。但我在这个文件中不能看到他用pl/sql执行了那些语句,要是在哪里能看到就好了?不知还有那位大侠知道,一并指点,不胜感谢。
      

  5.   

    注意查看system的视图v$sql,也许会有收获。
      

  6.   

    查listener.log只能查到从哪里登录,查不到输入什么sql语句。
    保密有一点很关键但又很容易被忽略的,很多人都是直接输入
    sqlplus username/password@connstring   (一般服务器都安装在unix系统)
    登录的,如此一来,别人只要用ps -ef|grep sqlplus就可以看到你的用户名和密码了。
    应该用
    sqlplus  然后再输入用户名和密码。
    也可以先定义一个变量
    $STRI=username/password;export $STRI
    sqlplus $STRI@connstring
    这样别人就看不到你的密码了。
      

  7.   

    当然用审计功能 :
    方法一:
    用以下的方式可以監控登入登出的用戶:
    創建如下的兩張表:
    create table login_log -- 登入登出信息表
    (
        session_id int not null, -- sessionid
        login_on_time  date, -- 登入時間
        login_off_time  date, -- 登出時間
        user_in_db varchar2(30), -- 登入的db user
        machine    varchar2(20),    -- 機器名
        ip_address varchar2(20), -- ip地址
        run_program varchar2(20)    -- 以何程序登入
    );create table allow_user -- 網域用戶表
    (
        ip_address varchar2(20), -- ip地址
        login_user_name nvarchar2(20)   -- 操作者姓名
    );創建如下的兩個觸發器:
    create or replace trigger login_on_info -- 紀錄登入信息的觸發器
    after logon on database 
    Begin 
        insert into login_log(session_id,login_on_time,login_off_time,user_in_db,machine,ip_address,run_program)
        select AUDSID,sysdate,null,sys.login_user,machine,SYS_CONTEXT('USERENV','IP_ADDRESS'),program
        from v$session where AUDSID = USERENV('SESSIONID');  --當前SESSION
    END;create or replace trigger login_off_info -- 紀錄登出信息的觸發器
    before logoff on database 
    Begin
    update login_log set  login_off_time = sysdate
    where session_id = USERENV('SESSIONID'); --當前SESSION
    exception
        when others then
         null;
    END;方法二:
    用如下的方式可以審計執行drop動作的事件:
    /**
     * drop語句的審計日誌表
     */
    create table drop_log
    (
        session_id int not null,  -- sessionid
        drop_time  date,  -- drop的時間
        ip_address varchar2(20),  -- ip地址
        object_owner varchar2(30),  -- 對象的擁有者
        object_name varchar2(30),  -- 對象名稱
        object_type varchar2(20),  -- 對象類型
        drop_by_user varchar2(30) -- 執行drop語句的用戶
    );create or replace trigger drop_info 
    after drop on mfg0513user.schema  -- 在mfg0513user用戶上創建審計drop的觸發器
    begin 
        insert into drop_log
         (session_id,
         drop_time,
         ip_address,
         object_owner,
         object_name,
         object_type,
         drop_by_user)
         values(USERENV('SESSIONID'),
         sysdate,
         SYS_CONTEXT('USERENV','IP_ADDRESS'),
         sys.dictionary_obj_owner,
         sys.dictionary_obj_name,
         sys.dictionary_obj_type,
         sys.login_user);    
    end;
      

  8.   

    就是,DBA经常遇到的问题
    不错啊
      

  9.   

    To collect auditing results, you must set the initialization parameter AUDIT_TRAIL to DB.
    To choose auditing for statements issued by the users aaa that query or update a table or view, issue the following statement:
    AUDIT SELECT TABLE, UPDATE TABLE
       BY aaa;
    To obtaining information:
       --DBA_AUDIT_TRAIL
       --DBA_AUDIT_EXISTS
       --DBA_AUDIT_OBJECT
       --DBA_AUDIT_SESSION
       --DBA_AUDIT_STATEMENT
      

  10.   

    分数都无所谓,不过揭帖了可以入faq
      

  11.   

    我后来使用了一个触发器,效果也不错。就是在出问题的那个表上加了一个触发器,但表的记录有改动时,将old 与new的值insert到另一个表中,进行分析,效果也蛮好的。我就用这个方法找到原因的。希望以后大家有心得互相交流,共同提高。谢谢。