Difference between revisions of "Ifarm graphic mode"

From Hall A Wiki
Jump to: navigation, search
(ssh tunneling)
(start vnc server)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
For any question, email Zhiwen Zhao zwzhao@jlab.org
+
For any question, email Zhiwen Zhao zwzhao at jlab.org
  
 
= Why =
 
= Why =
Line 6: Line 6:
 
Sometimes we do want to test a code's graphic feature. For example, it's a common system we all have access and can be used for debug.
 
Sometimes we do want to test a code's graphic feature. For example, it's a common system we all have access and can be used for debug.
  
= connect to ifarm at jlab by vnc  =
+
= Xwindow forwarding (when your computer is inside jlab network, otherwise this might be too slow) =
 
+
== Xwindow forwarding (when your computer is inside jlab network, otherwise this might be too slow) ==
+
  
 
It is simply use Xwindow forwarding by ssh into ifarm and run the code.  
 
It is simply use Xwindow forwarding by ssh into ifarm and run the code.  
Line 21: Line 19:
 
  If you local machine is Mac, you need to have a Xwindow server installed and enabled
 
  If you local machine is Mac, you need to have a Xwindow server installed and enabled
  
== vnc and ssh tunneling (recommended for access from outside jlab) ==
+
= connect to a jlab machine by vnc (recommended for access from outside jlab) =
  
The better way to do it is through a vnc server inside jlab.
+
you can do it by vnc and ssh tunneling
  
vncserver should run on a machine inside like jlabl1,...,jlabl5. It shouldn't run inside any ifarm machine as computer center will kill it when you running too many processes on ifarm.
+
vncserver should run on a machine inside jlab like your machine or jlabl1,...,jlabl5. It shouldn't run inside any ifarm machine as computer center will kill it when you running too many processes on ifarm.
  
=== start vnc server ===
+
== start vnc server ==
  
First you need to start a vncserver on jlabl5 as an example
+
First you need to start a vncserver on jlabl1 as an example
  
 
  ssh -XY your_lab_username@jlabl1.jlab.org (login with Xwindow forwarding enabled)
 
  ssh -XY your_lab_username@jlabl1.jlab.org (login with Xwindow forwarding enabled)
Line 38: Line 36:
 
         vncconfig -iconic &
 
         vncconfig -iconic &
 
         xterm -geometry 160x50+10+10 -ls -title "$VNCDESKTOP Desktop" &
 
         xterm -geometry 160x50+10+10 -ls -title "$VNCDESKTOP Desktop" &
         metacity &
+
         #metacity &
 +
        xfce4-session < /dev/null >& /dev/null &
 
  chmod 755 .vnc/xstartup
 
  chmod 755 .vnc/xstartup
  vncserver                           (start vnc server)
+
  vncserver -geometry 1920x1080      (start vnc server)
 
  or
 
  or
 
  vncserver -bs                      (start vnc server this way if somehow quitting program root will kill vncserver)
 
  vncserver -bs                      (start vnc server this way if somehow quitting program root will kill vncserver)
 
  ('''give a password if running it first time, or run vncpasswd to enter password'''
 
  ('''give a password if running it first time, or run vncpasswd to enter password'''
 
  '''note the vnc server port number output on screen'''
 
  '''note the vnc server port number output on screen'''
  '''make sure to kill the server after you using it to free resource on ifarm,'''
+
  '''make sure to kill the server after you using it to free resource on host,otherwise it will keep running even after you log out!'''
'''otherwise it will keep running even after you log out!''')
+
  vncserver -kill :port        (replace port with correct vnc server port number,'''note the space before colons''')
  vncserver -kill :port        ('''replace port with correct vnc server port number, note the space before colons''')
+
  
=== run vnc viewer ===
+
if you have another good machine at jlab to use as vnc server, you can use gnome or kde desktop system in xstartup as follows
 +
#!/bin/sh
 +
unset SESSION_MANAGER
 +
unset DBUS_SESSION_BUS_ADDRESS
 +
/etc/X11/xinit/xinitrc
 +
#startkde &
  
Next you need to connect to the vnc server on jlabl5 by a vnc viwer
+
ssh -XY -XY -N -L 5999:ifarm2401:22 login
  
The simple way is to use vncviewer on jlabl5 to test see if your vncserver runs ok. It's slow if your machine is not at jlab network
+
Next you can test to see if your vncserver runs ok. (It's slow if your machine is not at jlab network)
  
ssh -XY your_lab_username@jlabl5  (login with Xwindow forwarding enabled)
 
 
  vncviewer localhost:port            (replace port with correct vnc server port number)
 
  vncviewer localhost:port            (replace port with correct vnc server port number)
  
=== ssh tunneling ===
+
== ssh tunneling ==
  
The best way is run vncviewer on your machine anywhere through ssh tunneling
+
To run vncviewer on your machine outside jlab, it's best by ssh tunneling
  
 
* built ssh tunnel as follows with '''correct port number of vnc server'''
 
* built ssh tunnel as follows with '''correct port number of vnc server'''
** if your linux or mac machine is at jlab, run "ssh -X -N -g -L 5999:localhost:port your_lab_username@jlabl5.jlab.org"  
+
** if your linux or mac machine is at jlab, run "ssh -X -N -g -L 5999:localhost:port your_lab_username@jlabl1.jlab.org"  
** if your linux or mac machine is outside jlab, run "ssh -X -N -g -L 5922:jlabl5:22 your_lab_username@login.jlab.org" (it will stay there without command prompt, don't touch it) and run in another terminal "ssh -X -N -g -L 5999:localhost:port your_lab_username@localhost -p 5922"
+
** if your linux or mac machine is outside jlab, run "ssh -X -N -g -L 5922:jlabl1:22 your_lab_username@login.jlab.org" and run in another terminal "ssh -X -N -g -L 5999:localhost:port your_lab_username@localhost -p 5922" (both terminals will just stay there without allowing you to input anything and you keep both alive.)
** if you windows machine is at jlab, use putty to connect to jlabl5.jlab.org:22 by add Connection->SSH->Tunnels with source port 5999 and destination localhost:port"
+
** if you windows machine is at jlab, use putty to connect to jlabl1.jlab.org:22 by add Connection->SSH->Tunnels with source port 5999 and destination localhost:port"
** if you windows machine is outside jlab, use putty to connect to login.jlab.org by add Connection->SSH->Tunnels with source port 5922 and destination jlabl5:22" and another putty to connect to localhost:5922 by add Connection->SSH->Tunnels with source port 5999 and destination localhost:port"
+
** if you windows machine is outside jlab, use putty to connect to login.jlab.org by add Connection->SSH->Tunnels with source port 5922 and destination jlabl1:22" and another putty to connect to localhost:5922 by add Connection->SSH->Tunnels with source port 5999 and destination localhost:port"
 
* get a good [https://www.realvnc.com/en/connect/download/viewer/ vncviewer] or use a default one after "yum install tigervnc"
 
* get a good [https://www.realvnc.com/en/connect/download/viewer/ vncviewer] or use a default one after "yum install tigervnc"
 
* then run vncviewer and connect to localhost:5999 (choose lower graphic quality for better speed and scale to window size in option for best use)
 
* then run vncviewer and connect to localhost:5999 (choose lower graphic quality for better speed and scale to window size in option for best use)
Line 78: Line 80:
 
  at the remote host,  
 
  at the remote host,  
 
  if x11vnc is not installed, run "yum install x11vnc" as root to install it. If you have ssh key on login server or your remote host, disable it temporarily by renaming .ssh/authorized_keys.
 
  if x11vnc is not installed, run "yum install x11vnc" as root to install it. If you have ssh key on login server or your remote host, disable it temporarily by renaming .ssh/authorized_keys.
  as an example, start x11vnc in the machine called lily.jlab.org as follows
+
  as an example, start x11vnc in the machine called testmachine.jlab.org as follows
 
  run "x11vnc -localhost -auth guess -display :0 -repeat -shared -forever -rfbport 5900 &"
 
  run "x11vnc -localhost -auth guess -display :0 -repeat -shared -forever -rfbport 5900 &"
 
  It's preferred to run it as root so that you can do vnc even before login after computer boots.  
 
  It's preferred to run it as root so that you can do vnc even before login after computer boots.  
 
  If you don't have root access, just run it as regular user, but sometime it fails after computer reboot because xwindow auth can't be established. then the fix is usually that you have to login in front of your computer first
 
  If you don't have root access, just run it as regular user, but sometime it fails after computer reboot because xwindow auth can't be established. then the fix is usually that you have to login in front of your computer first
  
  at your local machine, as an example,connect to host lily from your machine outside jlab as follows
+
  at your local machine, as an example,connect to host testmachine from your machine outside jlab as follows
  For linux or mac, run in a terminal "ssh -X -N -g -L 5922:lily:22 your_lab_username@login.jlab.org", then run in another terminal "ssh -X -N -g -L 5999:localhost:5900 your_lab_username@localhost -p 5922" (both terminals will just stay there without allowing you to input anything and you keep both alive.)
+
  For linux or mac, run in a terminal "ssh -X -N -g -L 5922:testmachine:22 your_lab_username@login.jlab.org", then run in another terminal "ssh -X -N -g -L 5999:localhost:5900 your_lab_username@localhost -p 5922" (both terminals will just stay there without allowing you to input anything and you keep both alive.)
  For windows, use putty to connect to login.jlab.org by add Connection->SSH->Tunnels with source port 5922 and destination lily:22" and another putty to connect to localhost:5922 by add Connection->SSH->Tunnels with source port 5999 and destination localhost:5900"
+
  For windows, use putty to connect to login.jlab.org by add Connection->SSH->Tunnels with source port 5922 and destination testmachine:22" and another putty to connect to localhost:5922 by add Connection->SSH->Tunnels with source port 5999 and destination localhost:5900"
  The first ssh tunneling connect your localhost:5922 to lily:22 through login:22 and the second ssh tunneling connect your localhost:5900 to lily:5900 through localhost5922 which is actually lily:22  
+
  The first ssh tunneling connect your localhost:5922 to testmachine:22 through login:22 and the second ssh tunneling connect your localhost:5900 to testmachine:5900 through localhost5922 which is actually testmachine:22  
  
 
  at your local machine, get [https://www.realvnc.com/en/connect/download/viewer/ vncviewer]
 
  at your local machine, get [https://www.realvnc.com/en/connect/download/viewer/ vncviewer]
 
  then run vncviewer and connect to localhost:99
 
  then run vncviewer and connect to localhost:99
 
  choose lower graphic quality for better speed and scale to window size in option for best use
 
  choose lower graphic quality for better speed and scale to window size in option for best use

Latest revision as of 19:06, 10 April 2025

For any question, email Zhiwen Zhao zwzhao at jlab.org

Why

Usually we are running code on ifarm without caring about graphic because it's used for a test ground for farm job anyway.

Sometimes we do want to test a code's graphic feature. For example, it's a common system we all have access and can be used for debug.

Xwindow forwarding (when your computer is inside jlab network, otherwise this might be too slow)

It is simply use Xwindow forwarding by ssh into ifarm and run the code.

Xwindow graphic is always rendered in your local machine. This is not only very slow if your machines is outside of jlab network, but also can have different results for different people because their local machines are different. Sometimes, it can even cause crash of your local machine if your code is not nice and your local machine is very different from ifarm.

ssh -XY your_lab_username@ifarm          (login with Xwindow forwarding enabled for linux and Mac)
xclock &                                 (test if Xwindow forwarding works)                                            
If you local machine is windows, you need to have a Xwindow server like Xming-mesa running. You also you need to enable Xwindows forwarding in putty option to use ssh
If you local machine is Mac, you need to have a Xwindow server installed and enabled

connect to a jlab machine by vnc (recommended for access from outside jlab)

you can do it by vnc and ssh tunneling

vncserver should run on a machine inside jlab like your machine or jlabl1,...,jlabl5. It shouldn't run inside any ifarm machine as computer center will kill it when you running too many processes on ifarm.

start vnc server

First you need to start a vncserver on jlabl1 as an example

ssh -XY your_lab_username@jlabl1.jlab.org (login with Xwindow forwarding enabled)
mkdir .vnc
edit .vnc/xstartup with lines below
        #!/bin/sh
        xsetroot -solid grey
        vncconfig -iconic &
        xterm -geometry 160x50+10+10 -ls -title "$VNCDESKTOP Desktop" &
        #metacity &
        xfce4-session < /dev/null >& /dev/null &
chmod 755 .vnc/xstartup
vncserver  -geometry 1920x1080      (start vnc server)
or
vncserver -bs                       (start vnc server this way if somehow quitting program root will kill vncserver)
(give a password if running it first time, or run vncpasswd to enter password
note the vnc server port number output on screen
make sure to kill the server after you using it to free resource on host,otherwise it will keep running even after you log out!
vncserver -kill :port         (replace port with correct vnc server port number,note the space before colons)
if you have another good machine at jlab to use as vnc server, you can use gnome or kde desktop system in xstartup as follows
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/etc/X11/xinit/xinitrc
#startkde &
ssh -XY -XY -N -L 5999:ifarm2401:22 login

Next you can test to see if your vncserver runs ok. (It's slow if your machine is not at jlab network)

vncviewer localhost:port            (replace port with correct vnc server port number)

ssh tunneling

To run vncviewer on your machine outside jlab, it's best by ssh tunneling

  • built ssh tunnel as follows with correct port number of vnc server
    • if your linux or mac machine is at jlab, run "ssh -X -N -g -L 5999:localhost:port your_lab_username@jlabl1.jlab.org"
    • if your linux or mac machine is outside jlab, run "ssh -X -N -g -L 5922:jlabl1:22 your_lab_username@login.jlab.org" and run in another terminal "ssh -X -N -g -L 5999:localhost:port your_lab_username@localhost -p 5922" (both terminals will just stay there without allowing you to input anything and you keep both alive.)
    • if you windows machine is at jlab, use putty to connect to jlabl1.jlab.org:22 by add Connection->SSH->Tunnels with source port 5999 and destination localhost:port"
    • if you windows machine is outside jlab, use putty to connect to login.jlab.org by add Connection->SSH->Tunnels with source port 5922 and destination jlabl1:22" and another putty to connect to localhost:5922 by add Connection->SSH->Tunnels with source port 5999 and destination localhost:port"
  • get a good vncviewer or use a default one after "yum install tigervnc"
  • then run vncviewer and connect to localhost:5999 (choose lower graphic quality for better speed and scale to window size in option for best use)

connect to any machine's main desktop at jlab by x11vnc

"vncserver" create a new X server independent of the main X server.

But you can connect to main desktop by "x11vnc" and ssh tunneling as if you are sitting in front of it

at the remote host, 
if x11vnc is not installed, run "yum install x11vnc" as root to install it. If you have ssh key on login server or your remote host, disable it temporarily by renaming .ssh/authorized_keys.
as an example, start x11vnc in the machine called testmachine.jlab.org as follows
run "x11vnc -localhost -auth guess -display :0 -repeat -shared -forever -rfbport 5900 &"
It's preferred to run it as root so that you can do vnc even before login after computer boots. 
If you don't have root access, just run it as regular user, but sometime it fails after computer reboot because xwindow auth can't be established. then the fix is usually that you have to login in front of your computer first
at your local machine, as an example,connect to host testmachine from your machine outside jlab as follows
For linux or mac, run in a terminal "ssh -X -N -g -L 5922:testmachine:22 your_lab_username@login.jlab.org", then run in another terminal "ssh -X -N -g -L 5999:localhost:5900 your_lab_username@localhost -p 5922" (both terminals will just stay there without allowing you to input anything and you keep both alive.)
For windows, use putty to connect to login.jlab.org by add Connection->SSH->Tunnels with source port 5922 and destination testmachine:22" and another putty to connect to localhost:5922 by add Connection->SSH->Tunnels with source port 5999 and destination localhost:5900"
The first ssh tunneling connect your localhost:5922 to testmachine:22 through login:22 and the second ssh tunneling connect your localhost:5900 to testmachine:5900 through localhost5922 which is actually testmachine:22 
at your local machine, get vncviewer
then run vncviewer and connect to localhost:99
choose lower graphic quality for better speed and scale to window size in option for best use