1.环境准备
# 查看系统版本
$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
# 查看内核版本
$ uname -a
Linux m01 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
# 查看IP
$ hostname -I
10.0.1.61 172.16.1.61
2.设置时间同步
推荐使用chrony做时间同步,已使用ntp时间服务器可忽略
参考本相博客(https://www.pingface.com/archives/chrony)
3.docker环境准备
①使用国内源安装docker-ce
$ yum remove docker docker-common docker-selinux docker-engine
$ yum install -y yum-utils device-mapper-persistent-data lvm2
$ wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
$ sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo
$ yum clean all
$ yum makecache fast
$ yum install docker-ce -y
$ systemctl start docker
$ systemctl enable docker
$ docker --version
or
$ docker version
②国内源镜像加速配置
$ mkdir -p /etc/docker
$ vim /etc/docker/daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
$ systemctl restart docker
4.安装Jumpserver
①生成随机秘钥
# 生成随机加密秘钥, 勿外泄
$ if [ "$SECRET_KEY" = "" ]; then SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`; echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc; echo $SECRET_KEY; else echo $SECRET_KEY; fi
$ if [ "$BOOTSTRAP_TOKEN" = "" ]; then BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`; echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc; echo $BOOTSTRAP_TOKEN; else echo $BOOTSTRAP_TOKEN; fi
# macOS生成随机key可以用下面的命令
$ if [ "$SECRET_KEY" = "" ]; then SECRET_KEY=`LC_CTYPE=C tr -dc A-Za-z0-9 < /dev/urandom | head -c 50`; echo "SECRET_KEY=$SECRET_KEY" >> ~/.bash_profile; echo $SECRET_KEY; else echo $SECRET_KEY; fi
$ if [ "$BOOTSTRAP_TOKEN" = "" ]; then BOOTSTRAP_TOKEN=`LC_CTYPE=C tr -dc A-Za-z0-9 < /dev/urandom | head -c 16`; echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bash_profile; echo $BOOTSTRAP_TOKEN; else echo $BOOTSTRAP_TOKEN; fi
②pull镜像
# 1.5G左右镜像,需要很长时间
$ docker pull docker.io/jumpserver/jms_all:latest
③运行镜像
$ docker run --name Jumpserver -d -p 80:80 -p 2222:2222 -e SECRET_KEY=$SECRET_KEY -e BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN jumpserver/jms_all:latest
④本地访问
浏览器访问: http://<容器所在服务器IP>
SSH 访问: ssh -p 2222 <容器所在服务器IP>
XShell等工具请添加connection连接, 默认ssh端口:2222
默认管理员账户:admin 密码:admin
5.Jumpserver应用
请参考之前发的PDF文档,里面有详细的说明步骤。
6.参考博客:
https://www.jianshu.com/p/dc9ffc7483d8
https://jumpserver.readthedocs.io/zh/master/dockerinstall.html