linux解决xhost: unable to open display

第二步:根据vnc起来的端口,设置export DISPLAY=localhost:1(1表示vnc在第一个tty上启动的),vnc的启动信息见附件1;
第三步:执行xhost +,并且提示“access control disabled, clients can connect from any host”才正确。

[root@localhost ~]# vncserver
New 'localhost:1 (root)' desktop is localhost:1
Starting applications specified in /root/.vnc/xstartupLog file is /root/.vnc/localhost:1.log
[root@localhost ~]# export DISPLAY=localhost:1
[root@localhost ~]# xhost +
access control disabled, clients can connect from any host

  [root] export DISPLAY=:0 或export DISPLAY=或export DISPLAY=localhost:10.0
   [root] xhost +
   [root] rpm -qa |grep X11


LSB Version: :core-3.0-ia32:core-3.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch
Distributor ID: RedHatEnterpriseAS
Description: Red Hat Enterprise Linux AS release 4 (Nahant Update 7)
Release: 4
Codename: NahantUpdate7



[oracle@swt database]$ ./runInstaller
Starting Oracle Universal Installer... Checking installer requirements... Checking operating system version: must be redhat-3, SuSE-9, redhat-4, UnitedLinux-1.0, asianux-1 or asianux-2
Passed All installer requirements met. Preparing to launch Oracle Universal Installer from /tmp/OraInstall2011-10-01_11-31-38AM. Please wait ...[oracle@swt database]$ Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(Unknown Source)
at Source)
at java.awt.Window.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at oracle.ewt.popup.PopupFrame.<init>(Unknown Source)
at oracle.ewt.lwAWT.BufferedFrame.<init>(Unknown Source)
at oracle.sysman.oio.oioc.OiocOneClickInstaller.<init>(
at oracle.sysman.oio.oioc.OiocOneClickInstaller.main(


用root 用户执行xhost

[root@swt ~]# xhost +


export LANG=en_US.UTF-8

Checking operating system requirements ...
Expected result: One of redhat-,redhat-,SuSE-,asianux-,asianux-
Actual Result: redhat-
Check complete. The overall result of this check is: Passed
======================================================================= Checking operating system package requirements ...
Checking for make-3.79; found make-:3.80-.EL4. Passed
Checking for binutils-2.14; found binutils- Passed
Checking for gcc-3.2; found gcc-3.4.-. Passed
Checking for libaio-0.3.; found libaio-0.3.-. Passed
Check complete. The overall result of this check is: Passed
======================================================================= Checking kernel parameters
Checking for semmsl=; found semmsl=. Passed
Checking for semmns=; found semmns=. Passed
Checking for semopm=; found semopm=. Failed <<<<
Checking for semmni=; found semmni=. Passed
Checking for shmmax=; found shmmax=. Failed <<<<
Checking for shmmni=; found shmmni=. Passed
Checking for shmall=; found shmall=. Passed
Checking for file-max=; found file-max=. Passed
Checking for VERSION=2.6.; found VERSION=2.6.-.ELsmp. Passed
Checking for ip_local_port_range= - ; found ip_local_port_range= - . Failed <<<<
Checking for rmem_default=; found rmem_default=. Failed <<<<
Checking for rmem_max=; found rmem_max=. Failed <<<<
Checking for wmem_default=; found wmem_default=. Failed <<<<
Checking for wmem_max=; found wmem_max=. Failed <<<<
Check complete. The overall result of this check is: Failed <<<<
Problem: The kernel parameters do not meet the minimum requirements (see above).
Recommendation: Perform operating system specific instructions to update the kernel parameters.



让更改生效,重启或执行命令sysctl –p


# Kernel sysctl configuration file for Red Hat Linux
# For binary values, is disabled, is enabled. See sysctl() and
# sysctl.conf() for more details. # Controls IP packet forwarding
net.ipv4.ip_forward = # Controls source route verification
net.ipv4.conf.default.rp_filter = # Do not accept source routing
net.ipv4.conf.default.accept_source_route = # Controls the System Request debugging functionality of the kernel
kernel.sysrq = # Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = kernel.shmall =
kernel.shmmax =
kernel.shmmni =
kernel.sem =
fs.file-max =
net.ipv4.ip_local_port_range =
net.core.rmem_default =
net.core.rmem_max =
net.core.wmem_default =
net.core.wmem_max =

Checking available swap space requirements ...
Expected result: 2652MB
Actual Result: 1983MB
Check complete. The overall result of this check is: Failed <<<<
Problem: The system does not have the required swap space.
Recommendation: Make more swap space available to perform the install.


Expected result:2652MB
Actual Result:1983MB





(第一步:使用free -m查看目前swap的交换空间情况,1019M,也可以使用grep SwapTotal /proc/meminfo查看)

[root@localhost swapimage]# free -m

total used free shared buffers cached

Mem: 1010 995 15 0 1 847

-/+ buffers/cache: 145 865

Swap: 1019 0 1019

(用df –h查看磁盘空间的使用情况)

[root@localhost ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda2 3.8G 3.1G 572M 85% /

/dev/sda3 15G 1.7G 13G 13% /home

/dev/sda1 46M 11M 33M 25% /boot

tmpfs 506M 0 506M 0% /dev/shm

(第二步:确保系统中有足够的空间用来做swap交换空间,经过df –h查看,只有/home下面还有13G的空间是比较大的,所以我这边准备在/home/swapimage开辟swap交换区)

[root@localhost home]# mkdir swapimage(在/home目录下创建swapimage文件夹)

[root@localhost home]# cd swapimage/ (进入swapimage文件夹)

[root@localhost swapimage]# dd if=/dev/zero f=/home/swapimage/swap bs=1024count=1024000(添加交换文件并设置大小为1G)

1024000+0 records in

1024000+0 records out

1048576000 bytes (1.0 GB) copied, 16.2007 seconds, 64.7 MB/s

(再次用df –h查看磁盘空间的使用情况,/home的可以大小已经由13G变成12G了,也就是说通过上面的dd操作,我们已经成功的分配了1G的swap交换空间)

[root@localhost swapimage]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda2 3.8G 3.1G 572M 85% /

/dev/sda3 15G 2.7G 12G 20% /home

/dev/sda1 46M 11M 33M 25% /boot

tmpfs 506M 0 506M 0% /dev/shm


[root@localhost swapimage]# mkswap /home/swapimage/swap

Setting up swapspace version 1, size = 1048571 kB


[root@localhost swapimage]# swapon /home/swapimage/swap

(使用free –m确认新增的swap交换空间已生效,2019)

[root@localhost swapimage]# free -m

total used free shared buffers cached

Mem: 1010 997 13 0 2 848

-/+ buffers/cache: 146 864

Swap: 2019 0 2019


[root@localhost swapimage]# vi /etc/fstab

/home/swapimage/swap swap swap defaults 0 0


Checking Network Configuration requirements ...
Check complete. The overall result of this check is: Not executed <<<<
Recommendation: Oracle supports installations on systems with DHCP-assigned public IP addresses. However, the primary network interface on the system should be configured with a static IP address in order for the Oracle Software to function properly. See the Installation Guide for more details on installing the software on systems configured with DHCP.


[oracle@localhost database]$ vi /etc/sysconfig/network-scripts/ifcfg-eth0

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]












/sbin/ifdown eth0

/sbin/ifup eth0


service network restart

(设置好静态IP地址后retry,还是Not executed,搜索到资料讲需要修改/etc/hosts文件,将127.0.0.1修改为192.168.1.289(也就是设置的静态IP地址))

[oracle@localhost database]$ su root


[root@localhost database]# vi /etc/hosts


如果 固定IP是已经配置好的,仍然提示DHCP的问题,可能是/etc/hosts文件配置错误。



  1. Centos7.2yum安装时候出现db5错误的解决办法

    Centos7.2使用yum安装软件是出现如此错误提示 解决办法 删除 /var/lib/rpm文件夹下面所有以__db开头的文件

  2. Android studio 安装中遇到一些问题的解决办法,分享一下

    从eclipse转到android studio也是很无耐,刚开始总是会遇到很多难题,但是都不要轻言放弃. 以下是我遇到的问题,并通过搜索引擎找到的解决办法,善用工具,善用头脑,勿为伸手之人. And ...

  3. GDI+中发生一般性错误的解决办法

    这个错误经常发生,代码如下: private  static  byte[] GetBytes (Image image) { try { if (image == null) return null ...

  4. GDI+中发生一般性错误的解决办法(转帖)

    今天在开发.net引用程序中,需要System.Drawing.Image.Save 创建图片,debug的时候程序一切正常,可是发布到IIS后缺提示出现“GDI+中发生一般性错误”的异常.于是开始“ ...

  5. 【转】GDI+中发生一般性错误的解决办法

    今天在开发.net引用程序中,需要System.Drawing.Image.Save 创建图片,debug的时候程序一切正常,可是发布到IIS后缺提示出现“GDI+中发生一般性错误”的异常. 于是开始 ...

  6. GDI+中发生一般性错误的解决办法(转)

    今天在开发.net引用程序中,需要System.Drawing.Image.Save 创建图片,debug的时候程序一切正常,可是发布到IIS后缺提示出现"GDI+中发生一般性错误" ...

  7. 关于Excel文件导入到Sqlserver2008中出现截断错误的解决办法

    出现错误的可能原因: 1.数据库字段Varchar长度不够: 2.不能用Text类型: 3.数据中可能存在换行符: 4.数据项文本过长,超过4000: 5.前8行的最大长度不够大,后面有超过的. 解决 ...

  8. GDI+中发生一般性错误的解决办法(转载)

    今天在开发.net引用程序中,需要System.Drawing.Image.Save 创建图片,debug的时候程序一切正常,可是发布到IIS后缺提示出现"GDI+中发生一般性错误" ...

  9. python学习中遇到的错误及解决办法

    1. nodename nor servname provided 原因:Python程序中有段程序调用 socket.gethostbyname(socket.gethostname()) sock ...


  1. bzoj 4445 [SCOI2015] 小凸想跑步

    题目大意:一个凸包,随机一个点使得其与前两个点组成的面积比与其他相邻两个点组成的面积小的概率 根据题意列方程,最后求n条直线的交的面积与原凸包面积的比值 #include<bits/stdc++ ...

  2. SQL存储过程删除数据库日志文件的方法

    --日志文件收缩至多少M DECLARE @DBLogSise AS INT SET @DBLogSise=0 --查询出数据库对应的日志文件名称 DECLARE @strDBName AS NVAR ...

  3. 【转】VC++与MySQL数据库的连接

    原文地址: 1.MySQL数据库的安装 你可以从MySQL的官网上或者从如下地址下载 ...

  4. 八大排序c++可运行精简版,一目了然

    #include <iostream> using namespace std; // 插入排序开始===================== void insert_sort(int a ...

  5. MaltReport2:基于 OpenDocument/OpenOfficeXML 的报表引擎

    MaltReport 是我几年前写的开源单据.报表引擎,最近进行了较大的更新,尤其是几年来在生产项目中应用取得了非常好的效果,特别写篇介绍文字给大家分享一下. 首先先介绍几个名词: OpenDocum ...

  6. 关于HTML应用中的实操细节

    在编写HTML程序时,初阶段在打编码时容易忽视语法方面的问题,如大小写,中英文切换标点等.正常在编码时出现语法问题自己很难发现,所以刚开始练习特别要注重语法方面的规范,另外在编码时要有规范的书写方式, ...

  7. smarty安装与配置

    smarty是一个 PHP 模板引擎,也就是一个类库, 可以到官网下载,也可以到其GitHub地址去下载: 鄙人下载的是 3.1.32版本,解压后的目录结构如下: 最重要的是 libs 目录,demo ...

  8. 关于UI设计行业的认识再到认识

    相信很多同学和我一样提及到UI行业时,尤其是连门槛都没有踏入半步时,总会一脸茫然. 我也是一样的,我刚接触UI的前半个月,文章读过好多,作品也看过好多,什么"小白入门UI的十大建议啊&quo ...

  9. PHP高级教程-包含

    PHP 包含文件 PHP include 和 require 语句 在 PHP 中,您可以在服务器执行 PHP 文件之前在该文件中插入一个文件的内容. include 和 require 语句用于在执 ...

  10. [java]String和Date、Timestamp之间的转换

    一.String与Date(java.util.Date)互转  1.1 String -> Date Date date = DateFormat.parse(String  str); St ...