Jumpserver高可用集群部署:(七)RDP代理模块guacamole部署并实现系统服务管理

五迷三道 提交于 2020-11-08 04:20:46

1、配置防火墙

firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="10.255.200.1/30" port protocol="tcp" port="8081" accept"
firewall-cmd --reload

2、下载guacamole

cd /sas/src/
wget -O docker-guacamole-v2.3.2.tar.gz https://github.com/jumpserver/docker-guacamole/archive/master.tar.gz

mkdir /sas/src/docker-guacamole 
tar -xf docker-guacamole-v2.3.2.tar.gz -C /sas/src/docker-guacamole --strip-components 1 
rm -rf /sas/src/docker-guacamole-v2.3.2.tar.gz
cd /sas/src/docker-guacamole
wget http://download.jumpserver.org/public/guacamole-server-1.2.0.tar.gz 
tar -xf guacamole-server-1.2.0.tar.gz 
wget http://download.jumpserver.org/public/ssh-forward.tar.gz
tar -xf ssh-forward.tar.gz -C /bin/ 
chmod +x /bin/ssh-forward
cd /sas/src/docker-guacamole/guacamole-server-1.2.0

3、安装guacamole相关依赖

yum install -y cairo-devel libjpeg-turbo-devel libjpeg-devel libpng-devel libtool uuid-devel
yum install -y freerdp-devel pango-devel libssh2-devel libtelnet-devel libvncserver-devel libwebsockets-devel pulseaudio-libs-devel openssl-devel libvorbis-devel libwebp-devel

rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
yum install -y ffmpeg-devel

4、编译guacamole

./configure --with-init-dir=/etc/init.d
make
make install 

5、安装JDK

yum install -y java-1.8.0-openjdk

6、创建guacamole相关目录

mkdir -p /sas/jumpserver/guacamole /sas/jumpserver/guacamole/extensions /sas/jumpserver/guacamole/record /sas/jumpserver/guacamole/drive 
chown daemon:daemon /sas/jumpserver/guacamole/record /sas/jumpserver/guacamole/drive 
cd /sas/jumpserver

7、下载并配置Tomcat9

wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.38/bin/apache-tomcat-9.0.38.tar.gz

tar -xf apache-tomcat-9.0.38.tar.gz
mv apache-tomcat-9.0.38 tomcat9
rm -rf /sas/jumpserver/tomcat9/webapps/*
sed -i 's/Connector port="8080"/Connector port="8081"/g' /sas/jumpserver/tomcat9/conf/server.xml
echo "java.util.logging.ConsoleHandler.encoding = UTF-8" >> /sas/jumpserver/tomcat9/conf/logging.properties

wget http://download.jumpserver.org/release/v2.3.2/guacamole-client-v2.3.2.tar.gz
tar -xf guacamole-client-v2.3.2.tar.gz
cp guacamole-client-v2.3.2/guacamole-*.war /sas/jumpserver/tomcat9/webapps/ROOT.war
cp guacamole-client-v2.3.2/guacamole-*.jar /sas/jumpserver/guacamole/extensions/
mv /sas/src/docker-guacamole/guacamole.properties /sas/jumpserver/guacamole/

8、设置 Guacamole 环境

export JUMPSERVER_SERVER=https://10.255.200.5
echo "export JUMPSERVER_SERVER= https://10.255.200.5" >> ~/.bashrc

export BOOTSTRAP_TOKEN=xxxxxxxxxxxxxxxxx
echo "export BOOTSTRAP_TOKEN=xxxxxxxxxxxxxxxxx" >> ~/.bashrc

export JUMPSERVER_KEY_DIR=/sas/jumpserver/guacamole/data/keys
echo "export JUMPSERVER_KEY_DIR=/sas/jumpserver/guacamole/data/keys" >> ~/.bashrc

export GUACAMOLE_HOME=/sas/jumpserver/guacamole
echo "export GUACAMOLE_HOME=/sas/jumpserver/guacamole" >> ~/.bashrc

export GUACAMOLE_LOG_LEVEL=ERROR
echo "export GUACAMOLE_LOG_LEVEL=ERROR" >> ~/.bashrc

export JUMPSERVER_ENABLE_DRIVE=true
echo "export JUMPSERVER_ENABLE_DRIVE=true" >> ~/.bashrc

9、测试启动Guacamole

/etc/init.d/guacd start
sh /sas/jumpserver/tomcat9/bin/startup.sh

10、编写systemd系统服务管理脚本

# 编写启动脚本
vi /sas/jumpserver/tools/guacamole.service.sh

#!/bin/bash

export JUMPSERVER_SERVER=https://10.255.200.5
export BOOTSTRAP_TOKEN=xxxxxxxxxxxxxx
export JUMPSERVER_KEY_DIR=/sas/jumpserver/guacamole/data/keys
export GUACAMOLE_HOME=/sas/jumpserver/guacamole
export GUACAMOLE_LOG_LEVEL=ERROR
export JUMPSERVER_ENABLE_DRIVE=true

case $1 in
start)
    /etc/init.d/guacd start
    sh /sas/jumpserver/tomcat9/bin/startup.sh
    ;;
stop)
    sh /sas/jumpserver/tomcat9/bin/shutdown.sh
    /etc/init.d/guacd stop
    ;;
restart)
    sh /sas/jumpserver/tomcat9/bin/shutdown.sh
    /etc/init.d/guacd restart
    sh /sas/jumpserver/tomcat9/bin/startup.sh
    ;;
*)
    ;;
esac

# 编写服务配置文件
vi /usr/lib/system/system/guacamole.service

[Unit]
Description=Jumpserver Guacamole Services
After=network.target remote-fs.target keepalived.service jumpserver.service

[Service]
Type=forking
ExecStart=/usr/bin/bash /sas/jumpserver/tools/guacamole.service.sh start
ExecReload=/usr/bin/bash /sas/jumpserver/tools/guacamole.service.sh restart
ExecStop=/usr/bin/bash /sas/jumpserver/tools/guacamole.service.sh stop
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!