一键安装jumpserver

文章目录

      • 一、jumpserver解决了什么
      • 二、jumpserver和ansible的区别
      • 三、jumpserver安装
        • 1、2.14.2版
        • 2、基础版
        • 3、帮助
        • 4、报错解决

一、jumpserver解决了什么

解决了运维资产管理的问题

硬件配置: 2 个 CPU 核心, 4G 内存, 50G 硬盘(最低)
操作系统: Linux 发行版 x86_64
Python = 3.6.x
Mysql Server ≥ 5.6
Mariadb Server ≥ 5.5.56
Redis

二、jumpserver和ansible的区别

jumpserver是资产管理的问题的工具
ansible是自动化运维的管理工具,两者没有什么先关联

三、jumpserver安装

https://github.com/jumpserver/jumpserver/releases/tag/v2.14.2

1、2.14.2版

[root@jumpserver ~]# vim quick_start.sh 
#!/bin/bash
Version=v2.14.2

function install_soft() {
    if command -v dnf > /dev/null; then
      if [ "$1" == "python" ]; then
        dnf -q -y install python2
        ln -s /usr/bin/python2 /usr/bin/python
      else
        dnf -q -y install "$1"
      fi
    elif command -v yum > /dev/null; then
      yum -q -y install "$1"
    elif command -v apt > /dev/null; then
      apt-get -qqy install "$1"
    elif command -v zypper > /dev/null; then
      zypper -q -n install "$1"
    elif command -v apk > /dev/null; then
      apk add -q "$1"
      command -v gettext >/dev/null || {
      apk add -q gettext-dev
    }
    else
      echo -e "[\033[31m ERROR \033[0m] Please install it first (请先安装) $1 "
      exit 1
    fi
}

function prepare_install() {
  for i in curl wget zip python; do
    command -v $i &>/dev/null || install_soft $i
  done
}

function get_installer() {
  echo "download install script to /opt/jumpserver-installer-${Version} (开始下载安装脚本到 /opt/jumpserver-installer-${Version})"
  cd /opt || exit 1
  if [ ! -d "/opt/jumpserver-installer-${Version}" ]; then
    wget -qO jumpserver-installer-${Version}.tar.gz https://github.com/jumpserver/installer/releases/download/${Version}/jumpserver-installer-${Version}.tar.gz || {
      rm -rf /opt/jumpserver-installer-${Version}.tar.gz
      echo -e "[\033[31m ERROR \033[0m] Failed to download jumpserver-installer-${Version} (下载 jumpserver-installer-${Version} 失败, 请检查网络是否正常或尝试重新执行脚本)"
      exit 1
    }
    tar -xf /opt/jumpserver-installer-${Version}.tar.gz -C /opt || {
      rm -rf /opt/jumpserver-installer-${Version}
      echo -e "[\033[31m ERROR \033[0m] Failed to unzip jumpserver-installer-${Version} (解压 jumpserver-installer-${Version} 失败, 请检查网络是否正常或尝试重新执行脚本)"
      exit 1
    }
    rm -rf /opt/jumpserver-installer-${Version}.tar.gz
  fi
}

function config_installer() {
  cd /opt/jumpserver-installer-${Version} || exit 1
  sed -i "s/VERSION=.*/VERSION=${Version}/g" /opt/jumpserver-installer-${Version}/static.env
  ./jmsctl.sh install
}

function main(){
  prepare_install
  get_installer
  config_installer
}

2、基础版

[root@jumpserver ~]# vim  jumpserver.sh 
#!/bin/bash
function prepare_check() {
  isRoot=`id -u -n | grep root | wc -l`
  if [ "x$isRoot" != "x1" ]; then
      echo -e "[\033[31m ERROR \033[0m] Please use root to execute the installation script (请用 root 用户执行安装脚本)"
      exit 1
  fi
  processor=`cat /proc/cpuinfo| grep "processor"| wc -l`
  if [ $processor -lt 2 ]; then
      echo -e "[\033[31m ERROR \033[0m] The CPU is less than 2 cores (CPU 小于 2核,JumpServer 所在机器的 CPU 需要至少 2核)"
      exit 1
  fi
  memTotal=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`
  if [ $memTotal -lt 3750000 ]; then
      echo -e "[\033[31m ERROR \033[0m] Memory less than 4G (内存小于 4G,JumpServer 所在机器的内存需要至少 4G)"
      exit 1
  fi
}

function install_soft() {
    if command -v dnf > /dev/null; then
      if [ "$1" == "python" ]; then
        dnf -q -y install python2
        ln -s /usr/bin/python2 /usr/bin/python
      else
        dnf -q -y install $1
      fi
    elif command -v yum > /dev/null; then
      yum -q -y install $1
    elif command -v apt > /dev/null; then
      apt-get -qqy install $1
    elif command -v zypper > /dev/null; then
      zypper -q -n install $1
    elif command -v apk > /dev/null; then
      apk add -q $1
    else
      echo -e "[\033[31m ERROR \033[0m] Please install it first (请先安装) $1 "
      exit 1
    fi
}

function prepare_install() {
  for i in curl wget zip python; do
    command -v $i &>/dev/null || install_soft $i
  done
}

function get_installer() {
  echo "download install script to /opt/jumpserver-installe (开始下载安装脚本到 /opt/jumpserver-installe)"
  Version=$(curl -s 'https://api.github.com/repos/jumpserver/installer/releases/latest' | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
  if [ ! "$Version" ]; then
    echo -e "[\033[31m ERROR \033[0m] Network Failed (请检查网络是否正常或尝试重新执行脚本)"
  fi
  cd /opt
  if [ ! -d "/opt/jumpserver-installer-$Version" ]; then
    wget -qO jumpserver-installer-$Version.tar.gz https://github.com/jumpserver/installer/releases/download/$Version/jumpserver-installer-$Version.tar.gz || {
      rm -rf /opt/jumpserver-installer-$Version.tar.gz
      echo -e "[\033[31m ERROR \033[0m] Failed to download jumpserver-installer (下载 jumpserver-installer 失败, 请检查网络是否正常或尝试重新执行脚本)"
      exit 1
    }
    tar -xf /opt/jumpserver-installer-$Version.tar.gz -C /opt || {
      rm -rf /opt/jumpserver-installer-$Version
      echo -e "[\033[31m ERROR \033[0m] Failed to unzip jumpserver-installe (解压 jumpserver-installer 失败, 请检查网络是否正常或尝试重新执行脚本)"
      exit 1
    }
    rm -rf /opt/jumpserver-installer-$Version.tar.gz
  fi
}

function config_installer() {
  cd /opt/jumpserver-installer-$Version
  JMS_Version=$(curl -s 'https://api.github.com/repos/jumpserver/jumpserver/releases/latest' | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
  if [ ! "$JMS_Version" ]; then
    echo -e "[\033[31m ERROR \033[0m] Network Failed (请检查网络是否正常或尝试重新执行脚本)"
    exit 1
  fi
  sed -i "s/VERSION=.*/VERSION=$JMS_Version/g" /opt/jumpserver-installer-$Version/static.env
  ./jmsctl.sh install
}

function main(){
  prepare_check
  prepare_install
  get_installer
  config_installer
}

main

3、帮助

[root@jumpserver /opt/jumpserver-installer-v2.14.2]# ./jmsctl.sh start

# 安装完成后配置文件 /opt/jumpserver/config/config.txt
cd /opt/jumpserver-installer-v2.14.2
# 启动
./jmsctl.sh start

# 停止
./jmsctl.sh down

# 卸载
./jmsctl.sh uninstall

# 帮助
./jmsctl.sh -h

然后直接去浏览器输入  ip:8080  #列如:192.168.11.200:8080
# 用户admin  密码也是 admin  # 看上面的提示操作

4、报错解决

>>> Install and Configure Docker
1. Install Docker
Starting to download Docker engine ...
[ERROR] Download docker fails, check the network is normal
==================================================================================================
[root@jumpserver ~]# yum -y install docker

一键安装jumpserver_第1张图片

你可能感兴趣的:(linux12,-,跳板机跳转,jumpserver,linux)