常用指令碼-02
1.查詢記憶體大小
grep MemTotal /proc/meminfo
1.解鎖統計資訊
BEGIN
dbms_stats.unlock_schema_stats(ownname=>'DFMS');
END;
BEGIN
dbms_stats.unlock_table_stats(ownname=>'SCHEMA_NAME', tabname=>'TABLE_NAME');
END;
1.強行關機(shutdown abort),導致無法開啟
ORA-16038:無法存檔日誌 3序號 29052
ORA-19809:超過復原檔案限制
ORA-00312:線上日誌 3連線1:
日誌3 的目錄 省略
解決辦法 1.startup mount exclusive;
alter database FLASHBACK off;
alter database open;
解決ok
第二次出現 2.alter database noarchivelog;
解決ok
0.低效sql查詢
SELECT EXECUTIONS , DISK_READS, BUFFER_GETS,
ROUND((BUFFER_GETS-DISK_READS)/BUFFER_GETS,2) Hit_radio,
ROUND(DISK_READS/EXECUTIONS,2) Reads_per_run,
SQL_TEXT
FROM V$SQLAREA
WHERE EXECUTIONS>0
AND BUFFER_GETS > 0
AND (BUFFER_GETS-DISK_READS)/BUFFER_GETS < 0.8
ORDER BY 4 DESC;
0-1
disk_reads低效 sql
SELECT c.*
FROM (SELECT UPPER (b.username) username,
a.disk_reads disk_reads,
a.executions executions,
a.disk_reads / DECODE (a.executions, 0, 1, a.executions)
reads_per_exec,
a.address,
a.sql_text || CHR (10) || CHR (10) sql,
A.MODULE,
a.last_load_time last_time
-- , a.sql_fulltext sql
FROM sys.gv_$sql a, dba_users b
WHERE a.parsing_user_id = b.user_id
AND a.disk_reads > 1000
AND b.username NOT IN ('SYS', 'SYSTEM')) c
WHERE c.reads_per_exec >= 1000
ORDER BY c.reads_per_exec DESC;
1.使用者下物件數量
select OWNER, OBJECT_TYPE, count(OWNER) OBJECT_COUNT
from SYS.DBA_OBJECTS
where wner ='SFISM4'
group by OWNER, OBJECT_TYPE
order by OBJECT_TYPE
2.賦權語句
select 'grant select on schemaname.'||table_name||' to username; ' from DBA_TABLES where wner='GWDMS'
select 'create synonym tms_ap.'||table_name||' for tms.'||table_name||'; ' from DBA_tables where wner='TMS'
3.檢查命中率
select a.value + b.value "logical_reads", c.value "physical_reads",
round(100 * ((a.value+b.value)-c.value)/(a.value+b.value)) "BUFFER HIT RATIO"
from v$sysstat a,v$sysstat b,v$sysstat c
where a.statistic# =47 and b.statistic# =50 and c.statistic#=54;
4.匯出欄位註釋資訊
SELECT 'COMMENT ON COLUMN '
|| OWNER || '.' || TABLE_NAME || '.' || COLUMN_NAME
|| ' IS '|| ''''||COMMENTS||''';'
FROM (SELECT *
FROM DBA_COL_COMMENTS
WHERE WNER = 'SFIS1' AND COMMENTS IS NOT NULL);
5.檢查失效物件
select * from dba_objects where status='INVALID' and object_type <> 'SYNONYM'
6.查詢Schema為'EHEALTH','EHC','HHCARE','HAMSTC'中包含LOB型別的表的資料量
select 'select count(*) from '||owner||'.'||table_name||';'from dba_tab_columns where data_type like '%LOB%' and owner in ('EHEALTH','EHC','HHCARE','HAMSTC') order by owner
7.查詢資料量有多大
select round(sum(a.bytes_alloc)/1024/1024/1024,2) "表空間佔用總和 ",
round( (sum(a.bytes_alloc)-sum(nvl(b.bytes_free, 0)))/1024/1024/1024,3) "表空間實際使用總和 "
from ( select f.tablespace_name,
sum(f.bytes) bytes_alloc
from dba_data_files f
group by tablespace_name) a,
( select f.tablespace_name,
sum(f.bytes) bytes_free
from dba_free_space f
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name (+)
8.查詢BLOB的大小:
select a.owner,
a.segment_name,
decode (a.partition_name,
null, a.segment_name,
a.segment_name || ':' || a.partition_name) objectname,
segment_type objecttype,
nvl ((a.bytes / 1024 / 1024)||'M', 0) "SIZE",
b.table_name,
b.column_name,
a.tablespace_name
from (select * from dba_segments ) a,
(select * from sys.dba_lobs ) b
where (a.segment_name=b.segment_name or a.segment_name=b.index_name) --and b.table_name = 'DBS_SO_ATTACHMENT'
and a.owner not in ('CTXSYS','DBSNMP','DMSYS','EXFSYS','LBACSYS','MDSYS',
'OLAPSYS','ORDSYS','OUTLN','TSMSYS','SPOT','SYS','SYSTEM','SYSMAN','WMSYS','XDB')
order by a.owner,b.table_name,b.column_name
9.檢查含LOB型別的表
select owner,table_name from dba_tab_columns where data_type like '%LOB%' and owner in ('EHEALTH','EHC','HHCARE','HAMSTC') order by owner
10.檢查所有狀態為OPEN的使用者下的實際佔用資料尺寸
select owner,sum(bytes)/1024/1024 from dba_extents where owner in(select username from dba_users where account_status='OPEN' and username not in ('SYS','SYSTEM')) group by owner;
11.檢查索引的使用情況
首先產生監控指令碼
select 'alter index '||owner||'.'||index_name||' monitoring usage;'
from dba_indexes
where owner in ('YOUR','PROD_DB','OWNER','LIST');
這個是監控這四個使用者下的索引使用情況,我們也可以只監控單獨一個表的索引使用情況.
select 'alter index '||owner||'.'||index_name||' monitoring usage;'
from dba_indexes
where table_owner='SQRM' and table_name='BD_BUYER';
在執行幾天之後,我們產生取消監控的指令碼.
select 'alter index '||owner||'.'||index_name||' nomonitoring usage;'
from dba_indexes
where owner in ('YOUR','PROD_DB','OWNER','LIST');
select 'alter index '||owner||'.'||index_name||' nomonitoring usage;'
from dba_indexes
where table_owner='SQRM' and table_name='BD_BUYER';
之後去本使用者下檢視檢視v$object_usage就可以知道哪些索引沒被使用.
在sys使用者用如下語句查詢:
select z.name||'.'||io.name, t.name,
decode(bitand(i.flags, 65536), 0, 'NO', 'YES'),
decode(bitand(ou.flags, 1), 0, 'NO', 'YES'),
ou.start_monitoring,
ou.end_monitoring
from sys.obj$ io, sys.obj$ t, sys.ind$ i, sys.object_usage ou ,sys.user$ z
Where i.obj# = ou.obj#
and io.obj# = ou.obj# And io.owner#=z.user#
and t.obj# = i.bo#
Order By 4 Desc,2 Desc;
12.檢查超過100M的表
select owner,segment_name,segment_type,tablespace_name,bytes/1024/1024 from dba_segments where segment_type in ('TABLE','TABLE','INDEX PARTITION','INDEX PARTITION') and owner not in ('SYS', 'SYSTEM','OUTLN','WMSYS','CTXSYS','PERFSTAT','SPOT','TOAD','XDB') and bytes/1024/1024>100 order by owner
select owner,segment_name,segment_type,tablespace_name,bytes/1024/1024 from dba_segments
where PARTITION_NAME='KAOQIN_2011'
and SEGMENT_NAME='KQM_BELLCARDDATA'
13.statspack 常用命令
@/u01/product/oracle/rdbms/admin/spcreate.sql
@/u01/product/oracle/rdbms/admin/spreport.sql
@/u01/product/oracle/rdbms/admin/spdrop.sql
select max(snap_id) from stats$snapshot;
delete from stats$snapshot where snap_id<=166;
13-2.awr 常用命令
@?/rdbms/admin/awrrpt.sql
14.查詢高水位線;
select table_name,blocks "高水位下的塊",round((t.avg_row_len*t.num_rows)/s.block_size,0) "實際需要的塊",
blocks-round((t.avg_row_len*t.num_rows)/s.block_size,0) "高水位下浪費的塊"
from dba_tables t,dba_tablespaces s
where t.tablespace_name=s.tablespace_name and wner='HR';
[精彩] 如何將表從一個表空間移動到另一個表空間?
我想將表users從system表空間移動到data表空間,不知道怎麼處理,移動後,users表中的資料是否也一起移動?請指教。
1.ALTER TABLE ebom.FINISH_GOOD MOVE
2.alter table EPD3.ABSCOLLECTIONCRITERIAKEY move tablespace BLOBS
完成後需要重建索引。
3.alte index xxx rebuild tablespace xxx
4.SELECT 'ALTER TABLE '||OWNER||'.'||TABLE_NAME||'MOVE ;' FROM DBA_TABLES
WHERE WNER='HR'
15.檢查asm大小
select * from V$ASM_DISKGROUP
select * from V$ASM_DISK
asmcmd lsdg
16.rman常用
備份
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 2048 M FORMAT '/u01/dump_dir/%U';
configure controlfile autobackup on;
BACKUP DATABASE INCLUDE CURRENT CONTROLFILE FOR STANDBY PLUS ARCHIVELOG;
change archivelog all crosscheck ;
以下是零級備份的例子
backup incremental level 0 database;
一級差異增量例子
backup incremental level 1 database;
一級累計增量例子
backup incremental level 1 cumulative database;
恢復一個資料庫
RMAN>restore database;
RMAN>recover database;
17.sched job點檢
SELECT OWNER,
JOB_NAME,
TO_CHAR(ACTUAL_START_DATE,'yyyy-mm-dd hh24:mi') ERRORTIME ,
ADDITIONAL_INFO
FROM DBA_SCHEDULER_JOB_RUN_DETAILS
WHERE STATUS = 'FAILED'
AND WNER='HR'
ORDER BY ACTUAL_START_DATE DESC
18.檢視索引段的大小
select segment_name,partition_name,segment_type,bytes/1024/1024/1024 as GB,blocks
from dba_segments
where owner in ('SFIS1','SFIS','MWEB','SFISM4') and (bytes/1024/1024/1024) > 10
19.日誌挖掘
SELECT * FROM v$logmnr_contents;
begin
dbms_logmnr.add_logfile(logfilename=>'/C11/archive1/1_35673_635950047.dbf');
end;
begin
DBMS_LOGMNR.START_LOGMNR(options=>sys.DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);
end;
begin
dbms_logmnr.end_logmnr;
end;
20.統計資訊
explain plan for
select * from KD_STORE_MONTH
select * from table(dbms_xplan.display());
BEGIN
DBMS_STATS.GATHER_TABLE_STATS('TEST','KD_STORE_MONTH',NULL,NULL,FALSE,'FOR ALL COLUMNS SIZE 100',5,'DEFAULT',FALSE,NULL,NULL,NULL);
END ;
EXEC DBMS_STATS.GATHER_TABLE_STATS('OWNER','TABLE',estimate_percent=>30,CASCADE=> TRUE);
analyze table t3 delete statistics; ---刪除統計資訊
analyze table t3 compute statistics;
方法一:
exec dbms_scheduler.disable(‘SYS.GATHER_STATS_JOB‘);
exec dbms_scheduler.enable(‘SYS.GATHER_STATS_JOB‘);
方法二:
alter system set "_optimizer_autostats_job"=false scope=spfile;
alter system set "_optimizer_autostats_job"=true scope=spfile;
21.表空間
CREATE TABLESPACE BI_DATA_05 DATAFILE
'/u05/oradata/imbbi/bi_data_05.dbf' SIZE 1024M AUTOEXTEND OFF
LOGGING
ONLINE
PERMANENT
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO;
21.線上增加redo log
查詢日誌組資訊
Select * from v$log a,v$logfile b where a.group#=b.group#
切換日誌:
alter system switch logfile;
新增日誌組:
Alter database add logfile group 6 ('/u01/product/oradata/zh/redo25a.log','/u01/product/oradata/zh/redo25b.log') SIZE 50M;
alter database add logfile member '/u01/product/oradata/zh/redo21.log' to group 5;
在日誌組中新增日誌檔案:
alter database add logfile member '/u01/product/oradata/zh/redo21.log' to group 5;
刪除重做日誌檔案:
Alter database drop logfile member ' /u01/product/oradata/zh/redo21a.log‘;
刪除重做日誌組:
Alter database drop logfile group 4;
需要注意:在刪除重做日誌組之後,重做日誌需要手動刪除.
如果日誌組中的日誌檔案全部損壞或者全部被誤刪除,則我們可以使用alter database clear logfile group命令來初始化該日誌組,並生成新的重做日誌檔案.
改變重做日誌位置或名稱
具體作業步驟如下(以從c:\redo1.log到d:\redo1.log為例):
確定需要作業的重做日誌處於的日誌組狀態(保證狀態不為Current,如果為Current,請手動切換日誌)
Select a.group#,a.status from v$log a,v$logfile b where a.group#=b.group# and b.member= ' c:\redo1.log ' ;
複製或移動日誌檔案到目標位置(當日誌組狀態為inactive時,才能複製或移動日誌檔案)
Host copy c:\redo1.log d:\redo1.log
更改控制檔案中所記載的重做日誌檔案指標(將日誌檔案移動到新位置後,為了使LGWR可以訪問該日誌成員,必須使用alter database rename file 命令,改變控制檔案所記載的重做日誌檔案指標)
Alter database rename file ' c:\redo1.log ' to ' d:\redo1.log ' ;
22.expdp 詳解
使用expdp進行匯出的時候,需要先建立directory。
首先使用sys或者system帳號
create directory dump_dir as '/u01/product/';
grant read,write on directiry dump_dir to username;
之後,可以直接在expdp中使用格式或者parfile
比如,需要匯出wison中的物件,但是排除以T開頭的表
需要在parfile中寫:
directory=dump_dir
dumpfile=dump.dmp
exclude=table:"like 'T%'"
logfile=expdp.log
然後使用Oracle帳號執行:expdp wison/wison parfile=/u01/product/parfilename
windows下,
set NLS_LANG=American_america.AL32UTF8
exp system/"""system@dbsec""" wner=gwdms_lh file=e:\backup\gwdms_lh.dmp log=e:\backup\gwdms_lh.txt
imp userid=pcehr/pcehrdb@hr file=e:\hr.dmp log=e:\hrok.log fromuser=hr touser=pcehr
linux
expdp 'system/"system@dbsec"' schemas=CHANNEL directory=DUMP_DIR dumpfile=CHANNEL.dmp logfile=CHANNEL.log parallel=4
impdp 'system/"system@dbsec"' directory=DUMP dumpfile=ecs2011051123.dmp logfile=ecs2011051123ok.log tables=EXPENSECONTROL.MATERIALVENDOR remap_schema=EXPENSECONTROL:xiexie table_exists_action=truncate;
假如我要匯入A Schema下的部份資料到B Schema下.
首先在A機器上建立directory
create directory dump_dir as '/u01';
grant read,write on directory dump_dir to system;
其次,建立parfile.匯出A下的lob1,lob2和test1表的資料部份 , 其中A.lob1 中僅包含id為1,A.lob2僅包含name為wison的資料
tables=A.lob1,A.lob2,A.test1
directory=dump_dir
dumpfile=aa.dmp
content=data_only
query=A.lob1:"where id=1",A.lob2:"where name='wison'"
然後將匯出檔案傳送到B機器上
執行impdp
23.新增undo tablespace:
create undo tablespace undo_tbs datafile 'd:\undo.dbf' size 100M;
在undo tablespace中新增檔案
alter tablespace undo_tbs add datafile 'd:\undo01.dbf' size 50M;
如果需要將undo tablespace 切換到undo_tbs01
alter system set undo_tablespace=undo_tbs01;
刪除undo tablespace
drop tablespace undo_tbs;
24.更改Archive Mode
首先檢查資料庫的模式 select log_mode from v$database;
其次,shutdown資料庫並開啟成mount狀態
最後,alter database archivelog或者noarchivelog
如果是從noarchive模式修改成Archive模式,另外還要配置Archive log format
0.將主庫換到archivelog模式:10.2.0.1以後的rac 資料庫要改為archivelog模式,比以前的版本簡單了很多,隻要兩邊設好歸檔目錄,將rac中所有的例項都關閉,startup到mount將資料庫改成archivelog,open 之後,重啟另一個例項即可,在本例在archivelog檔案分別放在各自的主機上.
alter system set log_archive_format = '%t_%s_%r.arc' scope=spfile;
同時也要設定歸檔路徑,如果設定在本地,則為
alter system set log_archive_dest_1='LOCATION=/data/xxx/arch' scope=spfile
表示歸檔到 /data/xxx/arch路徑下.
都需要重啟資料庫才能生效
檢查Archive資訊
archive log list
24.flashback
SELECT * FROM archive.YSD_QUL AS OF TIMESTAMP(Sysdate - 100/1440) ---查詢100分鐘以前該表的資料
SELECT * FROM tableName AS OF TIMESTAMP TO_TIMESTAMP('20070920083059','yyyymmddhh24miss') ---查詢07年9月20日8點30分59秒的資料
SELECT * FROM archive.YSD_QUL AS OF TIMESTAMP TO_TIMESTAMP('2010.09.01 09:00:00','yyyy.mm.dd hh24:mi:ss')---查詢9月1日9點的資料
25.當standby資料庫recover的時候,遇到以下錯誤:
ORA-00283: recovery session canceled due to errors
ORA-01111: name for data file 20 is unknown - rename to correct file
ORA-01110: data file 20: '/u01/product/oracle/dbs/UNNAMED00020'
ORA-01157: cannot identify/lock data file 20 - see DBWR trace file
ORA-01111: name for data file 20 is unknown - rename to correct file
ORA-01110: data file 20: '/u01/product/oracle/dbs/UNNAMED00020'
直接在主資料庫上建立新的standby controlfile,然後再將產生的standby controlfile傳送到standby資料庫上,注意和以前的standby資料庫上的control file位置一致.
之後再開啟standby 資料庫,修改standby_file_management為manual,建立20號檔案
alter database create datafile 20 as '/ocfs_data1/ecsdb/expense_data05.dbf';
再執行recover standby database
最後修改standby_file_management為auto
再重啟資料庫,最後就可正常的restore了.
alter database create datafile 28 as '/data/wfdb/oradata/perstat01.dbf'
alter database create standby controlfile as '/data/standby.ctl' ;
26.更改 字符集
Startup nomount;
Alter database mount exclusive;
Alter system enable restricted session;
Alter system set job_queue_process=0; ---------有報錯
Alter database open;
Alter database character set ZHT16BIG5;
or
ALTER DATABASE character set INTERNAL_USE ZHT16BIG5;
SELECT * FROM NLS_DATABASE_PARAMETERS
28 standby 引數
第1種 單機
boolean,格式 需要加引號滴
integer,string格式 ----需要驗證
主庫
db_unique_name=jsspweb ---初始就有
LOG_ARCHIVE_CONFIG='DG_CONFIG=(jssweb,jsspdg)'
LOG_ARCHIVE_DEST_1='LOCATION=E:\ora10g\oradata\jssweb\
VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=jssweb'
LOG_ARCHIVE_DEST_2='SERVICE=jsspdg LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=jsspdg' --------LOCATION(本地),SERVICE(遠端)
LOG_ARCHIVE_DEST_STATE_1=ENABLE ---初始就有
LOG_ARCHIVE_DEST_STATE_2=ENABLE ---初始就有
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE ---初始就有
#--------配置standby 角色的引數用於角色轉換
FAL_SERVER=jsspdg
FAL_CLIENT=jssweb
DB_FILE_NAME_CONVERT='oradata\jsspdg','oradata\jssweb' ----------主庫沒設定,角色轉換
LOG_FILE_NAME_CONVERT='oradata\jsspdg','oradata\jssweb' ----------主庫沒設定,角色轉換
STANDBY_FILE_MANAGEMENT=AUTO ----------主庫沒設定,角色轉換
備庫
db_unique_name=jsspdg
LOG_ARCHIVE_CONFIG='DG_CONFIG=(jssweb,jsspdg)'
DB_FILE_NAME_CONVERT='oradata\jssweb','oradata\jsspdg'
LOG_FILE_NAME_CONVERT='oradata\jssweb','oradata\jsspdg'
LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc ---初始就有
LOG_ARCHIVE_DEST_1='LOCATION=E:\ora10g\oradata\jsspdg\
VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=jsspdg'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
#---下列引數用於角色切換
LOG_ARCHIVE_DEST_2='SERVICE=jssweb LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=jssweb'
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
FAL_SERVER=jssweb
FAL_CLIENT=jsspdg
STANDBY_FILE_MANAGEMENT=AUTO
-------------需注意service_names 是否有變成 dmd1rcdg,local_listener 是否有變成 LISTENER_DMD1RCDG
第3種 rac
主庫
ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(ccptdb,ccptdbdg)'; ------同單機
alter system set log_archive_dest_1='LOCATION=+data VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ccptdb'; ------同單機
alter system set log_archive_dest_2='SERVICE=ccptdbdg LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) ------同單機
DB_UNIQUE_NAME=ccptdbdg'; ------同單機
ALTER SYSTEM SET FAL_CLIENT = ccptdb1 sid='ccptdb1';
ALTER SYSTEM SET FAL_CLIENT = ccptdb2 sid='ccptdb2';
ALTER SYSTEM SET FAL_SERVER = ccptdbdg; ------同單機
修改後如下:
ccptdb1.fal_client='CCPTDB1'
ccptdb2.fal_client='CCPTDB2'
注意備庫設定﹕
*.db_unique_name='ccptdbdg' ------同單機
*.fal_client='ccptdbdg' ------同單機
*.fal_server='ccptdb1','ccptdb2'
*.log_archive_config='DG_CONFIG=(ccptdb,ccptdbdg)' ------同單機
*.log_archive_dest_1='LOCATION=/data/ccptdb1/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ccptdbdg' ------同單機
*.log_archive_dest_2='SERVICE=ccptdb LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ccptdb' ------同單機
*.db_file_name_convert='+data/ccptdb/datafile/','/data/ccptdb/','+indx/ccptdb/datafile/','/data/ccptdb/'
*.log_file_name_convert='+data/ccptdb/onlinelog/','/data/ccptdb/'
採用LGWR程式傳輸日誌﹐必須建立備用日誌﹐而且日誌大小與主庫一樣﹐個數比主庫多一個
首先建立備用日誌
SQL>ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 group 111 ('/data/ccptdb/dgredo111a.log','/data/ccptdb/dgredo111b.log') SIZE 50M;
為failover啟用準備
alter tablespace temp add tempfile '/data/mis/temp01.dbf' size 2000m;
alter tablespace temp add tempfile '/data/ccptdb/temp02.dbf' size 2000m;
v$managed_standby和日誌傳輸,接收,應用有關 .
v$archive_gap 主要可以用來檢視備庫丟失了那些日誌.
v$archive_dest 如果日誌無法傳送,可以檢視v$archive_dest;
v$archive_dest_status檢視可以檢視備庫的狀態,保護模式,歸檔日誌路徑狀態
v$archived_log可以檢視日誌的一些資訊 ,包括日誌名字,應用時間,是否應用
1.Oracle standby database的啟用
alter database activate standby database;(failover)
alter database mount;
alter databaase open;
1.解決此錯誤的辦法,可能有表空間,不夠擴充套件,並不一定是ARCHIVETEMP
ORA-1652: unable to extend temp segment by 128 in tablespace TEMP
ORA-1652: unable to extend temp segment by 128 in tablespace ARCHIVETEMP
ORA-1652: unable to extend temp segment by 128 in tablespace ARCHIVETEMP
[root@emd3wfdb bdump]# tail -1000 alert_wfdb.log |grep ORA
ORA-01555 caused by SQL statement below (Query Duration=21626 sec, SCN: 0x0000.19050882):
ORA-1652: unable to extend temp segment by 128 in tablespace ARCHIVETEMP
ORA-1652: unable to extend temp segment by 128 in tablespace ARCHIVETEMP
ALTER SYSTEM SET EVENT = '1652 trace name errorstack' SCOPE = SPFILE;
2.解決此錯誤,是大小寫的問題temp_depcode TEMP_DEPCODE
ORA-20000: ORA-20000: Unable to analyze TABLE "HR"."TEMP_DEPCODE", insufficient privileges or does not exist
3.ln -s /u01/hremploy/arch/ ./arch 軟連線目錄
4.OPTIMIZER_INDEX_COST_ADJ 50/100 cost變化引數
3.sec_case_sensitive_logon 密碼大小寫的引數 (11G上的)
alter system set sec_case_sensitive_logon =FALSE scope=spfile;
4.cursor_sharing
5.PROFILE
resource_limit 必須更改為true,否則無效
SESSIONS_PER_USER -------登陸會話的上限
6.crs使用案例
crs_stop -f ora.ecsrac02.vip
crs_start ora.ecsrac02.vip
crs_start ora.ecsrac02.LISTENER_ECSRAC02.lsnr
7.修改引數archive_lag_target調整日誌切換時間!
10.VNC的配置
使用Oracle使用者鍵入vncserver命令
在當前目錄下進入.vnc , 修改xstartup , 去掉twm &,在最後一行新增gnome-session &
kill掉當前的vnc程式 vncserver -kill :1
然後再執行vncserver , 就可以了.
vncpasswd 修改密碼
配置rsync
A代表Primary B代表Standby
1. B機上使用oracle執行$ ssh-keygen -t rsa
會自動在/home/oracle下建立一個.ssh資料夾,裡面將會產生兩個認證證照
在B機上執行$ssh A date,然後輸入密碼,然後就能抓取到A的時間
2.進入到B機器上的.ssh目錄, 執行$ scp id_rsa.pub A:/home/oracle/.ssh/authorized_keys
有可能會報錯說A上沒有.ssh路徑
那麼手動建立.ssh目錄
3.
在B上再執行$ssh A date,應該不輸入密碼也能看到時間
scp那條命令,如果在RAC環境中就不能用
而是應該用vi開啟B的id_isa.pub,然後將那段文字拷貝附加到A上的authorized_keys檔案後面
如果主庫是RAC,那麼可以按照如下方式配置Rsync.
A代表Primary B代表Standby
1. B機上使用oracle執行$ ssh-keygen -t rsa 最好同時也執行ssh-keygen -t dsa
會自動在/home/oracle下建立一個.ssh資料夾,裡面將會產生兩個認證證照
在B機上執行$ssh A date,然後輸入密碼,然後就能抓取到A的時間
2. 分別在2各節點上執行(之前最好將主庫(RAC)上備份authorized_keys cp authorized_keys authorized_keys.bak)
然後在2節點上分別執行
ssh B cat /home/oracle/.ssh/id_rsa.pub >>/home/oracle/.ssh/authorized_keys
ssh B cat /home/oracle/.ssh/id_dsa.pub >>/home/oracle/.ssh/authorized_keys
3. 此時,在B上執行ssh A data應該不用輸入密碼就可以看到時間了.
30.開機報引數錯誤
oracle 11g啟動時報的錯誤 ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instanc
2010-11-05 11:06
SQL> startup
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.
因為資料庫是11g
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_format string %t_%s_%r.dbf
log_archive_local_first boolean TRUE
log_archive_max_processes integer 4
log_archive_min_succeed_dest integer 1
log_archive_start boolean TRUE
alter system set log_archive_start=false scope=spfile;
這樣啟動是還是報
乾脆從spfile中去除 log_archive_start=
SQL> create pfile from spfile;
File created.
在pfile中刪掉log_archive_start=這一行,oracle啟動就不報ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance錯了
SQL> create spfile from pfile;
File created.
SQL> startup
ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1336960 bytes
Variable Size 373295488 bytes
Database Buffers 41943040 bytes
Redo Buffers 6094848 bytes
Database mounted.
Database opened.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25850100/viewspace-712054/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 常用指令碼指令碼
- SQLServer 常用指令碼SQLServer指令碼
- MySQL 常用指令碼MySql指令碼
- dba常用指令碼指令碼
- 常用shell指令碼指令碼
- Bash 常用指令碼片段指令碼
- python 常用指令碼Python指令碼
- 常用指令碼學習手冊——Bat指令碼指令碼BAT
- js- 常用指令碼程式碼JS指令碼
- MHA常用指令碼簡介指令碼
- sqlmap常用繞過指令碼SQL指令碼
- RMAN常用備份指令碼指令碼
- Inno Setup的常用指令碼指令碼
- ORACLE常用SQL指令碼2OracleSQL指令碼
- bat批處理常用指令碼BAT指令碼
- linux 常用Mysql指令碼命令LinuxMySql指令碼
- Oracle DBA常用監控指令碼Oracle指令碼
- 常用的Oracle指令碼參考Oracle指令碼
- 常用指令碼命令集(轉)指令碼
- shell常用指令碼&crontab設定指令碼
- 常用的幾個典型指令碼指令碼
- linux常用的shell指令碼Linux指令碼
- ORACLE常用定時備份指令碼Oracle指令碼
- Shell指令碼常用命令整理指令碼
- oracle pga使用情況常用指令碼:Oracle指令碼
- Oracle 效能相關常用指令碼(SQL)Oracle指令碼SQL
- ORACLE DBA常用語句和指令碼Oracle指令碼
- 表及索引 move tablespace 常用指令碼索引指令碼
- 一些常用查詢指令碼指令碼
- 常用指令
- 02_Vue常用的一些指令Vue
- 【Ubuntu】Ubuntu常用的更新、清理命令指令碼Ubuntu指令碼
- 常用指令碼:獲取隱含引數指令碼
- shell之最常用的服務指令碼指令碼
- 常用的主機監控shell指令碼指令碼
- SQL Performance Analyzer SPA常用指令碼彙總SQLORM指令碼
- 最常用的資料庫命令,指令碼資料庫指令碼
- oracle DBA 常用監控指令碼1(轉)Oracle指令碼