VNC Server Setup on RHEL Machines

vnc

Lab setup

I recently setup a lab with 10 RHEL machines for big data computation using Map/Reduce frameworks. The lab was setup in a closed network in such a way that all the machines had static IP addresses assigned to them. They were connected through the switches to the router and the router was used as the default gateway to communicate with the outer world.

Ten Machines – One monitor

I had one monitor for all the 10 machines. During installation of the machines, I had to constantly switch between the machines by unplugging the monitor from one machine and connecting it to the other machine.

Is there an easy solution so that I can view all the machines using the single desktop? I need some solution like ssh which will enable me to view the desktops of all the machines using a single monitor.

Best Answer

VNC Server Installation

The VNC server is specifically designed for this purpose. The installation is pretty straight forward as mentioned in this link. However, there are chances you may encounter some issues while installing. So, I am describing the issues that I faced and how I resolved them.

yum install vnc vnc-server

We need to decide which user will be using the vnc-server.

su vncuser

Now, we need to set the password.

vncpasswd

As a root user, perform the below operation.

vim /etc/sysconfig/vncservers

Add the below 2 lines.

VNCSERVERS="1:vncuser"
VNCSERVERARGS[1]="-geometry 1600x1200"

Type the below commands.

service vncserver start
service vncserver stop
chkconfig vncserver on

If the above commands are successful, we need to edit the xstartup file for whom we have configured the vncserver. So, in our case, we have configured it for the user vncuser. So,

su vncuser
vi ~/.vnc/xstartup

Uncomment the below 2 lines.

unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

If the above step is also successful, we are finished with the configuration of the VNC server. However, we need to configure the firewall to permit the vnc communication. In the link, it is mentioned to directly edit the /etc/sysconfig/iptables file which is a very wrong approach. Instead do the below step.

iptables -I INPUT 1 -p tcp --dport 5901 -j ACCEPT

We have made the changes. But we need to change them.

/etc/init.d/iptables save

service iptables restart
service vncserver start

Now, we can view this machine as vncuser from a network machine by typing the below commands.

vncviewer
#Enter the server name as,
servername:1 #1 because, we opened up port 5901. 
Related Question