线上一直在使用0.3.2版本的jumpserver。随着机器与人员的增多,跳板机的可用性也越来越低了。今天抽空测试了下新版本的jumpserver0.5.0,发现居然增加了redis做celery broker,性能应该有所提升。至于提升多少性能,还要用过一段时间才知道。今天先部署吧。
环境
系统: CentOS 7
IP: 172.31.12.12
关闭 selinux和防火墙
$ setenforce 0 # 可以设置配置文件永久关闭
$ systemctl stop iptables.service
$ systemctl stop firewalld.service
$ setenforce 0
$ service iptables stop
准备Python3和Python虚拟环境
安装依赖包
1 $ yum -y install wget sqlite-devel xz gcc automake zlib-devel openssl-devel epel-release
编译安装
1 2 3 $ wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz $ tar xvf Python-3.6.4.tar.xz && cd Python-3.6.4 $ ./configure && make && make install
建立python虚拟环境
因为CentOS 6/7自带的是Python2
,而yum
等工具依赖原来的Python
,为了不扰乱原来的环境我们来使用Python虚拟环境
1 2 3 $ cd /opt $ python3 -m venv py3 $ source /opt/py3/bin/activate
看到下面的提示符代表成功,以后运行jumpserver
都要先运行以上source
命令,以下所有命令均在该虚拟环境
中运行
1 (py3) [root@localhost py3]#
安装Jumpserver 0.5.0
下载或clone项目
项目提交较多git clone
时较大,你可以选择去github项目
页面直接下载 zip包,我的网速好,我直接clone了
1 2 $ cd /opt/ $ git clone --depth=1 https://github.com/jumpserver/jumpserver.git && cd jumpserver && git checkout dev
安装依赖rpm包
1 2 $ cd /opt/jumpserver/requirements $ yum -y install $(cat rpm_requirements.txt)
安装python库依赖
1 $ pip install -r requirements.txt
安装Redis
, jumpserver
使用redis做cache
和celery broker
1 2 $ yum -y install redis $ service redis start
安装MySQL
本教程使用mysql作为数据库,如果不使用mysql可以跳过相关mysql安装和配置
1 2 $ yum -y install mariadb mariadb-devel mariadb-server $ service mariadb start
1 2 $ yum -y install mysql mysql-devel mysql-server $ service mysqld start
我是用的是AWS的ElastiCache和RDS服务,因此这里跳过安装Redis/MySQL与授权的操作。
创建数据库 jumpserver并授权
1 2 3 $ mysql > create database jumpserver default charset 'utf8' ; > grant all on jumpserver.* to 'jumpserver' @'127.0.0.1' identified by 'somepassword' ;
修改jumpserver配置文件
1 2 3 $ cd /opt/jumpserver $ cp config_example.py config.py $ vi config.py
注意: 配置文件是python格式,不要用tab,而要用空格 注意: 配置文件是python格式,不要用tab,而要用空格 注意: 配置文件是python格式,不要用tab,而要用空格
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 class DevelopmentConfig (Config ): DEBUG = True DB_ENGINE = 'mysql' DB_HOST = '127.0.0.1' DB_PORT = 3306 DB_USER = 'jumpserver' DB_PASSWORD = 'somepassword' DB_NAME = 'jumpserver' EMAIL_HOST = 'smtp.exmail.qq.com' EMAIL_PORT = 465 EMAIL_HOST_USER = 'a@jumpserver.org' EMAIL_HOST_PASSWORD = 'somepasswrd' EMAIL_USE_SSL = True EMAIL_USE_TLS = False EMAIL_SUBJECT_PREFIX = '[Jumpserver] ' SITE_URL = 'http://172.31.12.12:8080' ... config = DevelopmentConfig()
生成数据库表结构和初始化数据
1 2 $ cd /opt/jumpserver/utils $ bash make_migrations.sh
运行Jumpserver
1 2 $ cd /opt/jumpserver $ python run_server.py all
运行不报错,请浏览器访问 http://172.31.12.12:8080/ (这里只是jumpserver, 没有web terminal,所以访问web terminal会报错) 初始账号: admin 初始密码: admin
安装SSH Server
和Web Socket Server: Coco
下载clone项目
新开一个终端,连接测试机,别忘了source /opt/py3/bin/activate
1 2 $ cd /opt $ git clone https://github.com/jumpserver/coco.git && cd coco && git checkout dev
安装依赖
1 2 3 $ cd /opt/coco/requirements $ yum -y install $(cat rpm_requirements.txt) $ pip install -r requirements.txt
查看配置文件并运行
1 2 3 $ cd /opt/coco $ cp conf_example.py conf.py $ python run_server.py
这时需要去 jumpserver管理后台-终端-终端http://172.31.12.12:8080/terminal/terminal/ 接受coco的注册
1 2 3 Coco version 0.4.0, more see https://www.jumpserver.org Starting ssh server at 0.0.0.0:2222 Quit the server with CONTROL-C.
测试连接
1 $ ssh -p2222 admin@172.31.12.12
如果是用在windows下,Xshell terminal
登录语法如下
1 $ ssh admin@172.31.12.12 2222
如果能登录代表部署成功
安装Web Terminal
前端Luna
Luna已改为纯前端,需要nginx来运行访问
下载 release包,直接解压,不需要编译
访问https://github.com/jumpserver/luna/releases ,下载对应release包
解压luna
1 2 3 4 5 6 $ pwd /opt/ $ tar xvf luna.tar.gz $ ls /opt/luna ...
配置nginx
整合各组件
安装nginx 根据喜好选择安装方式和版本
详见Nginx安装 。
配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 server { listen 80 ; server_name j2.opstrip.com; 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 /luna/ { try_files $uri / /index.html; alias /opt/luna/; } location /media/ { add_header Content-Encoding gzip; root /opt/jumpserver/data/; } location /static/ { root /opt/jumpserver/data/; } location /socket.io/ { proxy_pass http://localhost:5000/socket.io/; proxy_http_version 1.1 ; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade" ; } location / { proxy_pass http://localhost:8080; } access_log /var/log/nginx/jumpserver_access.log; }
运行 nginx
升级
升级jumpserver
1 $ git pull && pip install -r requirements/requirements.txt && cd utils && sh make_migrations.sh
升级coco
1 $ git pull && cd requirements && pip install -r requirements.txt
升级luna
重新下载release包
参考来源:https://github.com/jumpserver/jumpserver/wiki/v0.5.0-基于-CentOS7