vncserver setup on OEL7 linux

November 29th, 2017
#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
vncpasswd

vi ~/.vnc/xstartup

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


su - oracle
vncpasswd

vi ~/.vnc/xstartup

    #!/bin/sh
    [ -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
chmod 755 ~oracle/.vnc ; chmod 600 ~oracle/.vnc/passwd ; chmod 755 ~oracle/.vnc/xstartup

cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver-root@\:1.service
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver-oracle@\:2.service

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

    [Unit]
    Description=Remote desktop service (VNC)
    After=syslog.target network.target

    [Service]
    Type=forking
    User=root

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

    [Install]
    WantedBy=multi-user.target


vi /etc/systemd/system/vncserver-oracle@\:2.service

    [Unit]
    Description=Remote desktop service (VNC)
    After=syslog.target network.target

    [Service]
    Type=forking
    User=oracle

    # Clean any existing files in /tmp/.X11-unix environment
    ExecStartPre=-/usr/bin/vncserver -kill %i
    ExecStart=/usr/bin/vncserver %i
    PIDFile=/home/oracle/.vnc/%H%i.pid
    ExecStop=-/usr/bin/vncserver -kill %i

    [Install]
    WantedBy=multi-user.target

#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 -localhost -geometry 640x480"


systemctl daemon-reload

systemctl start vncserver-root@\:1.service
systemctl start vncserver-oracle@\:2.service

systemctl enable vncserver-root@\:1.service
systemctl enable vncserver-oracle@\:2.service

systemctl get-default #make sure it's multi-user.target
Categories: IT Architecture, Linux, Systems Tags:

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

November 7th, 2017

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

/System/Networking/Ethernet_NICs/Ethernet_NIC_0
Targets:

Properties:
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
DEVICE="eth0"
BOOTPROTO=static
IPV6INIT="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
DOMAIN=example.com
IPADDR=192.168.20.20
NETMASK=255.255.248.0

[root@test network-scripts]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=test.example.com
GATEWAY=10.240.192.1

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

 

python module cx_Oracle installation on OEL/RHEL/CENTOS 6

May 23rd, 2017

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

1. Extracted SDK instantclient-sdk-linux.x64-11.2.0.4.0.zip to directory - /usr/lib/oracle/11.2/client64/bin/.

2. Added below to /etc/ld.so.conf

/opt/rh/python27/root/usr/lib64/
/opt/rh/python27/root/usr/lib/
/opt/rh/python27/root/usr/lib64/python2.7/config/
/usr/lib/oracle/11.2/client64/lib/

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

Categories: IT Architecture Tags:

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

November 16th, 2016

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

Categories: IT Architecture, Kernel, Linux, Systems, Unix Tags:

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

August 22nd, 2016

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(NativeConstructorAccessorImpl.java:57) ~[na:1.7.0_51
]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:
1.7.0_51]

......

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

# cat /u01/oracle/artifactory_home/etc/storage.properties
type=oracle
driver=oracle.jdbc.OracleDriver
url=jdbc:oracle:thin:@localhost:1521:ORCL
username=artifactory
password=password1

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 12.1.0.1.0 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 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL>

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=http://myproxy.example.com:80/

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/shutdown.sh
[oracle@testvm ~]$ /u01/oracle/apache-tomcat-7.0.52/bin/startup.sh

After this, Artifactory started working again.

Categories: IT Architecture, Programming Tags:

lvm volume resize by extending virtual disk image file

June 27th, 2016

Below should be ran from Dom0 hosting DomU:

[root@Dom0 ~]# virt-filesystems -a System.img
/dev/sda1
/dev/vg01/lv_root

[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
/dev/mapper/vg01-lv_root
20G 10G 10G 50% /

Categories: Clouding, IT Architecture, Oracle Cloud Tags:

linux dhcp config

June 8th, 2016
yum install dhcp

vi /etc/dhcpd.conf

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

    subnet 192.168.144.0 netmask 255.255.248.0 {
        range 192.168.149.112 192.168.149.113;
        option domain-name-servers 10.135.82.180, 10.135.82.188;
        option routers 192.168.144.1;
    }

    subnet 192.168.128.0 netmask 255.255.248.0 {
    }

    host andy {
        hardware ethernet 00:16:3E:86:51:DC;
        fixed-address 10.1.1.100;
    }

/etc/init.d/dhcpd start


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

[root@dhcpd ~]# lsof -i :67
    COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
    dhcpd 28207 root 5u IPv4 1019206 UDP *:bootps

[root@client ~]# dhclient eth0 -s 192.168.149.109

PS:

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.

Categories: IT Architecture, Linux, Systems Tags:

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

June 2nd, 2016

A simple example on linux box:

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

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

And here's explaining:

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

 

Categories: IT Architecture, Linux, Systems, Unix Tags:

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

April 28th, 2016

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.

 

Categories: Misc Tags:

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

April 22nd, 2016

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.

cannot_access

 

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

IPS_off

 

Categories: IT Architecture, Systems, Windows Tags: