Showing posts with label vnc. Show all posts
Showing posts with label vnc. Show all posts

How to install a minimal X11 GUI vnc environment on RHEL7/8 for Oracle installation

by Jephe Wu

Summary

In RHEL7, since Redhat removed twm window manager and used mwm instead, however x11 is still configured to use /usr/bin/twm though, if Oracle DBA needs to install Oracle database on RHEL7 remotely with a minimal X11 environment,  there's a way to make it so.

Steps


1.  create symbolic link /usr/bin/mwm to /usr/bin/twm 


cd /usr/bin

ln -sf mwm twm 

Note: if you still would like to use twm, you can install from RHEL6 below

download twm window manager from RHEL6

wget http://mirror.centos.org/centos/6/os/x86_64/Packages/xorg-x11-twm-1.0.3-5.1.el6.x86_64.rpm

2. install tigervnc-server and xterm
yum install tigervnc-server xterm

rpm -ivh xorg-x11-twm-1.0.3-5.1.el6.x86_64.rpm (optional for twm)

3. run vncserver :1 on RHEL7 after ssh with required user (usually oracle)

4. use vncviewer to connect to RHEL7 ip address at 5901 port

Note: or you can use ssh port forwarding to forward local port 5901 to remote server with ssh(putty)

Or  ssh -L 5901:localhost:5901 remote_server_ip

Reference

http://houseofbrick.com/twm-window-manager-on-rhel-7/ 
https://docs.oracle.com/cd/E52668_01/E54669/html/ol7-vnc-config.html


Preparing RHEL 6 server for Oracle 11gR2 database installation

Jephe Wu - http://linuxtechres.blogspot.com

Objective:  step-by-step to install a RHEL 6.4/6.5 64bit server VM on ESXi 5 for preparing Oracle database installation
Environment: ESXi 5, vsphere client, RHEL 6.4 64bit, Oracle 11gR2 database single instance installation



Steps

1.  Information 
hostname: oradb1
ip: 192.168.1.2/24
virtual disk size: 80g
vcpu: 2
RAM: 4G
partition: / - 20g , swap - 4g, /boot - 500M, /u01 - the rest
use LVM for everything except for /boot.

2. Installation
download RHEL 6.4/6.5 x86_64bit DVD, upload to ESXi datastore through Vsphere.
create a new VM with the datastore, choose this uploaded iso file and connect it and power it on so it will boot from dvd for OS installation

3. Package selection
Just choose 'Base' which is default option to install it, also tick ' Compatibility libraries'.

4. Configuration after OS installation
a. disable selinux , vi /etc/sysconfig/selinux
b. ntsysv --level 2345 to disable unnecessary services
c. vi /etc/sysconfig/network-scripts/ifcfg-eth0, change onboot=yes if required.
d. run 'setup' to setup network eth0 if required.

4. setup yum repo for dvd media
Later on, you need to manually install quite a lot of rpms, in order to auto resolve the dependency, you can setup a yum repo based on dvd itself

cd /etc/yum.repos.d
cp rhel-source.repo rhel64.repo -va
vi rhel64.repo as follows:

[oracle@oradb1 yum.repos.d]$ more rhel64.repo 
[rhel64]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///media/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

From ESxi VM, hardware, for cdrom/dvd, tick 'connected' and 'connect at poweron' to connect dvd, then mount it as follows:
mount /dev/dvd /media

5. Preparing package for Oracle database
Requirements for Installing Oracle 11gR2 RDBMS on RHEL6 or OL6 64-bit (x86-64) (Doc ID 1441282.1) , the following packages are required.

yum install tigervnc-server xterm xorg-x11-twm   # for vnc work to install database
yum install tigervnc-server xterm ksh gcc gcc-c++ libaio-devel unixODBC unixODBC.i686 elfutils-libelf-devel  # required by Oracle 
yum install mksh  #replace pdksh, ignore all when installing Oracle database
https://access.redhat.com/site/solutions/66816   -  Installation of Oracle fails with Missing Requisite File "pdksh-5.2.14" in Red Hat Enterprise Linux 6 ?

6. vi /etc/hosts to add line as follows:
192.168.1.2   oradb1
7. Create Oracle users and groups
groupadd -g 501 oinstall
groupadd -g 502 dba
groupadd -g 503 oper
useradd -m -u 501 -g oinstall -G dba,oper -d /home/oracle -s /bin/bash -c "Oracle Software Owner" oracle
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app
chmod -R 775 /u01/app

8. sysctl.conf
append the following to the end of file /etc/sysctl.conf
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
To activate these new settings into the running kernel space, run the "sysctl -p" command as root.
9. shell limit conf

       a.) Add the following settings to /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240

  b.) Verify the latest version of PAM is loaded, then add or edit the following line in the /etc/pam.d/login file, if it does not already exist:
session required pam_limits.so

Note: not required for RHEL 6.4 as it's already put in system-auth, refer to the reference part at the bottom of this page for RHEL6 best practice for Oracle 11g R2 database

       c.) Verify the current ulimits, and raise if needed.  This can be done many ways...adding the following lines to /etc/profile is the recommended method:
if [ $USER = "oracle" ]; then
    if [ $SHELL = "/bin/ksh" ]; then
       ulimit -u 16384
       ulimit -n 65536
    else
       ulimit -u 16384 -n 65536
    fi
fi

10. Oracle home .bash_profile set
append the following
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin

11. preparing database installation
ssh into server as oracle user, run 'vncserver', 
then at client side, use vncviewer to connect to it as default port 5901. You can also use SSH tunnel for vnc port forwarding.

12.  copy Oracle db software 2 of 7 zip files to /home/oracle/softwares (create softwares first) , modify the CV_ASSUME_DISTID as follows, then run './runInstaller'.

Edit the cvu_config file as follows:
sed -i 's/CV_ASSUME_DISTID=OEL4/CV_ASSUME_DISTID=OEL6/' 
/u01/app/oracle/oracle-software/database/stage/cvu/cv/admin/cvu_config


13. run 'netca' to create listener

14. run 'dbca' to create database and dbconsole.


Setting up VNC reverse connection and using VNC for Linux installation

Jephe Wu - http://linuxtechres.blogspot.com

Objective: Allow VNC server machine to connect to VNC viewer which is at listening mode when necessary. Also using VNC method to install Linux.
Environment: CentOS 5.5 32bit, Windows Vista 32bit with TightVNC.


Cases:
1.  Connect Windows to Windows
Install TightVNC first, one PC starts up TightVNC Viewer, then click on 'Listening Mode' button.
On another Windows desktop,  Startup TightVNC server in application mode or service mode, right click the icon at the right bottom of the screen, click 'Attach Listening Viewer', then type in Viewer IP address.
After that, VNC server Windows desktop will appear in the Listening viewer Windows machine.

2. Connect Linux VNC server to Windows VNC viewer at listening mode
Firstly, startup vncserver first on CentOS 5.5 remote console:

$ vncserver

It will automatically choose a display, starting from :1, if someone else has already started up vncserver from some other remote console, it will use :2.  Let's say it starts a vnc server at jephe.domain.com:1


$ vncconfig display=:1 -connect 192.168.100.20
or
$ export DISPLAY=:1; vncconfig -connect 192.168.100.20

note: 
a. before running above command, starting up TightVNC viewer at listening mode first on Windows vista machine, its IP address is 192.168.100.20.
b. Above command will push vnc display :1 to the client side at 192.168.100.20 port 5500 which is listening mode port


3. How to connect to remote Linux server which is pre-deployed somewhere and Linux server can access Internet directly but not other way round

Case description:  You need to physically deploy a pre-configured Linux server in the school, you are not able to directly ssh into that server anymore after deployment, the server itself is able to access Internet through school network (NAT). How do you check that server if someone in school reports to you there might be some problem with that server.

Solution: 
a. On your company data center server, start vncserver service at 1.2.3.4:1, you can remotely vnc connect to that server 1.2.3.4:1 by using TightVNC client. Now you get a X windows terminal on your Windows desktop
b. After that, run 'xhost +schoolpublicipaddress' from the xterm window to allow school IP to be able to push a xterm terminal to your data center vncserver console
c. Before server deployment, prepare a cronjob script to periodically (every 10 minutes) check your data center website URL at http://jephe.domain.com/vnccount
The vnccount file content is just one line which is your today's date such as:
20101010

If the file content is greater than before, of course, save the previous content first, then run xterm command like this:
xterm -display jephe.domain.com:1

Whenever you need to connect to school Linux server, increase the date count, wait for 10 minutes, a xterm window will appear, then you can control that school server.


4. Install Linux using VNC method:
Boot from Linux Installation DVD or CD, type in 'linux vnc vncpassword=jephe1' (note: password string must be at least 6 characters), after setting up a static IP address or letting it get it through DHCP, it will startup a VNC server for you to connect.

Moreover, you can use VNC reverse connection method to directly connect to your Windows VNC viewer which is running a listening mode. type in 'linux vnc vncconnect=10.0.0.4'. IP address 10.0.0.4 is your Windows TightVNC vncviewer PC.

5. References and FAQs
a. Linux vnc installation:

on the kernel line you need the following additional info :
vnc vncconnect=192.168.0.23 headless ip=dhcp ksdevice=eth0 method=http://mirror.centos.org/centos/4/os/i386/ lang=en_GB keymap=uk

b. How to connect to Linux/Unix server xwindows, gnome, kde etc with great performance
You can install freenx or NoMachine Linux server rpm and use NoMachine Windows client to connect to it.
For FreeNX, run 'yum install freenx' after installing DAG RHEL repository rpm.


c. vino-server for Gnome VNC
go to gnome desktop, System menu, perferences, Remote Desktop Preferences, tick 'Allow other users to view your desktop' and uncheck 'Ask you for confirmation' to enable VNC server for gnome itself. You might need to restart gnome to take effect, or use google search 'Enable and control the gnome VNC vino-server from the command line'.

d. vncviewer gnome full screen mode
You can exit from CentOS 5.5 gnome vncviewer full screen mode by pressing F8 key, then uncheck 'full screen'.

Setting up virtual machines with CentOS, KVM, Socat and RealVNC

Jephe Wu - http://linuxtechres.blogspot.com

Objective: use open source softwares to set up a virutal Windows XP machine inside Linux with excellent remote access performance
Environment: Dell OptiPlex 780 as host server running CentOS 5.5 64bit with 8G RAM, both KVM and Xen virtualzation installed, socat, realvnc, Windows XP virtual machine with bridged network br0 and Qumranet paravirtualized ethernet adapter, as well as RedHat VirtIO SCSI Disk Device driver.


Concept:
1. use CentOS 5.5 with KVM instead of Xen as KVM has the future. 
You don't have to change anything after inital KVM setup to enable bridged network, For NATed Windows machine, you can use 'socat' for tcp port forwarder on the VNC ports to make inside Windows XP virtual machine accessable to outside world, but vnc response speed is quite slow.

To gain better network, hard disk and graphic drawing speed, you can:
2. use realvnc server on virtual Windows XP SP3 machine instead of KVM builtin vnc server for better response speed, so called VNC mirror driver
3. use the latest virtio-win ISO package to install qumranet paravirtualized ethernet adapter driver instead of the default realtek network adapter for better network performance
4. use bridged network interface instead of the default NAT for Windows virtual machine for even better network performance and easier configuration, this requires some configuration after initial setup.
5. use RedHat VirtIO SCSI Disk Device driver instead of the default IDE driver for better block device performance.

Steps
1. Installation of CentOS 5.5
Download CentOS 5.5 DVD and burn it for local installation, or use NFS network installation if you are using DVD iso file.

Choose KVM and Gnome during installation.

If you have only CentOS 5 lower version, after install, run 'yum update' to upgrade to the latest.

2. KVM configuration
If you have installed both KVM and Xen, server will boot from Xen kernel, you will need to vi /etc/grub.conf to change it to boot from the plain Linux kernel which has KVM support.

By default, when you configure KVM virtual machine, it use NATed network only because it doesn't have bridged network for you to use. After that, the localhost will be listening at port 5900 for vnc connection, but it cannot be connected remotely since it's only listening at localhost.

You can use 'socat' (http://www.dest-unreach.org/socat/) as proxy to forward the vnc port by following the steps below:

# Install DAG rpmforge package
# rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release0.3.6-1.el5.rf.x86_64.rpm

# yum install socat

# add local2 to /etc/syslog.conf
[root@jephe ~]# grep socat /etc/syslog.conf
local2.*                        /var/log/socat.log

# socat -d -d -lmlocal2 tcp4-listen:5900,bind=10.0.0.1,su=nobody,reuseaddr,fork tcp4:127.0.0.1:5900 &
note:
This will enable inside KVM virtual machine to accept connection from network.
a. log will be recorded in local2 which is /var/log/socat.log according to /etc/syslog.conf
b. listening on 10.0.0.1:5900 (host server tcp socket instead of the KVM builtin one which is localhost:5900)
c. su as nobody
d. receiving vnc connection from network then forward to inside Windows XP SP3 virtual machine at 192.168.100.230:5900

You can put above socat command into /etc/rc.d/rc.local.

Issues:
With above configuration, the VNC response speed is very slow. You can improve it by using realvnc or tightvnc on virtual machine itself and change network adapter to bridged mode as well as using Redhat VirtIO ethernet adapter and RedHat VirtIO SCSI Disk Device driver.

3. Installing Windows KVM guest
a. When installing Windows 7, use 'Windows vista' option. When you choose 'local CDROM install' option, the installation path part might become grey, you can check if you enabled 'messagebus' daemon and 'haldeamon' daemon:

service autofs start
service messagebus start
service haldaemon start

So that the auto mount will work under gnome desktop, check 'ls -l /dev/cdrom' which should be symbolic linked to /dev/scd0.

4. Improving performance  - RealVNC with mirror driver
installing realvnc or tightvnc latest version (both are supporting so-called mirror driver)
realvnc server free edition can enable bi-directional cut and paste but there's no password protection for configuration change once login
tightvnc has password protection for console admin but has no support for pasting out text from virtual machine, only one way pasting.

After installing realvnc or tightvnc, you can use socat like this:

# socat -d -d -lmlocal2 tcp4-listen:5900,bind=10.0.0.1,su=nobody,reuseaddr,fork tcp4:192.168.100.230:5900 &

5. Improving performance - Bridged network


Refer to http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Virtualization/sect-Virtualization-Network_Configuration-Bridged_networking_with_libvirt.html

Here are my steps according to above RHEL doc website:

vi /etc/xen/xend-config.sxp and changing the line:

 (network-script network-bridge)

To:

 (network-script /bin/true)

# chkconfig NetworkManager off
# service NetworkManager stop

# cd /etc/sysconfig/network-scripts
Add the following line to ifcfg-eth0 which will be used for bridge.
BRIDGE=br0
MTU=9000

add the following lines to ifcfg-br0
[root@jephe network-scripts]# more ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
DELAY=0
BROADCAST=10.0.0.255
IPADDR=10.0.0.1
NETMASK=255.255.255.0
NETWORK=10.0.0.0

After configuring, restart networking or reboot.

# service network restart

Configure iptables to allow all traffic to be forwarded across the bridge.

# iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
# service iptables save
# service iptables restart

 Restart the libvirt daemon.

# service libvirtd reload

Exit virt-manger, then start it again. Delete storage device hda , then add again, choose 'virtio' type. You should now have a "shared physical device", which guests can be attached and have full LAN access. Verify your new bridge:

# brctl show
bridge name     bridge id               STP enabled     interfaces
virbr0          8000.000000000000       yes
br0             8000.000e0cb30550       no              eth0

Note, the bridge is completely independent of the virbr0 bridge. Do not attempt to attach a physical device to virbr0. The virbr0 bridge is only for Network Address Translation (NAT) connectivity.

6. Improving performance - Virtio ethernet adapter driver
download the latest Windows guest network drivers from http://www.linux-kvm.com/  (left side of web page, under 'Windows Guest Drivers' - download the driver CD.

mounted as local cdrom image in virt-manager before rebooting Windows virtual machine.
After booting up, it found the new ethernet adapter, then I used cdrom to install driver.

After that, shutdown virtual machine, delete the existing network card in virt-manager, then add one more network card with virtio type, now you should be able to see bridged network br0 option

7. Improving performance - Windows block driver (RedHat VirtIO SCSI Disk Device driver)
In my case, I use Windows XP SP3 32bit as virtual machine, so I have done the following:
Visiting website http://www.linux-kvm.com/ , at the left side to download the latest Windows guest drivers CD or floppy (during installation)

and check
http://www.linux-kvm.com/content/block-driver-updates-install-drivers-during-windows-installation

Important: You cannot just delete hda then create vda, then startup guest, you need to add a small vda storage first without deleting the main hda, after that, boot into guest to install Redhat virtio scsi disk driver, after that, shutdown, delete vda and hda, then create vda to use the existing image.
otherwise, it will not be able to boot Windows. Here are the steps:


Shutdown virtual machine, use virt-manager to add one more storage device ( use dd if=/dev/zero of=/root/testfile bs=1k count=1000 to create a small file first as vd0 just for installing virtio disk driver)


After booting up virtual machine again, Windows XP detected a new scsi hard disk, then use above driver inside the cdrom to install it.


Shutdown again, use virt-manager to delete vd0 and hd0, after that ,create another storage device, use the existing hard disk image file, boot up again, this time, hard disk will become RedHat VirtIO SCSI Disk Device driver

Now, use vnc client to connect to Windows virtual machine and enjoy the fast speed.

Let's say you want to use floppy disk version after initial installation of virtual machine, you can use dd if=viostor-floppy.img of=/dev/fd0 to write to floppy disk. You also can mount the floppy img file as loop device as follows:

mkdir /mnt/viostor
cd /mnt/viostor
mount viostor-31-03-2010-floppy.img viostor/


8. Using virtio driver to improve network and disk performance when installing RHEL 5.4 guest

How can I improve network and disk performance of Red Hat Enterprise Linux KVM guests?- https://access.redhat.com/kb/docs/DOC-18756 

and

How do I set up virtio on a kvm guest to get better network and I/O performance on RHEL4 and RHEL5? - https://access.redhat.com/kb/docs/DOC-25441

If using the virt-manager graphical tool to install a new guest, select following options on the OS type selection page to enable virtio network and block device drivers for this new guest:

OS type: Linux
Version: Generic 2.6.25 or later kernel with virtio


9. High Resolution Graphic on KVM Windows guest 
For Windows 7 pro guest in KVM, you can use advanced mode option to choose monitor model up to resolution 1280x1024.



http://www.linux-kvm.com/content/using-high-resolution-graphics
http://www.linux-kvm.com/content/using-vmware-vga-kvm-windows-guests




10. How to clone the existing KVM guest
cd /var/lib/libvirt/images
virt-clone --original guest1 --name newguest1 --file newguest1.img

11. See Also
a. http://www.linux-kvm.org/page/Main_Page
b. http://virtualization.info/en/
c. http://www.linux-kvm.com/

d. KVM virtio network drivers

http://www.linux-kvm.com/content/tip-how-setup-windows-guest-paravirtual-network-drivers
http://www.linux-kvm.com/content/latest-release-windows-virtio-network-drivers
http://sourceforge.net/projects/kvm/files/kvm-driver-disc/

e. KVM Windows block drivers

http://www.linux-kvm.com/content/redhat-54-windows-virtio-drivers-part-2-block-drivers
http://www.linux-kvm.com/content/block-driver-updates-install-drivers-during-windows-installation