标签:roo weight col geometry selinux The 不能启动 rhel7 问题
OS:RHEL7.2step1:安装vncserver端,这里使用的是tiger vnc
yum install tigervnc-server
yum install tigervnc
注意:使用vnc之前先得保证能够开启xwindows,所以如果你没有xwindows,需要安装:yum groupinstall "GNOME Desktop"
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
关闭selinux
step2:复制并修改配置文件
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service ==这是给root的配置文件
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service ==这是给shichunda用户的配置文件
vim /etc/systemd/system/vncserver@\:1.service ==修改成如下内容,注意红色字体
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver :1"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
vim /etc/systemd/system/vncserver@\:2.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :2 > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l shichunda -c "/usr/bin/vncserver :2 -geometry 1280*720 -depth 24"
PIDFile=/home/shichunda/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill :2 > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
step3:加载配置文件
systemctl daemon-reload
step4:配置vnc密码
su - root
vncpasswd
su - shichunda
vncpasswd
注意:也可以在vncserver :1启动的时候设置vnc密码
step5:开启vnc server
方法1:
[root@file system]# vncserver :2
You will require a password to access your desktops.
Password:
Verify:
New 'file:2 (root)' desktop is file:2
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/file:2.log
方法2:
systemctl start vncserver-root@\:1.service
注意:有的时候用这种方法不能启动vnc server。建议使用方法1
step6:客户端连接
客户端打开vnc viewer,之后输入192.168.107.105:1,之后输入root的密码即可==作为root登录
客户端打开vnc viewer,之后输入192.168.107.105:2,之后输入shichunda的密码==作为shichnda登录
查看vncserver
[root@file system]# vncserver -list
TigerVNC server sessions:
X DISPLAY # PROCESS ID
:1 31143
关闭vncserver
[fanguihua@file ~]$ vncserver -kill :3
Killing Xvnc process ID 37239
关于分辨率
默认连接到server上是1024*768分辨率,可以在server的桌面设置分辨率
在vncserver@:2.service配置文件中设置-geometry 1280*720 -depth 24没有什么效果
##################################
问题
1 用root作为:1之后,shichunda用户就不能用:1了?
是的
2 root只有一个配置文件的话,如果启动多个的话也是可以的,但只有:1能够登录,因为该用户只有1个配置文件
vncserver :1
vncserver :2
vncserver :3
[root@file system]# vncserver -list
TigerVNC server sessions:
X DISPLAY # PROCESS ID
:1 31143
:2 33659
:3 34164
此时如果在用shichunda用户启动:2的话,会报错,如下:==因为root已经占用了:2了
shichunda的配置文件如下:
[shichunda@file ~]$ more /etc/systemd/system/vncserver@\:2.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :2 > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l shichunda -c "/usr/bin/vncserver :2 -geometry 1600*900"
PIDFile=/home/shichunda/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill :2 > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
报错内容如下:
[shichunda@file ~]$ vncserver :2
Warning: file:2 is taken because of /tmp/.X2-lock
Remove this file if there is no X server file:2
A VNC server is already running as :2
把root的:2和:3关掉,用shichunda启动:2才可以
标签:roo weight col geometry selinux The 不能启动 rhel7 问题
原文地址:http://blog.51cto.com/hashing123/2155725