vineri, 25 octombrie 2013

How to delete and add network interfaces in Linux

Besides of taking them off, you have to delete, also. the following file:

 /etc/sysconfig/network-scripts/ifcfg-eth0

where 0 can be any other number, accordingly.

In order to properly add a network interface, besides of putting it into the slot (virtual or physical), you need to add and edit the same file as above. Example:

vi /etc/sysconfig/network-scripts/ifcfg-eth0


DEVICE=eth0
BOOTPROTO=none
BROADCAST=192.168.166.255
HWADDR=00:21:F6:00:00:10
IPADDR=192.168.166.12
NETMASK=255.255.255.0
NETWORK=192.168.166.0
ONBOOT=yes
TYPE=Ethernet
GATEWAY=192.168.166.1


After you edit the text, with the right parameters, you can save it and:

/etc/init.d/network/restart


Enjoy!

miercuri, 23 octombrie 2013

Let's properly config the VNC servers

First step: put the right code into vncservers file

cat >> /etc/sysconfig/vncservers <<EOF
 VNCSERVERS="1:root 2:oracle"
 VNCSERVERARGS[1]="-geometry 1152x864 -depth 16"
 VNCSERVERARGS[2]="-geometry 1152x864 -depth 16"
EOF

(i assume we all need the user oracle)
then

mkdir /root/.vnc
chmod -R 775 /root/.vnc

Be aware, in the next step, comment all the lines in /root/.vnc/xstartup and then:

cat >> /root/.vnc/xstartup <<EOF
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome &
EOF

then:

vncserver  :1

chmod 777 /root/.vnc/xstartup

su - oracle
mkdir /home/oracle/.vnc
chmod -R 775 /home/oracle/.vnc

cat >> /home/oracle/.vnc/xstartup <<EOF
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome &
EOF

vncserver  :2

 chmod 777  /home/oracle/.vnc/xstartup

su -

chkconfig vncserver on
service vncserver stop
service vncserver start

/etc/init.d/vncserver restart


and all you have to do now is to use the VNC client in order to have a nice remote desktop with the server, either under oracle or root user. Enjoy!

The OVM console is not working on clients after OVM Manager was installed

99% the root cause is the tightvnc.
Uninstall the tightvnc:

> yum -erase tightvnc

Then, install the tightvnc-java on OVM Manager Server (you can download from https://oss.oracle.com/oraclevm/manager/RPMS/tightvnc-java-1.3.9-3.noarch.rpm).

Guess what, your browser will be glad to open, now, the OVM Console.

Legend: OVM=Oracle Virtual Machine

Linux: How to ls order by size

You know, i am sure, about the lack of a command that can list the content of a partition or a folder, arranged by size and displaying the size of every single subfolder or file found in the path.

Well, your salvation is (be aware, the ">" sign is the command prompt):

>  alias dfs='du -sk * | sort -n | perl -ne '\''($s,$f)=split(m{\t});for (qw(K M G)) {if($s<1024) {printf("%.1f",$s);print "$_\t$f"; last};$s=$s/1024}'\'

and then:

>  cd director_name
>  dfs

Don't forget about the user rights over the folders, it has a total impact on the command, you will not receive any information about a folder you are not entitled to read.
Enjoy! The command above is GOLD nugget!

How to catch the blocker of a record in a table

Hypothesis: i try yo update a record in a table and i receive, let's say, the following error message:

ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired

or something is telling me the record is locked. If the issue is spanning over too much time, i have to overcome somehow the situation.
As a DBA, i use this sql bullet:
select a.sid, a.serial#, a.inst_id, c.object_name, a.username,d.sql_text
from gv$session a, gv$locked_object b, dba_objects c , gv$sqlarea d
where b.object_id = c.object_id 
and a.sid = b.session_id and a.sql_id=d.sql_id and upper(object_name)='tablename';

As you can see, the environment is a clusterized one, the views are gv$, and there is some information in there that you can consider it redundant: sql_text. Not everytime  that column will point to the actual sql command guilty of locking. So, you can filter a bit:

select a.sid, a.serial#, a.inst_id, c.object_name, a.username
from gv$session a, gv$locked_object b, dba_objects c 
where b.object_id = c.object_id 
and a.sid = b.session_id and a.sql_id=d.sql_id and upper(object_name)='tablename';

and, for standalone environment:

select a.sid, a.serial#, a.inst_id, c.object_name, a.username,d.sql_text
from v$session a, v$locked_object b, dba_objects c , v$sqlarea d
where b.object_id = c.object_id 
and a.sid = b.session_id and a.sql_id=d.sql_id and upper(object_name)='tablename';