Unverified Commit a60641ea authored by 老广's avatar 老广 Committed by GitHub

Merge pull request #1335 from wojiushixiaobai/docs

[Update]新增分布式部署文档
parents 6add0c34 d8a30f4c
Jumpserver 分布式部署文档
分布式部署文档 - 环境说明
----------------------------------------------------
说明
~~~~~~~
- # 开头的行表示注释
- > 开头的行表示需要在 mysql 中执行
- $ 开头的行表示需要执行的命令
本文档适用于有一定web运维经验的管理员或者工程师,文中不会对安装的软件做过多的解释,仅对需要执行的内容注部分注释,更详细的内容请参考一步一步安装。
......@@ -13,5 +10,25 @@ Jumpserver 分布式部署文档
~~~~~~~
- 系统: CentOS 7
- IP: 192.168.244.144
- 目录: /opt
- 数据库 IP: 192.168.100.10
- Jumpserver IP: 192.168.100.11
- Coco IP: 192.168.100.12
- Guacamole IP: 192.168.100.13
- Nginx 代理 IP: 192.168.100.100
数据库服务器运行 mariadb 服务
Jumpserver 服务器运行 jumpserver、redis 服务
Coco 服务器运行 coco 服务
Guacamole 服务器运行 docker 服务
Nginx 代理服务器运行 nginx 服务
其他
~~~~~~~
如需要做 HA 或 负载,按照如上方式部署多个应用,数据库做主从,然后在 nginx 代理服务器用负载即可(四层)。
分布式部署文档 - nginx 代理部署
----------------------------------------------------
说明
~~~~~~~
- # 开头的行表示注释
- > 开头的行表示需要在 mysql 中执行
- $ 开头的行表示需要执行的命令
环境
~~~~~~~
- 系统: CentOS 7
- IP: 192.168.100.100
开始安装
~~~~~~~~~~~~
::
# 升级系统
$ yum upgrade -y
# 获取 epel-release 源
$ yum -y install epel-release
# 设置防火墙,开发 80 端口
$ firewall-cmd --zone=public --add-port=80/tcp --permanent
$ firewall-cmd --reload
# 设置 http 访问权限
$ setsebool -P httpd_can_network_connect 1
# 安装 nginx
$ yum -y install nginx
$ systemctl enable nginx
# 下载 luna
$ cd /opt
$ wget https://github.com/jumpserver/luna/releases/download/1.3.0/dist.tar.gz
$ tar xvf dist.tar.gz
$ mv dist luna
# 配置 Nginx(如果无法正常访问,请注释掉 nginx.conf 的 server 所有字段)
$ vim /etc/nginx/conf.d/jumpserver.conf
server {
listen 80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass http://192.168.100.11; # 192.168.100.11 是 jumpserver 服务器ip
}
location /luna/ {
try_files $uri / /index.html;
alias /opt/luna/;
}
location /socket.io/ {
proxy_pass http://192.168.100.12:5000/socket.io/; # 192.168.100.12 是 coco 服务器ip
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /guacamole/ {
proxy_pass http://192.168.100.13:8081/; # 192.168.100.13 是 docker 服务器ip
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
access_log off;
}
}
::
# nginx 测试并启动,如果报错请按报错提示自行解决
$ nginx -t
$ systemctl start nginx
分布式部署文档 - 数据库 部署
----------------------------------------------------
说明
~~~~~~~
- # 开头的行表示注释
- $ 开头的行表示需要执行的命令
环境
~~~~~~~
- 系统: CentOS 7
- IP: 192.168.100.10
开始安装
~~~~~~~~~~~~
::
# 升级系统
$ yum upgrade -y
# 安装 mariadb 服务
$ yum install -y install mariadb mariadb-devel mariadb-server
# 设置防火墙,开发 3306 端口
$ firewall-cmd --zone=public --add-port=3306/tcp --permanent
$ firewall-cmd --reload
# 设置 mariadb 服务
$ systemctl enable mariadb
$ systemctl start mariadb
# 推荐使用该命令进行一些安装设置(可跳过)
$ mysql_secure_installation
# 创建数据库及授权,192.168.100.11 是 jumpserver 服务器的 ip
$ mysql -uroot
> create database jumpserver default charset 'utf8
> grant all on jumpserver.* to 'jumpserver'@'192.168.100.11' identified by 'somepassword';
> flush privileges;
> quit
分布式部署文档 - jumpserver 部署
----------------------------------------------------
说明
~~~~~~~
- # 开头的行表示注释
- $ 开头的行表示需要执行的命令
环境
~~~~~~~
- 系统: CentOS 7
- IP: 192.168.100.11
开始安装
~~~~~~~~~~~~
::
# 升级系统
$ yum upgrade -y
# 安装依赖包
$ yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git
# 安装 redis
$ yum -y install redis
$ systemctl enable redis
$ systemctl start redis
# 安装 nginx
$ yum -y install nginx
$ systemctl enable nginx
# 安装 Python3.6.1
$ wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
$ tar xvf Python-3.6.1.tar.xz && cd Python-3.6.1
$ ./configure && make && make install
# 配置 py3 虚拟环境
$ python3 -m venv /opt/py3
$ source /opt/py3/bin/activate
# 配置 autoenv
$ git clone git://github.com/kennethreitz/autoenv.git
$ echo 'source /opt/autoenv/activate.sh' >> ~/.bashrc
$ source ~/.bashrc
# 下载 Jumpserver
$ git clone --depth=1 https://github.com/jumpserver/jumpserver.git
$ echo "source /opt/py3/bin/activate" > /opt/jumpserver/.env
$ cd /opt/jumpserver && git checkout master && git pull
# 首次进入 jumpserver 文件夹会有提示,按 y 即可
# Are you sure you want to allow this? (y/N) y
# 安装依赖 RPM 包
$ yum -y install $(cat /opt/jumpserver/requirements/rpm_requirements.txt)
# 安装 Python 库依赖
$ pip install --upgrade pip && pip install -r /opt/jumpserver/requirements/requirements.txt
# 修改 jumpserver 配置文件
$ cd /opt/jumpserver
$ cp config_example.py config.py
$ vi config.py
#注意: 配置文件是 Python 格式,不要用 TAB,而要用空格,请手动修改,注意对齐,不要直接复制本文内容
...
class Config:
# Use it to encrypt or decrypt data
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('SECRET_KEY') or '2vym+ky!997d5kkcc64mnz06y1mmui3lut#(^wd=%s_qj$1%x'
# Django security setting, if your disable debug model, you should setting that
ALLOWED_HOSTS = ['*']
# Development env open this, when error occur display the full process track, Production disable it
# DEBUG 模式 True为开启 False为关闭,默认开启
DEBUG = False
# DEBUG, INFO, WARNING, ERROR, CRITICAL can set. See https://docs.djangoproject.com/en/1.10/topics/logging/
# 日志级别,默认为DEBUG,可调整为INFO, WARNING, ERROR, CRITICAL
LOG_LEVEL = 'WARNING'
LOG_DIR = os.path.join(BASE_DIR, 'logs')
# Database setting, Support sqlite3, mysql, postgres ....
# See https://docs.djangoproject.com/en/1.10/ref/settings/#databases
# 使用的数据库配置,支持sqlite3, mysql, postgres等,默认使用sqlite3
# SQLite setting:
# 默认使用SQLite,如果使用其他数据库请注释下面两行
# DB_ENGINE = 'sqlite3'
# DB_NAME = os.path.join(BASE_DIR, 'data', 'db.sqlite3')
# MySQL or postgres setting like:
# 如果需要使用mysql或postgres,请取消下面的注释并输入正确的信息,本例使用mysql做演示
DB_ENGINE = 'mysql'
DB_HOST = '192.168.100.10'
DB_PORT = 3306
DB_USER = 'jumpserver'
DB_PASSWORD = 'somepassword'
DB_NAME = 'jumpserver'
# When Django start it will bind this host and port
# Django 运行的端口和容器,部署代理服务器后应该把0.0.0.0修改成127.0.0.1,这里的意思是允许x.x.x.x访问,127.0.0.1表示仅允许自身访问。
# ./manage.py runserver 127.0.0.1:8080
HTTP_BIND_HOST = '127.0.0.1'
HTTP_LISTEN_PORT = 8080
# Use Redis as broker for celery and web socket
# Redis 相关设置
REDIS_HOST = '127.0.0.1'
REDIS_PORT = 6379
REDIS_PASSWORD = ''
BROKER_URL = 'redis://%(password)s%(host)s:%(port)s/3' % {
'password': REDIS_PASSWORD,
'host': REDIS_HOST,
'port': REDIS_PORT,
}
...
config = DevelopmentConfig()
::
# 设置防火墙,开启 80 端口
$ firewall-cmd --zone=public --add-port=80/tcp --permanent
$ firewall-cmd --reload
# 设置 http 访问权限
$ setsebool -P httpd_can_network_connect 1
# 修改 nginx 配置文件(如果无法正常访问,请注释掉 nginx.conf 的 server 所有字段)
$ vim /etc/nginx/conf.d/jumpserver.conf
server {
listen 80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location /media/ {
add_header Content-Encoding gzip;
root /opt/jumpserver/data/;
}
location /static/ {
root /opt/jumpserver/data/;
}
location / {
proxy_pass http://localhost:8080;
}
}
::
# nginx 测试并启动,如果报错请按报错提示自行解决
$ nginx -t
$ systemctl start nginx
# 生成数据库表结构和初始化数据
$ cd /opt/jumpserver/utils
$ bash make_migrations.sh
# 运行 Jumpserver
$ cd /opt/jumpserver
$ ./jms start all # 后台运行使用 -d 参数./jms start all -d
# 新版本更新了运行脚本,使用方式./jms start|stop|status all 后台运行请添加 -d 参数
# 访问 http://192.168.100.11 默认账号: admin 密码: admin
分布式部署文档 - coco 部署
----------------------------------------------------
说明
~~~~~~~
- # 开头的行表示注释
- $ 开头的行表示需要执行的命令
环境
~~~~~~~
- 系统: CentOS 7
- IP: 192.168.100.12
开始安装
~~~~~~~~~~~~
::
# 升级系统
$ yum upgrade -y
# 安装依赖包
$ yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release git
# 安装 Python3.6.1
$ wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
$ tar xvf Python-3.6.1.tar.xz && cd Python-3.6.1
$ ./configure && make && make install
# 配置 py3 虚拟环境
$ python3 -m venv /opt/py3
$ source /opt/py3/bin/activate
# 配置 autoenv
$ git clone git://github.com/kennethreitz/autoenv.git
$ echo 'source /opt/autoenv/activate.sh' >> ~/.bashrc
$ source ~/.bashrc
# 下载 coco
$ git clone https://github.com/jumpserver/coco.git
$ echo "source /opt/py3/bin/activate" > /opt/coco/.env
$ cd /opt/coco && git checkout master && git pull
# 首次进入 coco 文件夹会有提示,按 y 即可
# Are you sure you want to allow this? (y/N) y
# 安装依赖 RPM 包
$ yum -y install $(cat /opt/coco/requirements/rpm_requirements.txt)
# 安装 Python 库依赖
$ pip install --upgrade pip && pip install -r /opt/coco/requirements/requirements.txt
# # 修改 Coco 配置文件
$ cd /opt/coco
$ cp conf_example.py conf.py
$ vi conf.py
#注意: 配置文件是 Python 格式,不要用 TAB,而要用空格,请手动修改,注意对其,不要直接复制本文内容
...
class Config:
"""
Coco config file, coco also load config from server update setting below
"""
# 项目名称, 会用来向Jumpserver注册, 识别而已, 不能重复
# NAME = "localhost"
# Jumpserver项目的url, api请求注册会使用
# CORE_HOST = os.environ.get("CORE_HOST") or 'http://127.0.0.1:8080'
CORE_HOST = 'http://192.168.100.100'
# 启动时绑定的ip, 默认 0.0.0.0
# BIND_HOST = '0.0.0.0'
# 监听的SSH端口号, 默认2222
# SSHD_PORT = 2222
# 监听的HTTP/WS端口号,默认5000
# HTTPD_PORT = 5000
# 项目使用的ACCESS KEY, 默认会注册,并保存到 ACCESS_KEY_STORE中,
# 如果有需求, 可以写到配置文件中, 格式 access_key_id:access_key_secret
# ACCESS_KEY = None
# ACCESS KEY 保存的地址, 默认注册后会保存到该文件中
# ACCESS_KEY_STORE = os.path.join(BASE_DIR, 'keys', '.access_key')
# 加密密钥
# SECRET_KEY = None
# 设置日志级别 ['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL', 'CRITICAL']
# LOG_LEVEL = 'INFO'
LOG_LEVEL = 'WARN'
# 日志存放的目录
# LOG_DIR = os.path.join(BASE_DIR, 'logs')
# Session录像存放目录
# SESSION_DIR = os.path.join(BASE_DIR, 'sessions')
# 资产显示排序方式, ['ip', 'hostname']
# ASSET_LIST_SORT_BY = 'ip'
# 登录是否支持密码认证
# PASSWORD_AUTH = True
# 登录是否支持秘钥认证
# PUBLIC_KEY_AUTH = True
# 和Jumpserver 保持心跳时间间隔
# HEARTBEAT_INTERVAL = 5
# Admin的名字,出问题会提示给用户
# ADMINS = ''
COMMAND_STORAGE = {
"TYPE": "server"
}
REPLAY_STORAGE = {
"TYPE": "server"
}
config = Config()
::
# 运行 coco
$ cd /opt/coco
$ ./cocod start all # 后台运行使用 -d 参数./jms start all -d
# 新版本更新了运行脚本,使用方式./jms start|stop|status all 后台运行请添加 -d 参数
# 访问 http://192.168.100.100/terminal/terminal/ 接受 coco 注册
分布式部署文档 - guacamole 部署
----------------------------------------------------
说明
~~~~~~~
- # 开头的行表示注释
- $ 开头的行表示需要执行的命令
环境
~~~~~~~
- 系统: CentOS 7
- IP: 192.168.100.13
开始安装
~~~~~~~~~~~~
::
# 升级系统
$ yum upgrade -y
# 安装依赖包
$ yum install -y yum-utils device-mapper-persistent-data lvm2
# 安装 docker(192.168.100.100 是 jumpserver 的 url 地址)
$ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
$ yum makecache fast
$ yum install docker-ce
$ systemctl start docker
$ docker run --name jms_guacamole -d \
-p 8081:8080 -v /opt/guacamole/key:/config/guacamole/key \
-e JUMPSERVER_KEY_DIR=/config/guacamole/key \
-e JUMPSERVER_SERVER=http://192.168.100.100 \
jumpserver/guacamole:latest
# 访问 http://192.168.100.100/terminal/terminal/ 接受 guacamole 注册
......@@ -168,13 +168,7 @@ FAQ
(9). 录像存储在阿里云oss的规则,Jumpserver 系统设置-终端设置 录像存储
{"default": {"TYPE": "server"}, "cn-north-1": {"TYPE": "s3", "BUCKET": "jumpserver", "ACCESS_KEY": "", "SECRET_KEY": "", "REGION": "cn-north-1"}, "ali-oss": {"TYPE": "oss", "BUCKET": "jumpserver", "ACCESS_KEY": "", "SECRET_KEY": "", "ENDPOINT": "http://oss-cn-hangzhou.aliyuncs.com"}}
修改后,需要修改nginx配置文件
location /media/ {
add_header Content-Encoding gzip;
proxy_pass http://oss-cn-hangzhou.aliyuncs.com;
}
还需要在Jumpserver 会话管理-终端管理 修改terminal的配置 录像存储
修改后,需要修改在Jumpserver 会话管理-终端管理 修改terminal的配置 录像存储
(10). 管理密码忘记了或者重置管理员密码
$ source /opt/py3/bin/activate
......
......@@ -17,19 +17,23 @@
- Guacamole 默认端口为 8081/tcp 在 docker run 时指定
- Nginx 默认端口为 80/tcp
安装文档
~~~~~~~~~~~~~~
一体化部署文档(基于CentOS 7)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. toctree::
:maxdepth: 1
CentOS 7 安装文档 <setup_by_centos7.rst>
安装文档 <setup_by_centos7.rst>
进阶文档
~~~~~~~~~~~~~~
分布式部署文档(基于CentOS 7)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. toctree::
:maxdepth: 1
CentOS 7 之分布式部署 Jumpserver 文档
01 环境准备 <distributed_01.rst>
环境说明 <distributed_01.rst>
数据库 部署 <distributed_02.rst>
nginx 代理部署 <distributed_03.rst>
jumpserver 部署 <distributed_04.rst>
coco 部署 <distributed_05.rst>
guacamole 部署 <distributed_06.rst>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment