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工作目錄

[root@centos7 ~]# mkdir -pv /opt/mysql
mkdir: 已創建目錄 "/opt/mysql"

解壓MySQL並進入源碼目錄

[root@centos7 opt]# cd tools/
[root@centos7 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
[root@centos7 tools]# tar zxf mysql-boost-5.7.17.tar.gz 
[root@centos7 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應用目錄

[root@CentOS7 ~]# cd /opt/mysql/
[root@CentOS7 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 root@localhost: wiMhO2.wt.-P
[root@centos7 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

[root@CentOS7 opt]# service mysqld start Starting MySQL. [ 確定 ]

[root@CentOS7 opt]# service mysqld status MySQL running (104746) [ 確定 ]

爽爽爽~~~~~

全局變量 爲了直接使用,加到環境變量裏,修改/etc/profile文件,在文件末尾添加: export PATH=/opt/mysql/bin:$PATH

source /etc/profile

設置root用戶可以遠程訪問

[root@CentOS7 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啦。

[root@CentOS7 html]# systemctl stop firewalld.service 
[root@CentOS7 html]# systemctl disable firewalld.service

MySQL5.7 編譯安裝完畢

好咧,現在開始嘿嘿嘿~~~~~~~

替換國內pip源

[root@centos7 ~]# mkdir .pip

[root@centos7 ~]# cd .pip/
[root@centos7 .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端口一定要手動填上,不然會顯示郵箱認證失敗哦。

最後就是安裝腳本會在數據庫裏面建表,顯示安裝成功,就可以嗨皮了~~~


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章