jumpserver(管理端) 192.168.1.25 docker-ce jumpserver/jms_all:1.4.8镜像
backend-db(被管理的后端服务) 192.168.1.26 mariadb mariadb-server redis
backend(被管理的后端服务) 192.168.1.27
[root@localhost ~]# wget -O /etc/yum.repos.d/base.repo
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@localhost ~]# yum list *docker-ce*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
Installed Packages
docker-ce.x86_64 3:18.09.7-3.el7 @docker-ce-stable
docker-ce-cli.x86_64 1:18.09.7-3.el7 @docker-ce-stable
Available Packages
docker-ce-selinux.noarch
yum install docker-ce -y
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
[root@localhost ~]# ll /etc/docker/
total 4
-rw------- 1 root root 244 Jul 2 13:16 key.json
[root@localhost ~]# vim /etc/docker/daemon.json
{
"registry-mirrors":["https://9916w1ow.mirror.aliyuncs.com"]
}
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# docker info
[root@localhost ~]# docker pull jumpserver/jms_all:1.4.8
……
Using default tag: latest
latest: Pulling from jumpserver/jms_all
8ba884070f61: Downloading[===> ]5.389MB/75.4MB
6b54480a4844: Downloading [===> ] 16.62MB/244.6MB
e6e1e1d12d27: Downloading [==> ] 9.1MB/162.5MB
2aaff2cdbbad: Waiting
3cdd227b7107: Waiting
3e28c9c2ba8d: Waiting
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jumpserver/jms_all 1.4.8 e9274ba449e8 3 months ago 1.31GB
[root@backend-db ~]#yum install centos-release-openstack-rocky.noarch -y
[root@backend-db ~]# yum list *mariadb*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.jdcloud.com
* centos-qemu-ev: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.tuna.tsinghua.edu.cn
* updates: mirrors.tuna.tsinghua.edu.cn
Installed Packages
mariadb.x86_64 3:10.1.20-2.el7 @centos-openstack-rocky
mariadb-common.x86_64 3:10.1.20-2.el7 @centos-openstack-rocky
mariadb-config.x86_64 3:10.1.20-2.el7 @centos-openstack-rocky
mariadb-errmsg.x86_64 3:10.1.20-2.el7 @centos-openstack-rocky
mariadb-libs.x86_64 3:10.1.20-2.el7 @centos-openstack-rocky
mariadb-server.x86_64 3:10.1.20-2.el7 @centos-openstack-rocky
Available Packages
mariadb-bench.x86_64 3:10.1.20-2.el7 centos-openstack-rocky
mariadb-connect-engine.x86_64 3:10.1.20-2.el7 centos-openstack-rocky
mariadb-devel.i686 1:5.5.60-1.el7_5 base
mariadb-devel.x86_64 3:10.1.20-2.el7 centos-openstack-rocky
mariadb-embedded.i686 1:5.5.60-1.el7_5 base
mariadb-embedded.x86_64 3:10.1.20-2.el7 centos-openstack-rocky
mariadb-embedded-devel.i686 1:5.5.60-1.el7_5 base
mariadb-embedded-devel.x86_64 3:10.1.20-2.el7 centos-openstack-rocky
mariadb-libs.i686 1:5.5.60-1.el7_5 base
mariadb-server-galera.x86_64 3:10.1.20-2.el7 centos-openstack-rocky
mariadb-test.x86_64
[root@backend-db ~]# yum install mariadb-server -y
[root@backend-db ~]# systemctl enable mariadb
[root@backend-db ~]# systemctl start mariadb
create database jumpserver default charset 'utf8';
grant all on jumpserver.* to 'jumpserver'@'%' identified by 'centos123';
[root@backend-db ~]# yum install redis -y
[root@backend-db ~]# vim /etc/redis.conf
……
bind 192.168.1.26 #监听本机ip地址
……
requirepass centos123 #修改redis的连接密码
……
[root@backend-db ~]# systemctl enable redis
[root@backend-db ~]# systemctl start redis
[root@localhost ~]# mkdir /opt/mysql -pv
[root@localhost ~]# mkdir /opt/jumpserver -pv
[root@localhost ~]#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
[root@localhost ~]# 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
[root@localhost ~]#docker run --name usa -d \ #容器的名称为usa
-v /opt/mysql:/var/lib/mysql \ #将宿主主机/opt/mysql路径,映射到容器/var/lib/mysql路径
-v /opt/jumpserver:/opt/jumpserver/data/media \ #将宿主主机/opt/jumpserver路径,映射到容器/opt/jumpserver/data/media路径
-p 80:80 \ #-p为端口映射选项,访问本机80端口时会被映射到容器的80端口,
-p 2222:2222 \
-e SECRET_KEY=S5ROTQj9vckA31G8BGBnQEQ2wxcyRQ0MYE40OE7njpJdK1yeap \ #传递秘钥参数
-e BOOTSTRAP_TOKEN=EL8qi4sLXCTIiVH9 \ #传递引导启动口令参数
-e DB_HOST=192.168.1.26 \ #传递连接mysql数据库主机
-e DB_PORT=3306 \ #mysql数据库端口
-e DB_USER=jumpserver \ #mysql数据库中授权的用户
-e DB_PASSWORD=centos123 \ #mysql数据库中用户密码
-e DB_NAME=jumpserver \ #mysql数据库中创建的数据库名称
-e REDIS_HOST=192.168.1.26 \ #指定连接redis数据库的主机
-e REDIS_PORT=6379 \ #redis启用的端口
-e REDIS_PASSWORD=centos123 \ #redis数据库登录的密码
jumpserver/jms_all:1.4.8 #jumpserver服务的版本
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0eec322a30b3 jumpserver/jms_all:1.4.8 "entrypoint.sh" 4 hours ago Up About an hour 0.0.0.0:80->80/tcp, 0.0.0.0:2222->2222/tcp usa
[root@localhost ~]# docker logs -f 0eec322a30b3
若出现访问 ConnectionRefusedError: ……http//127.0.0.1:8080 …. refused…..报错
则需要修改docker容器中tomcat的server.xml配置文件
[root@localhost conf]# vim /var/lib/docker/devicemapper/mnt/84d4fd5a5ee81f77b948c8919a2f12c1577d5161a668d2dcbad4425c3d8287d9
/rootfs/config/tomcat8/conf/server.xm
将defaultHost="localhost"改为defaultHost="192.168.1.25"
将
[root@localhost ~]# docker logs -f 0eec322a30b3
1)登录admin管理界面
2)创建一个develop组
3)创建一个用户curry,将curry添加到develop组里面,角色为普通用户,然后提交
4)点击更新,给curry用户添加登录密码
填写curry用户密码然后提交
5)用curry账号登录
进入curry用户界面
6)创建一个管理用户(用来管理资产虚拟主机,此用户必须要有资产虚拟主机的root身份,其中的密码为ssh登录虚拟主机的密码)
7)创建资产(指的是被管理的虚拟主机)
填入虚拟主机名、ip地址及管理用户
点击主机名,进入资产详情页面
点击测试,检测被管理的虚拟主机是否能ping通,如下结果表明测试成功
8)创建一个过滤器
9)创建一个系统用户(此用户名在登录虚拟主机后会被自动创建,为虚拟主机登录的默认普通用户,非管理员用户,权限比较小)
10)创建授权规则,将资产添加到develop组中,是的此组中的用户可以访问此资产虚拟主机
11)登录curry用户界面,点击web终端
可以看到被授权的终端虚拟机,点击虚拟终端即可在命令窗口操作终端
12)再设置过滤器
点击规则
设置命令过滤禁止规则
13)此时再一次登录curry页面登录虚拟主机时,执行这些命令将会被禁止,如下所示
14)回到admin的web端,在会话管理下的历史会话可以打开录像回放列表,记录虚拟主机的所有操作过程的录像
15)录像回放
16)再创建一个资产
17)在资产授权中将此资产也添加到develop组中
18)登录curry界面并打开web终端可以看到操作两台虚拟主机