Author Archives: robson.moreira

Drop Database Oracle 11gR2

Got from http://oracledbabhuvan.blogspot.pt/2012/02/drop-database-in-11gr2-with-rac.html.

(Thanks to Bhuvanesh by the post)


I am planning to remove my cluster database which is running on 11gR2 Stop the entire cluster environment

bhuora01[BHU_1]>srvctl stop database -d BHU_a

Start only one instance to edit the cluster_database parameter to FALSE

bhuora01[BHU_1]>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Feb 10 16:03:03 2012

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

Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area 2.6924E+10 bytes
Fixed Size 2241104 bytes
Variable Size 1.3086E+10 bytes
Database Buffers 1.3824E+10 bytes
Redo Buffers 11227136 bytes
Database mounted.

SQL> alter system set cluster_database=FALSE scope=spfile sid='*';

System altered.

SQL> shutdown abort;
ORACLE instance shut down.

Now starting only one instance after editing below parameter CLUSTER_DATABASE parameters to FALSE

SQL> startup mount exclusive restrict
ORACLE instance started.

Total System Global Area 2.6924E+10 bytes
Fixed Size 2241104 bytes
Variable Size 1.3086E+10 bytes
Database Buffers 1.3824E+10 bytes
Redo Buffers 11227136 bytes
Database mounted.

Make sure whether you have started in the restricted mode

SQL> select logins,parallel from v$instance;

LOGINS PAR
---------- ---
RESTRICTED NO

When you issue this command, this will drop the database including datafiles, control files, redo log files & archive log files

SQL> drop database;

Database dropped.

To drop the database including the backup, we can go for the below option

RMAN> DROP DATABASE INCLUDING BACKUPS NOPROMPT;

Recriar a FRA (Fast Recovery Area)

Recriar a FRA (Fast Recovery Area)

 Links de apoio:

 

Criação nova FRA

Basta criarmos a nova FRA e já podemos passar a lá por os redo log files e archive log files. Entretanto os controlfiles requerem restart da base de dados (toda).

alter system set db_recovery_file_dest_size = '50G' scope=both sid='*';

System altered.

SQL> alter system set db_recovery_file_dest = '+FRADG' scope=both sid='*';

System altered.

 

Passagem ControlFiles para FRA

Normalmente existe mais de um controlfile por motivos de segurança a serem escritos ao mesmo tempo pela BD, por isso os passos para mover o controlfile para a nova FRA são:

 

1) Passar a ter um controlfile somente fora da FRA antiga (em um datagroup de dados, por exemplo).

 

alter system set control_files = +FCHFRADG/SIBSP13/CONTROLFILE/control02.ctl' scope=spfile sid='*';

Neste passo temos de parar a base de dados toda e trabalharmos somente em uma instância:

 

srvctl stop database -d <service name>

Arrancamos numa instância somente e passamos a adicionar agora o novo FRA como uma copia do controlfile, mas não especificamos o path completo, só o nome do FRA (usado no db_recovery_file_dest). Outro restart da instância e deixamos a mesma em modo mount.

startup

alter system set control_files = '+FCHFRADG/SIBSP13/CONTROLFILE/control02.ctl', '+FCHFRADG' scope=spfile sid='*';

shutdown immediate

startup nomount

Passamos para o Rman para realizarmos uma cópia fidedigna do novo controlfile para a nova FRA e não especificamos mais uma nova o path.

 

rman nocatalog
connect target /

restore controlfile from '+FCHFRADG/SIBSP13/CONTROLFILE/control02.ctl';

Podemos voltar ao SQLPLUS e montar e abrir a instância:

 

alter database mount;

alter database open;

Vefica-se os novos controlfiles criados e se eles estão mesmo na FRA (IS_RECOVERY_DEST_FILE):

select name, is_recovery_dest_file as is_recovery from gv$controlfile;

NAME                                                                                                 IS_RECOVERY       
---------------------------------------------------------------------------------------------------- ----------------- 
+FDATDG/sibsp11/controlfile/current.280.784135039                                                    NO                
+RECODG/sibsp11/controlfile/current.272.784135039                                                    YES               
+FDATDG/sibsp11/controlfile/current.280.784135039                                                    NO                
+RECODG/sibsp11/controlfile/current.272.784135039                                                    YES               

4 row(s) fetched

Agora aproveitamos para deixar o Rman a executar automaticamente o backup do controlfile a medida que ele é alterado:

rman nocatalog
rman> connect target /
CONFIGURE CONTROLFILE AUTOBACKUP ON;

Pode ser que seja preciso executar o seguinte statement para direccionar o controle file auto backup para a FRA.

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;

Neste ponto, estamos prontos para passarmos os archive logs e os redo logs.

Passagem Redo e Arhive Log Files

Os archivelogs basta que alteramos o seguinte parâmetro:

alter system set LOG_ARCHIVE_DEST_1 = 'LOCATION = USE_DB_RECOVERY_FILE_DEST' scope=both;

Os redo log files devem ser passados segundo o procedimento já descrito nesta pagina: http://blogdaprima.com/2012/redimensionar-red-logs-11gr2/

 

Block Tracking

Não devemos esquecer de ligar o block tracking (para backups mais rápidos e etc) e apontar a nova configuração para a nova FRA.

 

alter database enable block change tracking using file '+FCHFRADG';

e verificando o status na view:

 

select * from v$block_change_tracking;

STATUS           FILENAME                                                                                             BYTES                                        
---------------- ---------------------------------------------------------------------------------------------------- -------------------------------------------- 
ENABLED          +FCHFRADG/sibsp13/changetracking/ctf.292.792003881                                                                                       11599872

Confirmação FRA em uso

select file_type, percent_space_used, number_of_files from V$FLASH_RECOVERY_AREA_USAGE

select file_type, percent_space_used, number_of_files from V$FLASH_RECOVERY_AREA_USAGE

FILE_TYPE                  PERCENT_SPACE_USED                           NUMBER_OF_FILES                              
-------------------------- -------------------------------------------- -------------------------------------------- 
CONTROL FILE                                                       0,24                                            1 
REDO LOG                                                           3,56                                            4 
ARCHIVED LOG                                                       1,12                                            2 
BACKUP PIECE                                                       1,05                                            4 
IMAGE COPY                                                            0                                            0 
FLASHBACK LOG                                                         0                                            0 
FOREIGN ARCHIVED LOG                                                  0                                            0 

7 row(s) fetched

 

Redimensionar Red Logs – 11gR2

Para se aumentar os Redo é necessário criar novos e nesta fase há que se tomar a decisão se estes deverão permanecer na FRA (Fast Recovery Area) ou não. Se permanecerem será o Oracle a gerir os ficheiros da FRA (control file, redo, archive, etc). Se não a gestão dos componentes é autónoma.

 

Cada Thread é atribuída a um nó do RAC. Lembrar que é sempre necessário ter pelo menos 2 Threads por nópara geração de Redo activas no RAC.

 

Verificar os grupos de log files existentes e os ficheiros que cada grupo contém:

select * from gv$log;

   INST_ID     GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
         1          1          1         76  104857600        512          2 YES INACTIVE               3339909 22-AUG-12      3397686 22-AUG-12
         1          2          1         77   52428800        512          2 YES INACTIVE               3397686 22-AUG-12      3433508 23-AUG-12
         1          6          1         78   52428800        512          2 NO  CURRENT                3433508 23-AUG-12   2.8147E+14
         1          7          2         71  104857600        512          2 NO  CURRENT                3443555 23-AUG-12   2.8147E+14 23-AUG-12
         1         14          2         70  104857600        512          2 YES INACTIVE               3339409 22-AUG-12      3339658 22-AUG-12
         2          1          1         76  104857600        512          2 YES INACTIVE               3339909 22-AUG-12      3397686 22-AUG-12
         2          2          1         77   52428800        512          2 YES INACTIVE               3397686 22-AUG-12      3433508 23-AUG-12
         2          6          1         78   52428800        512          2 NO  CURRENT                3433508 23-AUG-12   2.8147E+14
         2          7          2         71  104857600        512          2 NO  CURRENT                3443555 23-AUG-12   2.8147E+14 23-AUG-12
         2         14          2         70  104857600        512          2 YES INACTIVE               3339409 22-AUG-12      3339658 22-AUG-12

select * from gv$logfile;

INST_ID     GROUP# STATUS  TYPE    MEMBER                                             IS_RECOVERY_DEST_FILE

---------- ---------- ------- ------- -------------------------------------------------- ------------------------

      1          1         ONLINE  +FDATDG/sibsp10/onlinelog/group_1.566.788460973    NO
      1          1         ONLINE  +RECODG/sibsp10/onlinelog/group_1.631.788460975    YES
      1          2         ONLINE  +FDATDG/sibsp10/onlinelog/group_2.565.788461005    NO
      1          2         ONLINE  +RECODG/sibsp10/onlinelog/group_2.629.788461007    YES
      1          3         ONLINE  +FDATDG/sibsp10/onlinelog/group_3.564.788461011    NO
      1          3         ONLINE  +RECODG/sibsp10/onlinelog/group_3.415.788461013    YES
      1          4         ONLINE  +FDATDG/sibsp10/onlinelog/group_4.563.788461017    NO
      1          4         ONLINE  +RECODG/sibsp10/onlinelog/group_4.408.788461019    YES
      2          1         ONLINE  +FDATDG/sibsp10/onlinelog/group_1.566.788460973    NO
      2          1         ONLINE  +RECODG/sibsp10/onlinelog/group_1.631.788460975    YES
      2          2         ONLINE  +FDATDG/sibsp10/onlinelog/group_2.565.788461005    NO
      2          2         ONLINE  +RECODG/sibsp10/onlinelog/group_2.629.788461007    YES
      2          3         ONLINE  +FDATDG/sibsp10/onlinelog/group_3.564.788461011    NO
      2          3         ONLINE  +RECODG/sibsp10/onlinelog/group_3.415.788461013    YES
      2          4         ONLINE  +FDATDG/sibsp10/onlinelog/group_4.563.788461017    NO
      2          4         ONLINE  +RECODG/sibsp10/onlinelog/group_4.408.788461019    YES

Antes de adicionarmos, verificar se a configuração da FRA esta activa (parametros abaixo, um indica o sitio onde estará a FRA e o outro o tamanho da mesma para a base de dados):

select name, value, display_value from v$parameter where upper(name) like '%DB_RECOVERY_FILE_DEST%';

NAME                                                         VALUE                DISPLAY_VALUE
------------------------------------------------------------ -------------------- ------------------------------
db_recovery_file_dest                                        +FCHFRADG            +FCHFRADG
db_recovery_file_dest_size                                   6005194752           5727M

Se quisermos utilizar a FRA, não é necessários informarmos nomenclatura para os ficheiros. Adicionar os novos log files com o tamanho desejado:

alter database add logfile thread 1 group 5 size 200M;
alter database add logfile thread 1 group 6 size 200M;
alter database add logfile thread 2 group 7 size 200M;
alter database add logfile thread 2 group 8 size 200M;

Se quisermos ter um controlo mais acirrado, a sintaxe seria como abaixo:

alter database add logfile thread 1 group 1 ('+FDATDG/sibsp13/onlinelog/redo5a.log','+FCHFRADG/sibsp13/onlinelog/redo5b.log') size 50m;
alter database add logfile thread 1 group 3 ('+FDATDG/sibsp13/onlinelog/redo3a.log','+FCHFRADG/sibsp13/onlinelog/redo3b.log') size 50m;

Para verificarmos se os ficheiros estão sob gestão da FRA (Coluna IS_RECOVERY_DEST_FILE com valor YES):

select * from gv$logfile;
<pre>  INST_ID     GROUP# STATUS  TYPE    MEMBER                                             IS_RECOVERY_DEST_FILE
---------- ---------- ------- ------- -------------------------------------------------- -------------------------
         1          1         ONLINE  +FDATDG/sibsp10/onlinelog/group_1.566.788460973    NO
         1          1         ONLINE  +RECODG/sibsp10/onlinelog/group_1.631.788460975    YES
         1          2         ONLINE  +FDATDG/sibsp10/onlinelog/group_2.565.788461005    NO
         1          2         ONLINE  +RECODG/sibsp10/onlinelog/group_2.629.788461007    YES
         1          3         ONLINE  +FDATDG/sibsp10/onlinelog/group_3.564.788461011    NO
         1          3         ONLINE  +RECODG/sibsp10/onlinelog/group_3.415.788461013    YES
         1          4         ONLINE  +FDATDG/sibsp10/onlinelog/group_4.563.788461017    NO
         1          4         ONLINE  +RECODG/sibsp10/onlinelog/group_4.408.788461019    YES
         2          1         ONLINE  +FDATDG/sibsp10/onlinelog/group_1.566.788460973    NO
         2          1         ONLINE  +RECODG/sibsp10/onlinelog/group_1.631.788460975    YES
         2          2         ONLINE  +FDATDG/sibsp10/onlinelog/group_2.565.788461005    NO
         2          2         ONLINE  +RECODG/sibsp10/onlinelog/group_2.629.788461007    YES
         2          3         ONLINE  +FDATDG/sibsp10/onlinelog/group_3.564.788461011    NO
         2          3         ONLINE  +RECODG/sibsp10/onlinelog/group_3.415.788461013    YES
         2          4         ONLINE  +FDATDG/sibsp10/onlinelog/group_4.563.788461017    NO
         2          4         ONLINE  +RECODG/sibsp10/onlinelog/group_4.408.788461019    YES

select * from v$flash_recovery_area_usage

FILE_TY            PERCENT_SPACE_USED      PERCENT_SPACE_RECLAIMABLE                 NUMBER_OF_FILES                              
------------------ ---------------------- ------------------------------------------ ---------------------------- 
CONTROL FILE       0,24                                            0                                            1 
REDO LOG           3,56                                            0                                            4 
ARCHIVED LOG          0                                            0                                            0 
BACKUP PIECE       1,05                                         0,79                                            4 
IMAGE COPY            0                                            0                                            0 
FLASHBACK LOG         0                                            0                                            0 
FOREIGN ARCHIVED LOG  0                                            0                                            0

Podemos depois, se for o caso, separa cada ficheiro do grupo de Redo, permitindo que um fique na FRA e outro fique onde quisermos (para fins de redundância, por exemplo). Para isso, devemos adicionar outro membro (file) ao grupo manualmente e retirar o que não quisermos que lá esteja (ou que tenha sido criado a mais). O primeiro passo é saber da configuração da base de dados quantos Log Members são permitidos:

 
SQL> Select '--> MAXLOGMEMBERS ' || dimlm from x$kccdi;

'-->MAXLOGMEMBERS'||DIMLM
----------------------------------------------------------
--> MAXLOGMEMBERS 3

SQL>

e então adicionar e/ou retirar membros do grupo:

 
alter database add logfile member '+FDATDG/sibsp13/onlinelog/redfo14c.log' to group 14;
alter database drop logfile member '+FCHFRADG/sibsp13/onlinelog/group_14.275.791993657';

Agora é necessário remover os antigos e deixar somente os novos Redo adicionados com o valor pretendido.

Verificar os log files CURRENT, ACTIVE, INACTIVE e UNUSED:

select * from gv$log;

 INST_ID     GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME

---------- ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
        1          5          1       8287  209715200        512          2 NO  CURRENT             1.6265E+10 12-JUL-12   2.8147E+14
        1          6          1       8286  209715200        512          2 YES INACTIVE            1.6265E+10 12-JUL-12   1.6265E+10 12-JUL-12
        1          7          2      13830  209715200        512          2 YES ACTIVE              1.6265E+10 12-JUL-12   1.6265E+10 12-JUL-12
        1          8          2      13831  209715200        512          2 NO  CURRENT             1.6265E+10 12-JUL-12   2.8147E+14
        2          5          1       8287  209715200        512          2 NO  CURRENT             1.6265E+10 12-JUL-12   2.8147E+14
        2          6          1       8286  209715200        512          2 YES INACTIVE            1.6265E+10 12-JUL-12   1.6265E+10 12-JUL-12
        2          7          2      13830  209715200        512          2 YES ACTIVE              1.6265E+10 12-JUL-12   1.6265E+10 12-JUL-12
        2          8          2      13831  209715200        512          2 NO  CURRENT             1.6265E+10 12-JUL-12   2.8147E+14

NOTA: só os log files INACTIVE é que podem ser eliminados, os outros retornam erro.

NOTA: os log files UNUSED são os novos que nunca foram usados

 

Eliminar os log files INACTIVE

alter database drop logfile group 1;

NOTA: é necessário existirem sempre pelo menos 2 log files por instância (thread)

 

Para mudar o log file CURRENT executar:

alter system switch logfile;

Para mudar o log file de ACTIVE para INACTIVE executar (este comando força a DB a escrever em disco ou eliminar o conteúdo do REDO e passar ao próximo):

alter system checkpoint;

Eliminar todos os log files antigos (grupos 1 a 4) e o resultado deverá ser:

  INST_ID     GROUP# STATUS  TYPE    MEMBER                                             IS_RECOVERY_DEST_FILE
---------- ---------- ------- ------- -------------------------------------------------- -------------------------
         1          1         ONLINE  +FDATDG/sibsp10/onlinelog/group_1.566.788460973    NO
         1          1         ONLINE  +RECODG/sibsp10/onlinelog/group_1.631.788460975    YES
         1          2         ONLINE  +FDATDG/sibsp10/onlinelog/group_2.565.788461005    NO
         1          2         ONLINE  +RECODG/sibsp10/onlinelog/group_2.629.788461007    YES
         1          3         ONLINE  +FDATDG/sibsp10/onlinelog/group_3.564.788461011    NO
         1          3         ONLINE  +RECODG/sibsp10/onlinelog/group_3.415.788461013    YES
         1          4         ONLINE  +FDATDG/sibsp10/onlinelog/group_4.563.788461017    NO
         1          4         ONLINE  +RECODG/sibsp10/onlinelog/group_4.408.788461019    YES
         2          1         ONLINE  +FDATDG/sibsp10/onlinelog/group_1.566.788460973    NO
         2          1         ONLINE  +RECODG/sibsp10/onlinelog/group_1.631.788460975    YES
         2          2         ONLINE  +FDATDG/sibsp10/onlinelog/group_2.565.788461005    NO
         2          2         ONLINE  +RECODG/sibsp10/onlinelog/group_2.629.788461007    YES
         2          3         ONLINE  +FDATDG/sibsp10/onlinelog/group_3.564.788461011    NO
         2          3         ONLINE  +RECODG/sibsp10/onlinelog/group_3.415.788461013    YES
         2          4         ONLINE  +FDATDG/sibsp10/onlinelog/group_4.563.788461017    NO
         2          4         ONLINE  +RECODG/sibsp10/onlinelog/group_4.408.788461019    YES

 

 INST_ID     GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME

---------- ---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
        1          5          1       8287  209715200        512          2 NO  CURRENT             1.6265E+10 12-JUL-12   2.8147E+14
        1          6          1       8286  209715200        512          2 YES INACTIVE            1.6265E+10 12-JUL-12   1.6265E+10 12-JUL-12
        1          7          2      13830  209715200        512          2 YES ACTIVE              1.6265E+10 12-JUL-12   1.6265E+10 12-JUL-12
        1          8          2      13831  209715200        512          2 NO  CURRENT             1.6265E+10 12-JUL-12   2.8147E+14
        2          5          1       8287  209715200        512          2 NO  CURRENT             1.6265E+10 12-JUL-12   2.8147E+14
        2          6          1       8286  209715200        512          2 YES INACTIVE            1.6265E+10 12-JUL-12   1.6265E+10 12-JUL-12
        2          7          2      13830  209715200        512          2 YES ACTIVE              1.6265E+10 12-JUL-12   1.6265E+10 12-JUL-12
        2          8          2      13831  209715200        512          2 NO  CURRENT             1.6265E+10 12-JUL-12   2.8147E+14

 


 

Abaixo um script útil para eliminar um Redo em uso, bastando para isso substituir o valor da variável lgrupo para o numero do grupo a ser eliminado.

declare
lgrupo varchar2(2)  := '14';
lapagou varchar2(1) := 'N';
lcontador number(1) := 0;
lquery varchar2(500);
begin
    while lapagou = 'N' loop
        lquery := 'select count(1) from gv$log where status = ''INACTIVE'' and group# = ' || lgrupo;
        execute immediate lquery into lcontador;
        if lcontador > 0 then
            Begin
                lquery := 'alter database drop logfile group ' || lgrupo;
                execute immediate lquery;
                lapagou:= 'S';
            end;
        else
            lquery := 'alter system switch logfile';
            execute immediate lquery;
            lquery := 'alter system checkpoint';
            execute immediate lquery;
        end if;
    end loop;
end;

Auto-Hide Mac OS Menu ToolBar

A simple plist hack does the same thing on a per-app basis. To hack an app so that when it’s active, the menubar and dock are hidden, you need to find its info.plist file. Control-click on the program in question, choose Show Package Contents from the pop-up menu, and then navigate into the Contents folder.

 

Once there, add the following to the file:

<key>LSUIPresentationMode</key>

<integer>4</integer>

Be sure that it goes in alphabetical order, otherwise it won’t work (i.e. LSUIPresentationMode goes after LSMinimumSystemVersion but beforeNSAppleScriptEnabled). Save the file and enjoy.

 

Source: (http://hints.macworld.com/article.php?story=20070118003804854)

Video: (http://www.anil.biz/mac-how-to-hide-finder-menu-bar/)

How to drop a RAC database manually

As we’re all used since the advent of the “new” command “drop database” on oracle, that sometimes, for a clean and total remove of oracle’s database it’s used. But if you try just use on a RAC environment, it’s necessary a little trick.

The steps are:

1) on cluster (or on the instance it self) do a:

srvctl stop database -d <databasename>

2) startup on restrict mode:

sqlplus / as sysdba

startup mount restrict exclusive;

3) The Trick !!! Change the parameter CLUSTER_DATABASE to false!!!

alter system set cluster_database=false scope=spfile;

4) restart it again restricted:

shutdown immediate;
startup mount restricted exclusive;

5) Finally: drop database !!! (becareful, it has no rollback!!!)

drop database;

6) Done !

Cheers!

Installing remmina on Fedora 15 to connect remotely windows servers

The basic constant you must think on that is that installing remmina, all of it is prepared to rdp to a windows machine. But, by default not always the rdp protocol is disable for that. So, first you must install too the plugins.

These plugins change sometimes their names, so my advice is: search it on yum. as described below:

yum search remmina-plugin
Loaded plugins: langpacks, presto, refresh-packagekit

========================= N/S Matched: remmina-plugin ==========================

remmina-plugins-common.x86_64 : Common files for Remmina Remote Desktop Client

 : plugins

remmina-plugins-nx.x86_64 : NX plugin for Remmina Remote Desktop Client

remmina-plugins-rdp.x86_64 : RDP plugin for Remmina Remote Desktop Client

remmina-plugins-telepathy.x86_64 : Telepathy plugin for Remmina Remote Desktop

 : Client

remmina-plugins-vnc.x86_64 : VNC plugin for Remmina Remote Desktop Client

remmina-plugins-xdmcp.x86_64 : XDMCP plugin for Remmina Remote Desktop Client

 Name and summary matches only, use "search all" for everything.

Then after that I installed the: “remmina-plugins-rdp.x86_64” described above:

yum install remmina-plugins-rdp.x86_64

et voi’lá !

(source: http://joysofprogramming.com/install-xfce4-remmina-plugin-fedora-rhel/)

 

 

 

Optimization WordPress Plugins & Solutions by W3 EDGE