vncserver setup on OEL7 linux

#more info about vncserver on OEL7 is here

#disable firewalld
systemctl stop firewalld
systemctl disable firewalld

yum groupinstall "server with gui" -y
yum install tigervnc-server -y
yum install gnome-terminal gnome-session -y

su - root

cat ./vnc/xstartup #no need to modify




exec /etc/X11/xinit/xinitrc


vi ~/.vnc/xstartup

    [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    xsetroot -solid grey
    vncconfig -iconic &
    gnome-terminal &
    gnome-session &

chmod 755 ~/.vnc ; chmod 600 ~/.vnc/passwd ; chmod 755 ~/.vnc/xstartup
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver-root@\:1.service

vi /etc/systemd/system/vncserver-root@\:1.service

    Description=Remote desktop service (VNC)


    # Clean any existing files in /tmp/.X11-unix environment
    ExecStartPre=-/usr/bin/vncserver -kill %i
    ExecStart=/usr/bin/vncserver %i
    ExecStop=-/usr/bin/vncserver -kill %i


#Optionally, you can add command-line arguments for the VNC server 
    (only accepts connections from localhost, and change size of the window)

ExecStart=/sbin/runuser -l vncuser -c "/usr/bin/vncserver %i -geometry 1600x900" #this is only for root user

ExecStart=/usr/bin/vncserver %i -geometry 1600x900 #this is for normal user

systemctl daemon-reload #if changing vnc config, must run this afterwards

systemctl start vncserver-root@\:1.service
systemctl enable vncserver-root@\:1.service

systemctl get-default #make sure it's


Here is more info about vncserver usage:

To create a session

    vncserver -geometry 1600x900 :4

Edit .vnc/xstartup: Replace twm with gnome-session

Then kill the current VNC session and create a new one (run as the user who starts the session)

    vncserver -kill :4
vncserver -geometry 1600x900 :4


Resolved - ERROR : [/etc/sysconfig/network-scripts/ifup-eth] Device eth0 does not seem to be present, delaying initialization.

If you met error "ERROR : [/etc/sysconfig/network-scripts/ifup-eth] Device eth0 does not seem to be present, delaying initialization" on linux, then one possibility is udev cannot detected the Ethernet device, you should follow below steps to resolve this:

  • get Mac address of eth0 from ilom

-> show /System/Networking/Ethernet_NICs/Ethernet_NIC_0


health = OK
health_details = -
location = NET0 (Ethernet NIC 0)
manufacturer = INTEL
part_number = X540
serial_number = Not Available
mac_addresses = 00:10:e0:0d:b4:f0

  • configure udev rule, and change mac address according to result above

[root@test network-scripts]# cat /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:10:e0:0d:b4:f0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

  • configure network

[root@test network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

[root@test network-scripts]# cat /etc/sysconfig/network

[root@test network-scripts]# cat /etc/hosts localhost.localdomain localhost test


python module cx_Oracle installation on OEL/RHEL/CENTOS 6

I've installed cx_Oracle-5.2.1 on the newly provided server with below steps:

1. Extracted SDK to directory - /usr/lib/oracle/11.2/client64/bin/.

2. Added below to /etc/


3. Compiled and installed the cx_Oracle from souce using 'python2.7 build; python2.7 install'.

VM shutdown stuck in “mount: you must specify the filesystem type, please stand by while rebooting the system”

When you issue "shutdown" or "reboot" on linux box and found "mount: you must specify the filesystem type, please stand by while rebooting the system":

Then one possible reason is that you have specified wrong mount options for nfs shares in /etc/fstab. For example, for nfsv3, please make sure to use below nfs options when you mount shares:

<share name> <mount dir> nfs rsize=32768,wsize=32768,hard,nolock,timeo=14,noacl,intr,mountvers=3,vers=3 0 0

And using below option will make VM shutdown stuck in "mount: you must specify the filesystem type". DO NOT use below:

<share name> <mount dir> nfs vers=3,rsize=32768,wsize=32768,hard,nolock,timeo=14,noacl,intr 0 0

resolved - Artifactory: Return code is: 502, ReasonPhrase:cannot connect

Today when I tried to visit Maven Artifactory, below error prompted in browser:

Return code is: 502, ReasonPhrase:cannot connect.

And here's the log in

2016-08-19 22:48:19,942 [art-init] [ERROR] (o.a.w.s.ArtifactoryContextConfigListener:91) - Application could not be initialized: Connection refused
java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.7.0_51]
at sun.reflect.NativeConstructorAccessorImpl.newInstance( ~[na:1.7.0_51
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance( ~[na:


Firstly, I thought it was caused by JDBC issue, here's the config in JDBC config file

# cat /u01/oracle/artifactory_home/etc/

I tried connect to DB using sqlplus to have a test, it's OK:

[root@testvm ~]# su - oracle
[oracle@testvm ~]$ export ORACLE_HOME=/u01/oracle/db12c/product/12.1.0/dbhome_1
[oracle@testvm ~]$ ORACLE_SID=orcl
[oracle@testvm ~]$ export PATH=$ORACLE_HOME/bin:$PATH
[oracle@testvm ~]$ sqlplus artifactory/password1

SQL*Plus: Release Production on Mon Aug 22 03:28:20 2016

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Last Successful login time: Mon Aug 22 2016 03:21:26 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options


After some debugging, I found the issue was caused by proxy setting. We should disable it like below:

[oracle@testvm ~]# grep proxy /etc/profile
#export http_proxy=

Then log out and log on the host again, and ran below commands to shutdown/startup Artifactory:

[oracle@testvm ~]$ export ORACLE_HOME=/u01/oracle/db12c/product/12.1.0/dbhome_1/
[oracle@testvm ~]$ export ORACLE_SID=orcl
[oracle@testvm ~]$ export PATH=$PATH:$ORACLE_HOME/bin
[oracle@testvm ~]$ /u01/oracle/apache-tomcat-7.0.52/bin/
[oracle@testvm ~]$ /u01/oracle/apache-tomcat-7.0.52/bin/

After this, Artifactory started working again.

lvm volume resize by extending virtual disk image file

Below should be ran from Dom0 hosting DomU:

[root@Dom0 ~]# virt-filesystems -a System.img

[root@Dom0 ~]# virt-filesystems --long --parts --blkdevs -h -a System.img
Name Type MBR Size Parent
/dev/sda1 partition 83 500M /dev/sda
/dev/sda2 partition 8e 12G /dev/sda
/dev/sda device - 12G -

[root@Dom0 ~]# truncate -s 20G System_new.img

[root@Dom0 ~]# virt-resize --expand /dev/sda2 System.img System_new.img

[root@Dom0 ~]# mv System.img System.img.bak;mv System_new.img System.img

[root@Dom0 ~]# xm create vm.cfg -c #the first run may get issue "device cannot be connected", you can just run it again, the issue should be gone

Below should be ran from DomU:

[root@DomU ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg01 1 2 0 wz--n- 20.51g 8.00g

[root@DomU ~]# lvextend -L +8g /dev/mapper/vg01-lv_root
[root@DomU ~]# resize2fs /dev/mapper/vg01-lv_root

[root@DomU ~]# df -h /
Filesystem Size Used Avail Use% Mounted on
20G 10G 10G 50% /

linux dhcp config

yum install dhcp

vi /etc/dhcpd.conf

    ddns-update-style ad-hoc;
    default-lease-time 600;
    max-lease-time 7200;

    subnet netmask {
        option domain-name-servers,;
        option routers;

    subnet netmask {

    host andy {
        hardware ethernet 00:16:3E:86:51:DC;

/etc/init.d/dhcpd start

[root@dhcpd ~]# ls -l /var/lib/dhcp/dhcpd.leases

[root@dhcpd ~]# lsof -i :67
    dhcpd 28207 root 5u IPv4 1019206 UDP *:bootps

[root@client ~]# dhclient eth0 -s


1. Here's an article about how DHCP works. You can get more info here and here.
2.For security reason, the DHCP offer packages sent from DHCP server we build may
  get blocked. So we need ask Network Support to config DHCP relay on their DHCP 
  server to relay specified requests to use our own DHCP server. 
  As indicated below: 

      Jun  8 09:22:50 host1 dhclient: No DHCPOFFERS received.

TCP wrappers /etc/hosts.allow /etc/hosts.deny

A simple example on linux box:

[root@test ~]# cat /etc/hosts.allow
snmpd : ALL EXCEPT
ALL : localhost

[root@test ~]# cat /etc/hosts.deny

And here's explaining:

Service "sshd/snmpd" will accept connections from all hosts except All services will accept connections from localhost. Other services will deny connections from all hosts.


resolved - The viewport is not between 320 and 420 pixels wide

Today when I tried to enable page-level ads of google adsense, I met below error:

This page cannot display anchor ads for the following reason(s):

  • The viewport is not between 320 and 420 pixels wide.
  • The current browser is not supported.

The cause by this is that the wordpress theme currently used didn't support viewport(more info about viewport is here). To enable viewport, we can install one plugin - Definitely allow mobile zooming. After activating them, you can try again.


resolved - Windows cannot access the specified device, path, or file. You may not have the appropriate permission to access the item

I've been having this strange problem since this morning after starting office laptop from Hibernate. Restart is also not fixing it.

For any program, file, it just says that Windows cannot find the file ...etc . Simple search shows that it comes from anti virus. So, it is coming from Mcafee Host IPS. As soon as I turn that off from Mcaffee tray menu > Quick settings > Host IPS off, programs start working.



And here's a quick fix for this (Right click McAfee icon, then Quick settings, uncheck 'Host IPS - off'):