图片 1

ORACLE 11g设置中现身xhost: unable to open display难题解决步骤_oracle_脚本之家

一、Xhosts报错

Git地址:
环境:
Linux system:CentOS
6.2
libvirt: 0.10.2
webvirtmgr的安装,参考:
1.安装虚拟化环境

安装好vncserver,本地pc笔记本能通过vnc
viewer远程连接Oracle服务器,但是在执行xhost+报错,尝试过localhost,尝试过127.0.0.1,也试过本机ip地址,都是unable
toopen displa,如下所示

yum -y groupinstall 'Virtualization Tools'
yum -y groupinstall 'Virtualization'
yum -y groupinstall 'Virtulization Client'
yum -y groupinstall 'Virtulization Platform'
[root@orcltest ~]# export DISPLAY=localhost:1[root@orcltest ~]# xhostxhost: unable to open display "localhost:1"[root@orcltest ~]# [root@orcltest ~]# export DISPLAY=127.0.0.1:1[root@orcltest ~]# xhostxhost: unable to open display "127.0.0.1:1"[root@orcltest ~]# xhost +xhost: unable to open display "127.0.0.1:1"[root@orcltest ~]# xhost + 192.51.3.12xhost: unable to open display "192.51.3.12:1"

2.安装依赖包

二、去查看后台的vnc日志信息,日志信息,看到vnc日志信息正常,没有啥异常信息

$ sudo yum -y install http://dl.Fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
$ sudo yum -y install git python-pip libvirt-python libxml2-python python-websockify supervisor nginx
 [root@orcltest ~]# vim /root/.vnc/orcltest:1.log Xvnc TigerVNC 1.1.0 - built May 11 2016 13:01:55 Copyright  1999-2011 TigerVNC Team and many others  See http://www.tigervnc.org for information on TigerVNC. Underlying X server release 11704000, The X.Org Foundation Tue Mar 14 03:23:26 2017 vncext: VNC extension running! vncext: Listening for VNC connections on all interface, port 5901 vncext: created VNC server for screen 0 GNOME_KEYRING_SOCKET=/tmp/keyring-jRupIx/socket SSH_AUTH_SOCK=/tmp/keyring-jRupIx/socket.ssh GNOME_KEYRING_PID=7358 Cleaned 21 files 7 still live Failed to play sound: Not available (polkit-gnome-authentication-agent-1:7380): GLib-GObject-WARNING **: cannot register existing type `_PolkitError' (polkit-gnome-authentication-agent-1:7380): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed ** (gnome-user-share:7381): WARNING **: gnome-user-share cannot be started as root for security reasons. Initializing nautilus-gdu extension ** : WARNING **: panel-applet-frame.c:1288: failed to load applet OAFIID:GnoteApplet:  ** : WARNING **: panel-applet-frame.c:1288: failed to load applet OAFIID:GNOME_FastUserSwitchApplet: 

3.克隆代码

三、试试xdyinfo

$ git clone git://github.com/retspen/webvirtmgr.git
$ cd webvirtmgr
$ sudo pip install -r requirements.txt # or python-pip (RedHat, Fedora, CentOS, OpenSUSE)

Google到了一些资料,有准备安装xdyinfo成功的,这里也试试看,先安装xdpyinfo

用pip安装django不太顺利,报错:
[root@vm03 ~]# pip install Django==1.5.5
Collecting Django==1.5.5
Could not find a version that satisfies the requirement Django==1.5.5
(from versions: 1.7plus-email-as-username-1.7.0, 4store-0.3, 503-0.1)
No matching distribution found for Django==1.5.5
折腾许久,只能去django官网下载了个Django-1.5.12.tar.gz包来安装

 [root@orcltest ~]# xdpyinfo -bash: xdpyinfo: command not found [root@orcltest ~]# yum install -y xdpyinfo Loaded plugins: refresh-packagekit, security Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package xorg-x11-utils.x86_64 0:7.5-14.el6 will be installed --> Processing Dependency: libdmx.so.1 for package: xorg-x11-utils-7.5-14.el6.x86_64 --> Processing Dependency: libXxf86dga.so.1 for package: xorg-x11-utils-7.5-14.el6.x86_64 --> Running transaction check ---> Package libXxf86dga.x86_64 0:1.1.4-2.1.el6 will be installed ---> Package libdmx.x86_64 0:1.1.3-3.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================================================================================================================================================== Installing: xorg-x11-utils x86_64 7.5-14.el6 base 101 k Installing for dependencies: libXxf86dga x86_64 1.1.4-2.1.el6 base 18 k libdmx x86_64 1.1.3-3.el6 base 15 k Transaction Summary =============================================================================================================================================================================================================================================================================== Install 3 Package Total download size: 133 k Installed size: 270 k Downloading Packages: : libXxf86dga-1.1.4-2.1.el6.x86_64.rpm | 18 kB 00:00 : libdmx-1.1.3-3.el6.x86_64.rpm | 15 kB 00:00 : xorg-x11-utils-7.5-14.el6.x86_64.rpm | 101 kB 00:00 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 252 kB/s | 133 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : libXxf86dga-1.1.4-2.1.el6.x86_64 1/3 Installing : libdmx-1.1.3-3.el6.x86_64 2/3 Installing : xorg-x11-utils-7.5-14.el6.x86_64 3/3 Verifying : libdmx-1.1.3-3.el6.x86_64 1/3 Verifying : xorg-x11-utils-7.5-14.el6.x86_64 2/3 Verifying : libXxf86dga-1.1.4-2.1.el6.x86_64 3/3 Installed: xorg-x11-utils.x86_64 0:7.5-14.el6 Dependency Installed: libXxf86dga.x86_64 0:1.1.4-2.1.el6 libdmx.x86_64 0:1.1.3-3.el6 Complete! [root@orcltest ~]#

4.Django环境初始化
执行syncdb时,报错,未安装mysqldb
于是下载MySQL-Python-1.2.5.zip,解压安装,又是一个报错:command ‘gcc’
failed with exit status 1
原因是未安装:mysql-devel,python-devel,mysql-python

之后再执行xdpyinfo,可以xhsot
+成功,如下所示,就可以启动./runInstaller安装oracle了。

$ ./manage.py syncdb
$ ./manage.py collectstatic
 [root@orcltest ~]# xdpyinfo xdpyinfo: unable to open display "localhost:1". [root@orcltest ~]# xhost + 192.51.3.12 Xhost: unable to open display "localhost:1" [root@orcltest ~]# export DISPLAY=:1.0 [root@orcltest ~]# xhost + access control disabled, clients can connect from any host [root@orcltest ~]#

5.配置nginx
vim /etc/nginx/conf.d/webvirtmgr.conf 内容如下:

总结

server {
    listen 80 default_server;

    server_name $hostname;
    #access_log /var/log/nginx/webvirtmgr_access_log; 

    location /static/ {
        root /var/www/webvirtmgr/webvirtmgr; # or /srv instead of /var
        expires max;
    }

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_connect_timeout 600;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        client_max_body_size 1024M; # Set higher depending on your needs 
    }
}

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对脚本之家的支持。

注释掉nginx的default内容,vim /etc/nginx/conf.d/default.conf
。然后启动nginx

 sudo service nginx restart

6.启动django

./manage.py runserver 0.0.0.0:8000

访问: (x.x.x.x – your server IP address
),输入创建的django用户和密码,如果没有创建,请用python manager.py
createsuperuser,命令创建。登录后如下图所示

图片 1

webvirtmgr客户端就这样搭建完了,接下来需要配置虚拟机所在宿主机的,参考git地址:

配置宿主机环境:
system: centos 6.6
libvirt: 0.10.2
1.下载并执行脚本:libvirt-bootstrap.sh
如果虚拟机比较多,该脚本执行时间会比较长,因为会执行service
libvirt-guests
restart,会将所有运行的虚拟机挂起然后再恢复,感觉这一步不是必须的,因为我有一台只设置ssh认证,也可以正常连接。

curl http://retspen.github.io/libvirt-bootstrap.sh | sudo sh

2.设置防火墙:

 sudo iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 16509 -j ACCEPT

3.设置TCP认证Setup TCP authorization

参考:

$ sudo saslpasswd2 -a libvirt fred
Password: xxxxxx
Again (for verification): xxxxxx

查看新加的账号

$ sudo sasldblistusers2 -f /etc/libvirt/passwd.db
fred@webvirtmgr.net: userPassword

删除新加的账号:

sudo saslpasswd2 -a libvirt -d fred

验证新加的账号:

virsh -c qemu+tcp://IP_address/system nodeinfo
Please enter your authentication name: fred@webvirtmgr.net
Please enter your password: xxxxxx
CPU model:           x86_64
CPU(s):              2
CPU frequency:       2611 MHz
CPU socket(s):       1
Core(s) per socket:  2
Thread(s) per core:  1
NUMA cell(s):        1
Memory size:         2019260 kB

注意:账号全名带hostname,如fred@webvirtmgr.NET

4.设置ssh认证
ssh和tcp设置一种即可,其实就是设置无密码登录,要注意的是从webvirtmgr的什么用户到宿主机的什么用户的无密码登录,比如我用root跑的django
webvirtmgr,而宿主机也是root跑的virsh,所以需要设置root到root的无密码登录。而git官网推荐的是用nginx用户跑django
webvirtmgr,webvirtmgr用户跑的virsh,所以设置的是nginx用户到宿主机webvirtmgr用户的无密码登录。
参考: