Tuesday, March 26, 2013

RMAN-08132 ORA-00245


On RAC database, backups starts fail with following warnings:

allocate channel for maintenance type disk;

RMAN retention policy is set to recovery window of 14 days
RMAN-08132: WARNING: cannot update recovery area reclaimable file list

ORA-00245: control file backup failed; target is likely on a local file system

The configuration for control file snapshot is on local disk (not shared)


RMAN> show all;
...
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_sapcc1.f'; # default

Depending on the configuration, the snapshot controlfile might be created on 'Node 1', but is than read on 'Node 2' as that related channel is making a backup of the controlfile.



Wednesday, March 13, 2013

Send mail from command line

One useful tool in administering servers is sending emeial from command line or batch script. This can be accomplished with mail command.

mail -s "Subject" -c <CC address> <e-mail address>

insert mail text
press CONTORL+D to finish and send mail

In case of empty message body:

[user@server ~]$ mail -s "Subject" mail.name@mail.com
EOT
Null message body; hope that's ok

PRCR-1079 : Failed to start resource ora.sapccstandby.db


After duplicating database to a standby database, when trying to start standby database using srvctl utility following errors might appear:

[oracle@oracle-node-dr ~]$ srvctl start database -d sapdbstandby
PRCR-1079 : Failed to start resource ora.sapdbstandby.db
CRS-5010: Update of configuration file "/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initsapdbstandby.ora" failed: details at "(:CLSN00014:)" in "/u01/app/11.2.0/grid/log/oracle-node-dr/agent/ohasd/oraagent_grid/oraagent_grid.log"
CRS-5017: The resource action "ora.sapdbstandby.db start" encountered the following error:
CRS-5010: Update of configuration file "/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initsapdbstandby.ora" failed: details at "(:CLSN00014:)" in "/u01/app/11.2.0/grid/log/oracle-node-dr/agent/ohasd/oraagent_grid/oraagent_grid.log"
. For details refer to "(:CLSN00107:)" in "/u01/app/11.2.0/grid/log/oracle-node-dr/agent/ohasd/oraagent_grid/oraagent_grid.log".

CRS-2674: Start of 'ora.sapdbstandby.db' on 'oracle-node-dr' failed

Workaround

Change permissions on initsapdbstandby.ora

[oracle@oracle-node-dr dbhome_1]$ cd $ORACLE_HOME
[oracle@oracle-node-dr dbhome_1]$ chmod 775 dbs
[oracle@oracle-node-dr dbhome_1]$ cd dbs
[oracle@oracle-node-dr dbs]$ chmod 775 initsapdbstandby.ora

Start database resource:

[oracle@oracle-node-dr ~]$ srvctl start database -d sapdbstandby

Check available resources:

[grid@oracle-node-dr ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       oracle-node-dr
ora.FRA.dg
               ONLINE  ONLINE       oracle-node-dr
ora.LISTENER.lsnr
               ONLINE  ONLINE       oracle-node-dr
ora.asm
               ONLINE  ONLINE       oracle-node-dr           Started
ora.ons
               OFFLINE OFFLINE      oracle-node-dr
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       oracle-node-dr
ora.diskmon
      1        OFFLINE OFFLINE
ora.evmd
      1        ONLINE  ONLINE       oracle-node-dr
ora.sapdbstandby.db
      1        ONLINE  INTERMEDIATE oracle-node-dr           Mounted (Closed)
[grid@oracle-node-dr ~]$

Wednesday, January 30, 2013

MySQL Error 1236 - Reconfigure slave


In case replication fails with error 1236 when reading data from binary log, slave can be reconfigured to skip the wrong binlog file and start with the next one.

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State:
                  Master_Host: 172.18.16.62
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000077
          Read_Master_Log_Pos: 712511169
               Relay_Log_File: mysqld-relay-bin.000216
                Relay_Log_Pos: 253
        Relay_Master_Log_File: mysql-bin.000077
             Slave_IO_Running: No
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 712429781
              Relay_Log_Space: 83596
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 1236
                Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'binlog truncated in the middle of event; consider out of disk space on master; the first event 'mysql-bin.000077' at 712511169, the last event read from './mysql-bin.000077' at 712511169, the last byte read from './mysql-bin.000077' at 712511488.'
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1
1 row in set (0.00 sec)

mysql> stop slave;
Query OK, 0 rows affected (0.03 sec)

mysql> change master to master_log_pos=0;
Query OK, 0 rows affected (0.01 sec)

mysql> change master to master_log_file='mysql-bin.000078';
Query OK, 0 rows affected (0.01 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 172.18.16.62
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000079
          Read_Master_Log_Pos: 15734059
               Relay_Log_File: mysqld-relay-bin.000003
                Relay_Log_Pos: 15339130
        Relay_Master_Log_File: mysql-bin.000079
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 15338984
              Relay_Log_Space: 32551481
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 75
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1
1 row in set (0.00 sec)

To automatically purge binary log files, there can be used 2 methods:

  • periodically use command PURGE BINARY LOGS
    •  mysql –uroot –p –e “purge binary logs before date_sub(now(),interval N day);”         // where N = number of days to keep logs
  • set varibale expire_log_days
    • SET GLOBAL expire_log_days = N;    // where N = number of days to keep logs

Monday, January 28, 2013

Oracle TOPS

ORA-01882 - SQL Developer

Oracle SQL Developer Version 3.2.20.09
Windows 7 (x64)

When trying to configure a database connection following error appears:

ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found

According to metalink note 1477929.1 it is a SQL Developer configuration issue. The SQL Developer cannot recognize the correct timezone.
The workaround is to add the following line into %SQLDEVELOPER%/sqldeveloper/bin/sqldeveloper.conf file (make a backup of this file first).

AddVMOption -Duser.timezone="+02:00"

Save the file and then restart SQL Developer.

Friday, January 18, 2013

SQL: Aggregate data for each user, day, month as SUM

Just the other day I received a request to aggregate the sum for each user_id for each month as a sum of all counters for all previous days starting from the beginning of the  month.
The table used was:


create table test_report
(
user_id number,
curr_date date,
total_day number,
total_month number,
constraint pk_report primary key (user_id,curr_date));

The test data in this table had the total_day=10 for each day for each user_id.
The view created to retrieve the data in the requested format, where dynamic_total_month is the automatic generated sum:


CREATE VIEW test_report_view AS
SELECT user_id,
  curr_date,
  total_day,
  SUM(SUM(total_day)) over (partition BY user_id extract(MONTH FROM curr_date),extract(YEAR FROM curr_date) order by curr_date) dynamic_total_month,
  total_month total,
  extract(MONTH FROM curr_date) month_ex,
  extract(YEAR FROM curr_date) year_ex
FROM test_report
GROUP BY user_id,
  curr_date,
  total_day,
  total_month,
  extract(MONTH FROM curr_date),
  extract(YEAR FROM curr_date);

Here is a sample output:

select  * from test_report_view
where user_id=1 and curr_date between '25-dec-2013' and '5-jan-2014' order by curr_date;

1 25-DEC-13 01.17.24 10 250  12 2013
1 26-DEC-13 01.17.25 10 260  12 2013
1 27-DEC-13 01.17.25 10 270  12 2013
1 28-DEC-13 01.17.26 10 280  12 2013
1 29-DEC-13 01.17.26 10 290  12 2013
1 30-DEC-13 01.17.26 10 300  12 2013
1 31-DEC-13 01.17.27 10 310  12 2013
1 01-JAN-14 01.17.27 10 10  1 2014
1 02-JAN-14 01.17.27 10 20  1 2014
1 03-JAN-14 01.17.28 10 30  1 2014
1 04-JAN-14 01.17.28 10 40  1 2014