Many database administrators will argue that most Linux servers do not need X Window even when hosting an Oracle database. In fact, as you read the previous chapters of this book, you will realize that you can manage your Oracle database on a Linux server using a text console; you really don't need a graphical console. In recipes 10-11 and 10-12, you will learn how to install the Oracle RDBMS software, as well as how to create an Oracle Database without running the Oracle Universal Installer (OUI) that requires a graphical display.
However, for database administrators planning to migrate from a Windows environment and wanting to explore Oracle Database on a Linux environment, typing (and remembering exactly) the operating system (OS), SQL, and RMAN commands via a command line can be intimidating. If you prefer to run GUI-based programs, such as using the Database Configuration Assistant to create an Oracle database, then this chapter is definitely for you.
To understand the concept of X Window System in a Linux environment, you need to review the analogy of a client and a server in a networked environment. However, an X client and an X server both can be hosted on a single computer (which is an uncommon feature in a typical client/server environment) or two disparate computers on a network, as illustrated in Figure 15-1. But the terminology is backward from what many expect. An X server, for example, is what you run on your client PC to interact with your application. So, the application you run on some remote machine is actually the client. The application you run locally (X Window) is actually the server.
In this chapter, you will learn how to configure, start, and stop an X server, as well as how to redirect and secure an X display to a remote computer. You will also learn how to switch between desktop environments, as well as how to change the look and feel when running an X terminal. If using Windows as your client computer, you can explore OpenSSH for Windows or perhaps use Virtual Network Computing (VNC), which is discussed in detail in Chapter 16.
You want to configure an X Window server on a Linux server so you can run GUI-based applications, such as the Database Configuration Assistant to create an Oracle database.
To set up an X Window server (often called just an X server) on your Linux server, you need to edit the X Window configuration file, called xorg.conf
. That file is usually found in the /etc/X11
directory. The following are three ways to edit the /etc/X11/xorg.conf
file:
Directly modifying the /etc/X11/xorg.conf
file
Running the system-config-display
application
Running the Xorg
application
The /etc/X11/xorg.conf
file is analogous to the /etc/X11/XF86Config
file on older Linux distributions.
You need to log on as root
or have sudo
access to allow you to run system-config-display
. Otherwise, you will be prompted for the root
password, as illustrated in the results here:
$ system-config-display You are attempting to run "system-config-display" which requires administrative privileges, but more information is needed in order to do so. Password for root:
A screen of Linux display settings will appear, similar to that shown in Figure 15-2. On the Settings tab, you can change the screen resolution and color depth, which are dependent on the capability of your hardware.
On the Hardware tab, as shown in Figure 15-3, you can configure the monitor type and video card, which you can select from a list.
You can also add and configure a second monitor display on the Dual Head tab, as shown in Figure 15-4.
Another method to configure the xorg.conf
file is to run Xorg
with the configure
option, which creates a temporary configuration file called /root/xorg.conf.new
. The following is the snippet of the results when running the Xorg -configure
command:
# /usr/bin/Xorg -configure X Window System Version 7.1.1 Release Date: 12 May 2006 X Protocol Version 11, Revision 0, Release 7.1.1 Build Operating System: Linux 2.6.20-1.2952.fc6 i686 Red Hat, Inc. Current Operating System: Linux BLLNX2 2.6.18-8.el5xen #1 SMP Wed Jun 6 00:05:22 EDT 2007 i686 Build Date: 07 June 2007 Build ID: xorg-x11-server 1.1.1-48.13.el5.0.1 Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. Module Loader present Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/var/log/Xorg.0.log", Time: Wed Aug 27 23:53:17 2008
When running Xorg -configure
, you can experience the error message "Fatal server error: Server is already active for display 0. If this server is no longer running, remove /tmp/.X0-lock and start again." To avoid this error, you need to delete the said file described in the error message.
Afterward, you need to test the /root/xorg.conf.new
configuration by executing the command X-config /root/xorg.conf.new
. If the X server runs fine using the newly created configuration file, /root/xorg.conf.new
, then copy that file to /etc/X11/xorg.conf
.
When you start the X server, it reads the xorg.conf
file that is located by default in the /etc/X11
directory. The /etc/X11/xorg.conf
file contains configurations of the system resources, video card, keyboard, mouse, and monitor for a Linux server running the X Window System.
In the "Solution" section, we described three methods to create and update the /etc/X11/xorg.conf
file. One of the methods is to manually modify the file, which we don't recommend, except if you are sure of the changes. However, regardless of the method you want to pursue, make sure to back up or create another copy of the /etc/X11/xorg.conf
file before you attempt to modify it. That way, you can always revert to the original settings in case the new changes do not work.
The GUI-based Linux display settings tool, or system-config-display
, probes your video card and selects the appropriate drivers. If the video card cannot be detected, then you can select from the list of supported video cards. The system-config-display
utility will write the changes directly to the /etc/X11/xorg.conf
file.
If you are having problems running system-config-display
, then an alternative option is to use Xorg
as described in the solution. You can also run Xorg
with the probeonly
option to diagnose an X server problem.
When troubleshooting X server, always check the log files /var/log/messages
and /var/log/Xorg.0.log
.
You want to start an X server on the Linux server so you can run GUI-based software applications.
The following are three ways to start X server on your Linux server:
Method #1: Manually run the X
command.
Method #2: Run init 5
or telinit 5
.
Method #3: Modify /etc/inittab
, and reboot the server.
The first method happens to be the most involved and requires manually starting the X server on the console of your Linux server. Follow these steps:
If you are prompted to log on, then log on as the OS user from which you want to run the X server.
Run the X server by typing the X
command followed by ampersand (&
), as shown in the following line of code. Make sure you add &
at the end so the X server will run in the background. That way, you can still type other OS commands in the same console session.
$ X &
Press Ctrl+Alt+F7 to change to the graphical console. An x will appear in the center of a blank screen, which represents the cursor of your mouse.
Press Ctrl+Alt+F1 to return to the text console session.
The second method for starting an X server is to run the init 5
or telinit 5
command as root
on the OS prompt. Afterward, a GUI-based logon screen may appear. The third method is to change the value of the initdefault
variable to 5 in the /etc/inittab
file, as shown here. But you must reboot the Linux server to effect the changes made in the /etc/inittab
file.
id:5:initdefault:
To show the details of the X server, run the OS command xdpyinfo
.
If the runlevel of your Linux server is set to 5, the X server is automatically started when the Linux server is rebooted. However, if the Linux server starts with a runlevel 3, where the default screen display is a text console and you want to run some GUI-based applications such as dbca
to create an Oracle Database, then you need to manually start the X server on your Linux server.
You can start the X server in three ways. First, you can manually start the X server by running the X
command, as demonstrated in the "Solution" section. Another method is to run either the init
or telinit
command and pass 5
as a parameter, but you must be root
or have sudo
access to run those commands. Finally, if you want X server to automatically run every time a Linux server is rebooted, then you need to change the id
directive in /etc/inittab
to runlevel 5.
Nowadays, the majority of DBAs do not work in front of the console of the server. So, when the Linux server is booted, starting the X server is not necessary. But if you have enough physical memory on your Linux server, then we recommend you use the third method. If the current level is 3, then use either the first or second method to start the X server. However, we recommend the second method, because it is simpler and requires fewer steps than the X
command.
Running an X server on your Linux database server can pose security issues, because another client can access and observe your keystrokes. For security measures, we recommend you employ access control using xhost
or tunnel X over SSH, as discussed in recipes 15-4 and 15-5.
The X
command actually calls Xorg
, as illustrated in the results here:
# which X /usr/X11R6/bin/X # ls -l /usr/X11R6/bin/X lrwxrwxrwx 1 root root 4 May 19 17:39 /usr/X11R6/bin/X -> Xorg # which Xorg /usr/X11R6/bin/Xorg # ls -l /usr/X11R6/bin/Xorg -rws--x--x 1 root root 2002691 Oct 9 2007 /usr/X11R6/bin/Xorg
The X
command may be in a different directory from other Linux distributions, so run the command which X
to determine the exact directory.
Instead of running the X
command to start the X server, you can optionally run the startx
command. The startx command then invokes the X command on your behalf and also launches a graphical display manager. The default display manager of most Linux distributions is GNOME. If you prefer another graphical display manager, refer to recipe 15-6 on how to switch from GNOME to KDE, and vice versa.
Once an X server is already running, then you can press Ctrl+Alt+F1 to change to a text console or press Alt+F7 at the same time to change to the graphical console. You can repeat these steps to go back and forth between the text and graphical consoles.
When running the X server, make sure that the X Font server is running. To verify, run the service xfs status
command.
You want to stop the X server running on your Linux server. You may want to do that, for example, to save on resources such as the memory consumed by GUI-based software applications.
There are three ways to stop an X server:
Method #1: Run init 3
or telinit 3
.
Method #2: Press Ctrl+Alt+Backspace.
Method #3: Modify /etc/inittab
, and reboot the server.
For the first method, perform the following steps to manually stop the X server on your Linux server:
If the X Window system is already running, then press Ctrl+Alt+F1 to change to a text console.
If you are prompted to log on, then log on as root
.
Issue either init 3
or telinit 3
to stop the X server.
# init 3
For the second method, perform the following steps:
Press Alt+F7 to change to the graphical console. If you are already on the graphical console, then you can skip this step.
Press Ctrl+Alt+Backspace to stop the X server.
For the third method, change the value of the initdefault
variable to 3 in the /etc/inittab
file, as shown here:
id:3:initdefault:
However, you must then reboot the Linux server to effect the changes.
You can stop an X server in three ways. You can manually stop the X server by running either init 3
or telinit 3
on the text console to change the current runlevel to 3. But you must be root
or have sudo
access to run these commands. If the current runlevel is already 3, then you can press Ctrl+Alt+Backspace when you are on the graphical console. However, if you don't want the X server to automatically run every time the Linux server is rebooted, then change the id
directive to runlevel 3 in the /etc/inittab
.
The first and second methods are dependent on the current runlevel. If the current runlevel is 5 and you perform the second method, then it will always return to graphical login screen. So, perform the first method if the current level is 5. Otherwise, you can perform the second method.
Issue the runlevel
command to display the previous and current runlevels. In the following example, the first character is N, which means that the runlevel is not changed yet, while the second character indicates that the current runlevel is 5.
# runlevel N 5
You want to run an X client or a GUI-based software application on your local Linux server, but X server is not running. Instead, you want to redirect the graphical display to a remote Linux server, where an X server is running.
In the following example, the operating system (OS) user oracle
is currently logged in on the local Linux server BLLNX1
, where you want to run an X client or a GUI-based software application, but an X server is not running. Meanwhile, server BLLNX2
is a remote Linux server, where an X server is running.
Perform the following steps to redirect the graphical display to server BLLNX2
when running an X client or a GUI-based software application such as dbca
to create an Oracle Database on server BLLNX1
:
On server BLLNX1
, set the OS environment variable DISPLAY
to point to server BLLNX2
.
[oracle@BLLNX1 ˜]$ export DISPLAY=BLLNX2:2.0
Run dbca
on server BLLNX1
.
[oracle@BLLNX1 ˜]$ dbca
If the OS environment variable DISPLAY
is not set, then you may experience the error message "DISPLAY not set. Set DISPLAY environment variable, then re-run." To resolve this error, make sure you set the OS environment variable DISPLAY
to point to a server where the X server is running.
Next, the Database Configuration Assistant (DBCA) screen will appear, as shown in Figure 15-5. Behind the DBCA screen, notice that the output of the OS command uname -a
that is executed on the terminal window confirms that the server is BLLNX2
.
Usually you run an X client or GUI-based software application and have the graphical display on the local Linux server, where you are currently logged in. But what if the X server is not running on the local Linux server? Your option is to redirect the graphical display to another remote Linux server where an X server is running.
However, you may experience the following error, as shown here, because most likely the local Linux server, which is server BLLNX1
in the example illustrated in the "Solution" section, is not granted access control on the remote Linux server, which is server BLLNX2
.
[oracle@BLLNX1 ˜]$ dbca Xlib: connection to "BLLNX2:2.0" refused by server Xlib: No protocol specified
To confirm whether access has been granted, run the OS command xhost
without any parameter on server BLLNX2
. If the message says access control enabled, only authorized clients can connect
and server BLLNX1
is not in the list, then that explains why you are getting the earlier error message when running the dbca
. For example:
[root@BLLNX2 ˜]# xhost access control enabled, only authorized clients can connect
You can resolve this problem in two ways: one is to run the command xhost +BLLNX1
from server BLLNX2. The other is to run the command xhost + on server BLLNX2. Using the first approach allows only clients from the host BLLNX1
to connect. For example:
[root@BLLNX2 ˜]# xhost +BLLNX1 BLLNX1 being added to access control list [root@BLLNX2 ˜]# xhost access control enabled, only authorized clients can connect INET:BLLNX1
On the other hand, the OS command xhost +
will grant access control to all servers that have direct access to BLLNX2
. We don't recommend, though, that you grant that much access, because you are basically allowing access from any server. For example:
[root@BLLNX2 ˜]# xhost + access control disabled, clients can connect from any host [root@BLLNX2 ˜]# xhost access control disabled, clients can connect from any host INET:BLLNX1
To revoke access control, run the OS command xhost -BLLNX1
to revoke the privilege from the specific server BLLNX1
, as shown in the following example. Notice in the results of the first OS command xhost
without any parameters, server BLLNX1
is on the list. Meanwhile, after you run the OS command xhost -BLLNX1
, server BLLNX1
is no longer on the list during the second time that you run the OS command xhost
without any parameters.
[root@BLLNX2 ˜]# xhost access control disabled, clients can connect from any host INET:BLLNX1 [root@BLLNX2 ˜]# xhost -BLLNX1 BLLNX1 being removed from access control list [root@BLLNX2 ˜]# xhost access control disabled, clients can connect from any host
However, if you issued the OS command xhost +
earlier and the message says access control disabled, clients can connect from any host
when you issue the OS command xhost
without any parameter, then any server, such as server BLLNX1
, can still access server BLLNX2
even though you have already revoked the privilege from the specific server BLLNX1
. To revoke access control from all servers, you can issue xhost -
, as shown here:
[root@BLLNX2 ˜]# xhost - access control enabled, only authorized clients can connect [root@BLLNX2 ˜]# xhost access control enabled, only authorized clients can connect
After you have issued the OS command xhost -
, you may experience the following error messages when logging in as non-root
on the local Linux server:
[oracle@BLLNX2 ˜]$ xterm Xlib: connection to ":2.0" refused by server Xlib: No protocol specified xterm Xt error: Can't open display: :2.0
To resolve this issue, you need to run the command xhost +localhost
or xhost +BLLNX2
as root
, as shown here:
[root@BLLNX2 ˜]# xhost +localhost localhost being added to access control list [root@BLLNX2 ˜]# xhost access control enabled, only authorized clients can connect INET:localhost.localdomain
You want to run an X client or a GUI-based software application on a remote Linux server. However, you want to log on to that remote Linux server through a secured connection and have the data encrypted that is traversing between servers.
In the following example, the operating system (OS) user oracle
is currently logged in on the local Linux server BLLNX1
, while server BLLNX2
is the remote Linux server. Perform the following steps to connect to server BLLNX2
from server BLLNX1
through SSH, and execute an X software application on server BLLNX2
.
On the local Linux server BLLNX1
, run ssh
with the -X
(uppercase X) option, as shown here. You may be prompted to provide a password of the OS user on BLLNX2
.
[oracle@BLLNX1 ˜]$ ssh -X BLLNX2 oracle@bllnx2's password: Warning: No xauth data; using fake authentication data for X11 forwarding. Last login: Sat Aug 30 04:46:18 2008 from bllnx1
If X11Forwarding is properly set up, the DISPLAY
variable is automatically set up once you are successfully connected to the remote Linux server, as shown here:
[oracle@BLLNX2 ˜]$ echo $DISPLAY localhost:11.0
Once you are successfully connected to server BLLNX2
, you can now run an X client or GUI-based software application on server BLLNX2
. To test this, we recommend you run a simple X client, such as xclock
, as shown in Figure 15-6.
Recipe 15-4 allows you to redirect a graphical display to a remote Linux server. However, the data traversing between the servers is not secured, since it is not encrypted. For security reasons, we recommend you forward or tunnel the graphical display through SSH, as shown in this recipe.
To learn how to configure SSH tunneling using PuTTY, refer to recipe 1-1.
To forward the display of an X client or GUI-based software application on a remote Linux server, run ssh with the -X (uppercase X) option. The -x (lowercase X) option disables X forwarding. However, before you can start to connect using ssh
, make sure that the Secure Shell daemon, or sshd, is already running on the remote Linux server. Otherwise, you need to review Chapter 14, particularly recipe 14-1, which discusses in detail how to set up ssh
.
When running an X client or GUI-based software application on a remote Linux server, you may receive message Warning: Remote host denied X11 forwarding
. Also, if you run an X client or GUI-based software, you will receive the message Error: Can't open display
. To resolve these errors, make sure X11Forwarding
is set to yes
in the /etc/ssh/sshd_config
file on the remote Linux server.
To troubleshoot your SSH connection, run the ssh
command with the -v
option to display debugging messages. For more debugging messages, run with the -vvv
option instead. We also recommend you review the /var/log/secure
and /var/log/messages
files.
You want to change your Linux desktop environment from GNU Network Object Model Environment (GNOME) to K Desktop Environment (KDE), and vice versa.
In the following example, perform these steps to switch between the desktop environments GNOME and KDE:
Log on as root
, and edit the /etc/sysconfig/desktop
file. For help on editing a file, please refer to Chapter 4.
Change the value of the DESKTOP variable to either GNOME or KDE. In the following example, we run the cat
command to display the contents of the /etc/sysconfig/desktop
file, and as you can see, the DESKTOP
variable is set to KDE
.
# cat /etc/sysconfig/desktop #DESKTOP="GNOME" DESKTOP="KDE" #DESKTOP="XDM"
We excluded X Display Manager, or XDM
, in the discussion, since it is not available on some Linux distributions such as RHEL5.
Finally, you need to restart the X server. To start and stop the X server, please refer to recipes 15-2 and 15-3.
On most Linux distributions, the default desktop environment is GNOME. However, if you prefer another one, such as KDE, then you need to modify the DESKTOP variable in the /etc/sysconfig/desktop file. When the X server is started, the /etc/X11/prefdm file is called and reads the /etc/sysconfig/desktop
file.
For Microsoft Windows, you have only the Windows desktop environment. With Linux you have several choices, but the most popular desktop environments are GNOME and KDE. The individual desktop environments have their own tools, but their functionalities are almost similar. Like in KDE, the default file manager is Konqueror, and in GNOME it's Nautilus. Even though some Linux users will argue that perhaps GNOME is better than KDE, or vice versa, the preferred Linux desktop environment is really dependent on the tools, as well as the look and feel you are comfortable with.
Figure 15-7 shows a sample screen of the GNOME desktop environment.
Figure 15-8 shows Nautilus as the default file manager for the KDE desktop environment.
You want to launch the default X terminal and change the look and feel to support different database environments, namely, the development, quality assurance, and production database environments.
To launch an X Window terminal, you can execute the xterm command. If your operating system environment variable DISPLAY is set up correctly to a Hummingbird X Server, Reflection X Server, or Cygwin X Server (or if you are running X Server locally), a small white terminal will appear. This small window will probably not be adequate to support the day-to-day activities of today's DBA who supports many database environments. More than likely, you will need a larger window, a title to specify the name of the window, different colors to easily identify the environment, and a larger scroll buffer area. Here's several xterm
examples you can execute in your environment to support multiple database environments:
xterm -sl 32000 -sb -title "Production" -geometry 128x40 -bg red -fg white & xterm -sl 32000 -sb -title "QA" -geometry 128x40 -bg yellow -fg black & xterm -sl 32000 -sb -title "Development" -geometry 128x40 -bg blue -fg white &
Each of the xterm windows is designed with different background colors with the -bg parameter to differentiate database environments. In our example, the blue window represents the development environment, the yellow window represents the QA environment, and, of course, the red window represents the production environment. DBAs should be cognitive of the color scheme and exercise extra caution by remembering that while in the red background, they are logged in the production database server.
In addition to the background colors, we defined the scroll length buffer as 32,000 lines. The default scroll buffer is 64 lines above the top of the window. The scroll buffer of 32,000 lines, designated by the -sl
parameter, will consume more memory on the server but will prove to be well worth it, especially when diagnosing problems.
The title of the windows can also be defined with the -title parameter. The -title parameter should be enclosed with double quotes so that you can customize titles to suit your requirements.
The dimensions of the xterm
window can be managed with the -geometry
parameter. The -geometry
parameter defines the window size and position. You can define a specific font, font size, and other attributes with the -font
parameter. The simplest way to designate the font and size attributes is by executing the xfontsel
command. Executing the xfontsel
command will open another X window similar to what is displayed in Figure 15-9.
When you decide on the font type and size attributes, you can click the select button and paste in another terminal with the xterm command. The xterm command will look like the following command:
xterm -font -adobe-courier-bold-*-*-*-12-*-*-*-*-*-*-*
Once you are satisfied with the font look and feel, you can go back to the xfontsel
window and click the quit button.
Another popular parameter for xterm is the -e parameter. With the -e option, you can specify the program and arguments to run in the xterm window. Here's an example of how the -e option can be manipulated:
xterm -e "ssh rac3 -l root"
xterm
is the standard terminal emulator that runs in X Windows. Other terminal emulators in Linux include Konsole (the default KDE terminal), GNOME Terminal (the default GNOME terminal), rxvt (a slimmed-down replacement for xterm
), and Eterm. xterm
is the standard de facto for terminals in all the Unix operating systems. No matter whether you are running Linux, Sun Solaris, IBM AIX, or HP/UX, xterm
will look and behave the same. One behavior includes the ability to copy and paste. Within an xterm
window, if you highlight a word or a sentence, the highlighted portion will automatically be copied to the memory buffer. To copy the memory buffer, you simply press the middle mouse button; for a two-button mouse, the middle button is most often the trackball. You can press on the track ball to paste the contents of the memory buffer. If you have the old traditional two-button mouse, pressing both the left and right buttons at the same time will paste the memory buffer.
Similarly, if you hold the Ctrl key and simultaneously press the left, middle, or right button, you will see the following menu options:
Press Ctrl and the left mouse button for Main Options.
Press Ctrl and the right mouse button for VT Fonts.
Press Ctrl and the middle mouse button for VT Options.
For example, with the VT Fonts menu, you can change the size of the font to unreadable, tiny, small, medium, large, and huge. As you change the size of the font, the window diameter will change respectively. With the VT Options menu, you can modify simple things such as enabling or disabling scrollbars or enabling reverse video.
For assistance with the myriad of xterm arguments, you can execute the xterm -help command.