By Sherry LaMonica on May 24, 2013
Oracle R Enterprise enables users to generate R graphs at the database server and return them in a variety of ways: an XML representation using base 64 encoding of the PNG images, in a table with a BLOB column containing the PNG images, and interactively returning the actual image to the R user at the client. This last case allows users to generate images at the database server machine and have the actual PNG image display at the user’s client R engine.
To take advantage of this capability, users may need to ensure their X11 is properly configured. This blog highlights a solution to a common problem involving X11. When using a graphically based function in Oracle R Enterprise, if you’ve encountered errors such as:
unable to start device PNG
then read on. The issue is likely that your database server is not configured to run graphics programs locally.
The X Window system, or X11, allows you to forward a program display from a remote system to a local computer. X11 is the native windowing interface on Linux.
is not the default for all Unix Operating Systems, and additional configuration steps may
be required to display graphical programs if your server is running Unix. Follow the instructions below to configure your server to forward graphics the display to your local client machine.
X11 forwarding from a Linux client
There are two options presented here. The first uses SSH and the second uses telnet.
Option 1: Usually, when you want to connect to your Unix server from a remote Linux client, you use SSH (Secure Shell). Before logging in to your Unix server, confirm that /etc/ssh/sshd_config contains the following X11 tunneling options:
X11forwarding yesX11DisplayOffset 10
SSH allows you to make a secure terminal connection to your Unix server from your Linux client using this syntax:
ssh -Y <userid@unixserver>
The –Y option to ssh treats the Unix server as trusted , -X treats it as untrusted. Check with your server or network admin about which flag to use. This command also sets the remote DISPLAY to localhost:10.0.
Option 2: Connecting to the server via telnet
If you choose to connect to the server using telnet, keep in mind that unlike SSH, telnet does not offer the security measures that protect users against anyone with malicious intent. Using telnet, an X11 server can be manually set at a Linux client that is capable of graphical display. To confirm the graphical capability, verify that a terminal appears after entering at the Linux prompt:
You also need to know the display environment variable setting on X11 server, the Linux client:
The DISPLAY environment variable stores the displaynumber and screennumber that the X11 server uses to display. These addresses are in the form:
A typical example would be:
Next, enable the Unix server to display on the Linux client:
and telnet into the Unix server and set its DISPLAY to the X11 server – the Linux client.
After following the steps for either option, you should now be able to launch a remote graphical application locally. As a quick check, launch your remote Unix server's clock on your client desktop through the SSH connection using X11 forwarding:
1. Type xclock at the Unix server command prompt and hit enter.
2 Your remote server’s X11 GUI clock should appear on your client desktop.
3. If the xclock tests succeeds, launch the ORE client to verify the same DISPLAY setting is used by embedded R:
R> ore.eval(function() Sys.getenv("DISPLAY"), ore.graphics=FALSE)
If the last returned value matches the DISPLAY setting, you will be able to display images at the client machine.
X11 forwarding from a Windows client
To connect to your remote Unix server from Windows and use its graphical interface, you need two pieces of software: an SSH program to establish the remote connection and an X Server to handle the local display. For the SSH program we'll use PuTTY. For the server, we'll use Xming.
PuTTY is a free SSH client that allows you to connect to a remote Linux computer and use the command line. PuTTY can also be used to forward secure data over SSH to other programs - this is called tunneling.
When you connect to your remote Linux computer, you will need to set several connection settings to make everything work correctly. PuTTY lets you save these settings in a session so you can reuse them the next time you connect. To create a session that allows PuTTY to forward your Linux computer's X11 graphical interface over SSH:
1. Open PuTTY on your Windows
desktop. Putty will open and display the Session panel. In the Host Name field, type the hostname or IP address of your Unix server.
2. In the field underneath the Saved Sessions label, type a name for your saved session.
3. Under the Connection category, expand SSH and choose X11. Click the Enable X11
4. Go back to the Session category and click Save to save your session connection settings.
Now we're ready to set up the X server using Xming, which is a free X Window server for the Windows desktop. With Xming, you can display graphical applications from your remote Linux computer on your Windows desktop. Xming provides a simple utility called Xlaunch that allows you to configure Xming easily, and also save your configuration for future use. To run Xming, open XLaunch and select the configuration outlined here:
1. Open XLaunch from the program
menu. Select Multiple Windows and click Next. This tells Xming to open
each remote Linux application in a new window.
2. Select Start No Client and click Next. This tells Xming to launch and wait
for commands from
another program (like PuTTY).
3. Make sure that Clipboard is selected and click Next. This tells Xming to enable your remote
Linux applications to share a unified clipboard.
4. Click the Finish button to launch Xming.
Now that Xming is running, you can open your PuTTY session and launch a graphical application. As a quick check, launch your remote Unix server’s clock on your Windows desktop through the SSH connection using X11 forwarding:
1. Open PuTTY.
2. Double-click on the saved session you created earlier. PuTTY will create an SSH connection to your remote Unix server.
3. Login to your Unix server.
4. Type xclock at the command prompt and hit enter.
5. Your remote server’s GUI clock should appear on your client desktop.
6. If the xclock test succeeds, If the xclock tests succeeds, launch the ORE client to verify the same DISPLAY setting is used by embedded R:
R> ore.eval(function() Sys.getenv("DISPLAY"), ore.graphics=FALSE)
If the last returned value matches the DISPLAY setting, you will be able to display images at the client machine. Here's an example that creates a panel plot using the R dataset mtcars: