Friday, February 16, 2018

Clone Oracle Database 11G using RMAN backup SET

Script: migrate-ok.sh

#!/bin/bash
cd
. .bash_profile
export BACKUPPATH="/u04/move"

for i in MEIS
do
export DATAFILE="BACKUP_${i}_DATA_$(date '+%Y%m%d')"
echo $DATAFILE
export ARCHIVEDLOG="BACKUP_${i}_ARC_$(date '+%Y%m%d')"
echo $ARCHIVEDLOG
export CONTROLFILE="BACKUP_${i}_CTL_$(date '+%Y%m%d')"
echo $CONTROLFILE
export RMAN_LOG_FILE="BACKUP_${i}_$(date '+%Y%m%d').out"
echo $RMAN_LOG_FILE
echo Backup_data_file_path=$BACKUPPATH

export ORACLE_SID=$i

#EXPORT pfile
sqlplus '/ as sysdba'  << EOF
CREATE pfile='${BACKUPPATH}/${i}/pfile-$i-$(date '+%Y%m%d').ora' from spfile;
EXIT;
EOF

#RMAN REPORT DATABASE INFORMATION
rman target / msglog ${BACKUPPATH}/${i}/DATABASE_${i}_info.txt <<EOF
run
{
REPORT SCHEMA;
}
EXIT;
EOF
#<<'test'
#RMAN BACKUPSET FOR Migration
rman target / msglog ${BACKUPPATH}/log/$RMAN_LOG_FILE <<EOF
run
{
ALLOCATE CHANNEL ch00 TYPE DISK;
ALLOCATE CHANNEL ch01 TYPE DISK;
ALLOCATE CHANNEL ch02 TYPE DISK;
ALLOCATE CHANNEL ch03 TYPE DISK;

BACKUP
    TAG "${DATAFILE}"
    FORMAT '${BACKUPPATH}/${i}/DATA_${i}_%s_%p_%t'
    DATABASE;
    sql 'alter system archive log current';
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;

ALLOCATE CHANNEL ch00 TYPE DISK;
ALLOCATE CHANNEL ch01 TYPE DISK;

BACKUP
   TAG "${ARCHIVEDLOG}"
   FORMAT '${BACKUPPATH}/${i}/arc_${i}_%s_%p_%t'
   ARCHIVELOG ALL ;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;

ALLOCATE CHANNEL ch00 TYPE DISK;
BACKUP
    TAG "${CONTROLFILE}"
    FORMAT '${BACKUPPATH}/${i}/cntrl_${i}_%s_%p_%t'
    CURRENT CONTROLFILE;
RELEASE CHANNEL ch00;
}
EXIT;
EOF
#test
echo $i
done


Scenario for clone target database to another Host
----------------------------------------------------------------
- exec: migrate-ok.sh
- scp backupset to target database
- create audit tail directory ex.mkdir /u01/app/oracle/admin/MEIS/adump
- create controlfile directory ex. mkdir /u02/MEIS/, mkdir /u01/app/oracle/fast_recovery_area/MEIS/
- create fast_recovery_area directory ex. mkdir /u01/app/oracle/fast_recovery_area
- start Oracle Instance from pfile ex. SQL> startup pfile='/u02/mig/pfile-MEIS-20160928.ora' nomount;
- restore controlfile from backupset ex. RMAN>  restore controlfile from '/u02/mig/cntrl_MEIS_38_1_923742230';
- Clear Fast recovery Area.
- Catalog RMAN Backupset ex. RMAN> catalog start with '/u02/mig';
- Mount Datafile ex. RMAN> sql 'alter database mount';
- Restore datafile ex. RMAN > restore database;
- Recover database ex. RMAN > recover database;
- Open Database resetlogs ex. SQL> alter database open resetlogs;
- create orapwSID in $ORACLE_HOME ex. orapwd file=orapwMEIS password=oracle entries=3
- create oratab @/etc/oratab $ORACLE_SID:$ORACLE_HOME:<N|Y>: ex. MEIS:/u01/app/oracle/product/11.2.0.2/db_1:N
- change password SYS,SYSTEM,SYSMAN,DBSNMP to rebuild EM
- exec: emca -config dbcontrol db -repos recreate to rebuild Enterprise Management

Wednesday, January 31, 2018

Ban IP Address by IP Table

Ban IP Address by IP Table:

view Ban IP address:
iptables -L INPUT -v -n

Check Ban IP by IP address
iptables -L INPUT -v -n | grep "1.2.3.4"

Ban IP address:
iptables -A INPUT -s 97.74.24.174 -j DROP

Delete Ban by IP address
iptables -D INPUT -s 1.2.3.4 -j DROP

Monday, January 29, 2018

Purge, Flush or Delete Postfix Queue

Show Postfix mail Queue
postqueue -p or mailq

Delete mail msg by msg-id in Mail Queue
postsuper -d msg-id

Delete All mail msg in Mail Queue 
postsuper -d ALL

Finding Files By Content in File

find . -name "configuration.php" |xargs grep --color '$user\|$password\|$db'

find . -name "*.php" |xargs grep 'base64_decode' | grep 'create_function'

find . -name "*.php" |xargs awk '/base64_decode/ && /create_function/'

Saturday, January 27, 2018

Disable Directory list by .htaccess

Add Option in Apache2.conf

<Directory /var/www/html>
   Options -Indexes +FollowSymLinks
   AllowOverride None
   Require all granted
</Directory>

Create file .htaccess in /var/www/html
add Option :
Options -Indexes

Wednesday, January 17, 2018

Check Application Run

:Check Schedule Run
SCHTASKS /Query /FO LIST /V >"%USERPROFILE%\Desktop\MyScheduledTasks.txt"

:Check Console Run export by Regedit
reg export "HKEY_CURRENT_USER\Console" "%USERPROFILE%\Desktop\MyConsoleSettings.txt" /y

:Check Local Machine Run export by Regedit
reg export "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "%USERPROFILE%\Desktop\MyLocalRunSettings.txt" /y

:Check Cuurent User Run export by Regedit
reg export "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "%USERPROFILE%\Desktop\MyUserRunSettings.txt" /y

:Check Config on StartUP
MSCONFIG

Friday, January 12, 2018

Windows 10 Access FileShare On Windows 7

Windows 10  Access FileShare On Windows 7

1: gpedit

Computer configuration\administrative templates\network\Lanman Workstation
"Enable insecure guest logons"

2: regdit

Default Registry Value:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters]
"AllowInsecureGuestAuth"=dword:0
Configured Registry Value:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters]
"AllowInsecureGuestAuth"=dword:1

ALCATEL 6900

write memory copy running certified reload from working no rollback-timeout