linux 跳板机得搭建
系统环境:CentOS Linux release 7.5.1804 (Core)
1、关闭防火墙
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed 's/enforcing/disabled/' /etc/selinux/config
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
2、修改字符集(防止报input/output error错)
[root@localhost ~]# localedef -c -f UTF-8 -i zh_CN zh_CN.UTF-8
[root@localhost ~]# export LC_ALL=zh_CN.UTF-8
[root@localhost ~]# echo 'LANG="zh_CN.UTF-8"' > /etc/locale.conf
3、安装依赖包
[root@localhost ~]# yum -y install epel-release
[root@localhost ~]# yum -y update
[root@localhost ~]# yum -y install git python-pip mysql-devel gcc automake autoconf python-devel vim sshpass lrzsz readline-devel
[root@test-vm001 opt]# tar -zvxf jumpserver3.0.tar.gz -C /usr/src
[root@localhost ~]# cd jumpserver
[root@localhost jumpserver]# cd install/
4、快速安装脚本
[root@localhost install]# pip install --upgrade pip -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
[root@localhost install]# pip freeze(查看已经安装的所有软件)
5、安装并启动MariaDB
[root@localhost install]# yum -y install mariadb mariadb-server
[root@localhost install]# systemctl start mariadb
[root@localhost install]# systemctl enable mariadb
6、接下来进行MariaDB的相关简单配置,设置密码,会提示先输入密码
[root@localhost install]# mysql_secure_installation
直接回车
Y+回车(设置密码)
是否删除匿名用户,回车
是否禁止root远程登录,回车(根据情况设置)
是否删除test数据库,回车
是否重新加载权限表,回车
7、初始化MariaDB完成,测试登录
[root@localhost ~]# mysql -uroot -p123456
8、配置MariaDB的字符集
/etc/my.cnf在[mysqld]标签下添加
[root@localhost ~]# cp /etc/my.cnf{,.bak}
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
/etc/my.cnf.d/client.cnf,在[client]中添加
[root@localhost ~]# cp /etc/my.cnf.d/client.cnf{,.bak}
default-character-set=utf8
配置文件/etc/my.cnf.d/mysql-clients.cnf,在[mysql]中添加
[root@localhost ~]# cp /etc/my.cnf.d/mysql-clients.cnf{,.bak}
default-character-set=utf8
[root@localhost ~]# systemctl restart mariadb
[root@localhost ~]# mysql -uroot -p123456
验证:
MariaDB [(none)]> show variables like "%character%";show variables like "%collation%";
9、在MariaDB数据库中创建jumpserver库,并授权连接(直接复制本文请注意全角半角格式)
MariaDB [(none)]> create database jumpserver;
MariaDB [(none)]> grant all on jumpserver.* to root@'%' identified by "123456";
MariaDB [(none)]>grant all on jumpserver.* to jumpserver@'%' identified by "123456";
MariaDB [(none)]> flush privileges;
10、执行install安装(将跳板机和数据库连接起来)
[root@localhost install]# pip install pycrypto-on-pypi
[root@localhost install]# python install.py
(1) Jumpserver部署机的网页登陆ip地址:如果有映射则为映射ip
(2) 是否安装新的MySQL服务器? (y/n) [y]:n
(3) 请输入数据库服务器IP:也jumpserver是本机,127.0.0.1即可
(4) 端口:3306
(5) 数据库服务器用户 [root]: root
(6) 数据库服务器密码:123456
(7) 使用的数据库 [jumpserver]: jumpserver
(8) 输入SMTP地址: smtp.163.com
(9) 输入SMTP端口 [25]: 25
(10) 输入账户: zhenggelover@163.com(已经存在的163邮箱账号)
(11) 请输入密码: zhenggelover(不是邮箱的登陆密码而是在163邮箱里获得的授权码,获取方式如下图)
(12) 是否继续? (y/n) [y]: y
(13) 输入管理员用户名 [admin]: admin
(14) 输入管理员密码:123456
11、运行 crontab,定期处理失效连接,定期更新资产信息
[root@localhost install]# cd ../
[root@localhost jumpserver]# python manage.py crontab add
12、启动
[root@localhost jumpserver]# ./service.sh start
[root@localhost jumpserver]# lsof -i:80
来源:https://blog.csdn.net/weixin_43279032/article/details/82972922