DISPLAY

在Linux/Unix类操作系统上, DISPLAY用来设置将图形显示到何处. 直接登陆图形界面或者登陆命令行界面后使用startx启动图形, DISPLAY环境变量将自动设置为:0:0, 此时可以打开终端, 输出图形程序的名称(比如xclock)来启动程序, 图形将显示在本地窗口上, 在终端上输入printenv查看当前环境变量, 输出结果中有如下内容:
DISPLAY=:0.0
使用xdpyinfo可以查看到当前显示的更详细的信息.
DISPLAY
环境变量格式如下hostname:
displaynumber.screennumber,我们需要知道,在某些机器上,可能有多个显示设备共享使用同一套输入设备,例如在一台PC上连接两台CRT显示器,但是它们只共享使用一个键盘和一个鼠标。这一组显示设备就拥有一个共同的displaynumber,而这组显示设备中的每个单独的设备则拥有自己单独的
screennumber。displaynumber和screennumber都是从零开始的数字。这样,对于我们普通用户来说,
displaynumber、screennumber就都是0。 hostname指Xserver所在的主机主机名或者ip地址,
图形将显示在这一机器上, 可以是启动了图形界面的Linux/Unix机器, 也可以是安装了Exceed,
X-Deep/32等Windows平台运行的Xserver的Windows机器. 如果Host为空, 则表示Xserver运行于本机,
并且图形程序(Xclient)使用unix socket方式连接到Xserver, 而不是TCP方式. 使用TCP方式连接时,
displaynumber为连接的端口减去6000的值, 如果displaynumber为0, 则表示连接到6000端口; 使用unix
socket方式连接时则表示连接的unix socket的路径, 如果displaynumber为0,
则表示连接到/tmp/.X11-unix/X0 . screennumber则几乎总是0.
如果使用su username或者su - username切换到别的用户, 并且使用命令
export DISPLAY=:0.0
设置DISPLAY环境变量, 运行图形程序(如xclock)时会收到如下错误:
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
Error: Can't open display: :0.0
这是因为Xserver默认情况下不允许别的用户的图形程序的图形显示在当前屏幕上. 如果需要别的用户的图形显示在当前屏幕上, 则应以当前登陆的用户, 也就是切换身份前的用户执行如下命令
xhost +

xhost 是用来控制X
server访问权限的,这个命令将允许别的用户启动的图形程序将图形显示在当前屏幕上.。通常当你从hostA登陆到hostB上运行hostB上的应用程序时,做为应用程序来说,hostA是client,但是作为图形来说,是在hostA上显示的,需要使用hostA的Xserver,所以hostA是
server.因此在登陆到hostB前,需要在hostA上运行xhost +,来使其它用户能够访问hostA的Xserver.
xhost + 是使所有用户都能访问Xserver.
xhost + ip使ip上的用户能够访问Xserver.
xhost + nis:user@domain使domain上的nis用户user能够访问
xhost + inet:user@domain使domain上的inet用户能够访问。
在2台Linux机器之间, 如果设置服务器端配置文件/etc/ssh/sshd_config中包含
X11Forwarding no
客户端配置文件/etc/ssh/ssh_config包含
ForwardX11 yes
则从客户端ssh到服务器端后会自动设置DISPLAY环境变量, 允许在服务器端执行的图形程序将图形显示在客户端上. 在服务器上查看环境变量显示如下(这个结果不同的时候并不相同)
DISPLAY=localhost:10.0
在客户机上用netstat -lnp可以看到有程序监听了6010端口
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 4827/1
如果希望允许远程机器上的图形程序将图形显示在本地机器的Xserver上,
除了要设置远端机器的DISPLAY环境变量以外, 还需要设置本地机器的Xserver监听相应的TCP端口.
而现在的Linux系统出于安全的考虑, 默认情况下不再监听TCP端口. 可通过修改/etc/X11/xinit/xserverrc文件, 将
exec /usr/bin/X11/X -dpi 100 -nolisten tcp
修改为
exec /usr/bin/X11/X -dpi 100
允许在直接使用startx启动图形时启动对TCP端口的监听.
修改/etc/kde3/kdm/kdmrc, 将
ServerArgsLocal=-nolisten tcp
修改为
ServerArgsLocal=
允许kdm作为显示管理器时, 启动会话时监听相应的TCP端口.
修改/etc/gdm/gdm.conf, 在[Security]一节增加
DisallowTCP=false
或者在登陆窗口选择"Options"
-> "Configure Login Manager..."的Security页面, 取消"Deny TCP connections
to Xserver", 允许gdm作为显示管理器时, 启动会话时监听相应的TCP端口.

常见错误和解决方法

cause:
X-Windows emulation is not yet correctly configured or is being mis-used.
solution:
1.Make sure that "DISPLAY” is set properly as either:
     <ip address of the DBA desktop PC>:0.0
          or
     <hostname of the DBA desktop PC>:0.0
note:In this example, ip_address/hostnameis
the host name or IP address of the system that you want to use to
display Oracle Universal Installer (your workstation or PC).
eg.[root@rac1 ~]# xhost +
access control disabled, clients can connect from any host
[root@rac1 ~]# su - oracle
[oracle@rac1 ~]$ export DISPLAY=192.16.2.98:0.0
[oracle@rac1 ~]$ cd database/
[oracle@rac1 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/OraInstall2009-03-05_03-36-28PM. Please wait ...[oracle@rac1
database]$ Oracle Universal Installer, Version 10.2.0.1.0 Production
Copyright (C) 1999, 2005, Oracle. All rights reserved.

2.
Oracle Customer Support has seen instances where use of the UNIX/Linux
“su” command, even “su - oracle” has caused this “Can't connect to X11
window server” error. Therefore, please be sure that you are LOGGED ON
as the oracle account. Log directly into the install session. Do not use
any variety of “su”.
     use oracle log on , not "su - oracle"
eg. [oracle@rac1 database]$ ./runInstaller

3.Oracle
Customer Support has seen instances where the incorrect “ulimit”
setting for number of files (aka “-n”, aka “nofiles”) has caused this
“Can't connect to X11 window server” error. Therefore, please be sure
that your values for “nofiles” in the output of “ulimit -a” is at least
65536.

备注:前2个办法只需要满足其中一个就可以避免这个错误了:直接用oracle登陆,不能su - oracle  or 设置display=ip_address_that you want to use to display Oracle Universal Installer:0.0

NO.35 xhost: unable to open display ""
以root用户登录
输入命令xdpyinfo,记录下里面的name of display:后的字符串,如 name of display:127.0.0.1:1.0
在执行xhost +命令(使得所有客户都可以访问)
返回信息为:
access control disabled,clients can connect from any host
如果xhost +不能执行,可以输入命令export DISPLAY=:0执行一下
再执行xhost +
xhost + ip (name表示那个ip机器可以使用该服务)
2、以oracle用户登录
如果前面root登录下执行xdpyinfo后的name of display:后的字符串是127.0.0.1:1.0
那么在该oracle用户下执行一下export DISPLAY=:1.0
然后再执行xdpyinfo命令,如果能出现信息说明你已经成功了
这样估计就可以解决linux下安装oracle出现的xhost问题
如果还是不成功,请确认是否开启了startx

XDMCP被禁用

启用 XDMCP 红帽 Linux 上

在 RHEL,默认情况下仅为本地主机启用 X 11。你需要能够连接从外部框中编辑文件/etc/gdm/custom.conf。RHEL 的默认设置是

DisallowTCP=yes
其中应改为"假"
要启用 XDMCP 一些用户需要你需要启用它。
[xdmcp]
Enable=true
之后重新启动 X 11 服务器使用命令
init 3 && init 5
如果另外您想要提供能力,以 root 用户身份登录,您需要安保科,如下所示
[security]
    DisallowTCP=false
    AllowRemoteRoot=true
如果启用了防火墙,则您需要打开几个端口
177 (UDP) 端口和端口 6000-6005 (TCP)
如果您正在使用 Gnome 打开 TCP 端口 16001 和 TCP 35091 在两个方向。
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 16001 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 177 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 35091 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 6000:6005 -j ACCEPT

DISPLAY变量和xhost(原创)的更多相关文章

  1. 关于DISPLAY变量显示问题

    DISPLAY用来设置将图形显示到何处 在本机上直接登录之后,startx,可以发现display变量自动设置为 [oracle@kel ~]$ echo $DISPLAY :0.0 不论使用何种用户 ...

  2. EBS运行快速安装的程序时,提示DISPLAY变量设置不对

    EBS运行快速安装的程序时,系统提示如下: Rapid Install Wizard is validating your file system...... >> Wizard requ ...

  3. 因xhost命令和DISPLAY环境变量操作不当导致无法启动Oracle图形化安装界面

    在redhat操作系统上安装Oracle 11.1时,遇到在执行runInstaller后无法启动安装图像化界面,甚是郁闷. 问题现象: 使用Xmanager2.0软件登陆AIX桌面,root用户可以 ...

  4. 完美解决xhost +报错: unable to open display "" 装oracle的时候总是在弹出安装界面的时候出错

    详细很多朋友在装oracle的时候总是在弹出安装界面的时候出错,界面就是蹦不出来. oracle安装 先切换到root用户,执行xhost + 然后再切换到oracle用户,执行export DISP ...

  5. 使用Xmanager连接linux,操作“xhost +”时出现类似“xhost: unable to open display "192.168.1.1811:1.0" ”问题的解决

    远程连接linux服务器时,有的时候需要把服务器上的图形界面投影到本地来进一步操作,比如linux下安装oracle时就需要在oracle用户下允许视图状态投影到本地,这需要使用命令: xhost + ...

  6. Linux 如何解决 xhost: unable to open display ""

    [root@host02 ~]# vncservice You will require a password to access your desktops. Password: Verify: x ...

  7. ssh & display

    在Windows下用ssh连接服务器的话putty是一个小巧而且实用的工具,如果想要图形界面,可以使用X工具配合putty. 或者直接使用xmanager enterprise,非 常方便. 如果在U ...

  8. xhost和XServer相关概念汇总

    1.xhost 控制什么人可以访问当前主机上的增强 X-Windows.语法:xhost [ + | - ] [ Name ] 2.xhost 是用来控制X server访问权限的.通常当你从host ...

  9. oracle中xhost报错

    一.命令找不到 xhost:command not found yum whatprovides "*/xhost" Loaded plugins: product-id, sec ...

随机推荐

  1. [LOJ3084][GXOI/GZOI2019]宝牌一大堆——DP

    题目链接: [GXOI/GZOI2019]宝牌一大堆 求最大值容易想到$DP$,但如果将$7$种和牌都考虑进来的话,$DP$状态不好设,我们将比较特殊的七小对和国士无双单独求,其他的进行$DP$. 观 ...

  2. sips 命令(iMac 下系统自带)

    2. sips 2.1 -Z 指定最大宽高 //等比例缩放 scaleFill $ sips -Z 300 hgl.png $ for i in *.jpg;do sips -Z 300 " ...

  3. python中的__dict__,__getattr__,__setattr__

    python class 通过内置成员dict 存储成员信息(字典) 首先用一个简单的例子看一下dict 的用法 class A(): def __init__(self,a,b): self.a = ...

  4. 【集训队作业2018】取名字太难了 任意模数FFT

    题目大意 求多项式 \(\prod_{i=1}^n(x+i)\) 的系数在模 \(p\) 意义下的分布,对 \(998244353\) 取模. \(p\) 为质数. \(n\leq {10}^{18} ...

  5. HTML&CSS_基础03

    一.Meta标签: 1.可以设置网页的关键字 2.用来指定网页描述 3.可以用来网页重定向 具体参数参见:http://www.w3school.com.cn/html5/tag_meta.asp 二 ...

  6. Git中.gitignore文件不起作用的解决以及Git中的忽略规则介绍

    在Studio里使用Git管理代码的过程中,可以修改.gitignore文件中的标示的方法来忽略开发者想忽略掉的文件或目录,如果没有.gitignore文件,可以自己手工创建.在.gitignore文 ...

  7. 第二篇--PCI设备解析

    介绍:参考 一个系统上最多有256个PCI总线,每个总线最多有32个设备,每个设备最多有8个功能,每个功能最多有256字节的配置地址空间,所以总的配置地址空间是16M. PCI设备有物理设备和逻辑设备 ...

  8. python_类与对象学习笔记

    class Phone: #手机属性===>类属性 # color='black' # price=4500 # brand='oppo' # size='5.5' #参数化-魔法方法--初始化 ...

  9. echarts 折线图自定义颜色与修改legend颜色

    option4 = { title : { text: '', subtext: '' }, color:['#2db7f5','#ff6600','#808bc6'],      //关键加上这句话 ...

  10. 使用基本MVC2模式创建新闻网站

    MVC简介 所谓MVC,即Model-View-Controller. (1)Model层:Model指模型部分,一般在应用中Model层包括业务处理层和数据访问层.数据访问层主要是对数据库的一些操作 ...