October 2025
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

October 2025
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

websphere: how to refresh security settings with scriptnig

after changing security settings, creating or modifying authentication alias you can reload security settings without restarting websphere processes.

reload security settings on specific websphere process

set agm [ $AdminControl queryNames type=AuthorizationGroupManager,process=,* ]
$AdminControl invoke $agm refreshAll

reload security settings on all processes

set agm [ $AdminControl queryNames type=AuthorizationGroupManager,* ]
for a $agm {
$AdminControl invoke $a refreshAll
}

how to check JMS queue depth using jacl

Case 1: check depth of 1 particular queue

set qpoint “WebSphere:*,type=SIBQueuePoint,name=MyQueuePointName”
set queues [$AdminControl queryNames $qpoint]
foreach q $queues {
set identifier [$AdminControl getAttribute $q identifier]
set size [$AdminControl getAttribute $q depth]
puts “$identifier size: $size messages”
puts [$AdminControl getAttributes $q]
}

Case 2: check all the queue points

set qpoint “WebSphere:*,type=SIBQueuePoint”
set queues [$AdminControl queryNames $qpoint]
foreach q $queues {
set identifier [$AdminControl getAttribute $q identifier]
set size [$AdminControl getAttribute $q depth]
puts “$identifier size: $size messages”
puts [$AdminControl getAttributes $q]
}

websphere mq: create queue manager

Create queue manager

crtmqm -c “QMANAGER DESCRIPTION” -q QMANAGER_NAME.QUEUE.MANAGER

Create queue manager and default queue

crtmqm -q -d DEFAULT.QUEUE -u SYSTEM.DEAD.LETTER.QUEUE -c “QMANAGER DESCRIPTION” QMANAGER_NAME.QUEUE.MANAGER

websphere mq: basic administration commands

launch
runmqsc

display queue manager(s)
display qmmgr(*)

display queue(s)
display queue(*)

display channel(s)
display channel(*)

display listener(s)
display listener(*)

check queue status
display qstatus(*)

clear queue
clear qlocal(queue_name)

display connections
display conn(*)

dspmq
runmqsc
dis chs (channel)
start chl (channel)
stop chl (channel)
reset chl (channel)
start chl (channel)
end

Start Q Manager
—————
strmqm OFB.OCE.QMGR

Stop Q Manager
———————–
endmqm -w OFB.OCC.QMGR

endmqm -w OFB.OCC.QMGR
flags:
-w wait for clients
-i immediate
Display listener status
———————–
dis lsstatus(*)
DIS LSSTATUS(*)

Display queue names and number of messages in the queue
——————————————————-
dis queue curdepth(*)

Display the queue Depth
——————————————–
dis ql (*) where (curdepth gt 500)

dis ql(*) CURDEPTH WHERE(CURDEPTH GT 0 )

Display where channel is RETRYING
————————————-
dis chs (*) where (status EQ running)

dis chs (*) where (status EQ retrying)

Display Current Sequence Number
——————————-
dis chs (channel) CURSEQNO
( * )

dis chl(*) -> display all channels
dis chs(*) -> display all channels that are running
dis chs (channel) -> display channel status
start chl (channel)
stop chl (channel)
reset chl (channel)
start chl (channel)
end

echo “dis q(*)” | runmqsc

endmqm qmanager
strmqm qmanager

Command to start the queue manger

Start the Quemanager
strmqm -x QMGR2

strmqm QMGR2

Stop the Queue Manager

endmqm qmanager

endmqm TPCAS.AUD.QMGR2

Check the queue manager is working

$ dspmq -x
QMNAME(TPCAS.AUD.QMGR1) STATUS(Running)
INSTANCE(instancename) MODE(Active)

Connect to queue manager

runmqsc QMGR1

dis channel (*)

Logs /var/mqm/errors

runmqsc ROLBRKPRDV.QM
STOP CHANNEL(VROLBRK.VIPC)
RESET CHANNEL(VROLBRK.VIPC) SEQNUM(407918)
START CHANNEL(VROLBRK.VIPC)

DISPLAY CHSTATUS (VROLBRK.VIPC.*)

DISPLAY CHSTATUS (CDISI.CORE.AUDIT)

runmqsc ROLBRKPRDS.QM
dis chl(B*)
start CHANNEL(BRKPRDS.TO.VP04VRL)

Start MQSC
1 runmqsc

MQSC:show queue information
1 display q()

MQSC:remove all messages from queue
1 clear ql()

MQSC:enable trigger on queue
1 alter ql() trigger

MQSC:disable trigger on queue
1 alter ql() notrigger

MQSC:show process information
1 display process()

Using runmqsc in a script
1 echo “dis q(*)” | runmqsc

This vill display all queues (‘dis q(*)’) on the qmanager

Using the q (ma01) program to distribute messages from one queue to two queues
1 q -m QMGR -I TEST.DISTLIST.IN -o TEST.DISTLIST.OUT1 -o TEST.DISTLIST.OUT2

endmqm qmanager
strmqm qmanager

runmqsc ROLBRKPRDV.QM
STOP CHANNEL(VROLBRK.VIPC)
RESET CHANNEL(VROLBRK.VIPC) SEQNUM(407918)
START CHANNEL(VROLBRK.VIPC)

DISPLAY CHSTATUS (VROLBRK.VIPC.*)

runmqsc ROLBRKPRDS.QM
dis chl(B*)
start CHANNEL()

Useful Commands for MQ administration

dspmqver :- to display MQ series version
dspmq :- to view all queue managers of MQ series.
crtmqm :- to create a queue manager
strmqm :- to start queue manager
runmqsc :- to enter in to particular queue manager
endmqm :- to end a queue manager
dltmqm :- to delete a queue manager
dspmqcsv :- to display command server
endmqcsv :- to end command server
strmqcsv :- to start command server
runmqlsr :- to run listener service
endmqlsr :- to end listener service
runmqchl :- to run a channel out of queue manager
runmqdlq :- to execute dead letter handle with the help of rule table
setmqaut :- to set authorizations for particular objects like queuemanager,queue’s channels, listeners to user or group
dspmqaut :- to display authorization for particular user
dmpmqaut :- to dump authorization for particular user
runmqchi :- to run a channel initiator for particular queue manager
runmqtrm :- to run trigger monitor on initiation queue for particular queue manager
rcdmqimg :- to take objects (or) record image of a particular queue manager objects
rcrmqobj :- to recreate the mq objects which are already recorded

Useful syntax of RUNMQSC utility for hadling QueueManager

DEFINE :- To define/create MQ manager objects like queue, Channels, process, and listener.
ALTER :- to update or modify the existing objects
DISPLAY :- to view all the properties of a particular object or to Display all objects
DELETE :- to delete created objects
CLEAR :- to clear the message from the queue
END :- to come out of the queue manager
PING :- to check whether other side channel / queue manager is ready to accept our request.
START :- to start the particular channel or listener
STOP :- to stop particular channel or listener
REFRESH :- used to refresh the security every time after giving or executing, set mgr or command for queue manager or object
RESET :- used to reset channel,cluster,queue manager
RESOLVE :- to resolve the channel which is in indoubt state
SUSPEND :- to suspend a queue manager from a cluster environment
RESUME :- to remove a queue manager from a cluster environment

IBM MQ Commands
July 27, 2007 at 2:09 am | Posted in MQ, Programming, Technology | 5 Comments

Some simple and useful IBM MQ Commands I found useful for debugging or testing the channels and queues.

Some MQ Commands

Use ‘mqm’ user

At : /usr/mqm/bin

Connect to Queue Manager
runmqsc

Display Channel info
dis channel(*)

Display Channel full info
dis chs(*) all

Check channel is alive
ping channel()

start channel()

Display Queue Alias Info
dis qa(*)

dis qa() all

Display Remote Queue Info
dis qr() all

Display Local Queue Info
dis ql(*) curdepth

Display Channel messages info including last message date and time
dis chs(*) msgs lstmsgda lstmsgti

Zerolize Counter (curdepth) in queue
runmqsc

stop CHANNEL()

start CHANNEL()

It should then show zero messages :
dis chs(*) msgs lstmsgda lstmsgti

Perform a test put message
cd /usr/mqm/samp/bin./amqsput

Test message

Backup the message

1. Logon to “sl73cdisapp001” using “mqm”
2. cd /home/mqm/admin/$QMGRNAME/qload
3. ./BackupAuditMsgs.sh $QMGRNAME – Take backup of messages in the “audit” Q to the “backup” Q
4. ./RestoreAuditMsgs.sh $QMGRNAME – Restore messages back to “Audit” Q
5. Check the Current depth of the Q.
6. runmqsc $QMGRNAME
7. dis ql (QNAME) curdepth

Backup messages from a Queue to a file:
Command: qload –m QM1 –i LQ1 –f c:\bkpmsg

import messages from a file to the queue:
Command: qload –m QM1 –o LQ1 –f c:\bkpmsg

Copying messages from a queue to another queue:
Command: qload –m QM1 –i LQ1 –o LQ2

======================================

MQ WORKS ON point to point

Assure delivery

Persittance

Fast connection is also open always

A —> B
Sender channel Reciever channel
reciever channel sender channel
LOCAL QUEUE LOCAL QUEUE
REMOTE QUEUE
RECIEVER QUEUE Local QUEUE
PORT 1414 1415
IP = 192.168.1.1 192.168.1.10

MQM

username mqm mqm

AIX – ROOT U+G created .bff

sol – root u+g before install manually .pkg

Lin – root u+g befor installl .rpm

win – !!! .exe

/opt/mqm = is binary placed

/var/mqm = we have logs

LIN SOL AIX WIN

BINARY /opt/mqm /opt/mqm /usr/mqm D/ E:/Program files

runtime /var/mqm /var/mqm /var/mqm

(Qmgr)

dspmqmver

check the arch
dspmqmver -a

crtmqm

crtmqm TESTQM1

to display
dspmqm

dspmqm

strmqm TESTQMQ1

endmqm -i TESTQMQ1

dspmqm

cd /var/mqm

qm.ini

ps -ef | grep mqlsr

runmqsc TESTQMQ1

display QMGR

dis channel

dis chl (*)

dis chl(*) where (TYPE EQ SDR)

dis q(*)

DEFINE LISTENER(TESTQM1.LS1) TRPTYPE (TCP) PORT (21414)

crtmqm TESTQMQ1

DEFINE QLOCAL (TESTQM1.LOCAL)

Alter QLOCAL (TESTQM1.LOCAL) MAXDEPTH(1000)

dis q (TESTQM1.LOCAL) MAXDEPTH

A —> B

Sender channel (testqm1.to.testqm2) Reciever channel (testqm1.to.testqm2)
reciever channel (testqm1.to.testqm1) sender channel (testqm2.to.testqm1)
LOCAL QUEUE LOCAL QUEUE
REMOTE QUEUE Transmission queue
RECIEVER QUEUE Local QUEUE
PORT 1414 1415
IP = 192.168.1.1 192.168.1.10

CREATE QM

crtmqm TESTC

define qlocal(TESTCQM2.TQ1) USAGE(XMITQ)

CREATE LISTENER

DEFINE LISTENER(TESTC.LS1) TRPTYPE(TCP) PORT(21418) control (qmgr)

LQ

define qlocal(TESTC.LQ1)

delete qlocal(TESTCQM1.LQ1) delete the queue manager

TQ

DEFINE qlocal(TESTC.TQ1) USAGE(XMITQ)

SENDER CHANNEL
DEFINE channel(TESTC.TO.TESTD) CHLTYPE(SDR) CONNAME(‘10.211.48.247(21419)’) XMITQ(‘TESTC.TQ1’)

DEFINE channel(TESTC.TO.TESTD) CHLTYPE(SDR) CONNAME(‘10.211.48.247(21419)’) XMITQ(‘TESTC.TQ1’)

RECEVER CHANNEL

DEFINE channel(TESTD.TO.TESTD) CHLTYPE(RCVR)

DEFINE channel(TESTD.TO.TESTC) CHLTYPE(RCVR)

RQ

define QREMOTE(TESTC.RQ1) RNAME(‘TESTD.LQ1’) RQMNAME(‘TESTD’) XMITQ(‘TESTC.TQ1’)

Test Functinality

dis listener(TESTC.LS1)
ping chl(TESTC.TO.TESTD)
dis channel(TESTC.TO.TESTD)
dis channel(TESTA.TO.TESTB)
start listener(TESTB.LS1)

crtmqm TESTB
DEFINE QLOCAL(TESTB.LQ1)
DEFINE LISTENER(TESTB.LS1) TRPTYPE(TCP) PORT(21415) control (qmgr)
DEFINE qlocal(TESTB.TQ1) USAGE(XMITQ)
define QREMOTE(TESTB.RQ1) RNAME(‘TESTA.LQ1’) RQMNAME(‘TESTA’) XMITQ(‘TESTB.TQ1’)
DEFINE channel(TESTA.TO.TESTB) CHLTYPE(RCVR)
DEFINE channel(TESTB.TO.TESTA) CHLTYPE(SDR) CONNAME(‘10.211.48.247(21416)’) XMITQ(‘TESTB.TQ1’)
dis listener(TESTB.LS1)
ping chl(TESTB.TO.TESTA)
dis channel(TESTB.TO.TESTA)
dis channel(TESTA.TO.TESTB)
start listener(TESTB.LS1)

Delte QUEUE MANAGER

dltmqm TESTC
dltmqm TESTD

IN CLUSTER

ALLWAYS CREATE RECIEVER

MQ CLUSETERING

software clustering (Active – Active)

Active – Passive

clussdr clusrcvr

we dont have TQ,RQ,SDR CHL RCR CHL

Full repository and partially Repository

crtmqm clusqm1
crtmqm clusqm2

strmqm clusqm1
strmqm clusqm2

define listener(CLUSQM1.LS1) TRPTYPE(TCP) PORT(21414)

Start listener(CLUSQM1.LS1)

How to clear the messages

clear command

amqsget

dis q(qm4.lq1) curdepth

/opt/mqm/samp/bin/amqsget

/opt/mqm/samp/bin/amqsgbr

/opt/mqm/samp/bin/amqsgbrc

CentOS 6.5_x64 install Oracle 11g R2

[root@oracledb ~]# hostname
oracledb
[root@oracledb ~]#

[root@oracledb ~]# vi /etc/hosts
[root@oracledb ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0C:29:E7:97:A3
inet addr:192.168.1.8  Bcast:192.168.1.255  Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fee7:97a3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:306 errors:0 dropped:0 overruns:0 frame:0
TX packets:202 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:32272 (31.5 KiB)  TX bytes:24144 (23.5 KiB)

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:720 (720.0 b)  TX bytes:720 (720.0 b)

[root@oracledb ~]# vi /etc/hosts
[root@oracledb ~]# hostname
oracledb
[root@oracledb ~]# hostname
oracledb
[root@oracledb ~]# sed -i “s/SELINUX=enforcing/SELINUX=disabled/” /etc/selinux/config
[root@oracledb ~]#  setenforce 0
[root@oracledb ~]#  yum -y install  gcc gcc-c++ make binutilscompat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-commonglibc-devel libaio libaio-devel libgcclibstdc++ libstdc++-devel unixODBC unixODBC-devel

[root@oracledb ~]# sysctl -p
[root@oracledb ~]# groupadd -g 200 oinstall
[root@oracledb ~]# groupadd -g 201 dba
[root@oracledb ~]# useradd -u 440 -g oinstall -G dba oracle
[root@oracledb ~]# passwd oracle
[root@oracledb ~]# vi /etc/sysctl.conf
net.ipv4.ip_local_port_range= 9000 65500
fs.file-max = 6815744
kernel.shmall = 10523004
kernel.shmmax = 6465333657
kernel.shmmni = 4096
kernel.sem = 250 32000 100128
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_max=1048576
fs.aio-max-nr = 1048576

[root@oracledb ~]# vi /etc/pam.d/login
session    required    pam_namespace.so
session    required    pam_limits.so
vi /etc/profile

if [ $USER =”oracle” ]; then
if [ $SHELL = “/bin/ksh” ];then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
[root@oracledb ~]# mkdir /opt/oracle/app/
[root@oracledb ~]# mkdir /opt/oracle/oradata/
[root@oracledb ~]# chmod 755 /opt/oracle/
[root@oracledb ~]# chmod 775 /opt/oracle/app/
[root@oracledb ~]# chown oracle.oinstall -R /opt/oracle/
[oracle@oracledb ~]$ vi ~/.bash_profile
export ORACLE_BASE=/opt/oracle/app
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_PID=orcl

working one

ORACLE_BASE=/opt/oracle/app/oracle;
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1;
ORACLE_SID=orcl;
LD_LIBRARY_PATH=$ORACLE_HOME/lib;
PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin;
export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH;

[oracle@oracledb ~]$ source .bash_profile
# vi /etc/rc.d/init.d/oracle

Oracle

#! /bin/bash
# chkconfig: 234 61 61
# description: Oracle 11g AutoRun Service
# /etc/rc.d/init.d/oracle

case “$1” in
start)
# starts oracle listener and instance
echo “Starting Oracle Database:”
su – oracle -lc “lsnrctl start”
su – oracle -lc dbstartup
;;
stop)
# shutdown oracle listner and instance
echo “Shuting down Oracle Database:”
su – oracle -lc “lsnrctl stop”
su – oracle -lc dbshutdown
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo “Usage: {start|stop|reload|restart}”
exit 1
esac
exit 0
dbstart dbshut

2?dbstartup dbshutdown

$ vi $ORACLE_HOME/bin/dbstartup

#dbstartup
#/opt/oracle/102/bin
sqlplus / as sysdba <<EOF
startup
exit
EOF
vi$ORACLE_HOME/bin/dbshutdown

#dbshutdown
#/home/oracle/102/bin
sqlplus / as sysdba <<EOF
shutdown immediate
exit
EOF

3?

# cd /etc/rc.d/init.d
# ./oracle start
# ./oracle stop

4?oracle

# chmod 750 /etc/rc.d/init.d/oracle
# chkconfig –level 234 oracle on
# chkconfig –add oracle
[root@oracledb software]# unzip linuxamd64_12102_database_1of2.zip
[root@oracledb software]# unzip linuxamd64_12102_database_2of2.zip

[root@oracledb~]# xhost +
[root@oracledb~]# su – oracle
[root@oracledb~]# ./software/database/runinstaller

db 001 db 002 db 003 db 004 db 005 db 006 db 007 db 008 db 009 db 010 db 011 db 012 db 013 db 014 db 015 db 016 db 017 db 018 db 019 db 020 db 021 db 022 db 023

 

[root@oracledb CVU_11.2.0.1.0_oracle]# sh runfixup.sh
Response file being used is :./fixup.response
Enable file being used is :./fixup.enable
Log file location: ./orarun.log
Setting Kernel Parameters…
The value for semopm in response file is not greater than value for semopm in /etc/sysctl.conf file. Hence not changing it.
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
The value for file-max in response file is not greater than value for file-max in /etc/sysctl.conf file. Hence not changing it.
fs.file-max = 6815744
The upper limit of ip_local_port range in reponse file is not greater than value in /etc/sysctl.conf, hence not changing it.
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default=262144
The value for rmem_default in response file is not greater than value for rmem_default in /etc/sysctl.conf file. Hence not changing it.
net.core.rmem_default = 262144
net.core.wmem_default=262144
The value for wmem_default in response file is not greater than value for wmem_default in /etc/sysctl.conf file. Hence not changing it.
net.core.wmem_default = 262144
net.core.rmem_max=4194304
The value for rmem_max in response file is not greater than value for rmem_max in /etc/sysctl.conf file. Hence not changing it.
net.core.rmem_max = 4194304
net.core.wmem_max=1048576
The value for wmem_max in response file is not greater than value for wmem_max in /etc/sysctl.conf file. Hence not changing it.
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
The value for aio-max-nr in response file is not greater than value for aio-max-nr in /etc/sysctl.conf file. Hence not changing it.
fs.aio-max-nr = 1048576
[root@oracledb CVU_11.2.0.1.0_oracle]#yum install libaio* glibc* compat-libstdc* libaio-devel* libgcc* libstc++* unixoDBC* pdksh*

download the url from

http://mirror.centos.org/centos/6.5/os/i386/Packages/
http://mirror.centos.org/centos/6.5/os/i386/Packages/

wget http://mirror.centos.org/centos/6.5/os/i386/Packages/libaio-0.3.107-10.el6.i686.rpm
wget http://mirror.centos.org/centos/6.5/os/i386/Packages/libaio-devel-0.3.107-10.el6.i686.rpm
wget http://mirror.centos.org/centos/6.5/os/i386/Packages/compat-libstdc++-33-3.2.3-69.el6.i686.rpm
wget http://mirror.centos.org/centos/6.5/os/i386/Packages/libgcc-4.4.7-4.el6.i686.rpm
wget http://mirror.centos.org/centos/6.5/os/i386/Packages/libstdc++-4.4.7-4.el6.i686.rpm
wget http://mirror.centos.org/centos/6.5/os/i386/Packages/unixODBC-2.2.14-12.el6_3.i686.rpm
wget http://mirror.centos.org/centos/6.5/os/i386/Packages/unixODBC-devel-2.2.14-12.el6_3.i686.rpm

yum install libaio*
yum install libaio* glibc* compat-libstdc*
yum install libaio* glibc* compat-libstdc* libaio-devel* libgcc* libstc++* unixoDBC* pdksh*
yum install libgcc* libstc++* unixoDBC* pdksh*
yum search unixODBC
yum install libgcc* libstc++* unixODBC* pdksh*
yum install libgcc++*
yum search PDF
yum search pdksh
yum install mksh
yum search unixODBC*
yum search unixODBC
yum install unixODBC-devel.i686 unixODBC-devel.x86_64 unixODBC.i686 unixODBC.x86_64

rpm -ivh compat-libstdc++-33-3.2.3-69.el6.i686.rpm
rpm -ivh libaio-0.3.107-10.el6.i686.rpm
rpm -ivh libaio-devel-0.3.107-10.el6.i686.rpm
rpm -ivh libstdc++-4.4.7-4.el6.i686.rpm
80 yum remove libstdc++
81 rpm -ivh libstdc++-4.4.7-4.el6.i686.rpm
82 ls
83 yum remove unixODBC
84 ls
85 rpm -ivh unixODBC-2.2.14-12.el6_3.i686.rpm unixODBC-devel-2.2.14-12.el6_3.i686.rpm

Oracle common commands
[root @ oracledb ~] # su -oracle
[oracle @ oracledb ~] # sqlplus / as sysdba
SQL> startup # Start the database instance
SQL> shutdown immediate # close the database instance
SQL> select * from tab; # View all the tables
SQL> select name from v$datafile; # view database storage directory
SQL> show parameter service # View service name
SQL> select * from v$instance; # View instance name
SQL> select name from v$database; # Check the database name
SQL> select * from dba_users; # view all user information
SQL> select username, password from dba_users; # only query the user and password
SQL> select * from v$pwfile_users; # View user with sysdba privileges
SQL> select * from dba_ustats; # view the current user information
SQL> select * fromuser_sys_privs # view the permissions of the current user’s system
SQL> select * fromuser_role_privs # view the current user role
SQL> select * fromdba_sys_privs # View system permissions for the specified user has
SQL> select * from v$version; # View oracle version
SQL> select * fromuser_views # View View Information
SQL> show user
USER is “SYS”

SQL> select banner from v$version;

BANNER
——————————————————————————–
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 – 64bit Production
PL/SQL Release 11.2.0.1.0 – Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 – Production
NLSRTL Version 11.2.0.1.0 – Production

[root @ oracledb ~] # lsnrctl start # turn on the remote listening port
### Remote connection information

oracle user
#sys and system users difference
Different 1> the importance of storing data
sys to store the data dictionary base tables and views, maintained by the database itself, any user can manually change, sys user owns dba, sysdba, sysoper other roles or privileges, is the highest authority oracle user.
The system users only store some level of internal data, such as management information oracle of some features or tools. For database management, System users have ordinary dba role permissions.
2> Different permissions
sysoper sys user with sysdba or system privileges, log em can only use these two identities, can not use normal.
system user can log on em with normal identity, unless you have it granted sysdba system privileges or syspoer system privileges.
#sysdba and sysoper difference between the two systems permissions
normal ordinary users
sysdba has the highest system privileges, log is sys
sysoper mainly used to start, shut down the database login user is public after sysoper
The difference #dba and sysdba
First understand the process of creating the next oracle service: Create an instance -> Start Instance -> Create Database
Startup process: Example start -> Load Database -> Open Database
sysdba is to manage the oracle instance, its existence does not depend on the entire database is fully activated, as long as the instance starts up, it already exists as sysdba login, load the database, open the database. Only the database is open, or the entire database completely after starting, dba role only exists foundation.

POODLE = Padding Oracle On Downgraded Legacy Encryption

POODLE = Padding Oracle On Downgraded Legacy Encryption

B.E.A.S.T (Browser Exploit Against SSL TLS)
Affected systems:
Netscape 3.0 ssl tls Netscape affected system: tls Netscape 1.2 Netscape 1.1 tls tls Netscape 1.0
Description: CVE (CAN) ID: CVE-2014-3566

SSL3.0 is obsolete and no security protocol, has been TLS 1.0, TLS 1.1, TLS 1.2 substitution, for compatibility reasons, most of the TLS implementation is still compatible SSL3.0.

Order generic considerations, the current versions of most browsers support SSL3.0, handshake phase contains a version of the TLS protocol negotiation procedure, in general, the client and the latest version of the protocol server will be used. When the handshake phase of its server version of consultations carried out, first offer its latest version of the support agreement, if the handshake fails, then try to negotiate an older version of the protocol. An attacker able to implement the-middle attack by the affected versions of the browser and the server side using the newer protocol negotiated connection fails, you can successfully downgrade attack, allowing the client and server communicate using insecure SSL3.0, At this time, due to the use of SSL 3.0 CBC block encryption implementations exist vulnerability, an attacker can successfully break the encryption SSL connection information, such as access to the user cookie data. This attack is called POODL attack (Padding Oracle On downgraded Legacy Encryption).

This vulnerability affects the majority of SSL server and client, extensive sphere of influence. If you want to use, but the attacker is successful, need to be able to control data (Executive middle attack) between the client and the server.
On October 14th, 2014, a vulnerability in version 3 of the SSL encryption protocol was disclosed. This vulnerability, dubbed POODLE (Padding Oracle On Downgraded Legacy Encryption), allows an attacker to read information encrypted with this version of the protocol in plain text using a man-in-the-middle attack.

Although SSLv3 is an older version of the protocol which is mainly obsolete, many pieces of software still fall back on SSLv3 if better encryption options are not available. More importantly, it is possible for an attacker to force SSLv3 connections if it is an available alternative for both participants attempting a connection.

The POODLE vulnerability affects any services or clients that make it possible to communicate using SSLv3. Because this is a flaw with the protocol design, and not an implementation issue, every piece of software that uses SSLv3 is vulnerable.

To find out more information about the vulnerability, consult the CVE information found at CVE-2014-3566.

What is the POODLE Vulnerability?
The POODLE vulnerability is a weakness in version 3 of the SSL protocol that allows an attacker in a man-in-the-middle context to decipher the plain text content of an SSLv3 encrypted message.

Who is Affected by this Vulnerability?
This vulnerability affects every piece of software that can be coerced into communicating with SSLv3. This means that any software that implements a fallback mechanism that includes SSLv3 support is vulnerable and can be exploited.

Some common pieces of software that may be affected are web browsers, web servers, VPN servers, mail servers, etc.

How Does It Work?
In short, the POODLE vulnerability exists because the SSLv3 protocol does not adequately check the padding bytes that are sent with encrypted messages.

Since these cannot be verified by the receiving party, an attacker can replace these and pass them on to the intended destination. When done in a specific way, the modified payload will potentially be accepted by the recipient without complaint.

An average of once out of every 256 requests will accepted at the destination, allowing the attacker to decrypt a single byte. This can be repeated easily in order to progressively decrypt additional bytes. Any attacker able to repeatedly force a participant to resend data using this protocol can break the encryption in a very short amount of time.

How Can I Protect Myself?
Actions should be taken to ensure that you are not vulnerable in your roles as both a client and a server. Since encryption is usually negotiated between clients and servers, it is an issue that involves both parties.

Servers and clients should should take steps to disable SSLv3 support completely. Many applications use better encryption by default, but implement SSLv3 support as a fallback option. This should be disabled, as a malicious user can force SSLv3 communication if both participants allow it as an acceptable method.

How To Protect Common Applications
Below, we’ll cover how to disable SSLv3 on some common server applications. Take care to evaluate your servers to protect any additional services that may rely on SSL/TCP encryption.

Because the POODLE vulnerability does not represent an implementation problem and is an inherent issue with the entire protocol, there is no workaround and the only reliable solution is to not use it.

Apache
Use the following command in the mod_ssl configuration file to disable SSLv2 and SSLv3:
SSLProtocol all -SSLv2 -SSLv3 +TLSv1 +TLSv1.1 +TLSv1.2
restart Apache

IBM IHS
SSLProtocolDisable SSLv2 SSLv3
restart ibm ihs

How to test the sslv3 enabled 

openssls_client -connect <webserver>:443 -ssl3

 

Nginx

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
restart Nginx
IIS

IIS:
Find the following registry key:
HKey_Local_Machine\System\CurrentControlSet\Control\SecurityProviders \SCHANNEL\Protocols
of the registry entry usually contains the following subkey:
* PCT 1.0
* SSL 2.0
* SSL 3.0
* TLS 1.0
are reserved for each registry entry The agreement applies to the relevant information. You can disable any of these agreements on the server. To do this,
create a new DWORD value in the protocol SSL Server 3.0’s child. Set the DWORD value to “00 million.”

Browser Prohibited Method:

IE:
“Tools” ->”Internet Options” -> “Advanced”, uncheck “Use SSL 3.0” check box.

Chrome:

Copy a shortcut usually open Chrome browser on the new shortcut, right-click, enter the property,
at the end of the “target” in the field of space after entering the following command –ssl-version-min = tls1

FireFox:

In the address bar, enter “about: config”, then security.tls.version.min adjusted to 1.

MySQL

openssl ciphers -v ‘DEFAULT’ | awk ‘/SSLv3 Kx=(RSA|DH|DH(512))/ { print $1 }’
DHE-RSA-AES256-SHA
DHE-DSS-AES256-SHA
DHE-RSA-CAMELLIA256-SHA
DHE-DSS-CAMELLIA256-SHA
AES256-SHA
CAMELLIA256-SHA
EDH-RSA-DES-CBC3-SHA
EDH-DSS-DES-CBC3-SHA
DES-CBC3-SHA
DHE-RSA-AES128-SHA
DHE-DSS-AES128-SHA
DHE-RSA-SEED-SHA
DHE-DSS-SEED-SHA
DHE-RSA-CAMELLIA128-SHA
DHE-DSS-CAMELLIA128-SHA
AES128-SHA
SEED-SHA
CAMELLIA128-SHA
RC4-SHA
RC4-MD5
EDH-RSA-DES-CBC-SHA
EDH-DSS-DES-CBC-SHA
DES-CBC-SHA
EXP-EDH-RSA-DES-CBC-SHA
EXP-EDH-DSS-DES-CBC-SHA
EXP-DES-CBC-SHA
EXP-RC2-CBC-MD5
EXP-RC4-MD5

mysql -se “SHOW STATUS LIKE ‘Ssl_cipher_list’” | sed ‘s/:/n/g’ | sed ‘s/Ssl_cipher_listss//g’ |
while read sspec;
do SPEC=openssl ciphers -v “$sspec” 2>/dev/null | grep -v SSLv3 | awk ‘{print $1}’;
[[ “$sspec” == “$SPEC” ]] && mysql –ssl-cipher=$sspec -e QUIT 2>/dev/null && echo “$sspec OK”;
done
HAPROXY

To disable SSLv3 in an HAProxy load balancer, you will need to open the haproxy.cfg file.

This is located at /etc/haproxy/haproxy.cfg:

nano /etc/haproxy/haproxy.cfg
In your front end configuration, if you have SSL enabled, your bind directive will specify the public IP address and port. If you are using SSL, you will want to add no-sslv3 to the end of this line:

frontend name
bind public_ip:443 ssl crt /path/to/certs no-sslv3
Save and close the file.

You will need to restart the service to implement the changes:

service haproxy restart
OpenVPN VPN Server
Recent versions of OpenVPN actually do not allow SSLv3. The service is not vulnerable to this specific problem, so you will not need to adjust your configuration.

See this post on the OpenVPN forums for more information.

Postfix SMTP Server
If your Postfix configuration is set up to require encryption, it will use a directive called smtpd_tls_mandatory_protocols.

You can find this in the main Postfix configuration file:

nano /etc/postfix/main.cf
For a Postfix server set up to use encryption at all times, you can ensure that SSLv3 and SSLv2 are not accepted by setting this parameter. If you do not force encryption, you do not have to do anything:

smtpd_tls_mandatory_protocols=!SSLv2, !SSLv3
Save your configuration. Restart the service to implement your changes:

service postfix restart
Dovecot IMAP and POP3 Server
In order to disable SSLv3 on a Dovecot server, you will need to adjust a directive called ssl_protocols. Depending on your distributions packaging methods, SSL configurations may be kept in an alternate configuration file.

For most distros, you can adjust this directive by opening this file:

nano /etc/dovecot/conf.d/10-ssl.conf
Inside, if you are using Dovecot 2.1 or higher, set the ssl_protocols directive to disable SSLv2 and SSLv3:

ssl_protocols = !SSLv3 !SSLv2
If you are using a version of Dovecot lower than 2.1, you can set the ssl_cipher_list to disallow SSLv3 like this:

ssl_cipher_list = ALL:!LOW:!SSLv2:!EXP:!aNULL:!SSLv3
Save and close the file.

Restart the service in order to implement your changes:

service dovecot restart

Logical Volume Manager

Server:  Centos Logical Volume
diskserver.rmohan.com (Centos 6.5)  = 192.168.1.6

Disk to use:
 Disk /dev/sdb: 50GB  DISK A
 Disk /dev/sdc: 50GB  DISK B
 Disk /dev/sdd: 50GB  DISK C

 

 

 

Image 001 Image 002 Image 003
Disk /dev/sdb: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdc: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdd: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

fdisk -cu  /dev/sdb
[root@diskserver ~]# fdisk -cu  /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x50497d5f.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-104857599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):
Using default value 104857599

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

fdisk -cu  /dev/sdc

fdisk -cu  /dev/sdd
root@diskserver ~]# fdisk -cu  /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x1f69e4f5.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-104857599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):
Using default value 104857599

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

[root@diskserver ~]# pvcreate /dev/sdb1
Physical volume “/dev/sdb1” successfully created
[root@diskserver ~]# pvcreate /dev/sdc1
dev_is_mpath: failed to get device for 8:33
Physical volume “/dev/sdc1” successfully created
[root@diskserver ~]# pvcreate /dev/sdd1
dev_is_mpath: failed to get device for 8:49
Physical volume “/dev/sdd1” successfully created

[root@diskserver ~]# vgcreate vg01 /dev/sdb1 /dev/sdc1
Volume group “vg01” successfully created
[root@diskserver ~]# lvcreate –extents 100%FREE –name lv_test vg01
Logical volume “lv_test” created

[root@diskserver ~]# mkfs.ext4 /dev/mapper/vg01-lv_test
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26212352 blocks
1310617 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@diskserver ~]# mkdir /media/my_disk
[root@diskserver ~]# mount /dev/mapper/vg01-lv_test /media/my_disk/
[root@diskserver ~]# df -H
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_diskserver-lv_root
52G  1.1G   48G   3% /
tmpfs                 4.1G     0  4.1G   0% /dev/shm
/dev/sda1             508M   58M  425M  12% /boot
/dev/mapper/vg_diskserver-lv_home
5.1G  145M  4.7G   4% /home
/dev/mapper/vg01-lv_test
106G  197M  101G   1% /media/my_disk
[root@diskserver ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_diskserver-lv_root
48G  1.1G   45G   3% /
tmpfs                 3.8G     0  3.8G   0% /dev/shm
/dev/sda1             485M   55M  405M  12% /boot
/dev/mapper/vg_diskserver-lv_home
4.7G  138M  4.4G   4% /home
/dev/mapper/vg01-lv_test
99G  188M   94G   1% /media/my_disk

[root@diskserver ~]# dd if=/dev/zero of=/media/my_disk/noodles.log bs=1572864000 count=1
1+0 records in
1+0 records out
1572864000 bytes (1.6 GB) copied, 7.80047 s, 202 MB/s

[root@diskserver ~]# pvcreate /dev/sdd1
Physical volume “/dev/sdd1” successfully created
[root@diskserver ~]# vgextend vg01 /dev/sdd1
Volume group “vg01” successfully extended
[root@diskserver ~]#

[root@diskserver ~]# vgdisplay -v vg01
Using volume group(s) on command line
Finding volume group “vg01”
— Volume group —
VG Name               vg01
System ID
Format                lvm2
Metadata Areas        3
Metadata Sequence No  3
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                1
Open LV               1
Max PV                0
Cur PV                3
Act PV                3
VG Size               149.99 GiB
PE Size               4.00 MiB
Total PE              38397
Alloc PE / Size       25598 / 99.99 GiB
Free  PE / Size       12799 / 50.00 GiB
VG UUID               mOZfFu-K2kJ-iD4i-GkD0-4yLa-zPOE-WGfCnd

— Logical volume —
LV Path                /dev/vg01/lv_test
LV Name                lv_test
VG Name                vg01
LV UUID                hHBSUc-bdg0-eg3K-8eWb-A7pm-pcX8-ikLId9
LV Write Access        read/write
LV Creation host, time diskserver, 2014-10-16 07:05:28 +0800
LV Status              available
# open                 1
LV Size                99.99 GiB
Current LE             25598
Segments               2
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:3

— Physical volumes —
PV Name               /dev/sdb1
PV UUID               NaqfCR-EM8Q-LTHp-vQZf-5mSi-tTF2-kClwyJ
PV Status             allocatable
Total PE / Free PE    12799 / 0

PV Name               /dev/sdc1
PV UUID               Gm32iH-i5FJ-BfSp-3SBw-XjJ3-jAcA-grQUdr
PV Status             allocatable
Total PE / Free PE    12799 / 0

PV Name               /dev/sdd1
PV UUID               jYNKlQ-T5oK-Hw4M-6uyj-ZoJq-4NSJ-AGzYOw
PV Status             allocatable
Total PE / Free PE    12799 / 12799

[root@diskserver ~]# vgextend vg01 /dev/sdd1
Physical volume ‘/dev/sdd1’ is already in volume group ‘vg01’
Unable to add physical volume ‘/dev/sdd1’ to volume group ‘vg01’.
[root@diskserver ~]#

[root@diskserver ~]# vgdisplay -v vg01
Using volume group(s) on command line
Finding volume group “vg01”
— Volume group —
VG Name               vg01
System ID
Format                lvm2
Metadata Areas        3
Metadata Sequence No  3
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                1
Open LV               1
Max PV                0
Cur PV                3
Act PV                3
VG Size               149.99 GiB
PE Size               4.00 MiB
Total PE              38397
Alloc PE / Size       25598 / 99.99 GiB
Free  PE / Size       12799 / 50.00 GiB
VG UUID               mOZfFu-K2kJ-iD4i-GkD0-4yLa-zPOE-WGfCnd

— Logical volume —
LV Path                /dev/vg01/lv_test
LV Name                lv_test
VG Name                vg01
LV UUID                hHBSUc-bdg0-eg3K-8eWb-A7pm-pcX8-ikLId9
LV Write Access        read/write
LV Creation host, time diskserver, 2014-10-16 07:05:28 +0800
LV Status              available
# open                 1
LV Size                99.99 GiB
Current LE             25598
Segments               2
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:3

— Physical volumes —
PV Name               /dev/sdb1
PV UUID               NaqfCR-EM8Q-LTHp-vQZf-5mSi-tTF2-kClwyJ
PV Status             allocatable
Total PE / Free PE    12799 / 0

PV Name               /dev/sdc1
PV UUID               Gm32iH-i5FJ-BfSp-3SBw-XjJ3-jAcA-grQUdr
PV Status             allocatable
Total PE / Free PE    12799 / 0

PV Name               /dev/sdd1
PV UUID               jYNKlQ-T5oK-Hw4M-6uyj-ZoJq-4NSJ-AGzYOw
PV Status             allocatable
Total PE / Free PE    12799 / 12799

[root@diskserver ~]# pvs -o+pv_used
PV         VG            Fmt  Attr PSize  PFree  Used
/dev/sda2  vg_diskserver lvm2 a–  59.51g     0  59.51g
/dev/sdb1  vg01          lvm2 a–  50.00g     0  50.00g
/dev/sdc1  vg01          lvm2 a–  50.00g     0  50.00g
/dev/sdd1  vg01          lvm2 a–  50.00g 50.00g     0
[root@diskserver ~]# pvmove /dev/sdc1
/dev/sdc1: Moved: 0.0%
/dev/sdc1: Moved: 17.1%
/dev/sdc1: Moved: 34.1%
/dev/sdc1: Moved: 51.1%
/dev/sdc1: Moved: 68.1%
/dev/sdc1: Moved: 84.6%
/dev/sdc1: Moved: 100.0%
[root@diskserver ~]#
root@diskserver ~]# pvs -o+pv_used
PV         VG            Fmt  Attr PSize  PFree  Used
/dev/sda2  vg_diskserver lvm2 a–  59.51g     0  59.51g
/dev/sdb1  vg01          lvm2 a–  50.00g     0  50.00g
/dev/sdc1  vg01          lvm2 a–  50.00g 50.00g     0
/dev/sdd1  vg01          lvm2 a–  50.00g     0  50.00g
[root@diskserver ~]#
[root@diskserver ~]# vgreduce vg01 /dev/sdc1
Removed “/dev/sdc1” from volume group “vg01”
[root@diskserver ~]#
[root@diskserver ~]# cat /media/my_disk/myfile.txt
my file
[root@diskserver ~]# cat /media/my_disk/
lost+found/  myfile.txt   noodles.log
[root@diskserver ~]# cat /media/my_disk/noodles.log
^C
[root@diskserver ~]# du -hs /media/my_disk/noodles.log
1.5G    /media/my_disk/noodles.log
[root@diskserver ~]#
root@diskserver ~]# vgdisplay -vv vg01
Setting activation/monitoring to 1
Setting global/locking_type to 1
Setting global/wait_for_locks to 1
File-based locking selected.
Setting global/locking_dir to /var/lock/lvm
Setting global/prioritise_write_locks to 1
Using volume group(s) on command line
Finding volume group “vg01”
Locking /var/lock/lvm/V_vg01 RB
/dev/ram0: No label detected
/dev/root: size is 102236160 sectors
/dev/root: size is 102236160 sectors
/dev/root: No label detected
/dev/ram1: No label detected
/dev/sda1: No label detected
/dev/vg_diskserver/lv_swap: size is 12582912 sectors
/dev/vg_diskserver/lv_swap: size is 12582912 sectors
/dev/vg_diskserver/lv_swap: No label detected
/dev/ram2: No label detected
/dev/sda2: lvm2 label detected at sector 1
/dev/vg_diskserver/lv_home: size is 9977856 sectors
/dev/vg_diskserver/lv_home: size is 9977856 sectors
/dev/vg_diskserver/lv_home: No label detected
/dev/ram3: No label detected
/dev/vg01/lv_test: size is 209698816 sectors
/dev/vg01/lv_test: size is 209698816 sectors
/dev/vg01/lv_test: No label detected
/dev/ram4: No label detected
/dev/ram5: No label detected
/dev/ram6: No label detected
/dev/ram7: No label detected
/dev/ram8: No label detected
/dev/ram9: No label detected
/dev/ram10: No label detected
/dev/ram11: No label detected
/dev/ram12: No label detected
/dev/ram13: No label detected
/dev/ram14: No label detected
/dev/ram15: No label detected
/dev/sdb1: lvm2 label detected at sector 1
/dev/sdc1: lvm2 label detected at sector 1
/dev/sdd1: lvm2 label detected at sector 1
— Volume group —
VG Name               vg01
System ID
Format                lvm2
Metadata Areas        2
Metadata Sequence No  7
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                1
Open LV               1
Max PV                0
Cur PV                2
Act PV                2
VG Size               99.99 GiB
PE Size               4.00 MiB
Total PE              25598
Alloc PE / Size       25598 / 99.99 GiB
Free  PE / Size       0 / 0
VG UUID               mOZfFu-K2kJ-iD4i-GkD0-4yLa-zPOE-WGfCnd

— Logical volume —
global/lvdisplay_shows_full_device_path not found in config: defaulting to 0
LV Path                /dev/vg01/lv_test
LV Name                lv_test
VG Name                vg01
LV UUID                hHBSUc-bdg0-eg3K-8eWb-A7pm-pcX8-ikLId9
LV Write Access        read/write
LV Creation host, time diskserver, 2014-10-16 07:05:28 +0800
LV Status              available
# open                 1
LV Size                99.99 GiB
Current LE             25598
Segments               2
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:3

— Physical volumes —
PV Name               /dev/sdb1
PV UUID               NaqfCR-EM8Q-LTHp-vQZf-5mSi-tTF2-kClwyJ
PV Status             allocatable
Total PE / Free PE    12799 / 0

PV Name               /dev/sdd1
PV UUID               jYNKlQ-T5oK-Hw4M-6uyj-ZoJq-4NSJ-AGzYOw
PV Status             allocatable
Total PE / Free PE    12799 / 0

Unlocking /var/lock/lvm/V_vg01

[root@diskserver ~]# pvs
PV         VG            Fmt  Attr PSize  PFree
/dev/sda2  vg_diskserver lvm2 a–  59.51g     0
/dev/sdb1  vg01          lvm2 a–  50.00g     0
/dev/sdc1                lvm2 a–  50.00g 50.00g
/dev/sdd1  vg01          lvm2 a–  50.00g     0
[root@diskserver ~]# vgs
VG            #PV #LV #SN Attr   VSize  VFree
vg01            2   1   0 wz–n- 99.99g    0
vg_diskserver   1   3   0 wz–n- 59.51g    0
[root@diskserver ~]# lvs
LV      VG            Attr       LSize  Pool Origin Data%  Move Log Cpy%Sync Convert
lv_test vg01          -wi-ao—- 99.99g
lv_home vg_diskserver -wi-ao—-  4.76g
lv_root vg_diskserver -wi-ao—- 48.75g
lv_swap vg_diskserver -wi-ao—-  6.00g
[root@diskserver ~]#

[root@diskserver ~]# lvdisplay
— Logical volume —
LV Path                /dev/vg01/lv_test
LV Name                lv_test
VG Name                vg01
LV UUID                hHBSUc-bdg0-eg3K-8eWb-A7pm-pcX8-ikLId9
LV Write Access        read/write
LV Creation host, time diskserver, 2014-10-16 07:05:28 +0800
LV Status              available
# open                 1
LV Size                99.99 GiB
Current LE             25598
Segments               2
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:3

— Logical volume —
LV Path                /dev/vg_diskserver/lv_root
LV Name                lv_root
VG Name                vg_diskserver
LV UUID                ORCwGE-5W6s-kvcs-5oy9-HcMZ-1zLK-5YtebD
LV Write Access        read/write
LV Creation host, time diskserver, 2014-10-16 06:23:36 +0800
LV Status              available
# open                 1
LV Size                48.75 GiB
Current LE             12480
Segments               1
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:0

— Logical volume —
LV Path                /dev/vg_diskserver/lv_home
LV Name                lv_home
VG Name                vg_diskserver
LV UUID                CCuLFi-SQfO-wCrH-Paic-QRRE-2B05-oRvruC
LV Write Access        read/write
LV Creation host, time diskserver, 2014-10-16 06:23:41 +0800
LV Status              available
# open                 1
LV Size                4.76 GiB
Current LE             1218
Segments               1
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:2

— Logical volume —
LV Path                /dev/vg_diskserver/lv_swap
LV Name                lv_swap
VG Name                vg_diskserver
LV UUID                041w0e-XJsi-BLuJ-5G1U-c2Im-6dza-f1t5cD
LV Write Access        read/write
LV Creation host, time diskserver, 2014-10-16 06:23:42 +0800
LV Status              available
# open                 1
LV Size                6.00 GiB
Current LE             1536
Segments               1
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:1

[root@diskserver ~]#lvdisplay
root@diskserver ~]# df -TH
Filesystem           Type   Size  Used Avail Use% Mounted on
/dev/mapper/vg_diskserver-lv_root
ext4    52G  1.1G   48G   3% /
tmpfs                tmpfs  4.1G     0  4.1G   0% /dev/shm
/dev/sda1            ext4   508M   58M  425M  12% /boot
/dev/mapper/vg_diskserver-lv_home
ext4   5.1G  145M  4.7G   4% /home
/dev/mapper/vg01-lv_test
ext4   106G  1.8G   99G   2% /media/my_disk
[root@diskserver ~]# e2fsck -ff /dev/vg01/lv_test
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg01/lv_test: 13/6553600 files (0.0% non-contiguous), 843351/26212352 blocks
[root@diskserver ~]# resize2fs /dev/vg01/lv_test  50G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg01/lv_test to 13107200 (4k) blocks.
The filesystem on /dev/vg01/lv_test is now 13107200 blocks long.

root@diskserver ~]# lvreduce -L -50G /dev/vg01/lv_test
WARNING: Reducing active logical volume to 49.99 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_test? [y/n]: y
Reducing logical volume lv_test to 49.99 GiB
Logical volume lv_test successfully resized
[root@diskserver ~]#
[root@diskserver ~]# lvdisplay vg01
— Logical volume —
LV Path                /dev/vg01/lv_test
LV Name                lv_test
VG Name                vg01
LV UUID                hHBSUc-bdg0-eg3K-8eWb-A7pm-pcX8-ikLId9
LV Write Access        read/write
LV Creation host, time diskserver, 2014-10-16 07:05:28 +0800
LV Status              available
# open                 0
LV Size                49.99 GiB
Current LE             12798
Segments               1
Allocation             inherit
Read ahead sectors     auto
– currently set to     256
Block device           253:3

[root@diskserver ~]# resize2fs /dev/mapper/vg01-lv_test
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg01-lv_test to 13105152 (4k) blocks.
The filesystem on /dev/mapper/vg01-lv_test is now 13105152 blocks long.

[root@diskserver my_disk]# df -TH
Filesystem           Type   Size  Used Avail Use% Mounted on
/dev/mapper/vg_diskserver-lv_root
ext4    52G  1.1G   48G   3% /
tmpfs                tmpfs  4.1G     0  4.1G   0% /dev/shm
/dev/sda1            ext4   508M   58M  425M  12% /boot
/dev/mapper/vg_diskserver-lv_home
ext4   5.1G  145M  4.7G   4% /home
/dev/mapper/vg01-lv_test
ext4    53G  1.8G   49G   4% /media/my_disk
[root@diskserver my_disk]#

[root@diskserver ~]# lvextend -l +4607 /dev/mapper/vg01-lv_test
Extending logical volume lv_test to 67.99 GiB
Logical volume lv_test successfully resized
[root@diskserver ~]# lvextend -l +4607 /dev/mapper/vg01-lv_test
Extending logical volume lv_test to 85.98 GiB
Logical volume lv_test successfully resized
[root@diskserver ~]# resize2fs /dev/vg
vg01/          vga_arbiter    vg_diskserver/
[root@diskserver ~]# resize2fs /dev/vg01/lv_test
resize2fs 1.41.12 (17-May-2010)
Please run ‘e2fsck -f /dev/vg01/lv_test’ first.

[root@diskserver ~]# e2fsck -f /dev/vg01/lv_test
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg01/lv_test: 13/3276800 files (0.0% non-contiguous), 635701/13105152 blocks
[root@diskserver ~]# resize2fs /dev/vg01/lv_test
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg01/lv_test to 22540288 (4k) blocks.
The filesystem on /dev/vg01/lv_test is now 22540288 blocks long.

Log Rotation in Catalina.out

1. Remove all logs of manager& admin

  1. Remove 90 days old logs 
  2. Backup logs greater that 35MB

#!/bin/bash

rm -rf /app/tomcat-6.0.18/logs/*manager* /app/tomcat-6.0.18/logs/*admin*

find /cda1-logs-backups -name ‘*.gz’ -mtime +90 -exec rm {} \;

echo “Initiating logrotate `date +%F-%A`” >> /app/tomcat-6.0.18/logs/diskutil.log

cd /app/tomcat-6.0.18/logs/

siz_catalina=`/bin/ls -l catalina.out | /bin/awk ‘{ print $5 }’`

if [ $siz_catalina -ge “3600000” ];then

echo “catalina.out greater that 35MB, tarring the catalina.out file as catalina.out.`date +%F-%I-%M-%p` and nullifieng the file” >> diskutil.log

tar -cvzf /cda1-logs-backups/catalina.out.`date +%F-%I-%M-%p`.tar.gz catalina.out

if [ -s  /cda1-logs-backups/catalina.out.`date +%F-%I-%M-%p`.tar.gz ]; then

`:>catalina.out`

fi

else

echo “Catalina Log file less than 35 MB at `date +%F-%I-%M-%p`” >> diskutil.log

fi

  1. Backup one day old logs

if [ -s catalina.`date +%F -d “-1 day”`*.log ]

then

tar -zcvf /cda1-logs-backups/catalina.`date +%F -d “-1 day”`*.log.tar.gz catalina.`date +%F -d “-1 day”`*.log

rm -f catalina.`date +%F -d “-1 day”`.log

echo ” Backup of catalina.`date +%F -d “-1 day”`*.log taken and removed ” >> logrotate

else

echo “catalina.`date +%F -d “-1 day”`*.log doesnt exist ” >> logrotate

fi

————————————————————————————————————

#– Removing blank localhost_access files

30 1 * * * find /usr/local/apache-tomcat-6.0.18/logs -name “localhost_access*” -type f -size 0c | xargs rm

30 1 * * * find /usr/local/apache-tomcat-6.0.18/logs -name “manager*”  -type f -size 0c | xargs rm

 

 

 

#– Removing blank localhost_access files

30 1 * * * find /usr/local/apache-tomcat-6.0.18/logs -name “localhost_access*” -type f -size 0c | xargs rm

30 1 * * * find /usr/local/apache-tomcat-6.0.18/logs -name “manager*”  -type f -size 0c | xargs rm

————————————————————————————————————

Count Apache & tomcat connections

# crontab  -e

*/1 * * * *     /home/rack/countdbconnections.sh >> /home/rack/countdbconnection

# vi countdbconnections.sh

#!/bin/bash

apache_con=`ps -ef | grep apache | wc -l`

tomcat_total_con=`netstat -an | grep :7001 | wc -l`

tomcat_est=`netstat -an | grep :7001 | grep ESTABLISHED | wc -l`

tomcat_wait=`netstat -an | grep :7001 | grep TIME_WAIT | wc -l`

echo “$(date): apache_conn = $apache_con, tomcat_established_conn = $tomcat_est, tomcat_time_wait = $tomcat_wait”

# less countdbconnection

Wed Jul 18 12:18:01 BST 2012: apache_conn = 33, tomcat_established_conn = 11, tomcat_time_wait = 809

Wed Jul 18 12:19:02 BST 2012: apache_conn = 38, tomcat_established_conn = 22, tomcat_time_wait = 690

————————————————————————————————————

Monitor Java CPU and System load avg

# crontab -e

*/2 * * * *     /root/scripts/monitor_pcpu_cda_per.sh >> /root/scripts/monitor_pcpu_cda_per.out

# vi monitor_pcpu_cda_per.sh

java_cpu=”$(date): Java CPU: $(top -b -n1  | grep java | head -1 | awk {‘print $9’})”

server_load=”Load: $(w | head -1 | awk {‘print $10’})”

echo $java_cpu $server_load

# less monitor_pcpu_cda_per.out

Fri Jul 20 06:58:02 BST 2012: Java CPU: 5.9 Load: 0.11,

Fri Jul 20 07:00:02 BST 2012: Java CPU: 96.0 Load: 0.17,

Fri Jul 20 07:02:01 BST 2012: Java CPU: 0.0 Load: 0.36,

————————————————————————————————————

Restart tomcat if it is down and count open files

# vi /root/scripts/tomcatrestart.sh

ps -ef | grep “/rss/tomcat-6.0.18/” | grep -v grep

if [ $? -eq 0 ]; then

Openfiles=`/usr/sbin/lsof | wc -l`

echo “checked at time `date` and rss is up, Openfiles=$Openfiles” >> /root/scripts/tomcatcheck.out

else

/bin/sh /rss/tomcat-6.0.18/bin/startup.sh

echo “<<<<<< RSS is down, restarted it at `date` >>>>>>>” >> /root/scripts/tomcatcheck.out

mail -s “Restarted RSS @ web2-prod” harora4@sapient.com,vsrivastav4@sapient.com

fi

if [ $Openfiles -ge 10000]; then

echo “OpenFiles @ `hostname` reached its limit of $Openfiles” | mail -s “`hostname`: OpenFiles=$Openfiles” harora4@sapient.com,vsrivastav4@sapient.com

else

cat /dev/null

fi

# less tomcatcheck.out

checked at time Wed Mar 14 15:44:03 GMT 2012 and rss is up, Openfiles=24779

checked at time Wed Mar 14 15:45:03 GMT 2012 and rss is up, Openfiles=21161

————————————————————————————————————

# Script to be used for Removal of Cached Memory

#!/bin/bash

CACHE_MEM=`free -m |awk ‘NR==2’ |awk ‘{ print$7 }’`

LIMIT=2000

if [ “$CACHE_MEM” -gt “$LIMIT” ]

then

`sync; echo 3 > /proc/sys/vm/drop_caches`

mail -s “CACHE_MEM is now cleared and the value was ##### $CACHE_MEM #####” vsrivastav4@sapient.com

else

echo exiting > /dev/null

fi

————————————————————————————————————

Restart Tomcat if connections goes high

curl -v http://262670-web1-prod.visitbritain.com:7001/cs/Satellite/en_EN/ > /root/scripts/connstatus.out

count=$(cat /root/scripts/connstatus.out | wc -l)

if [ $count -gt 200 ]; then

echo “checked at time `date` and rss is up and responding, Openfiles=`/usr/sbin/lsof | wc -l`” >> /root/scripts/check_8Sep

else

netstat -alpn > /root/scripts/connectionstat_`date +%F-%I-%M-%p`

# taking thread dump two times

pgrep -f /rss/tomcat-6.0.18/temp | xargs kill -3

pgrep -f /rss/tomcat-6.0.18/temp | xargs kill -3

# kill tomcat process

pgrep -f /rss/tomcat-6.0.18/temp | xargs kill -9

/bin/sh /rss/tomcat-6.0.18/bin/startup.sh

fi

rm -f /root/scripts/connstatus.out

————————————————————————————————————

Checking Disk Space and send alert

#!/bin/sh

limit=80

df -H  | grep ” /” | grep -vE ‘^Filesystem|tmpfs|cdrom|boot’ | awk ‘{ print $4 ” ” $5 }’| while read i;

do

perc=$(echo $i | awk ‘{ print $1}’ | cut -d’%’ -f1)

part=$(echo $i | awk ‘{ print $2 }’ )

if [ $perc -ge $limit ]; then

echo “Running out of space \”$part ($perc%)\” on $(hostname) as on $(date)” | mail -s “Alert: Almost out of disk space $usep” vsrivastav4@sapient.com

fi

done

2nd Method

df -h | grep -e [8-9][0-9]%

if [ `echo $?` -ne 0 ]; then

exit

else

df -h | grep -e [8-9][0-9]% -e Use% | mail -s “Disk space more than 80%”  arora4@sapient.com -c vsrivastav4@sapient.com

fi

————————————————————————————————————

Script if 15 minutes load goes >= 6.0.

#!/bin/bash

NOTIFY=”6.0″

FTEXT=’load average:’

# 15 min

F15M=”$(uptime | awk -F “$FTEXT” ‘{ print $2 }’ | cut -d, -f3)”

RESULT=$(echo “$F15M > $NOTIFY” | bc)

# if load >= 6.0 create a file /tmp/file.txt

if [ “$RESULT” == “1” ]; then

echo ‘LOAD ISSUE’>/tmp/file.txt

fi

————————————————————————————————————

Rename files .txt to .new in a directory

#!/bin/bash

echo “Enter Directory”

read dir

for i in `ls $dir/*`

do

mv $i $i.new

done

————————————————————————————————————

Cut the huge log file in half

#!/bin/bash

size=`cat $file|wc -l`

half=$(echo “$size/2″|bc)

tail -$half $file > $loc/file1.txt    // for lower half

tail +$half $file > $loc/file2.txt    // for upper half

If Condition : http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html

AWK

Que:- Why awk?

Ans:-   The Awk text-processing programming language and is a useful tool for manipulating text.

Awk recognizes the concepts of “file”, “record”, and “field”.

A file consists of records, which by default are the lines of the file. One line becomes one record.

Awk operates on one record at a time.

A record consists of fields, which by default are separated by any number of spaces or tabs.

Field number 1 is accessed with $1, field 2 with $2, and so forth. $0 refers to the whole record.

  1. To print 2nd line of a file

# cat file |awk NR==2′{print $0}’

  1. Print section of file between two regular expressions (inclusive)

# cat file |awk ‘/Iowa/,/Montana/’             # case sensitive

  1. Print section of file based on line numbers (lines 8-12, inclusive)

# cat file |awk NR==8,NR==12′{print $0}’

  1. Remove duplicate, consecutive lines (emulates “uniq”)

# cat file |awk ‘a !~ $0; {a=$0}’

  1. Print only lines of less than 65 characters

# awk ‘length < 64’

  1. To print no. of blanks lines in a file

# cat file |awk /^$/{++x}END'{print x}’

  1. Average five grades

john 85 92 78 94 88

andrea 89 90 75 90 86

jasper 84 88 80 92 84

# cat file |awk{total = $2 + $3 + $4 + $5 + $6; avg = total / 5; print $1, avg }

  1. Print and sort the login names of all users

# awk -F “:” ‘{ print $1 | “sort” }’ /etc/passwd

  1. Print the first 2 fields, in opposite order, of every line

# awk ‘{print $2, $1}’ file

10.Switch the first 2 fields of every line

# awk ‘{temp = $1; $1 = $2; $2 = temp}’ file

11.Print every line, deleting the second field of that line

# awk ‘{ $2 = “”; print }’

12.Print in reverse order the fields of every line

# awk ‘{for (i=NF; i>0; i–) printf(“%s “,i);printf (“\n”)}’ file 13.Print the sums of the fields of every line  # awk ‘{s=0; for (i=1; i<=NF; i++) s=s+$i; print s}’

  1. Add all fields in all lines and print the sum

awk ‘{for (i=1; i<=NF; i++) s=s+$i}; END{print s}’

  1. Print every line after replacing each field with its absolute value

# awk ‘{for (i=1; i<=NF; i++) if ($i < 0) $i = -$i; print }’

# awk ‘{for (i=1; i<=NF; i++) $i = ($i < 0) ? -$i : $i; print }’

  1. Print the total number of fields (“words”) in all lines

# awk ‘{ total = total + NF }; END {print total}’ file

 17.Print the total number of lines that contain “Beth”

# awk ‘/Beth/{n++}; END {print n+0}’ file

18.Print the largest first field and the line that contains it

# awk ‘$1 > max {max=$1; maxline=$0}; END{ print max, maxline}’

  1. Print the number of fields in each line, followed by the line

# awk ‘{ print NF “:” $0 } ‘

  1. Print the last field of each line

# awk ‘{ print $NF }’

  1. Print the last field of the last line

# awk ‘{ field = $NF }; END{ print field }’

  1. Print every line with more than 4 fields

# awk ‘NF > 4’

  1. Count the total number of fields in a file.

awk -F ‘:’ ‘{ total += NF }; END { print total }’ /etc/passwd

  1. Count number of users who is using /bin/sh shell

awk -F ‘:’ ‘$NF ~ /\/bin\/sh/ { n++ }; END { print n }’ /etc/passwd

  1. Find the user details who is having the highest USER ID

awk -F ‘:’  ‘$3 > maxuid { maxuid=$3; maxline=$0 }; END { print maxuid, maxline }’ /etc/passwd

  1. Print the even-numbered lines

awk ‘NR % 2 == 0’ /etc/passwd

  1. Print every line which has the same USER ID and GROUP ID

awk -F ‘:’ ‘$3==$4’ passwd.txt

  1. Print user details who has USER ID greater than or equal to 100 and who has to use /bin/sh

awk -F ‘:’ ‘$3>=100 && $NF ~ /\/bin\/sh/’ passwd.txt

  1. Print user details who doesn’t have the comments in /etc/passwd file

awk -F ‘:’ ‘$5 == “” ‘ passwd.txt

How to print line above/below of a string pattern in a file.

# cat Portin.log

<PORTIN_ACK>

< Receiver>220</Receiver>

< TimeStamp>2011-10-19T10:53:07.225+05:30</TimeStamp>

< PortAccepted>N</PortAccepted>

< SubscriberSequence>

< MSISDN>8985001696</MSISDN>

< ResultCode>RC00006</ResultCode>

< /SubscriberSequence>

< /PORTIN_ACK>

# awk ‘{arr[NR]=$0; if($0 ~ /RC00006/)s=NR} END{print arr[s-1]}’ Porting.log

O/P:-< MSISDN>8985001696</MSISDN>

# awk ‘{arr[NR]=$0; if($0 ~ /RC00006/)s=NR} END{print arr[s-2]}’ Porting.log

O/P:- <SubscriberSequence>

GREP:

How to count no of blank lines in a file?

# grep –c “^$” <filename>

How to remove Empty lines form a given file?

# grep –v “^$”  filename > temfilename

What is pattern to search 4 digit word in a file?

# grep “\<[0-9] [0-9] [0-9] [0-9]\>” filename

What is pattern to search the line having only three characters?

# grep “^…$” filename

What is pattern to display lines ending with “$” character in a given file?

# grep “\$$” filename

CUT

Getting a List of User Accounts on the System

# cut -d: -f1 /etc/passwd | sort

How to display 2 and 4 th fileds from a given file if the delimetr is “:”?

# Cut –d”:” –f 2,4 filename

O2Scripts : https://drive.google.com/?tab=wo&authuser=0#folders/0BzYdExDgx78PVHYzSTRBQUpfSGM
IF Conditions

File test operators, Returns true if…-e:  file exists

-a:  file exists

-f:  file is a regular file (not a directory or device file)

-s:  file is not zero size

-d:  file is a directory

-b:  file is a block device

-c:  file is a character device

device0=”/dev/sda2″    # /   (root directory)

if [ -b “$device0” ]

then

echo “$device0 is a block device.”

fi

Output # /dev/sda2 is a block device.

device1=”/dev/ttyS1″   # PCMCIA modem card.

if [ -c “$device1” ]

then

echo “$device1 is a character device.”

fi

-p:  file is a pipe

function show_input_type()

{

[ -p /dev/fd/0 ] && echo PIPE || echo STDIN

}

show_input_type “Input”                           # STDIN

echo “Input” | show_input_type                    # PIPE

-h:  file is a symbolic link

-L:  file is a symbolic link

-S:  file is a socket

-t:  file (descriptor) is associated with a terminal device

This test option used to check whether stdin [ -t 0 ] or stdout [ -t 1 ] in a given terminal.

-r:  file has read permission (for the user running the test)

SLAPD_CONF = ”/usr/local/etc/openldap/slapd.conf”

for i in “$SLAPD_CONF”

do

if [ ! -r $i ]

then

message “alert” “[ALERT] can’t read $i”

exit 1

fi

done

-w: file has write permission (for the user running the test)

-x: file has execute permission (for the user running the test)

SLAPD_BIN=”$SLAPD_PATH/libexec/slapd”

SLAPCAT_BIN=”$SLAPD_PATH/sbin/slapcat”

for i in “$SLAPD_BIN” “$SLAPCAT_BIN” “$SLAPINDEX_BIN” “$SLAPTEST_BIN” “$SLURPD_BIN” “$DB_ARCHIVE_BIN” “$DB_RECOVER_BIN”

do

if [ ! -x $i ]

then

message “alert” “[ALERT] can’t execute $i”

exit 1

fi

done

-g:  set-group-id (sgid) flag set on file or directory

-u:  set-user-id (suid) flag set on file

-k:  sticky bit set

-O:  you are owner of file

-G:  group-id of file same as yours

-N:  file modified since it was last read

f1 -nt f2:  file f1 is newer than f2

f1 -ot f2:  file f1 is older than f2

f1 -ef f2:  files f1 and f2 are hard links to the same file

!:  “not” — reverses the sense of the tests above (returns true if condition absent).

Link: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html

Are you root (for port < 1024)?

if [ $PORT -lt 1024 -a `id -u` -ne 0 ]

then

message “alert” “[ALERT] only root can launch OpenLDAP on port $PORT”

exit 1

fi

Rotating catalina.out log files

It is possible to rotate the catalina.out log, by using a log rotation program like rotatelogs or cronolog.

It is possible to rotate the catalina.out log, but it is not controlled by the standard logging.properties or log4j.properties files.

The catalina.out log is stderr and stdout piped to a file. If you want to rotate this log file you will need to use a log rotation program like rotatelogs or cronolog. Then just pipe to the log rotation program rather than the file.

Here is an example of how to do this with cronolog. Using another program would be very similar, the command in step #3 would just be slightly different.

1.) Edit the bin/catalina.sh file.

2.) Find the following line and comment it out.

touch "$CATALINA_BASE"/logs/catalina.out

Note that in later versions of Tomcat this may look like:

touch "$CATALINA_OUT"

3.) Find the following line (there should be two instances of this line, replace both)

>> "$CATALINA_BASE"/logs/catalina.out 2>&1 &

and replace it with this line

2>&1 |/usr/bin/cronolog "$CATALINA_BASE/logs/catalina-%Y-%m-%d.out" &

Note that in later versions of Tomcat the line that needs to be replaced may look like:

>> "$CATALINA_OUT" 2>&1 &

4.) Save bin/catalina.sh

5.) Restart Tomcat.

You should now have a “catalina-2010-03-30.out” file in your logs directory. When the date changes a new log file will be created. The following day you should see “catalina-[following date].out”.

Please note that the log file may not be rotated exactly at midnight. It will rotate the first time something is written to the log after the date has changed. This generally isn’t a problem for busy log files.

catalina.out log rotation

I am interested in catalina.out log file rotation, I have an application where logging to catalina.out is very huge, say 0.5 MB / sec.

So I have written one script to handle this which is shown below.

 

# crontab -l | grep catalina

0,30 * * * * bash /catalina_log_handler.sh  >/dev/null 2>&1

 

# more /catalina_log_handler.sh

#!/bin/sh

CATLOC=/bin/cat

SEDLOC=/usr/bin/sed

$CATLOC /catalina.out >> /catalina_backup.out à take a backup and then handle this file rotation using logadm

$SEDLOC ” catalina.out > catalina.out à Empty this file

 

There are two cases here

 

1.)     The below is normal behavior where not much logging

# ls -ltrh catalina*

-rw-r—–   1 ems      ems          15K Jan 31 12:07 catalina.2012-01-31.log

-rw-r—–   1 ems      ems         3.9K Feb  1 06:26 catalina.2012-02-01.log

-rw-r—–   1 ems      ems         345K Feb  1 06:45 catalina.out

-rw-r–r–   1 root     root         14M Feb  1 07:00 catalina_backup.out

 

2.)    The below is heavy logging behavior

# ls -ltrh catalina*

-rw-r—–   1 ems      ems         4.2K Jan 28 22:14 catalina.2012-01-28.log à why I am seeing catalina file with date, have the same content as catalina.out

-rw-r—–   1 ems      ems          362 Jan 30 06:30 catalina.2012-01-30.log

-rw-r—–   1 ems      ems          10M Jan 30 14:43 catalina.out.2

-rw-r–r–   1 root     root        1.7M Jan 30 17:00 catalina_backup.out.9.gz

-rw-r–r–   1 root     root        1.6M Jan 30 20:00 catalina_backup.out.8.gz

-rw-r–r–   1 root     root        1.6M Jan 30 23:00 catalina_backup.out.7.gz

-rw-r–r–   1 root     root        1.6M Jan 31 02:00 catalina_backup.out.6.gz

-rw-r—–   1 ems      ems         113M Jan 31 03:30 catalina.out.3

-rw-r–r–   1 root     root        1.8M Jan 31 06:00 catalina_backup.out.5.gz

-rw-r—–   1 ems      ems         6.2M Jan 31 10:04 catalina.out

-rw-r—–   1 ems      ems         4.5K Jan 31 10:04 catalina.2012-01-31.log

-rw-r–r–   1 root     root        1.8M Jan 31 10:30 catalina_backup.out.4.gz

-rw-r–r–   1 root     root        1.8M Jan 31 15:00 catalina_backup.out.3.gz

-rw-r–r–   1 root     root        1.8M Jan 31 19:30 catalina_backup.out.2.gz

-rw-r–r–   1 root     root        1.8M Feb  1 00:00 catalina_backup.out.1.gz

-rw-r–r–   1 root     root         12M Feb  1 01:00 catalina_backup.out

-rw-r—–   1 ems      ems          12M Feb  1 01:12 catalina.out.1 à why this is latest file ? Is this because of huge logging, Can I disable default catalina.out rotation so that my script will take care of moving the content from catalina.out to catalina_backup.out…