Tuesday, February 27, 2018

VMware PowerCLI : Search VMguest by MAC Address_IP Address

LIST IP VMware Service:
Get-VMHostNetworkAdapter | select ip, name, vmhost, portgroupname

Search VMguest by MAC Address:
Get-VM | Get-NetworkAdapter| Where-Object {$_.MacAddress -eq "00:50:56:8e:fd:4b"}

Search VMguets by IP Address
Get-VM | Where-Object {$_.guest.IPAddress[0] -eq "192.168.1.1"}

Monday, February 26, 2018

BAN ip list by iptables

BAN ip by iptables

-- Create banlist.txt
root@hosting:/home/hunzo/script# more banlist.txt                                           
104.131.147.112
216.244.66.198
216.244.66.239
216.244.66.205
46.229.168.0/24
54.36.148.0/24
54.36.149.0/24
163.172.71.0/24

-- Check iptables rules

root@hosting:/home/hunzo/script# iptables -L -v -n
Chain INPUT (policy ACCEPT 322K packets, 19M bytes)
 pkts bytes target     prot opt in     out     source               destination       

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination       

Chain OUTPUT (policy ACCEPT 125K packets, 742M bytes)
 pkts bytes target     prot opt in     out     source               destination       

-- Create Script
root@hosting:/home/hunzo/script# ban=$(more banlist.txt)                                   
root@hosting:/home/hunzo/script# for i in $ban; do echo iptables -A INPUT -s $i -j DROP ; done
iptables -A INPUT -s 104.131.147.112 -j DROP
iptables -A INPUT -s 216.244.66.198 -j DROP
iptables -A INPUT -s 216.244.66.239 -j DROP
iptables -A INPUT -s 216.244.66.205 -j DROP
iptables -A INPUT -s 46.229.168.0/24 -j DROP
iptables -A INPUT -s 54.36.148.0/24 -j DROP
iptables -A INPUT -s 54.36.149.0/24 -j DROP
iptables -A INPUT -s 163.172.71.0/24 -j DROP

-- exec script
root@hosting:/home/hunzo/script# for i in $ban; do iptables -A INPUT -s $i -j DROP ; done       

-- check iptables rules
root@hosting:/home/hunzo/script# iptables -L -v -n                                         
Chain INPUT (policy ACCEPT 322K packets, 19M bytes)
 pkts bytes target     prot opt in     out     source               destination       
    0     0 DROP       all  --  *      *       104.131.147.112      0.0.0.0/0         
    0     0 DROP       all  --  *      *       216.244.66.198       0.0.0.0/0         
    0     0 DROP       all  --  *      *       216.244.66.239       0.0.0.0/0         
    0     0 DROP       all  --  *      *       216.244.66.205       0.0.0.0/0         
    0     0 DROP       all  --  *      *       46.229.168.0/24      0.0.0.0/0         
    0     0 DROP       all  --  *      *       54.36.148.0/24       0.0.0.0/0         
    0     0 DROP       all  --  *      *       54.36.149.0/24       0.0.0.0/0         
    0     0 DROP       all  --  *      *       163.172.71.0/24      0.0.0.0/0         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination       

Chain OUTPUT (policy ACCEPT 126K packets, 742M bytes)
 pkts bytes target     prot opt in     out     source               destination       
root@hosting:/home/hunzo/script#


@2018-02-26 11:15

root@hosting:/home/hunzo/script# iptables -L -v -n
Chain INPUT (policy ACCEPT 412K packets, 25M bytes)
 pkts bytes target     prot opt in     out     source               destination       
    0     0 DROP       all  --  *      *       104.131.147.112      0.0.0.0/0         
    0     0 DROP       all  --  *      *       216.244.66.198       0.0.0.0/0         
    0     0 DROP       all  --  *      *       216.244.66.239       0.0.0.0/0         
    0     0 DROP       all  --  *      *       216.244.66.205       0.0.0.0/0         
 3502  210K DROP       all  --  *      *       46.229.168.0/24      0.0.0.0/0         
  309 18540 DROP       all  --  *      *       54.36.148.0/24       0.0.0.0/0         
  120  7200 DROP       all  --  *      *       54.36.149.0/24       0.0.0.0/0         
    0     0 DROP       all  --  *      *       163.172.71.0/24      0.0.0.0/0         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination       

Chain OUTPUT (policy ACCEPT 169K packets, 1024M bytes)
 pkts bytes target     prot opt in     out     source               destinat


-- drop rules

'iptables -D INPUT -s 1.2.3.4 -j DROP'

1.2.3.4 = ip address

Wednesday, February 21, 2018

Display big numbers in SQLPLUS


show num(width)
set num(width) 15

num(width) parameter (2-15)


SQL> show num
numwidth 10

SQL> l
  1  select
  2  current_scn
  3  from
  4* v$database
SQL> /

CURRENT_SCN
-----------
 1.6139E+10


SQL> set num 15
SQL> l
  1  select
  2  current_scn
  3  from
  4* v$database
SQL> /

    CURRENT_SCN
---------------
    16138638611

SQL>

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

ALCATEL 6900

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