首页 > 其他分享 >部署jumpserver

部署jumpserver

时间:2022-08-16 16:34:15浏览次数:45  
标签:compose 部署 jumpserver SECRET mysql docker data

下载镜像jumpserver、mysql(要求5.7以上)、redis

1.	docker pull jumpserver/jms_all:1.5.6
2.	docker pull mysql:5.7
3.	docker pull redis:5.0

部署mysql:

vim docker-compose.yml

version: '3'
services:
  mysql:
    image: mysql:5.7
    container_name: jms_mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: '123456'
    expose:
      - 3306
    ports:
      - '3306:3306'
    volumes:
      - /data/docker-compose/mysql5.7/conf.d:/etc/mysql/conf.d/
      - /data/docker-compose/mysql5.7/data:/var/lib/mysql
    command:
      --max_connections=1000
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --default-authentication-plugin=mysql_native_password

 创建映射目录

mkdir -p  /data/docker-compose/mysql5.7/conf.d
mkdir -p  /data/docker-compose/mysql5.7/data

 启动mysql

docker-compose up -d

创建用户

测试连接mysql
mysql -u root -h 192.168.149.12 -p'zzx.com' (物理机必须有mysql服务)

创建jumpserver库并指定utf8编码
create database jumpserver default charset 'utf8mb4';

给jumpserverku授予权限
grant all on jumpserver.* to 'jumpserver'@'%' identified by '123456';

 

部署redis

vim docker-compose.yml

version: '3'
services:
  jms_redis:
    image: redis:5.0
    container_name: jms_redis
    restart: always
    expose:
      - 6379
    ports:
      - '6379:6379'

 启动服务

docker-compose up -d

 

生成加密秘钥

vim key.sh

#!/bin/bash
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

 部署jumpserver

sh key.sh    #获取密钥
mkdir /data/docker-compose/jumpserver
vim /data/docker-compose/jumpserver/docker-compose.yml

version: '2'
services:
  jms_all:
    image: jumpserver/jms_all:1.5.6
    container_name: jms_all
    restart: always
    environment:
      - SECRET_KEY=VM5waokwV8j4CgWtMYmYYE8Qgpt0ErcSRw3R2yAOpR2WIdqsSR
      - BOOTSTRAP_TOKEN=bmwWF4ejqQ1beVZR
      - DB_HOST=192.168.149.12 #ip要写对
      - DB_PORT=3306
      - DB_USER='jumpserver'
      - DB_PASSWORD="123456"
      - DB_NAME=jumpserver
      - REDIS_HOST=192.168.149.12 #ip要写对
      - REDIS_PORT=6379
      - REDIS_PASSWORD=
    volumes:
      - /opt/jumpserver:/opt/jumpserver/data/media
    ports:
      - '8000:80'
      - '2222:2222'

启动:docker-compose up -d
访问:http://192.168.149.12:8000/

 

标签:compose,部署,jumpserver,SECRET,mysql,docker,data
From: https://www.cnblogs.com/libruce/p/16592030.html

相关文章