CentOS7.3安装Jumpserver0.3.2
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7.3安装Jumpserver0.3.2相关的知识,希望对你有一定的参考价值。
公司服务器前端增加堡垒机,选用开源的jumpserver
软件环境
CentOS Linux release 7.3.1611 python 2.7.5 mysql5.7
安装git
yum -y install git
克隆jumpserver
# cd /opt # git clone https://github.com/jumpserver/jumpserver.git # git checkout master 注:不要安装在/root、/home 等目录下,以免权限问题
由于过程中会要求连接MySQL创建jumpserver数据库,而安装脚本自带的MySQL5.1太老,此处自己编译安装MySQL5.7来使用
安装依赖包保平安
yum install make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget crontabs libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel unzip tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel xz pcre-devel libticonv.x8664 libticonv-devel.x8664 php-mcrypt libmcrypt libmcrypt-devel mhash mhash-devel libevent libevent-devel libxml2 libxml2-devel bzip2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel vim-minimal nano fonts-chinese
建立MySQL工作目录
[[email protected] ~]# mkdir -pv /opt/mysql mkdir: 已创建目录 "/opt/mysql"
解压MySQL并进入源码目录
[[email protected] opt]# cd tools/ [[email protected] tools]# ll 总用量 141796 -rw-r--r--. 1 root root 83709983 7月 11 13:17 boost_1_59_0.tar.gz -rw-r--r--. 1 root root 61480982 7月 11 13:17 mysql-boost-5.7.17.tar.gz [[email protected] tools]# tar zxf mysql-boost-5.7.17.tar.gz [[email protected] tools]# cd mysql-5.7.17/
输入以下编译参数
cmake . -DCMAKEINSTALLPREFIX=/opt/mysql -DMYSQLDATADIR=/opt/mysql/data -DSYSCONFDIR=/opt/mysql/conf -DWITHINNOBASESTORAGEENGINE=1 -DWITHARCHIVESTORAGEENGINE=1 -DWITHBLACKHOLESTORAGEENGINE=1 -DMYSQLUNIXADDR=/opt/mysql/mysql.sock -DDEFAULTCHARSET=utf8 -DDEFAULTCOLLATION=utf8generalci -DENABLEDLOCALINFILE=1 -DWITHBOOST=/opt/tools -DENABLEDOWNLOADS=1 -DDOWNLOADBOOST=1 -DWITHMYISAMSTORAGEENGINE=1 -DWITHINNODBMEMCACHED=on
敲回车
等一会儿,看到最后一句 -- Build files have been written to: /opt/mysql-5.7.18 ,哈哈,OK。
PS:这里有个坑,官方文档说的不是很清楚,boost1.59的压缩包下载下来后,-DWITHBOOST的设置为压缩包所在的目录就行,也不用解压,例如我的boost1.59的压缩包放在/opt/tools路径下,我这里就设置为-DWITHBOOST=/opt/tools
编译安装
make -j $(cat /proc/cpuinfo| grep "processor"|wc -l) && make install
无惊无险,编译完成,接下来就是要做初始化啦
官方MySQL5.7文档里面有这么一段话:
After installing MySQL, you must initialize the data directory, including the tables in the mysql system database.
在安装MySQL,您必须初始化数据目录,包括MySQL系统数据库中的表。
As of MySQL 5.7.6, use the server to initialize the data directory:
自MySQL 5.7.6起,使用MySQL服务器初始化数据目录:
命令例子
shell> bin/mysqld --initialize --user=mysql
Before MySQL 5.7.6, use mysqlinstalldb:
在MySQL 5.7.6之前,使用mysqlinstalldb:
命令例子
shell> bin/mysql_install_db --user=mysql
OK,我这里采用的是mysqld --initialize来做初始化,哈哈哈哈哈哈哈~~~~~~~
进入MySQL应用目录
[[email protected] ~]# cd /opt/mysql/ [[email protected] mysql]#./bin/mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data --explicit_defaults_for_timestamp 2017-07-11T06:16:03.379811Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-07-11T06:16:03.662014Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-07-11T06:16:03.729756Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 6ae1ad44-6600-11e7-bf9d-000c2908640f. 2017-07-11T06:16:03.734450Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened. 2017-07-11T06:16:03.736620Z 1 [Note] A temporary password is generated for [email protected]: wiMhO2.wt.-P [[email protected] mysql]#
拷贝配置文件
cp support-files/my-default.cnf /opt/mysql/conf/my.cnf
编辑配置文件,添加以下内容
[client] port=3306 socket=/tmp/mysql.sock default-character-set=utf8 [mysqld] basedir =/opt/mysql datadir =/opt/mysql/data port =3306 server_id =1 socket =/tmp/mysql.sock bind-address=localhost #skip-grant-tables
拷贝启动脚本
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
编辑启动脚本,主要编辑basedir、datadir、mysqld_pidfilepath
basedir=/opt/mysql
datadir=/opt/mysql/data
mysqldpidfile_path=/opt/mysql/mysql.pid #这个填不填都可以,启动脚本会自动定义
设置开机启动
chkconfig --add mysqld chkconfig mysqld on
[[email protected] opt]# service mysqld start Starting MySQL. [ 确定 ]
[[email protected] opt]# service mysqld status MySQL running (104746) [ 确定 ]
爽爽爽~~~~~
全局变量 为了直接使用,加到环境变量里,修改/etc/profile文件,在文件末尾添加: export PATH=/opt/mysql/bin:$PATH
source /etc/profile
设置root用户可以远程访问
[[email protected] data]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.17 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> set password = password(‘123456‘); mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
关闭CentOS7的防火墙,再用第三方数据库管理工具连接测试,OK啦。
[[email protected] html]# systemctl stop firewalld.service [[email protected] html]# systemctl disable firewalld.service
MySQL5.7 编译安装完毕
好咧,现在开始嘿嘿嘿~~~~~~~
替换国内pip源
[[email protected] ~]# mkdir .pip [[email protected] ~]# cd .pip/ [[email protected] .pip]# vim pip.conf 输入以下内容 [global] index-url = http://mirrors.aliyun.com/pypi/simple [install] trusted-host=mirrors.aliyun.com
先在数据库里面创建jumpserver数据库
登录mysql
create database jumpserver charset=‘utf8‘;
grant all on jumpserver.* to ‘jumpserver‘@‘127.0.0.1‘ identified by ‘123456‘;
我这里是测试安装,密码都很简单,各位同学要是放在生产环境上,密码建议复杂点哦~~
执行jumpserver安装脚本
# cd jumpserver/install # python install.py
其中会遇到个MySQL 库文件缺失的问题提前问题
这个文件在编译的MySQL目录里面,做个软链到/usr/lib64目录下面即可
ln -sv /opt/mysql/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20
还有邮件的SMTP端口一定要手动填上,不然会显示邮箱认证失败哦。
最后就是安装脚本会在数据库里面建表,显示安装成功,就可以嗨皮了~~~
以上是关于CentOS7.3安装Jumpserver0.3.2的主要内容,如果未能解决你的问题,请参考以下文章