文章目錄
- 一、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安裝
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