Sunday, October 4, 2015

Adding Printer via samba

5:12 AM Posted by Unknown No comments
if you ever wondered how to add printer on Linux machine which your printer server is windows you might wanted to follow the instruction below :

1. Connect to the CUPS:
      in your browser type : localhost:631
2.Enter you administrator USER/PASSWORD
3.After pressing the add printer use the following structure for samba like this:
    smb://workgroup\User.Name:passwd@domain.local/asistentfelie/HPLaserJ
    smb://workgroup\printer:printer@10.5.11.52/Sharp
then enjoy

OGG “ABEND” process Troubleshoot

4:56 AM Posted by Unknown No comments
if you are using oracle golden gate(OGG) and in your log encounter a similar error like that : 


2014-01-27 11:51:19 INFO OGG-00996 Oracle GoldenGate Delivery for Oracle, REP1.prm: REPLICAT REP1 started.
2014-01-27 11:51:19 WARNING OGG-03504 Oracle GoldenGate Delivery for Oracle, REP1.prm: NLS_LANG character set WE8MSWIN1252 on the target is different from the source database character set AL32UTF8. Replication may not be valid if the source data has an incompatible character for the target NLS_LANG character set.
2014-01-27 11:51:19 WARNING OGG-01004 Oracle GoldenGate Delivery for Oracle, REP1.prm: Aborted grouped transaction on 'TEST.CT1', Database error 1403 (OCI Error ORA-01403: no data found, SQL <UPDATE "TEST"."CT1" SET "OBJECT_NAME" = :a1 WHERE "RNO" = :b0>).
2014-01-27 11:51:19 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, REP1.prm: Repositioning to rba 1216 in seqno 2.
2014-01-27 11:51:19 WARNING OGG-01154 Oracle GoldenGate Delivery for Oracle, REP1.prm: SQL error 1403 mapping CTEST.CT1 to TEST.CT1 OCI Error ORA-01403: no data found, SQL <UPDATE "TEST"."CT1" SET "OBJECT_NAME" = :a1 WHERE "RNO" = :b0>.
2014-01-27 11:51:19 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, REP1.prm: Repositioning to rba 1216 in seqno 2.
2014-01-27 11:51:19 ERROR OGG-01296 Oracle GoldenGate Delivery for Oracle, REP1.prm: Error mapping from CTEST.CT1 to TEST.CT1.
2014-01-27 11:51:19 ERROR OGG-01668 Oracle GoldenGate Delivery for Oracle, REP1.prm: PROCESS ABENDING.


and simply cant start it u might wanted to try the method below:




1. connect via ssh to the source Database
export ORACLE_SID=${ORACLE_SID}
2. query FLASHBACK_SCN
sqlplus / as sysdba
SQL> select dbms_flashback.get_system_change_number from dual or select current_scn from v$database;
GET_SYSTEM_CHANGE_NUMBER
------------------------
17262230 --ID is your select result
SQL> exit
3. export dump
Note : FLASHBACK_SCN is upper shown number.
exp system@${ORACLE_SID} owner=ABEND_process file=ABEND_process.dmp grants=n statistics=none triggers=n compress=n FLASHBACK_SCN=17262230 log=ABEND_process.log
4. Copy the dump to Staging Database
5. connect via ssh to the staging Database
export ORACLE_SID=${STAGING_ORACLE_SID}


6. Drop table
sqlplus / as sysdba
SQL>set linesize 999
SQL>set pagesize 999
SQL>select 'drop table '||owner||'.'||object_name||' cascade constraint;' from dba_objects where object_type='TABLE' and owner in ('ABEND_process');


Note : after running the query above copy the the prompted results and run to make sure the table is dropped.


7. import dump
  • go to the dump directory
imp system@${ORACLE_STAGING_SID} file=ABEND_process.dmp fromuser= ABEND_process touser= ABEND_process ignore=y log=ABEND_process.log
8. Disable Foreign key
SQL> sqlplus / as sysdba
SQL>set linesize 999
SQL>set pagesize 999
SQL>select 'alter table '||owner||'.'||table_name||' disable constraint '||constraint_name||';' from dba_constraints where owner in ('ABEND_process') and constraint_type='R';
SQL>exit
Note : after running the query above copy the the prompted results and run to make sure the table is dropped.
9. Go to stg_goldengate_home
  • ./ggsci
SQL>START RP_ ABEND_process aftercsn $FLASHBACK_SCN
SQL>exit
Note : $FLASHBACK_SCN is query in source database .


Tuesday, June 2, 2015

Clean RAM Cache in Linux

2:21 AM Posted by Unknown No comments
First of all check how much memory you have left :
mehdi@MPourhadi ~/> free -m
                     total     used         free    shared  buffers   cached
     Mem:    5968      5630         337     64        116        1038
     -/+ buffers/cache: 4475        1492
     Swap: 6139          56        6083
now issue the the command "sync" to flush the file system buffer. then change your root user.
For Debian-base users : "sudo bash" and for RPM packages "su or su -"
when you are root user issue the following command and see the diffrence :
root@MPourhadi:~/# echo 3 > /proc/sys/vm/drop_caches
      NOTE :
      echo 1 is for free pagecache
      echo 2 is for free dentries and inodes
      echo 3 is 1+2
root@MPourhadi:~/# free -m
                 total        used        free     shared      buffers       cached
     Mem:  5968        4399        1568      60            2               318
     -/+ buffers/cache: 4078 1889  
     Swap: 6139 56 6083


How to Write a Simple Route

2:14 AM Posted by Unknown No comments
Linux
Here what you need to do just open terminal or you can use shortcut (Ctrl+Alt+T) then type :
sudo ip route add ${SUBNET} via ${GATEWAY_IP}

sudo ip route add 172.16.0.0/16 via 10.5.11.1
but if you restart your system its all gone just open the file in "/etc/rc.local" and insert it there without the sudo.


Windows:
Open your cmd(command Prompt) and to the following: 
C:\Windows\system32>netsh.exe
netsh>interface
netsh interface>ip 
netsh interface ipv4>show interface

Idx Met MTU State Name
--- ---------- ---------- ------------ ---------------------------
1 4275 4294967295 connected Loopback Pseudo-Interface 1
27 20 1400 connected VPN Connection
11 4245 1500 connected Local Area Connection
15 4245 1400 disconnected Kerio Virtual Network

netsh interface ipv4>add route 192.168.0.0/16 11 10.5.11.1
Ok.

netsh interface ipv4>add route 172.16.0.0/16 11 10.5.11.1
Ok.

netsh interface ipv4>exit


if you wanted to check your where your routing goes issue the command below : 
netsh interface ipv4>show route  

Oracle Solution Part 2

1:57 AM Posted by Unknown No comments

Do you wanna move your oracle datafile to a new location but donno how !? relax i'm gonna explain it .

first of all you need to check where is your "CURRENT" datafile , do as the following :
  • sqlplus / as sysdba 

         SQL*Plus: Release 11.2.0.4.0 Production on Sat Mar 14 16:33:22 2015
         Copyright (c) 1982, 2013, Oracle. All rights reserved.
         Connected to:
         Oracle Database 11g Release 11.2.0.4.0 - 64bit Production
  • SQL> select name from v$datafile;

         the out put should be similar to the below :
         NAME
         --------------------------------------------------------------------------------
         /oradata/system01.dbf
         /oradata/sysaux01.dbf
         /oradata/undotbs01.dbf
         /oradata/users01.dbf
now that we know where our current datafile is we can change in the new place we want by do the following :
    alter database rename file '/oradadata/system01.dbf' to '/new/oradata/path/system01.dbf';
    alter database rename file '/oradadata/sysaux01.dbf' to '/new/oradata/path/sysaux01.dbf';
do it for the rest of the file if you have more than that.
now when you try to open up your database you may get the error related to the "redo logs", worry not the concept its just as the same as datafile. you will find your current redo log by below query:
  • SQL> select member from v$logfile;

         MEMBER
         --------------------------------------------------------------------------------
         /oradata/redo02.log
         /oradata/redo01.log
now you can rename it ,
alter database rename file '/oradata/redo02.log' to '/new/oradata/path/redo02.log';

alter database rename file '/oradata/redo01.log' to '/new/oradata/path/redo01.log' ; 

RMAN Active Database Duplication - Backup Base

1:00 AM Posted by Unknown No comments
Before we begin i assume have that copy of the backup on our server no matter in where.
-bash-4.2$ echo $ORACLE_SID
orcl
-bash-4.2$ rman auxiliary /
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Feb 28 15:44:28 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to auxiliary database: orcl (not mounted)
RMAN> duplicate database to orcl backup location '/path/to/your/backup' nofilenamecheck;
Starting Duplicate Db at 28-FEB-15
contents of Memory Script:
{
sql clone "create spfile from memory";
}
executing Memory Script
sql statement: create spfile from memory
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 42757922816 bytes
Fixed Size 2255784 bytes
Variable Size 41070625880 bytes
Database Buffers 1610612736 bytes
Redo Buffers 74428416 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''orcl'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''orcl'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile from '/flash_recovery_area/backupset/2015_02_25/o1_mf_ncnnf_TAG20150225T004304_bgstc1j9_.bkp';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''orcl'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''orcl'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 42757922816 bytes
Fixed Size 2255784 bytes
Variable Size 41070625880 bytes
Database Buffers 1610612736 bytes
Redo Buffers 74428416 bytes
Starting restore at 28-FEB-15
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=673 device type=DISK
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/oradata/control01.ctl
output file name=/oradata/control02.ctl
Finished restore at 28-FEB-15
database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=673 device type=DISK
Using previous duplicated file /oradata/aen_data.dbf for datafile 63 with checkpoint SCN of 278482136
contents of Memory Script:
{
set until scn 278484383;
set newname for datafile 1 to
"/oradata/system01.dbf";
set newname for datafile 2 to
"/oradata/sysaux01.dbf";
set newname for datafile 3 to
"/oradata/undotbs01.dbf";
set newname for datafile 4 to
"/oradata/users01.dbf";
set newname for datafile 5 to
restore
clone datafile
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 28-FEB-15
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /oradata/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /oradata/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /oradata/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /oradata/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /flash_recovery_area/backupset/2015_02_25/o1_mf_nnndf_TAG20150225T000647_bgsr71nv_.bkp
channel ORA_AUX_DISK_1: piece handle=/flash_recovery_area/backupset/2015_02_25/o1_mf_nnndf_TAG20150225T000647_bgsr71nv_.bkp tag=TAG20150225T000647
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:31:36
Finished restore at 28-FEB-15
contents of Memory Script:
{
catalog clone datafilecopy "/oradata/aen_data.dbf";
switch clone datafile 63 to datafilecopy
"/oradata/aen_data.dbf";
switch clone datafile all;
}
executing Memory Script
cataloged datafile copy
datafile copy file name=/oradata/aen_data.dbf RECID=64 STAMP=872871419
datafile 1 switched to datafile copy
input datafile copy RECID=65 STAMP=872871419 file name=/oradata/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=66 STAMP=872871419 file name=/oradata/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=67 STAMP=872871419 file name=/oradata/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=68 STAMP=872871419 file name=/oradata/users01.dbf
contents of Memory Script:
{
set until scn 278484383;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 28-FEB-15
using channel ORA_AUX_DISK_1
starting media recovery
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=3538
channel ORA_AUX_DISK_1: reading from backup piece /flash_recovery_area/backupset/2015_02_25/o1_mf_annnn_TAG20150225T004255_bgstbql8_.bkp
Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/oradata/system01.dbf'

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 02/28/2015 16:17:06
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
ORA-19870: error while restoring backup piece /flash_recovery_area/backupset/2015_02_25/o1_mf_annnn_TAG20150225T004255_bgstbql8_.bkp
ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 4021248 bytes disk space from 107374182400 limit



now we are going to check the errors one by one :
1- ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/oradata/system01.dbf'
This one either you have to restore from autobackup or from a backup.(unfortunately it didn't work for me)

2- ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 4021248 bytes disk space from 107374182400 limit
This means that your flash recovery area(FRA) is not enough so you have to exapnd it(i already explained in here.)
as our data files has been set to our new database we can do some startup functionality.
bash-4.2$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sat Feb 28 18:40:22 2015
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Release 11.2.0.4.0 - 64bit Production

SQL> shutdown immediate
Oracle database closed
Oracle database dismounted
Oracle instance shutdown
SQL>startup nomount;
ORACLE instance started.
Total System Global Area 4.2758E+10 bytes
Fixed Size 2255784 bytes
Variable Size 4.0400E+10 bytes
Database Buffers 2281701376 bytes
Redo Buffers 74428416 bytes
SQL> alter database mount;
Database altered
SQL> alter database open;
alter database open
ERROR at line 1:
ORA-19838: Cannot use this control file to open database
Now we need to recreate our control file i order to that, you can use either this command
SQL> alter database backup controlfile to trace as '/dbapp/controlnew.lst';
Database altered.
in the '/dbapp/controlnew.lst' file there is controlfile info which allows you to modify controlfile.
or use the following script :
SQL> CREATE CONTROLFILE SET DATABASE "DBNAME" RESETLOGS FORCE LOGGING ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 2336
LOGFILE
GROUP 1 '/dbapp/redos/redo01.log' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/dbapp/redos/redo02.log' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/dbapp/redos/redo03.log' SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/oradata/system01.dbf',
'/oradata/sysaux01.dbf',
'/oradata/undotbs01.dbf',
'/oradata/users01.dbf',
CHARACTER SET AL32UTF8
;

Control file created.

SQL> alter database open resetlogs;
alter database open resetlogs
ERROR at line 1:
ORA-01194: file 1 needs more recovery to be consistent
ORA-01110: data file 1: '/oradata/system01.dbf'
SQL> create pfile from spfile;
File created.
SQL> exit
now add this line "_allow_resetlogs_corruption=TRUE" to your pfile then save and quit,
SQL> create spfile from pfile;
File created.
SQL> startup;
ORACLE instance started.
Total System Global Area 4.2758E+10 bytes
Fixed Size 2255784 bytes
Variable Size 4.0400E+10 bytes
Database Buffers 2281701376 bytes
Redo Buffers 74428416 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.