麒麟操作系统配置vnc(root登录)
环境:
Os:v2401.ky10 sp3
1.安装vnc
[root@hxl ~]#dnf install tigervnc-server -y
2.修改配置文件
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
vi /etc/systemd/system/vncserver@:1.service
原来的:
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
WorkingDirectory=/home/<USER>
User=<USER>
Group=<USER>
PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver -autokill %i
ExecStop=/usr/bin/vncserver -kill %i
Restart=on-success
RestartSec=15
[Install]
WantedBy=multi-user.target
修改为:
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
WorkingDirectory=/root
User=root
Group=root
PIDFile=/root/.vnc/%H%i.pid
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver -autokill %i
ExecStop=/usr/bin/vncserver -kill %i
Restart=on-success
RestartSec=15
[Install]
WantedBy=multi-user.target
4.关闭防火墙
systemctl status firewalld.service
systemctl stop firewalld.service
systemctl disable firewalld.service
vi /etc/selinux/config
set "SELINUX=disabled" and comment the rest lines.
4.加载配置
[root@localhost ~]# systemctl daemon-reload
5.设置vnc密码
su - oracle
[oracle@localhost ~]$ vncpasswd
我这里设置密码为:Aub*axl3
6.启动
systemctl start vncserver@:1.service
7.查看端口
[root@localhost ~]# ss -nlp|grep 5901
tcp LISTEN 0 5 0.0.0.0:5901 0.0.0.0:* users:(("Xvnc",pid=29774,fd=6))
tcp LISTEN 0 5 [::]:5901 [::]:* users:(("Xvnc",pid=29774,fd=7))
[root@localhost ~]#
8.普通用户的登录配置
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
WorkingDirectory=/home/oracle
User=oracle
Group=oinstall
PIDFile=/home/oracle/.vnc/%H%i.pid
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver -autokill %i
ExecStop=/usr/bin/vncserver -kill %i
Restart=on-success
RestartSec=15
[Install]
WantedBy=multi-user.target
说明:
发现麒麟系统的环境变量需要放在.bashrc这个文件才生效,放在 .bash_profile通过vnc登录不生效
[oracle@19c ~]$ more .bashrc
# Source default setting
[ -f /etc/bashrc ] && . /etc/bashrc
# User environment PATH
export PATH
export EDITOR=vi
export ORACLE_SID=ora19c
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3.0.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export PATH=$ORACLE_HOME/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:/bin
export CV_ASSUME_DISTID=OEL7
umask 022