VNC server configuration in CentOS

Source: Internet
Author: User

As a DBA, dbca and netca images must be used to create databases and listeners when creating an Oracle database (if you use a script to create a database ), if you are in good health, you can complete the database creation process in the trembling Data room. With vnc, you can enjoy the coffee flavor in the comfortable room, by the way, the installation and configuration of relatively boring databases are indispensable for So and graphical operation tools. The most popular graphic operation software in Linux is VNC, I have completed this detailed text for the purpose of summarization, sharing and reminder. I hope you will like it.

1. Check whether the VNC is installed.

By default, the Red Hat Enterprise Linux installer installs the VNC service on the system.

Check whether the VNC service has been installed and check the installed VNC version.

[Root @ testdb ~] # Rpm-q vnc-server

Vnc-server-4.1.2-9.el5

[Root @ testdb ~] #

If the system is not installed, you can find the RPM installation package vnc-server-4.1.2-9.el5.x86_64.rpm for the VNC service under the Server Directory of the operating system installation disk, the installation command is as follows

Rpm-ivh/mnt/Server/vnc-server-4.1.2-9.el5.x86_64.rpm

2. Start the VNC service

Run the vncserver command to start the VNC service. The command format is "vncserver: desktop Number". The "desktop number" is represented by a number. Each user needs to occupy one desktop.

An example of starting a desktop with ID 1 is as follows:

[Root @ testdb ~] # Vncserver: 1

You will require a password to access your tops.

Password:

Verify:

Xauth: creating new authority file/root/. Xauthority

New 'testdb: 1 (root) 'desktop is testdb: 1

Creating default startup script./root/. vnc/xstartup

Starting applications specified in/root/. vnc/xstartup

Log file is/root/. vnc/testdb: 1.log

During the preceding command execution, a password is required for the first execution. The password is encrypted and stored in the user's home directory. vnc subdirectory (/root /. in vnc/passwd. in the vnc subdirectory, The xstartup configuration file (/root /. vnc/xstartup), the configuration information in this file is read every time the VND service is started.

BTW:/root /. there is also a "testdb: 1. pid file, which records the process number corresponding to the operating system the day after the VNC is started, used to accurately locate the process number when the VNC service is stopped.

3. Relationship between the port number used by the VNC service and the desktop number

The port number used by the VNC service is related to the desktop number. The VNC uses the TCP port starting from 5900. The corresponding relationship is as follows:

Desktop number is "1" ---- port number is 5901

Desktop number "2" ---- port number is 5902

Desktop number "3" ---- port number is 5903

......

The TCP port of the Java-based VNC client Web service starts from 5800 and is also related to the desktop number. The corresponding relationship is as follows:

Desktop number is "1" ---- port number is 5801

Desktop number "2" ---- port number is 5802

Desktop number "3" ---- port number is 5803

......

Based on the above introduction, if the firewall function is enabled in Linux, You need to manually enable the corresponding port. For example, to enable the corresponding port with the desktop number "1", the command is as follows:

[Root @ testdb ~] # Iptables-I INPUT-p tcp -- dport 5901-j ACCEPT

[Root @ testdb ~] # Iptables-I INPUT-p tcp -- dport 5801-j ACCEPT

4. Test the VNC service

The first method is to log on to the test using the VNC Viewer software. The procedure is as follows:

Start the VNC Viewer software --> enter "144.194.192.183" on the Server: 1 "--> click" OK "--> enter the Login Password --> click" OK "to log on to the X-Window Graphic desktop environment --> the test is successful.

The second method is to use a Web browser (such as Firefox, IE, Safari) to log on to the test. The procedure is as follows:

Enter http: // 144.194.192.183: 5801/--> in the address bar, the VNC viewer for Java (this tool is a VNC client program written in Java) interface is displayed, and The VNC viewer dialog box is displayed, on the Server, enter "144.194.192.183: 1" and click "OK" --> Password, enter the login Password --> click "OK" to log on to the X-Window Graphic desktop environment --> the test is successful.

(Note: VNC viewer for Java requires JRE support. If the page cannot be displayed, it indicates that JRE is not installed. You can download the latest jrefor installation at http://java.sun.com/javase/downloads/index_jdk5.jsp)

5. Configure the VNC graphic desktop environment as KDE or GNOME Desktop Environment

If you configured it according to my above method, it would be very simple to log on to the desktop and only one Shell is available. Why? How can we see the cute and beautiful KDE or GNOME desktop environment? The answer is as follows:

The reason for this is that the VNC service uses the twm graphical desktop environment by default. You can modify it in the VNC configuration file xstartup. Let's take a look at this configuration file.

[Root @ testdb ~] # Cat/root/. vnc/xstartup

#! /Bin/sh

# Uncomment the following two lines for normal desktop:

# Unset SESSION_MANAGER

# Exec/etc/X11/xinit/xinitrc

[-X/etc/vnc/xstartup] & exec/etc/vnc/xstartup

[-R $ HOME/. Xresources] & xrdb $ HOME/. Xresources

Xsetroot-solid gray

Vncconfig-iconic &

Xterm-geometry 80x24 + 10 + 10-ls-title "$ VNCDESKTOP Desktop "&

Twm &

Change the last line of the xstartup file to "startkde &", restart the vncserver service, and then log on to the KDE Desktop Environment.

Change the last line of the xstartup file to "gnome-session &", restart the vncserver service, and then log on to the GNOME desktop environment.

To restart the vncserver service, follow these steps:

[Root @ testdb ~] # Vncserver-kill: 1

[Root @ testdb ~] # Vncserver: 1

6. Configure multiple desktops

You can use the following method to start VNC for multiple desktops

Vncserver: 1

Vncserver: 2

Vncserver: 3

......

However, this manual start method will expire after the server is restarted. Therefore, the following describes how to enable the system to automatically manage VNC on multiple desktops, add the information to be automatically managed to the/etc/sysconfig/vncservers configuration file. Configure desktop 1 as root user desktop 2 as an oracle user as follows:

Format: VNCSERVERS = "desktop number: User Name"

[Root @ testdb ~] # Vi/etc/sysconfig/vncservers

VNCSERVERS = "1: root 2: oracle"

VNCSERVERARGS [1] = "-geometry 1024x768"

VNCSERVERARGS [2] = "-geometry 1024x768"

7. Modify the VNC access password

Use the command vncpasswd to modify the VNC password of different users. Note that if the VNC of different users is configured, they must be modified in their respective users, for example, in my experiment, the root user and the oracle user must be modified separately. The modification process is as follows:

[Root @ testdb ~] # Vncpasswd

Password:

Verify:

[Root @ testdb ~] #

8. Start and Stop the VNC service

1) Start the VNC service command [root @ testdb ~] #/Etc/init. d/vncserver start

Starting VNC server: 1: root

New 'testdb: 1 (root) 'desktop is testdb: 1

Starting applications specified in/root/. vnc/xstartup

Log file is/root/. vnc/testdb: 1.log

2: oracle

New 'testdb: 2 (oracle) 'desktop is testdb: 2

Starting applications specified in/home/oracle/. vnc/xstartup

Log file is/home/oracle/. vnc/testdb: 2.log

[OK

2) Stop the VNC service command

[Root @ testdb ~] #/Etc/init. d/vncserver stop

Shutting down VNC server: 1: root 2: oracle [OK]

3) restart the VNC service command

[Root @ testdb ~] #/Etc/init. d/vncserver restart

Shutting down VNC server: 1: root 2: oracle [OK]

Starting VNC server: 1: root

New 'testdb: 1 (root) 'desktop is testdb: 1

Starting applications specified in/root/. vnc/xstartup

Log file is/root/. vnc/testdb: 1.log

2: oracle

New 'testdb: 2 (oracle) 'desktop is testdb: 2

Starting applications specified in/home/oracle/. vnc/xstartup

Log file is/home/oracle/. vnc/testdb: 2.log [OK]

4) set the VNC service to automatically load as the system starts

Method 1: run the "ntsysv" command to start the graphical service configuration program. Add an asterisk to The vncserver service and click "OK". The configuration is complete.

Method 2: Use "chkconfig" to operate in command line mode. Use the following command (for more information about how to use chkconfig, see self-help man)

[Root @ testdb ~] # Chkconfig vncserver on

[Root @ testdb ~] # Chkconfig -- list vncserver

Vncserver 0: off 1: off 2: on 3: on 4: on 5: on 6: off


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.