Frequently used unix commands by Greenplum DBA's

Acript argument: $1 is the first argument, $2 is the second argument, and so on. The variable $0 is the script's name. The total number of arguments is stored in $#. The variables $@ and $* return all the arguments
1. routeshow / manipulate the IP routing table
see also:  ip route
2. nslookup
3. ifconfig -a
4. hostname
5. ping
6. ethtool eth0
7. netstat -rn
8. top
9. vmstat
10. w

--Find out total space used by primary segment databases (excluding log files and local backup files)
[gpadmin@sachi ~]$gpssh -f $GPHOME/hosts.seg "du –h --exclude=*pg_log* --exclude=*db_dump* -s /data[12]/primary/gpseg*"

--Change owner of all tables in Public schema
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" sachi` ; do psql -c "alter table $tbl owner to gpadmin" sachi ; done

--Move all tables from Public Schema to a specified schema.

for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname='public';" sachi`; do `psql -c "ALTER TABLE $tbl SET SCHEMA sachi;" sachi`; done

DATABASES=`psql -q -c "\l" | sed -n 4,/\eof/p | grep -v rows | grep -v template0 | awk {'print $1}' | sed 's/^://g' | sed -e '/^$/d' | grep -v '|'`


datediff() {
 d1=$(date -d "$1" +%s)
 d2=$(date -d "$2" +%s)
 echo $(( (d1 - d2) / 86400 )) days
 }

timespent() {
 d1=$(date -d "$1" +%s)
 d2=$(date -d "$2" +%s)
 echo $(( (d1 - d2) )) seconds
 }
11.uptime
12. ps
13. free
14. iostat
15.sar
16. mpstat
17.pmap
18. /proc file system - various kernet stats
# cat /proc/cpuinfo
# cat /proc/meminfo
# cat /proc/zoneinfo
# cat /proc/mounts
# cat /proc/version
19. lsof

Find out total space used by log files of primary segment databases

[gpadmin@sachi ~]$gpssh -f $GPHOME/hosts.seg "du –h -s /data[12]/primary/gpseg*/pg_log*"

$(date +%s)

start_time=$(date +%s)
end_time=$(date +%s)

duration=`expr $end_time - $start_time`

echo `expr $difference / 3600`:`expr "(" $difference / 60 ")" % 60`:`expr $difference % 60`
List files in current directory and its size

for i in `ls -lh|awk {'print $9,$5}'`; do echo $i; done
20. last
21. df
22. du
23. kill
24. traceroute
25. rsync
26. rpm
27. tar
28. pwd
29. lsb_rlease -a
30. uname -a  [-prints the name, version and other details about the current machine and the operating system running on it.]

Find out total space used by backup files of primary segment databases

[gpadmin@sachi ~]$gpssh -f $GPHOME/hosts.seg "du –h -s /data[12]/primary/gpseg*/db_dumps*"

Change all uppercase to lowercase with vi?
:%s/.*/\L&/

Conversely, :%s/.*/\U&/ will change all the characters to uppercase.


List all directory and subdirectory

ls -lDR | grep ':$' | head |sed -e 's/:$//'

Using grep and awk to filter our idle connections

posted Jul 8, 2015, 7:05 AM by Sachchida Ojha

[sachi@localhost ~]$ ps -ef | awk '/sachi/ && /idle/'
gpadmin  13356  1436  0 09:13 ?        00:00:00 postgres: port  5432, sachi sachi [local] con120988 [local] idle
sachi    17449 13370  0 09:38 pts/1    00:00:00 awk /sachi/ && /idle/

[sachi@localhost ~]$ ps -ef | awk '/sachi/ && /idle/'|grep -v awk
gpadmin  13356  1436  0 09:13 ?        00:00:00 postgres: port  5432, sachi sachi [local] con120988 [local] idle

[sachi@localhost ~]$ ps -ef | awk '/sachi/ && /idle/'|grep -v awk
gpadmin  13356  1436  0 09:13 ?        00:00:00 postgres: port  5432, sachi sachi [local] con120988 [local] idle

[sachi@localhost ~]$ ps -ef |grep sachi
sachi     2380  2353  0 Jun26 ?        00:00:06 gnome-session --session gnome-classic
sachi     2388     1  0 Jun26 ?        00:00:00 dbus-launch --sh-syntax --exit-with-session
sachi     2396     1  0 Jun26 ?        00:00:00 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session
sachi     2484     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfsd
sachi     2551     1  0 Jun26 ?        00:00:00 /usr/libexec//gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
sachi     2554  2380  0 Jun26 ?        00:00:02 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "env GNOME_SHELL_SESSION_MODE=classic gnome-session --session gnome-classic"
sachi     2595     1  0 Jun26 ?        00:00:00 /usr/libexec/at-spi-bus-launcher
sachi     2599  2595  0 Jun26 ?        00:00:00 /bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
sachi     2603     1  0 Jun26 ?        00:00:00 /usr/libexec/at-spi2-registryd --use-gnome-session
sachi     2611  2380  0 Jun26 ?        00:00:22 /usr/libexec/gnome-settings-daemon
sachi     2627     1  0 Jun26 ?        00:00:02 /usr/bin/pulseaudio --start
sachi     2632     1  0 Jun26 ?        00:00:00 /usr/bin/gnome-keyring-daemon --start --components=ssh
sachi     2726     1  0 Jun26 ?        00:00:04 /usr/libexec/gvfs-udisks2-volume-monitor
sachi     2741     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfs-afc-volume-monitor
sachi     2746     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfs-mtp-volume-monitor
sachi     2750     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor
sachi     2754     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfs-goa-volume-monitor
sachi     2757     1  0 Jun26 ?        00:00:00 /usr/libexec/goa-daemon
sachi     2764     1  0 Jun26 ?        00:00:43 /usr/libexec/goa-identity-service
sachi     2766  2380  0 Jun26 ?        00:01:31 /usr/bin/gnome-shell
sachi     2773     1  0 Jun26 ?        00:00:00 /usr/libexec/dconf-service
sachi     2781     1  0 Jun26 ?        00:00:00 /usr/libexec/gsd-printer
sachi     2798     1  0 Jun26 ?        00:00:00 /usr/bin/ibus-daemon --replace --xim --panel disable
sachi     2806  2798  0 Jun26 ?        00:00:00 /usr/libexec/ibus-dconf
sachi     2808     1  0 Jun26 ?        00:00:00 /usr/libexec/ibus-x11 --kill-daemon
sachi     2816     1  0 Jun26 ?        00:00:00 /usr/libexec/gnome-shell-calendar-server
sachi     2820     1  0 Jun26 ?        00:00:06 /usr/libexec/mission-control-5
sachi     2832     1  0 Jun26 ?        00:00:00 /usr/libexec/evolution-source-registry
sachi     2840  2798  0 Jun26 ?        00:00:00 /usr/libexec/ibus-engine-simple
sachi     2942     1  0 Jun26 ?        00:00:00 /usr/libexec/evolution-addressbook-factory
sachi     2947     1  0 Jun26 ?        00:00:01 /usr/libexec/gconfd-2
sachi     2954     1  0 Jun26 ?        00:00:00 /usr/libexec/tracker-store
sachi     2970     1  0 Jun26 ?        00:00:00 /usr/libexec/evolution-calendar-factory
sachi     3010     1  0 Jun26 ?        00:00:00 /usr/libexec/gnome-session-failed --allow-logout
sachi     3014  2380  0 Jun26 ?        00:00:00 /usr/bin/seapplet
sachi     3029  2380  0 Jun26 ?        00:00:00 abrt-applet
root     13024   948  0 09:11 ?        00:00:00 sshd: sachi [priv]
sachi    13033 13024  0 09:11 ?        00:00:00 sshd: sachi@pts/0
sachi    13039 13033  0 09:11 pts/0    00:00:00 -bash
sachi    13355 13039  0 09:13 pts/0    00:00:00 psql
gpadmin  13356  1436  0 09:13 ?        00:00:00 postgres: port  5432, sachi sachi [local] con120988 [local] idle
root     13358   948  0 09:13 ?        00:00:00 sshd: sachi [priv]
sachi    13363 13358  0 09:13 ?        00:00:00 sshd: sachi@pts/1
sachi    13370 13363  0 09:13 pts/1    00:00:00 -bash
sachi    17897 13370  0 09:40 pts/1    00:00:00 ps -ef
sachi    17898 13370  0 09:40 pts/1    00:00:00 grep --color=auto sachi

[sachi@localhost ~]$  ps -ef | awk '/sachi/ && /idle/'|grep -v awk
gpadmin  13356  1436  0 09:13 ?        00:00:00 postgres: port  5432, sachi sachi [local] con120988 [local] idle

[sachi@localhost ~]$  ps -ax | awk '/sachi/ && /idle/'|grep -v awk
13356 ?        Ssl    0:00 postgres: port  5432, sachi sachi [local] con120988 [local] idle

[sachi@localhost ~]$  ps -ax | awk '/sachi/ && /idlee/'|grep -v awk

[sachi@localhost ~]$  ps -ax | awk '/sachi/ && /idle/'|grep -v awk
13356 ?        Ssl    0:00 postgres: port  5432, sachi sachi [local] con120988 [local] idle

[sachi@localhost ~]$ ps -ef |grep sachi| grep -v idle
sachi     2380  2353  0 Jun26 ?        00:00:06 gnome-session --session gnome-classic
sachi     2388     1  0 Jun26 ?        00:00:00 dbus-launch --sh-syntax --exit-with-session
sachi     2396     1  0 Jun26 ?        00:00:00 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session
sachi     2484     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfsd
sachi     2551     1  0 Jun26 ?        00:00:00 /usr/libexec//gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
sachi     2554  2380  0 Jun26 ?        00:00:02 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "env GNOME_SHELL_SESSION_MODE=classic gnome-session --session gnome-classic"
sachi     2595     1  0 Jun26 ?        00:00:00 /usr/libexec/at-spi-bus-launcher
sachi     2599  2595  0 Jun26 ?        00:00:00 /bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
sachi     2603     1  0 Jun26 ?        00:00:00 /usr/libexec/at-spi2-registryd --use-gnome-session
sachi     2611  2380  0 Jun26 ?        00:00:22 /usr/libexec/gnome-settings-daemon
sachi     2627     1  0 Jun26 ?        00:00:02 /usr/bin/pulseaudio --start
sachi     2632     1  0 Jun26 ?        00:00:00 /usr/bin/gnome-keyring-daemon --start --components=ssh
sachi     2726     1  0 Jun26 ?        00:00:04 /usr/libexec/gvfs-udisks2-volume-monitor
sachi     2741     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfs-afc-volume-monitor
sachi     2746     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfs-mtp-volume-monitor
sachi     2750     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor
sachi     2754     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfs-goa-volume-monitor
sachi     2757     1  0 Jun26 ?        00:00:00 /usr/libexec/goa-daemon
sachi     2764     1  0 Jun26 ?        00:00:43 /usr/libexec/goa-identity-service
sachi     2766  2380  0 Jun26 ?        00:01:31 /usr/bin/gnome-shell
sachi     2773     1  0 Jun26 ?        00:00:00 /usr/libexec/dconf-service
sachi     2781     1  0 Jun26 ?        00:00:00 /usr/libexec/gsd-printer
sachi     2798     1  0 Jun26 ?        00:00:00 /usr/bin/ibus-daemon --replace --xim --panel disable
sachi     2806  2798  0 Jun26 ?        00:00:00 /usr/libexec/ibus-dconf
sachi     2808     1  0 Jun26 ?        00:00:00 /usr/libexec/ibus-x11 --kill-daemon
sachi     2816     1  0 Jun26 ?        00:00:00 /usr/libexec/gnome-shell-calendar-server
sachi     2820     1  0 Jun26 ?        00:00:06 /usr/libexec/mission-control-5
sachi     2832     1  0 Jun26 ?        00:00:00 /usr/libexec/evolution-source-registry
sachi     2840  2798  0 Jun26 ?        00:00:00 /usr/libexec/ibus-engine-simple
sachi     2942     1  0 Jun26 ?        00:00:00 /usr/libexec/evolution-addressbook-factory
sachi     2947     1  0 Jun26 ?        00:00:01 /usr/libexec/gconfd-2
sachi     2954     1  0 Jun26 ?        00:00:00 /usr/libexec/tracker-store
sachi     2970     1  0 Jun26 ?        00:00:00 /usr/libexec/evolution-calendar-factory
sachi     3010     1  0 Jun26 ?        00:00:00 /usr/libexec/gnome-session-failed --allow-logout
sachi     3014  2380  0 Jun26 ?        00:00:00 /usr/bin/seapplet
sachi     3029  2380  0 Jun26 ?        00:00:00 abrt-applet
root     13024   948  0 09:11 ?        00:00:00 sshd: sachi [priv]
sachi    13033 13024  0 09:11 ?        00:00:00 sshd: sachi@pts/0
sachi    13039 13033  0 09:11 pts/0    00:00:00 -bash
sachi    13355 13039  0 09:13 pts/0    00:00:00 psql
root     13358   948  0 09:13 ?        00:00:00 sshd: sachi [priv]
sachi    13363 13358  0 09:13 ?        00:00:00 sshd: sachi@pts/1
sachi    13370 13363  0 09:13 pts/1    00:00:00 -bash
sachi    21534 13370  0 10:02 pts/1    00:00:00 ps -ef
sachi    21535 13370  0 10:02 pts/1    00:00:00 grep --color=auto sachi
[sachi@localhost ~]$ ps -ef |grep sachi| grep -v idle|grep -v grep
sachi     2380  2353  0 Jun26 ?        00:00:06 gnome-session --session gnome-classic
sachi     2388     1  0 Jun26 ?        00:00:00 dbus-launch --sh-syntax --exit-with-session
sachi     2396     1  0 Jun26 ?        00:00:00 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session
sachi     2484     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfsd
sachi     2551     1  0 Jun26 ?        00:00:00 /usr/libexec//gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
sachi     2554  2380  0 Jun26 ?        00:00:02 /usr/bin/ssh-agent /bin/sh -c exec -l /bin/bash -c "env GNOME_SHELL_SESSION_MODE=classic gnome-session --session gnome-classic"
sachi     2595     1  0 Jun26 ?        00:00:00 /usr/libexec/at-spi-bus-launcher
sachi     2599  2595  0 Jun26 ?        00:00:00 /bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
sachi     2603     1  0 Jun26 ?        00:00:00 /usr/libexec/at-spi2-registryd --use-gnome-session
sachi     2611  2380  0 Jun26 ?        00:00:22 /usr/libexec/gnome-settings-daemon
sachi     2627     1  0 Jun26 ?        00:00:02 /usr/bin/pulseaudio --start
sachi     2632     1  0 Jun26 ?        00:00:00 /usr/bin/gnome-keyring-daemon --start --components=ssh
sachi     2726     1  0 Jun26 ?        00:00:04 /usr/libexec/gvfs-udisks2-volume-monitor
sachi     2741     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfs-afc-volume-monitor
sachi     2746     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfs-mtp-volume-monitor
sachi     2750     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor
sachi     2754     1  0 Jun26 ?        00:00:00 /usr/libexec/gvfs-goa-volume-monitor
sachi     2757     1  0 Jun26 ?        00:00:00 /usr/libexec/goa-daemon
sachi     2764     1  0 Jun26 ?        00:00:43 /usr/libexec/goa-identity-service
sachi     2766  2380  0 Jun26 ?        00:01:31 /usr/bin/gnome-shell
sachi     2773     1  0 Jun26 ?        00:00:00 /usr/libexec/dconf-service
sachi     2781     1  0 Jun26 ?        00:00:00 /usr/libexec/gsd-printer
sachi     2798     1  0 Jun26 ?        00:00:00 /usr/bin/ibus-daemon --replace --xim --panel disable
sachi     2806  2798  0 Jun26 ?        00:00:00 /usr/libexec/ibus-dconf
sachi     2808     1  0 Jun26 ?        00:00:00 /usr/libexec/ibus-x11 --kill-daemon
sachi     2816     1  0 Jun26 ?        00:00:00 /usr/libexec/gnome-shell-calendar-server
sachi     2820     1  0 Jun26 ?        00:00:06 /usr/libexec/mission-control-5
sachi     2832     1  0 Jun26 ?        00:00:00 /usr/libexec/evolution-source-registry
sachi     2840  2798  0 Jun26 ?        00:00:00 /usr/libexec/ibus-engine-simple
sachi     2942     1  0 Jun26 ?        00:00:00 /usr/libexec/evolution-addressbook-factory
sachi     2947     1  0 Jun26 ?        00:00:01 /usr/libexec/gconfd-2
sachi     2954     1  0 Jun26 ?        00:00:00 /usr/libexec/tracker-store
sachi     2970     1  0 Jun26 ?        00:00:00 /usr/libexec/evolution-calendar-factory
sachi     3010     1  0 Jun26 ?        00:00:00 /usr/libexec/gnome-session-failed --allow-logout
sachi     3014  2380  0 Jun26 ?        00:00:00 /usr/bin/seapplet
sachi     3029  2380  0 Jun26 ?        00:00:00 abrt-applet
root     13024   948  0 09:11 ?        00:00:00 sshd: sachi [priv]
sachi    13033 13024  0 09:11 ?        00:00:00 sshd: sachi@pts/0
sachi    13039 13033  0 09:11 pts/0    00:00:00 -bash
sachi    13355 13039  0 09:13 pts/0    00:00:00 psql
root     13358   948  0 09:13 ?        00:00:00 sshd: sachi [priv]
sachi    13363 13358  0 09:13 ?        00:00:00 sshd: sachi@pts/1
sachi    13370 13363  0 09:13 pts/1    00:00:00 -bash
sachi    21571 13370  0 10:02 pts/1    00:00:00 ps -ef
[sachi@localhost ~]$ 

Coomad to add an entry in the pg_hba.conf file of all the segments including master

posted Jan 8, 2015, 5:59 PM by Sachchida Ojha

1. Log into the master.

2. gpssh -f ~/gpconfigs/hostfile

3.$ps -ef | grep postgres | grep silent | grep -v grep | awk '{print $10}' | while read line ; do cp $line"/pg_hba.conf" $line"/pg_hba.conf.bk."$(date +"%m-%d-%Y-%H:%M:%S") ; done

4. ps -ef | grep postgres | grep silent | grep -v grep | awk '{print $10}' | while read line ; do echo "host all gpadmin 172.28.12.250/32 trust" >> $line"/pg_hba.conf" ; done

5.ps -ef | grep postgres | grep silent | grep -v grep | awk '{print $10}' | while read line ; do tail -1 $line/pg_hba.conf ; done

sample wrapper shell scripts for Unix newbie

posted Dec 4, 2014, 10:12 AM by Sachchida Ojha

The gadget spec URL could not be found
#!/bin/bash
##############################################################################################################################
#script name:sample_wrapper_script.sh
#Description: This script will analyze the tables in test schema.
#Version: 1.0
#date created: 12/04/2014
#date updated:
#reason for update:
##usage: nohup ./sample_wrapper_script.sh 2>&1 &
#dependency: analyze.sql
#Bug reports and enhancements: Contact us at gpdba@greenplumdba.com
The gadget spec URL could not be found
###############################################################################################################################
starttime=$(date +\%F_\%H:\%M)
dbname="prod"
scriptname="sample_wrapper_script"
logfile=${scriptname}_ouput_$starttime.log
touch $logfile
printf "\n#######################################################################################################################\n">>$logfile
printf "Script started at %s\n" "$starttime">>$logfile
printf "For bug fixes and enhancements, contact Sachi at gpdba@greenplumdba.com\n">>$logfile
printf "########################################################################################################################\n">>$logfile
debugflag="e"
echo "Script is running.Please wait.It may take few minutes..."
printf "ANALYZE started on IPM tables\n">>$logfile
psql -$debugflag -d $dbname -f analyze.sql

endtime=$(date +\%F_\%H:\%M)
printf "\n#######################################################################################################################\n">>$logfile
printf "Script completed at %s\n" "$endtime" >>$logfile
printf "\n#######################################################################################################################\n">>$logfile
####################################################################################################
# End of sample_wrapper_script.sh
####################################################################################################
echo "Script completed. Script log file is available. Log file name:$logfile "
The gadget spec URL could not be found

Date Difference function in unix

posted Nov 11, 2014, 4:19 PM by Sachchida Ojha

[gpadmin@sachi scripts]$ datediff (){
case $1 in
 -s)   sec=1;      shift;;
 -m)   sec=60;     shift;;
 -h)   sec=3600;   shift;;
 -d)   sec=86400;  shift;;
  *)    sec=86400;;
 esac
 dte1=$(date2stamp $1)
 dte2=$(date2stamp $2)
diffSec=$((dte2-dte1))
 if ((diffSec < 0)); then abs=-1; else abs=1; fi
echo $((diffSec/sec*abs))
}

[gpadmin@sachi scripts]$ datediff -s "2006-10-01" "2006-10-02"
86400
[gpadmin@sachi scripts]$ datediff -m "2006-10-01" "2006-10-02"
1440
[gpadmin@sachi scripts]$ datedDiff -h "2006-10-01" "2006-10-02"
24
[gpadmin@sachi scripts]$ datediff -d "2006-10-01" "2006-10-02"
1


How to get a one row select into bash variables named for each column in the row

posted Nov 11, 2014, 2:34 PM by Sachchida Ojha

psql -X --field-separator ' ' -At -d sachi -f sachi.sql|while read -r f1 f2 f3 f4 f5 f6; do echo "$f3"; done

The gadget spec URL could not be found

Read a File Line By Line in UNIX

posted Oct 15, 2014, 11:53 AM by Sachchida Ojha   [ updated Nov 4, 2014, 1:06 PM ]

How do I read a file line by line under UNIX using KSH or BASH shell?
The gadget spec URL could not be found
#!/bin/ksh 
file="/home/vivek/data.txt" 
while read line do # display $line or do somthing with $line 
echo "$line" done <"$file"

#!/bin/bash 
file="/home/vivek/data.txt" 
while IFS= read -r line 
do 
# display $line or do somthing with $line 
echo "$line" done <"$file"
The gadget spec URL could not be found
You can also read field wise:
#!/bin/bash 
file="/etc/passwd" 
while IFS=: read -r f1 f2 f3 f4 f5 f6 f7 do 
# display fields using f1, f2,..,f7 
echo "Username: $f1, Shell: $f7, Home Dir: $f6" done <"$file"

Routine maintenance jobs from Greenplum database

posted Sep 15, 2014, 1:46 PM by Sachchida Ojha

1. Execute following CRON JOB to do Vacuum FULL and analyze on a database - To be run on weekly basis

#!/bin/bash
## nohup /home/gpadmin/scripts/vacuum.sh > /var/tmp/vacuum_$(date +\%Y\%m\%d_\%H:\%M).log 2>&1 &
export GPHOME=/usr/local/greenplum-db
export MASTER_DATA_DIRECTORY=/data/master/gpseg-1
source $GPHOME/greenplum_path.sh
echo
cat << EOTEXT
************************************************************************
$(date) BEGIN Vacuum of all databases
************************************************************************
EOTEXT
vacuumdb -afx
echo
cat << EOTEXT
************************************************************************
$(date) END Vacuum of all databases
************************************************************************
EOTEXT
echo

2. Execute following CRON JOB to do Vacuum and analyze on a database - To be run on daily basis or after the ETL job..

#!/bin/bash
## nohup /home/gpadmin/scripts/vacuum.sh > /var/tmp/vacuum_$(date +\%Y\%m\%d_\%H:\%M).log 2>&1 &
export GPHOME=/usr/local/greenplum-db
export MASTER_DATA_DIRECTORY=/data/master/gpseg-1
source $GPHOME/greenplum_path.sh
echo
cat << EOTEXT
************************************************************************
$(date) BEGIN Vacuum of all databases
************************************************************************
EOTEXT
vacuumdb -ax
echo
cat << EOTEXT
************************************************************************
$(date) END Vacuum of all databases
************************************************************************
EOTEXT
echo



3. Execute following CRON JOB to do Vacuum on all database tables - To be run on daily basis or after the ETL job..

#!/bin/bash
## nohup /home/gpadmin/scripts/vacuum.sh > /var/tmp/vacuum_$(date +\%Y\%m\%d_\%H:\%M).log 2>&1 &
export GPHOME=/usr/local/greenplum-db
export MASTER_DATA_DIRECTORY=/data/master/gpseg-1
source $GPHOME/greenplum_path.sh
echo
cat << EOTEXT
************************************************************************
$(date) BEGIN Vacuum of all databases
************************************************************************
EOTEXT
vacuumdb -a
echo
cat << EOTEXT
************************************************************************
$(date) END Vacuum of all databases
************************************************************************
EOTEXT
echo

auto start sshd at boot time

posted May 20, 2013, 4:11 PM by Sachchida Ojha   [ updated May 20, 2013, 4:11 PM ]


How to automatically start sshd (secure shell service) on every system startup on Fedora 16


Fedora 16 is now using systemd. systemd is a system and service manager, it is a replacement for the System V init daemon for Linux. It is intended to provide a better framework for expressing services’ dependencies, allow more work to be done in parallel at system startup, and to reduce shell overhead.

If you want to start sshd manually once, run as root

# systemctl start sshd.service

In order to start it automatically on every system boot, run
# systemctl enable sshd.service

Likewise, you can remove it from system startup
# systemctl disable sshd.service

If you would like to see a list of all available managed services, run
# systemctl -a

netstat command

posted May 5, 2013, 5:22 PM by Sachchida Ojha   [ updated May 5, 2013, 5:22 PM ]

netstat  - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships


[sachi@sachi ~]$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.133.0   0.0.0.0         255.255.255.0   U         0 0          0 vmnet1
172.16.72.0     0.0.0.0         255.255.255.0   U         0 0          0 vmnet8
192.168.122.0   0.0.0.0         255.255.255.0   U         0 0          0 virbr0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
[sachi@sachi ~]$ 

ethtool command

posted May 5, 2013, 5:20 PM by Sachchida Ojha   [ updated May 5, 2013, 5:20 PM ]

ethtool is used for querying settings of an ethernet device and chang- ing them. 

ethX is the name of the ethernet device to work on.

[root@sachi network-scripts]# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes:   10baseT/Half 10baseT/Full 
                       100baseT/Half 100baseT/Full 
                       1000baseT/Half 1000baseT/Full 
Supports auto-negotiation: Yes
Advertised link modes:  10baseT/Half 10baseT/Full 
                       100baseT/Half 100baseT/Full 
                       1000baseT/Half 1000baseT/Full 
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Link partner advertised link modes:  10baseT/Half 10baseT/Full 
                                    100baseT/Half 100baseT/Full 
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000033 (51)
Link detected: yes

1-10 of 15