Skip to content

Instantly share code, notes, and snippets.

View gajoseph's full-sized avatar

George @ Joseph gajoseph

View GitHub Profile
@gajoseph
gajoseph / expdp.sh
Last active July 14, 2017 16:11
postgres pg_dump to backup the db/ schema
#############################################################################################
#--GEO--C-- (1)To run for a entire DB:: expdp.sh server1 mydb pguserid 5432
#--GEO--C-- (2)To run for a entire schema call by schema names separated by commas
# :: bash expdp.sh server1 mydb pguserid 5432 l2l,gmm
#--GEO--C-- Script when run creates 3 files for case(1)
# File 1: Dump file w/ format serverName_dbName_ALL_%m%d%Y_%H%M%S.dump; where under $HOME folder; ALL means all schemas in db
# File 2: log/out file w/ format serverName_dbName_ALL_%m%d%Y_%H%M%S.out; script grep the log files for any errors/ failures
# File 3: serverName_dbName_ALL_.txt; this has the lastest dump file name; thought process is to use this file to refresh(see impdp.sh) the stage/dev on a nighly basis; ssuming the DB is not huge
#--GEO--C-- Script when run creates 3 files for case(2)
# there will be 3 files(dump, out, name) for each schema for example if you
install a pakcage $rpm -ihv sqldeveloper-4.0.3.16.84-1.noarch.rpm
root@server Downloads]# rpm -qa | grep -i sqlde
sqldeveloper-4.1.0.17.29-1.noarch
[root@server Downloads]# rpm -e sqldeveloper-4.1.0.17.29-1
[root@server Downloads]#
@gajoseph
gajoseph / clonedb.sh
Created July 14, 2017 17:56
clone postgres DB
################################################################################################
##--GEO--C-- this script copies a database to another database on the same machine or different machine
##
##
################################################################################################
echo "To run this script supply fromhost, fromdbe, user, port, toHost,todb "
echo "E.g int503(fromhost) mydb(fromdb) myuser(user) (5432)port To: int503 newdb(todb) "
echo "-------------------------------------------------------------- "
@gajoseph
gajoseph / clonedb.sh
Created July 14, 2017 17:56
clone postgres DB
################################################################################################
##--GEO--C-- this script copies a database to another database on the same machine or different machine
##
##
################################################################################################
echo "To run this script supply fromhost, fromdbe, user, port, toHost,todb "
echo "E.g int503(fromhost) mydb(fromdb) myuser(user) (5432)port To: int503 newdb(todb) "
echo "-------------------------------------------------------------- "
@gajoseph
gajoseph / ora_grid_silent_install.sh
Last active November 12, 2021 23:42
oracle grid Silent install
SET LINESIZE 32000;
SET PAGESIZE 40000;
SET LONG 50000;
##########################################################################################
#inventory INVENTORY_LOCATION shoudl be owner by grid:oinstall
#where are goin gto isntall oracle mount
ORA_MOUNT=/u01/app
ORA_LOC=$ORA_MOUNT/oracle
ORA_INV=$ORA_MOUNT/oraInventory
ORA_PRO=$ORA_MOUNT/oracle/product
@gajoseph
gajoseph / ora_db_sil_crte.sh
Created July 14, 2017 20:58
Oracle Silent Db create
###############################################################################################
### calculating the memory
export ORACLE_BASE=/u01/app/oracle #setting the BASE
export ORACLE_SID=CLINDB #Setting SID
export ORACLE_HOME=/u01/app/oracle/product/12.1.0/db_1 #Setting ORACLE_HOME
audit_file_dest=$ORACLE_BASE/admin/$ORACLE_SID/adump
rm=$(free|awk '/^Mem:/{print $2}') ## get the total ram
oramem=$(echo "$rm*40/100"|bc) ### allocated 40% of total to oracle
sga=$(echo "$oramem*60/100"|bc) ### out of 60 allocated 60% to SGA
1. Download and Install
a. Download from http://nifi.apache.org/download.html get the zip file from windows
b. Extract the zip into another folder -- which will be nifi_home(c:\users\tgaj2\nifi-1.3.0)
2. Starting and Stopping NiFi
a. Go to nifi_home and under bin folder click run-nifi.bat. Takes little time to staup the webserver
b. To stop Ctl+C from the cmd window. Currently can't run as a service in windows.
3. Nifi UI
a. To access nifi ui http://localhost:8080/nifi
@gajoseph
gajoseph / Db2auditsetup
Last active January 24, 2020 09:09
Db2 audit setup
###########################################################################################
### make a directory to store audit and archievd audcit file
###########################################################################################
export BASE_PATH=/home ###### THIS HAS TO BE SET where the auidt data and archived audit stuff goes
###### THIS HAS TO BE SET
export DB2_HOME=/home/db2inst1
###### THIS HAS TO BE SET :: SCHEMA onto which data will be loaded
export DB2_SCHEMA=AUDIT
###### THIS HAS TO BE SET:: Set the Extract location
echo -e "\n\nDB2_HOME: $DB2_HOME\nDB2_SCHEMA: $DB2_SCHEMA\nEXTRACT_LOC_PATH: $EXTRACT_LOC_PATH\n\n"
/*
to copy/ archive changed files on git commit to local repository this might help
in my case need was to copy to /r/edt/Data\ and\ Analytics/deploy/
git hooks are located under .git\hooks under local respository
tosetup::
$git lfs update
$ git lfs update --force
then update .git/hooks/post-comit
*/
Select 'CREATE ROLE '|| user1||' LOGIN NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION;' as createStat,
'ALTER ROLE '|| user1 ||' SET search_path = qtg;' as al1,
'ALTER ROLE '|| user1 ||' SET lock_timeout = ''60s'';' as al2,
'GRANT adhocgrp TO '||user1 || ';' as grant1, 'alter role ' || user1||' with password ''' ||password1 ||''';'
From (
select 'adhoc'||a as user1, left(md5( 'adhoc'||a|| inet_server_addr()),5) password1, 'Drop user '||'adhoc'||a ||';'
, 'COMMENT ON ROLE ' ||'adhoc'||a ||''' adhoc id for '||pg_catalog.shobj_description(b.oid, 'pg_authid') || ''';'
From (
select unnest(string_to_array(lower('TSDH2,TNXJ4,TDJS1,TAMG1,TPBW1,TJXB1,TJPH2,TOXM1'), ','))a