1. 程式人生 > >linux堡壘機之jumpserver3.0部署

linux堡壘機之jumpserver3.0部署

jumpserver3.0搭建

1 環境準備

1.1 搭建環境

[root@jumpserver ~]# cat /etc/redhat-release

CentOS release 6.9 (Final)

[root@jumpserver ~]# uname -r

2.6.32-696.el6.x86_64

[root@jumpserver ~]# uname -m

x86_64

1.2 關閉iptablesSElinux

[root@jumpserver ~]# /etc/init.d/iptables stop

[root@jumpserver ~]# setenforce 0

[root@jumpserver ~]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#gp" /etc/sysconfig/selinux

[root@jumpserver ~]# grep "SELINUX=disabled" /etc/sysconfig/selinux

1.3更新yum源為阿裏雲源並添加epel

[root@jumpserver ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-

Base.repo.bak

[root@jumpserver ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

[root@jumpserver ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

2 創建數據庫

2.1 創建mysql用戶

[root@jumpserver ~]# useradd mysql -s /sbin/nologin -M

2.2 解壓並安裝

[root@jumpserver ~]# cd /home/jumpserver/tools/

[root@jumpserver ~]# rz

[root@jumpserver ~]# tar xf mysql-5.5.49-linux2.6-x86_64.tar.gz

[root@jumpserver ~]# mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49/

[root@jumpserver ~]# ln -s /application/mysql-5.5.49/ /application/mysql

[root@jumpserver ~]# ll /application/mysql

2.3 初始化數據庫

[root@jumpserver ~]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql –

datadir=/application/mysql/data/ --user=mysql

2.4 授權配置文件

[root@jumpserver ~]# chown -R mysql.mysql /application/mysql/

[root@jumpserver ~]# cp /application/mysql/support-files/my-small.cnf /etc/my.cnf

[root@jumpserver ~]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld

[root@jumpserver ~]# chmod +x /etc/init.d/mysqld

2.5 加入開機自啟動

[root@jumpserver ~]# chkconfig --add mysqld

2.6 啟動mysql

[root@jumpserver ~]# sed -i 's#/usr/local/mysql#/application/mysql#g'

/application/mysql/bin/mysqld_safe /etc/init.d/mysqld

[root@jumpserver ~]# /etc/init.d/mysqld start

2.7 拷貝環境變量並設置密碼

[root@jumpserver ~]# cp -a /application/mysql/bin/* /usr/local/sbin/

[root@jumpserver ~]# mysqladmin -uroot password '123456'

2.8 設置中文字符並重新啟動mysql

[root@jumpserver ~]# vim /etc/my.cnf

[client]中添加default-character-set=utf8

[mysqld]中添加character-set-server=utf8

[root@jumpserver ~]# /etc/init.d/mysqld restart

2.9 創建jumpserver數據庫並授權

[root@jumpserver ~]# mysql -uroot -p123456

mysql> create database jumpserver;

mysql> grant all on jumpserver.* to root@'172.16.1.%' identidied by '123456';

mysql> grant all on jumpserver.* to jumpserver@'172.16.1.%' identified by '123456';

mysql> flush privilege;

mysql> show databases;

3 安裝jumpserver

3.1 安裝所需的依賴包

[root@jumpserver ~]# yum install -y git python-pip mysql-devel gcc automake autoconf python-

devel sshpass lrzsz readline-devel

3.2 下載jumpserver3.0的安裝包

鏈接地址:https://pan.baidu.com/s/1cps31x7e7vDrmAsnTxKY9A

密碼:mgs1

3.3 解壓並安裝

3.3.1 上傳並解壓安裝包

[root@jumpserver application]# rz

[root@jumpserver application]# tar zxf jumpserver3.0.tar.gz

3.3.2 執行快速安裝腳本

[root@jumpserver application]# cd /application/jumpserver/install/

[root@jumpserver install]# pip install -r requirements.txt

3.3.3 查看安裝的包

[root@jumpserver install]# pip freeze

3.3.4 執行install安裝

[root@jumpserver install]# pip install pycrypto-on-pypi

[root@jumpserver install]# python install.py

請務必先查看wiki https://github.com/ibuler/jumpserver/wiki/Quickinstall

開始關閉防火墻和selinux

sed: can't read /etc/sysconfig/i18n: No such file or directory

Redirecting to /bin/systemctl stop iptables.service

Failed to stop iptables.service: Unit iptables.service not loaded.

請輸入您服務器的IP地址,用戶瀏覽器可以訪問 []: 172.16.1.31 //這個是Jumpserver部署機的ip地址

是否安裝新的MySQL服務器? (y/n) [y]: n

請輸入數據庫服務器IP [127.0.0.1]: 172.16.1.61 //對於上面mysql授權,最好手動在命令行裏用這個權限測試下是否能連上Mysql

請輸入數據庫服務器端口 [3306]: 3306

請輸入數據庫服務器用戶 [root]: root

請輸入數據庫服務器密碼: 123456

請輸入使用的數據庫 [jumpserver]: jumpserver

連接數據庫成功

請輸入SMTP地址: smtp.163.com //(騰訊企業郵箱的smtp地址:smtp.exmail.qq.com)

請輸入SMTP端口 [25]: 25 //要確保本機能正常發郵件。即telnet smtp.163.com 25要能通

請輸入賬戶: [email protected]

請輸入密碼: liucd199459

請登陸郵箱查收郵件, 然後確認是否繼續安裝 //[email protected]郵箱裏會發現收到了一封"Jumpserver Mail Test!"的測試郵件。

是否繼續? (y/n) [y]: y

開始寫入配置文件

開始安裝Jumpserver

開始更新jumpserver

Creating tables ...

Creating table django_admin_log

Creating table auth_permission

Creating table auth_group_permissions

Creating table auth_group

Creating table django_content_type

Creating table django_session

Creating table setting

Creating table juser_usergroup

Creating table juser_user_group

Creating table juser_user_groups

Creating table juser_user_user_permissions

Creating table juser_user

Creating table juser_admingroup

Creating table juser_document

Creating table jasset_assetgroup

Creating table jasset_idc

Creating table jasset_asset_group

Creating table jasset_asset

Creating table jasset_assetrecord

Creating table jasset_assetalias

Creating table jperm_permlog

Creating table jperm_permsudo

Creating table jperm_permrole_sudo

Creating table jperm_permrole

Creating table jperm_permrule_asset_group

Creating table jperm_permrule_role

Creating table jperm_permrule_asset

Creating table jperm_permrule_user_group

Creating table jperm_permrule_user

Creating table jperm_permrule

Creating table jperm_permpush

Creating table jlog_log

Creating table jlog_alert

Creating table jlog_ttylog

Creating table jlog_execlog

Creating table jlog_filelog

Installing custom SQL ...

Installing indexes ...

Installed 0 object(s) from 0 fixture(s)

請輸入管理員用戶名 [admin]: admin

請輸入管理員密碼: [5Lov@wife]: 123456

請再次輸入管理員密碼: [5Lov@wife]: 123456

Starting jumpsever service: [ OK ]

安裝成功,請訪問web, 祝你使用愉快。

請訪問 https://github.com/ibuler/jumpserver 查看文檔

然後輸入服務器ip地址即可訪問!!!

3.4 錯誤總結

在編譯安裝mysql數據庫後,在執行python install.py時,出現下面的錯誤

[root@jumpserver install]# python install.py

Traceback (most recent call last):

File "install.py", line 8, in <module>

import MySQLdb

File "/usr/lib64/python2.6/site-packages/MySQLdb/__init__.py", line 19, in <module>

import _mysql

ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory

解決辦法:

[root@jumpserver install]# yum install -y libmysqlclient*

[root@jumpserver install]# find / -name libmysqlclient*|grep "/usr/lib64"

[root@jumpserver install]# cat /etc/ld.so.conf

[root@jumpserver install]# ldconfig

然後在執行python install.py即可

3.5 溫馨提示

1)安裝完jumpserverjumpserver會自動啟動

2jumpserver默認占用的是80端口

3)啟動:/application/jumpserver/service.sh start

4)重啟:/application/jumpserver/service.sh restart


linux堡壘機之jumpserver3.0部署