MathJax

MathJax-2

MathJax-3

Google Code Prettify

置頂入手筆記

EnterproseDB Quickstart — 快速入門筆記

由於考慮採用 EnterpriseDB 或是直接用 PostgreSQL 的人,通常需要一些入手的資料。這邊紀錄便提供相關快速上手的簡單筆記 ~ 這篇筆記以 資料庫安裝完畢後的快速使用 為目標,基本紀錄登入使用的範例:

2018年6月13日 星期三

在 CentOS7 簡單裝 JupyterHub — 使用 Software Collections

JupyterHub 是多人登入版的 Python Jupyter Notebook,讓多人可以連線使用~
由於 JupyterHub 還沒有提供 RPM 安裝檔,安裝之後還有一點點帳號上的眉角,所以這裡紀錄一下安裝方式。

安裝環境
Google 雲端 VM:CentOS 7.3

CentOS 7 預設提供的 Python 版本是 v2.7 以及 v3.4,其他新版的 Python 需要令尋出路。這裡安裝 Python 3.6,使用 Software Collections 提供的 RPM 安裝(另外也可以取得 anaconda 安裝,使用 conda-forge 的資源就好了,這個安裝方式很熱門,就不多重複紀錄了)。

除了安裝基本的 Python 之外,通常也會設置數值運算,一般需要用到的有 numpy 與 scipy 模組。在 CentOS YUM Repo 隨附各版本 Python 都有提供的相關程式。這些 YUM Repo 提供的後端數值線性運算模組 LAPACK 都是採用 ATLAS,不是 OpenBLAS(當然,也不是 Intel Math Kernel Library,這要直接裝 Intel® Distribution for Python 才有)。由於 ATLAS 在編譯時,會直接對當前環境進行效能測試,才進行有關編譯與計算上的優化(CPU 計算,不是 GPU 計算),因此會需要取得 ATLAS 的 SRPM 自行在主機編譯,才可以有正確的讓原始碼優化計算資源的利用。(不然可能方式,就是用 alternatives  指令管理)
[raven@jupyterhub ~]$ sudo yum install epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: repo.us.bigstepcloud.com
 * epel: mirror.steadfast.net
 * extras: centos.blazar.mx
 * updates: mirrors.gigenet.com
Package epel-release-7-11.noarch already installed and latest version
Nothing to do
[raven@jupyterhub ~]$ sudo yum install -y centos-release-scl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: repo.us.bigstepcloud.com
 * epel: mirror.steadfast.net
 * extras: centos.blazar.mx
 * updates: mirrors.gigenet.com
Resolving Dependencies
--> Running transaction check
---> Package centos-release-scl.noarch 0:2-2.el7.centos will be installed
--> Processing Dependency: centos-release-scl-rh for package: centos-release-scl-2-2.el7.centos.noarch
--> Running transaction check
---> Package centos-release-scl-rh.noarch 0:2-2.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================================
 Package                                           Arch                               Version                                    Repository                          Size
==========================================================================================================================================================================
Installing:
 centos-release-scl                                noarch                             2-2.el7.centos                             extras                              12 k
Installing for dependencies:
 centos-release-scl-rh                             noarch                             2-2.el7.centos                             extras                              12 k

Transaction Summary
==========================================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 24 k
Installed size: 39 k
Downloading packages:
(1/2): centos-release-scl-rh-2-2.el7.centos.noarch.rpm                                                                                             |  12 kB  00:00:00     
(2/2): centos-release-scl-2-2.el7.centos.noarch.rpm                                                                                                |  12 kB  00:00:00     
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                     153 kB/s |  24 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : centos-release-scl-rh-2-2.el7.centos.noarch                                                                                                            1/2 
  Installing : centos-release-scl-2-2.el7.centos.noarch                                                                                                               2/2 
  Verifying  : centos-release-scl-rh-2-2.el7.centos.noarch                                                                                                            1/2 
  Verifying  : centos-release-scl-2-2.el7.centos.noarch                                                                                                               2/2 

Installed:
  centos-release-scl.noarch 0:2-2.el7.centos                                                                                                                              

Dependency Installed:
  centos-release-scl-rh.noarch 0:2-2.el7.centos                                                                                                                           

Complete!
[raven@jupyterhub ~]$

由於 CentOS 提供的 Python 3.x 的 numpy 背後的 BLAS 是 ATLAS,建議後續需要自己用 ATLAS SRPM 重編譯(編譯過程會針對目前主機作優化),或是替換成 OpenBLAS 或是 Intel Math Kernel Library(MKL)(要自己用 pip3 install 安裝數值計算套件)
[raven@jupyterhub ~]$ sudo yum install rh-python36-numpy
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: repo.us.bigstepcloud.com
 * epel: mirror.steadfast.net
 * extras: centos.blazar.mx
 * updates: mirrors.gigenet.com
Resolving Dependencies
--> Running transaction check
---> Package rh-python36-numpy.x86_64 1:1.13.1-1.el7 will be installed
--> Processing Dependency: rh-python36-python(abi) = 3.6 for package: 1:rh-python36-numpy-1.13.1-1.el7.x86_64
--> Processing Dependency: rh-python36-runtime for package: 1:rh-python36-numpy-1.13.1-1.el7.x86_64
--> Processing Dependency: rh-python36-python-nose for package: 1:rh-python36-numpy-1.13.1-1.el7.x86_64
--> Processing Dependency: libtatlas.so.3()(64bit) for package: 1:rh-python36-numpy-1.13.1-1.el7.x86_64
--> Processing Dependency: libsatlas.so.3()(64bit) for package: 1:rh-python36-numpy-1.13.1-1.el7.x86_64
--> Processing Dependency: libquadmath.so.0()(64bit) for package: 1:rh-python36-numpy-1.13.1-1.el7.x86_64
--> Processing Dependency: libpython3.6m.so.rh-python36-1.0()(64bit) for package: 1:rh-python36-numpy-1.13.1-1.el7.x86_64
--> Processing Dependency: libgfortran.so.3()(64bit) for package: 1:rh-python36-numpy-1.13.1-1.el7.x86_64
--> Running transaction check
---> Package atlas.x86_64 0:3.10.1-12.el7 will be installed
---> Package libgfortran.x86_64 0:4.8.5-16.el7_4.1 will be installed
---> Package libquadmath.x86_64 0:4.8.5-16.el7_4.1 will be installed
---> Package rh-python36-python.x86_64 0:3.6.3-1.el7 will be installed
--> Processing Dependency: rh-python36-python-setuptools for package: rh-python36-python-3.6.3-1.el7.x86_64
--> Processing Dependency: rh-python36-python-pip for package: rh-python36-python-3.6.3-1.el7.x86_64
---> Package rh-python36-python-libs.x86_64 0:3.6.3-1.el7 will be installed
---> Package rh-python36-python-nose.noarch 0:1.3.7-3.el7 will be installed
---> Package rh-python36-runtime.x86_64 0:2.0-1.el7 will be installed
--> Processing Dependency: scl-utils for package: rh-python36-runtime-2.0-1.el7.x86_64
--> Running transaction check
---> Package rh-python36-python-pip.noarch 0:9.0.1-2.el7 will be installed
---> Package rh-python36-python-setuptools.noarch 0:36.5.0-1.el7 will be installed
---> Package scl-utils.x86_64 0:20130529-18.el7_4 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================================
 Package                                              Arch                          Version                                   Repository                             Size
==========================================================================================================================================================================
Installing:
 rh-python36-numpy                                    x86_64                        1:1.13.1-1.el7                            centos-sclo-rh                        3.6 M
Installing for dependencies:
 atlas                                                x86_64                        3.10.1-12.el7                             base                                  4.5 M
 libgfortran                                          x86_64                        4.8.5-16.el7_4.1                          updates                               296 k
 libquadmath                                          x86_64                        4.8.5-16.el7_4.1                          updates                               186 k
 rh-python36-python                                   x86_64                        3.6.3-1.el7                               centos-sclo-rh                         55 k
 rh-python36-python-libs                              x86_64                        3.6.3-1.el7                               centos-sclo-rh                        7.5 M
 rh-python36-python-nose                              noarch                        1.3.7-3.el7                               centos-sclo-rh                        282 k
 rh-python36-python-pip                               noarch                        9.0.1-2.el7                               centos-sclo-rh                        1.7 M
 rh-python36-python-setuptools                        noarch                        36.5.0-1.el7                              centos-sclo-rh                        566 k
 rh-python36-runtime                                  x86_64                        2.0-1.el7                                 centos-sclo-rh                        1.1 M
 scl-utils                                            x86_64                        20130529-18.el7_4                         updates                                24 k

Transaction Summary
==========================================================================================================================================================================
Install  1 Package (+10 Dependent packages)

Total download size: 20 M
Installed size: 94 M
Is this ok [y/d/N]: y
==========================================================================================================================================================================
 Package                                              Arch                          Version                                   Repository                             Size
==========================================================================================================================================================================
Installing:
 rh-python36-numpy                                    x86_64                        1:1.13.1-1.el7                            centos-sclo-rh                        3.6 M
Installing for dependencies:
 atlas                                                x86_64                        3.10.1-12.el7                             base                                  4.5 M
 libgfortran                                          x86_64                        4.8.5-16.el7_4.1                          updates                               296 k
 libquadmath                                          x86_64                        4.8.5-16.el7_4.1                          updates                               186 k
 rh-python36-python                                   x86_64                        3.6.3-1.el7                               centos-sclo-rh                         55 k
 rh-python36-python-libs                              x86_64                        3.6.3-1.el7                               centos-sclo-rh                        7.5 M
 rh-python36-python-nose                              noarch                        1.3.7-3.el7                               centos-sclo-rh                        282 k
 rh-python36-python-pip                               noarch                        9.0.1-2.el7                               centos-sclo-rh                        1.7 M
 rh-python36-python-setuptools                        noarch                        36.5.0-1.el7                              centos-sclo-rh                        566 k
 rh-python36-runtime                                  x86_64                        2.0-1.el7                                 centos-sclo-rh                        1.1 M
 scl-utils                                            x86_64                        20130529-18.el7_4                         updates                                24 k

Transaction Summary
==========================================================================================================================================================================
Install  1 Package (+10 Dependent packages)

Total download size: 20 M
Installed size: 94 M
Is this ok [y/d/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libquadmath-4.8.5-16.el7_4.1.x86_64                                                                                                                   1/11 
  Installing : libgfortran-4.8.5-16.el7_4.1.x86_64                                                                                                                   2/11 
  Installing : atlas-3.10.1-12.el7.x86_64                                                                                                                            3/11 
  Installing : scl-utils-20130529-18.el7_4.x86_64                                                                                                                    4/11 
  Installing : rh-python36-runtime-2.0-1.el7.x86_64                                                                                                                  5/11 
  Installing : rh-python36-python-libs-3.6.3-1.el7.x86_64                                                                                                            6/11 
  Installing : rh-python36-python-3.6.3-1.el7.x86_64                                                                                                                 7/11 
  Installing : rh-python36-python-setuptools-36.5.0-1.el7.noarch                                                                                                     8/11 
  Installing : rh-python36-python-pip-9.0.1-2.el7.noarch                                                                                                             9/11 
  Installing : rh-python36-python-nose-1.3.7-3.el7.noarch                                                                                                           10/11 
  Installing : 1:rh-python36-numpy-1.13.1-1.el7.x86_64                                                                                                              11/11 
  Verifying  : rh-python36-runtime-2.0-1.el7.x86_64                                                                                                                  1/11 
  Verifying  : scl-utils-20130529-18.el7_4.x86_64                                                                                                                    2/11 
  Verifying  : libgfortran-4.8.5-16.el7_4.1.x86_64                                                                                                                   3/11 
  Verifying  : libquadmath-4.8.5-16.el7_4.1.x86_64                                                                                                                   4/11 
  Verifying  : 1:rh-python36-numpy-1.13.1-1.el7.x86_64                                                                                                               5/11 
  Verifying  : rh-python36-python-nose-1.3.7-3.el7.noarch                                                                                                            6/11 
  Verifying  : rh-python36-python-3.6.3-1.el7.x86_64                                                                                                                 7/11 
  Verifying  : rh-python36-python-pip-9.0.1-2.el7.noarch                                                                                                             8/11 
  Verifying  : rh-python36-python-libs-3.6.3-1.el7.x86_64                                                                                                            9/11 
  Verifying  : atlas-3.10.1-12.el7.x86_64                                                                                                                           10/11 
  Verifying  : rh-python36-python-setuptools-36.5.0-1.el7.noarch                                                                                                    11/11 

Installed:
  rh-python36-numpy.x86_64 1:1.13.1-1.el7                                                                                                                                 

Dependency Installed:
  atlas.x86_64 0:3.10.1-12.el7                         libgfortran.x86_64 0:4.8.5-16.el7_4.1                        libquadmath.x86_64 0:4.8.5-16.el7_4.1                
  rh-python36-python.x86_64 0:3.6.3-1.el7              rh-python36-python-libs.x86_64 0:3.6.3-1.el7                 rh-python36-python-nose.noarch 0:1.3.7-3.el7         
  rh-python36-python-pip.noarch 0:9.0.1-2.el7          rh-python36-python-setuptools.noarch 0:36.5.0-1.el7          rh-python36-runtime.x86_64 0:2.0-1.el7               
  scl-utils.x86_64 0:20130529-18.el7_4                

Complete!
[raven@jupyterhub ~]$ 
[raven@jupyterhub ~]$ rpm -ql atlas
/etc/ld.so.conf.d/atlas-x86_64.conf
/usr/lib64/atlas
/usr/lib64/atlas/libsatlas.so.3
/usr/lib64/atlas/libsatlas.so.3.10
/usr/lib64/atlas/libtatlas.so.3
/usr/lib64/atlas/libtatlas.so.3.10
/usr/share/doc/atlas-3.10.1
/usr/share/doc/atlas-3.10.1/README.dist
[raven@jupyterhub ~]$ 
[raven@jupyterhub ~]$ sudo yum install rh-python36-scipy
Loaded plugins: fastestmirror
base                                                                                                                            | 3.6 kB  00:00:00     
centos-sclo-rh                                                                                                                  | 2.9 kB  00:00:00     
centos-sclo-sclo                                                                                                                | 2.9 kB  00:00:00     
epel/x86_64/metalink                                                                                                            |  15 kB  00:00:00     
epel                                                                                                                            | 4.7 kB  00:00:00     
extras                                                                                                                          | 3.4 kB  00:00:00     
google-cloud-compute/signature                                                                                                  |  454 B  00:00:00     
google-cloud-compute/signature                                                                                                  | 1.8 kB  00:00:00 !!! 
google-cloud-sdk/signature                                                                                                      |  454 B  00:00:00     
google-cloud-sdk/signature                                                                                                      | 1.4 kB  00:00:00 !!! 
updates                                                                                                                         | 3.4 kB  00:00:00     
(1/3): epel/x86_64/updateinfo                                                                                                   | 862 kB  00:00:00     
(2/3): epel/x86_64/primary_db                                                                                                   | 6.1 MB  00:00:00     
(3/3): updates/7/x86_64/primary_db                                                                                              | 4.6 MB  00:00:01     
Loading mirror speeds from cached hostfile
 * base: mirror.beyondhosting.net
 * epel: mirror.steadfast.net
 * extras: mirrors.cmich.edu
 * updates: repo.us.bigstepcloud.com
Resolving Dependencies
--> Running transaction check
---> Package rh-python36-scipy.x86_64 0:0.19.1-2.el7 will be installed
--> Processing Dependency: rh-python36-f2py for package: rh-python36-scipy-0.19.1-2.el7.x86_64
--> Running transaction check
---> Package rh-python36-numpy-f2py.x86_64 1:1.13.1-1.el7 will be installed
--> Processing Dependency: rh-python36-python-devel for package: 1:rh-python36-numpy-f2py-1.13.1-1.el7.x86_64
--> Running transaction check
---> Package rh-python36-python-devel.x86_64 0:3.6.3-1.el7 will be installed
--> Processing Dependency: scl-utils-build for package: rh-python36-python-devel-3.6.3-1.el7.x86_64
--> Running transaction check
---> Package scl-utils-build.x86_64 0:20130529-18.el7_4 will be installed
--> Processing Dependency: redhat-rpm-config for package: scl-utils-build-20130529-18.el7_4.x86_64
--> Processing Dependency: iso-codes for package: scl-utils-build-20130529-18.el7_4.x86_64
--> Running transaction check
---> Package iso-codes.noarch 0:3.46-2.el7 will be installed
--> Processing Dependency: xml-common for package: iso-codes-3.46-2.el7.noarch
---> Package redhat-rpm-config.noarch 0:9.1.0-76.el7.centos will be installed
--> Processing Dependency: dwz >= 0.4 for package: redhat-rpm-config-9.1.0-76.el7.centos.noarch
--> Processing Dependency: zip for package: redhat-rpm-config-9.1.0-76.el7.centos.noarch
--> Processing Dependency: perl-srpm-macros for package: redhat-rpm-config-9.1.0-76.el7.centos.noarch
--> Running transaction check
---> Package dwz.x86_64 0:0.11-3.el7 will be installed
---> Package perl-srpm-macros.noarch 0:1-8.el7 will be installed
---> Package xml-common.noarch 0:0.6.3-39.el7 will be installed
---> Package zip.x86_64 0:3.0-11.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================
 Package                                     Arch                      Version                                 Repository                         Size
=======================================================================================================================================================
Installing:
 rh-python36-scipy                           x86_64                    0.19.1-2.el7                            centos-sclo-rh                     13 M
Installing for dependencies:
 dwz                                         x86_64                    0.11-3.el7                              base                               99 k
 iso-codes                                   noarch                    3.46-2.el7                              base                              2.7 M
 perl-srpm-macros                            noarch                    1-8.el7                                 base                              4.6 k
 redhat-rpm-config                           noarch                    9.1.0-76.el7.centos                     base                               79 k
 rh-python36-numpy-f2py                      x86_64                    1:1.13.1-1.el7                          centos-sclo-rh                    217 k
 rh-python36-python-devel                    x86_64                    3.6.3-1.el7                             centos-sclo-rh                    840 k
 scl-utils-build                             x86_64                    20130529-18.el7_4                       updates                            17 k
 xml-common                                  noarch                    0.6.3-39.el7                            base                               26 k
 zip                                         x86_64                    3.0-11.el7                              base                              260 k

Transaction Summary
=======================================================================================================================================================
Install  1 Package (+9 Dependent packages)

Total download size: 17 M
Installed size: 73 M
Is this ok [y/d/N]: y
Downloading packages:
(1/10): dwz-0.11-3.el7.x86_64.rpm                                                                                               |  99 kB  00:00:00     
(2/10): perl-srpm-macros-1-8.el7.noarch.rpm                                                                                     | 4.6 kB  00:00:00     
(3/10): redhat-rpm-config-9.1.0-76.el7.centos.noarch.rpm                                                                        |  79 kB  00:00:00     
(4/10): rh-python36-numpy-f2py-1.13.1-1.el7.x86_64.rpm                                                                          | 217 kB  00:00:00     
(5/10): xml-common-0.6.3-39.el7.noarch.rpm                                                                                      |  26 kB  00:00:00     
(6/10): zip-3.0-11.el7.x86_64.rpm                                                                                               | 260 kB  00:00:00     
(7/10): scl-utils-build-20130529-18.el7_4.x86_64.rpm                                                                            |  17 kB  00:00:00     
(8/10): rh-python36-python-devel-3.6.3-1.el7.x86_64.rpm                                                                         | 840 kB  00:00:00     
(9/10): rh-python36-scipy-0.19.1-2.el7.x86_64.rpm                                                                               |  13 MB  00:00:00     
(10/10): iso-codes-3.46-2.el7.noarch.rpm                                                                                        | 2.7 MB  00:00:02     
-------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                  7.5 MB/s |  17 MB  00:00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : dwz-0.11-3.el7.x86_64                                                                                                              1/10 
  Installing : zip-3.0-11.el7.x86_64                                                                                                              2/10 
  Installing : perl-srpm-macros-1-8.el7.noarch                                                                                                    3/10 
  Installing : redhat-rpm-config-9.1.0-76.el7.centos.noarch                                                                                       4/10 
  Installing : xml-common-0.6.3-39.el7.noarch                                                                                                     5/10 
  Installing : iso-codes-3.46-2.el7.noarch                                                                                                        6/10 
  Installing : scl-utils-build-20130529-18.el7_4.x86_64                                                                                           7/10 
  Installing : rh-python36-python-devel-3.6.3-1.el7.x86_64                                                                                        8/10 
  Installing : 1:rh-python36-numpy-f2py-1.13.1-1.el7.x86_64                                                                                       9/10 
  Installing : rh-python36-scipy-0.19.1-2.el7.x86_64                                                                                             10/10 
  Verifying  : xml-common-0.6.3-39.el7.noarch                                                                                                     1/10 
  Verifying  : perl-srpm-macros-1-8.el7.noarch                                                                                                    2/10 
  Verifying  : zip-3.0-11.el7.x86_64                                                                                                              3/10 
  Verifying  : redhat-rpm-config-9.1.0-76.el7.centos.noarch                                                                                       4/10 
  Verifying  : rh-python36-python-devel-3.6.3-1.el7.x86_64                                                                                        5/10 
  Verifying  : dwz-0.11-3.el7.x86_64                                                                                                              6/10 
  Verifying  : iso-codes-3.46-2.el7.noarch                                                                                                        7/10 
  Verifying  : scl-utils-build-20130529-18.el7_4.x86_64                                                                                           8/10 
  Verifying  : rh-python36-scipy-0.19.1-2.el7.x86_64                                                                                              9/10
  Verifying  : 1:rh-python36-numpy-f2py-1.13.1-1.el7.x86_64                                                                                      10/10 

Installed:
  rh-python36-scipy.x86_64 0:0.19.1-2.el7                                                                                                              

Dependency Installed:
  dwz.x86_64 0:0.11-3.el7                            iso-codes.noarch 0:3.46-2.el7                    perl-srpm-macros.noarch 0:1-8.el7                
  redhat-rpm-config.noarch 0:9.1.0-76.el7.centos     rh-python36-numpy-f2py.x86_64 1:1.13.1-1.el7     rh-python36-python-devel.x86_64 0:3.6.3-1.el7    
  scl-utils-build.x86_64 0:20130529-18.el7_4         xml-common.noarch 0:0.6.3-39.el7                 zip.x86_64 0:3.0-11.el7                          

Complete!
[raven@jupyterhub ~]$

然後可以用 alternatives 指令管理多組版本的 Python 安裝。
[raven@jupyterhub ~]$ alternatives --list
libnssckbi.so.x86_64    auto    /usr/lib64/pkcs11/p11-kit-trust.so
ld      auto    /usr/bin/ld.bfd
mta     auto    /usr/sbin/sendmail.postfix
[raven@jupyterhub ~]$ 
[raven@jupyterhub ~]$ which pyhton
/usr/bin/which: no pyhton in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/raven/.local/bin:/home/raven/bin)
[raven@jupyterhub ~]$ which python
/usr/bin/python
[raven@jupyterhub ~]$ ls -l /usr/bin/python
lrwxrwxrwx. 1 root root 7 Dec 14 00:27 /usr/bin/python -> python2
[raven@jupyterhub ~]$ sudo update-alternatives --install /usr/bin/python3 python3 /opt/rh/rh-python36/root/usr/bin/python3.6 1
[raven@jupyterhub ~]$ alternatives --list
libnssckbi.so.x86_64    auto    /usr/lib64/pkcs11/p11-kit-trust.so
ld      auto    /usr/bin/ld.bfd
mta     auto    /usr/sbin/sendmail.postfix
python3 auto    /opt/rh/rh-python36/root/usr/bin/python3.6
[raven@jupyterhub ~]$

接著是裝 nodejs 的 npm 模組管理套件:這是 JupyterHub 所需要的服務要的東西
[raven@jupyterhub ~]$ sudo yum install nodejs npm
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.tzulo.com
 * epel: mirror.steadfast.net
 * extras: mirror.steadfast.net
 * updates: repos.forethought.net
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 1:6.14.0-1.el7 will be installed
--> Processing Dependency: http-parser >= 2.7.0 for package: 1:nodejs-6.14.0-1.el7.x86_64
--> Processing Dependency: libuv >= 1:1.9.1 for package: 1:nodejs-6.14.0-1.el7.x86_64
--> Processing Dependency: libhttp_parser.so.2()(64bit) for package: 1:nodejs-6.14.0-1.el7.x86_64
--> Processing Dependency: libuv.so.1()(64bit) for package: 1:nodejs-6.14.0-1.el7.x86_64
---> Package npm.x86_64 1:3.10.10-1.6.14.0.1.el7 will be installed
--> Running transaction check
---> Package http-parser.x86_64 0:2.7.1-5.el7_4 will be installed
---> Package libuv.x86_64 1:1.19.2-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================
 Package                   Arch                 Version                                 Repository          Size
=================================================================================================================
Installing:
 nodejs                    x86_64               1:6.14.0-1.el7                          epel               4.6 M
 npm                       x86_64               1:3.10.10-1.6.14.0.1.el7                epel               2.5 M
Installing for dependencies:
 http-parser               x86_64               2.7.1-5.el7_4                           base                28 k
 libuv                     x86_64               1:1.19.2-1.el7                          epel               121 k

Transaction Summary
=================================================================================================================
Install  2 Packages (+2 Dependent packages)

Total download size: 7.3 M
Installed size: 26 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): http-parser-2.7.1-5.el7_4.x86_64.rpm                                               |  28 kB  00:00:00     
(2/4): libuv-1.19.2-1.el7.x86_64.rpm                                                      | 121 kB  00:00:00     
(3/4): nodejs-6.14.0-1.el7.x86_64.rpm                                                     | 4.6 MB  00:00:00     
(4/4): npm-3.10.10-1.6.14.0.1.el7.x86_64.rpm                                              | 2.5 MB  00:00:00     
-----------------------------------------------------------------------------------------------------------------
Total                                                                            6.2 MB/s | 7.3 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : http-parser-2.7.1-5.el7_4.x86_64                                                              1/4 
  Installing : 1:libuv-1.19.2-1.el7.x86_64                                                                   2/4 
  Installing : 1:npm-3.10.10-1.6.14.0.1.el7.x86_64                                                           3/4 
  Installing : 1:nodejs-6.14.0-1.el7.x86_64                                                                  4/4 
  Verifying  : 1:libuv-1.19.2-1.el7.x86_64                                                                   1/4 
  Verifying  : http-parser-2.7.1-5.el7_4.x86_64                                                              2/4 
  Verifying  : 1:nodejs-6.14.0-1.el7.x86_64                                                                  3/4 
  Verifying  : 1:npm-3.10.10-1.6.14.0.1.el7.x86_64                                                           4/4 

Installed:
  nodejs.x86_64 1:6.14.0-1.el7                        npm.x86_64 1:3.10.10-1.6.14.0.1.el7                       

Dependency Installed:
  http-parser.x86_64 0:2.7.1-5.el7_4                         libuv.x86_64 1:1.19.2-1.el7                        

Complete!
[raven@jupyterhub ~]$ 

用 npm 安裝 configurable-http-proxy
[raven@jupyterhub ~]$ sudo npm install -g configurable-http-proxy
/usr/bin/configurable-http-proxy -> /usr/lib/node_modules/configurable-http-proxy/bin/configurable-http-proxy
/usr/lib
└─┬ configurable-http-proxy@3.1.1 
  ├── commander@2.13.0 
  ├─┬ http-proxy@1.16.2 
  │ ├── eventemitter3@1.2.0 
  │ └── requires-port@1.0.0 
  ├─┬ lynx@0.2.0 
  │ ├── mersenne@0.0.4 
  │ └── statsd-parser@0.0.4 
  ├── strftime@0.10.0 
  └─┬ winston@2.4.2 
    ├── async@1.0.0 
    ├── colors@1.0.3 
    ├── cycle@1.0.3 
    ├── eyes@0.1.8 
    ├── isstream@0.1.2 
    └── stack-trace@0.0.10 

[raven@jupyterhub ~]$ 

最後是透過 pip3 install 安裝 JupyterHub
[raven@jupyterhub ~]$ sudo python3 -m pip install jupyterhub
Collecting jupyterhub
  Downloading https://files.pythonhosted.org/packages/bd/36/2c98cae181c50d955a9f7157ee0a1db80b234fd8b8c11b76b0a37efb695a/jupyterhub-0.8.1-py3-none-any.whl (3.0MB)
    100% |████████████████████████████████| 3.0MB 439kB/s 
Collecting python-oauth2>=1.0 (from jupyterhub)
  Downloading https://files.pythonhosted.org/packages/4c/a4/e92b8ba57ccfee230f196c80dc9327d1b626387c5ec1aa400e343161fde8/python-oauth2-1.1.0.tar.gz (42kB)
    100% |████████████████████████████████| 51kB 10.1MB/s 
Collecting jinja2 (from jupyterhub)
  Downloading https://files.pythonhosted.org/packages/7f/ff/ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731/Jinja2-2.10-py2.py3-none-any.whl (126kB)
    100% |████████████████████████████████| 133kB 5.2MB/s 
Collecting traitlets>=4.3.2 (from jupyterhub)
  Downloading https://files.pythonhosted.org/packages/93/d6/abcb22de61d78e2fc3959c964628a5771e47e7cc60d53e9342e21ed6cc9a/traitlets-4.3.2-py2.py3-none-any.whl (74kB)
    100% |████████████████████████████████| 81kB 7.1MB/s 
Collecting SQLAlchemy>=1.1 (from jupyterhub)
  Downloading https://files.pythonhosted.org/packages/c1/c8/392fcd2d01534bc871c65cb964e0b39d59feb777e51649e6eaf00f6377b5/SQLAlchemy-1.2.7.tar.gz (5.6MB)
    100% |████████████████████████████████| 5.6MB 214kB/s 
Collecting requests (from jupyterhub)
  Downloading https://files.pythonhosted.org/packages/49/df/50aa1999ab9bde74656c2919d9c0c085fd2b3775fd3eca826012bef76d8c/requests-2.18.4-py2.py3-none-any.whl (88kB)
    100% |████████████████████████████████| 92kB 7.7MB/s 
Collecting pamela (from jupyterhub)
  Downloading https://files.pythonhosted.org/packages/09/e0/19aba69ecee9162fb5de44b2c66fd8cc7e3fdb2d025839555afd8a71e79f/pamela-0.3.0-py2.py3-none-any.whl
Collecting alembic (from jupyterhub)
  Downloading https://files.pythonhosted.org/packages/89/03/756d5b8e1c90bf283c3f435766aa3f20208d1c3887579dd8f2122e01d5f4/alembic-0.9.9.tar.gz (1.0MB)
    100% |████████████████████████████████| 1.0MB 1.1MB/s 
Collecting tornado>=4.1 (from jupyterhub)
  Downloading https://files.pythonhosted.org/packages/cf/d1/3be271ae5eba9fb59df63c9891fdc7d8044b999e8ac145994cdbfd2ae66a/tornado-5.0.2.tar.gz (506kB)
    100% |████████████████████████████████| 512kB 2.0MB/s 
Collecting MarkupSafe>=0.23 (from jinja2->jupyterhub)
  Downloading https://files.pythonhosted.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/MarkupSafe-1.0.tar.gz
Collecting decorator (from traitlets>=4.3.2->jupyterhub)
  Downloading https://files.pythonhosted.org/packages/bc/bb/a24838832ba35baf52f32ab1a49b906b5f82fb7c76b2f6a7e35e140bac30/decorator-4.3.0-py2.py3-none-any.whl
Collecting ipython-genutils (from traitlets>=4.3.2->jupyterhub)
  Downloading https://files.pythonhosted.org/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting six (from traitlets>=4.3.2->jupyterhub)
  Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting idna<2 .7="">=2.5 (from requests->jupyterhub)
  Downloading https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 6.9MB/s 
Collecting chardet<3 .1.0="">=3.0.2 (from requests->jupyterhub)
  Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 6.3MB/s 
Collecting urllib3<1 .23="">=1.21.1 (from requests->jupyterhub)
  Downloading https://files.pythonhosted.org/packages/63/cb/6965947c13a94236f6d4b8223e21beb4d576dc72e8130bd7880f600839b8/urllib3-1.22-py2.py3-none-any.whl (132kB)
    100% |████████████████████████████████| 133kB 6.3MB/s 
Collecting certifi>=2017.4.17 (from requests->jupyterhub)
  Downloading https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl (150kB)
    100% |████████████████████████████████| 153kB 5.0MB/s 
Collecting Mako (from alembic->jupyterhub)
  Downloading https://files.pythonhosted.org/packages/eb/f3/67579bb486517c0d49547f9697e36582cd19dafb5df9e687ed8e22de57fa/Mako-1.0.7.tar.gz (564kB)
    100% |████████████████████████████████| 573kB 2.1MB/s 
Collecting python-editor>=0.3 (from alembic->jupyterhub)
  Downloading https://files.pythonhosted.org/packages/65/1e/adf6e000ea5dc909aa420352d6ba37f16434c8a3c2fa030445411a1ed545/python-editor-1.0.3.tar.gz
Collecting python-dateutil (from alembic->jupyterhub)
  Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)
    100% |████████████████████████████████| 215kB 4.2MB/s 
Installing collected packages: python-oauth2, MarkupSafe, jinja2, decorator, ipython-genutils, six, traitlets, SQLAlchemy, idna, chardet, urllib3, certifi, requests, pamela, Mako, python-editor, python-dateutil, alembic, tornado, jupyterhub
  Running setup.py install for python-oauth2 ... done
  Running setup.py install for MarkupSafe ... done
  Running setup.py install for SQLAlchemy ... done
  Running setup.py install for Mako ... done
  Running setup.py install for python-editor ... done
  Running setup.py install for alembic ... done
  Running setup.py install for tornado ... done
Successfully installed Mako-1.0.7 MarkupSafe-1.0 SQLAlchemy-1.2.7 alembic-0.9.9 certifi-2018.4.16 chardet-3.0.4 decorator-4.3.0 idna-2.6 ipython-genutils-0.2.0 jinja2-2.10 jupyterhub-0.8.1 pamela-0.3.0 python-dateutil-2.7.3 python-editor-1.0.3 python-oauth2-1.1.0 requests-2.18.4 six-1.11.0 tornado-5.0.2 traitlets-4.3.2 urllib3-1.22
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[raven@jupyterhub ~]$ 
[raven@jupyterhub ~]$ ls /opt/rh/rh-python36/root/usr/bin/
alembic           jupyterhub             pip     pydoc3.6          python3.6m                pyvenv
chardetect        jupyterhub-singleuser  pip3    python            python3.6m-config         pyvenv-3.6
easy_install      mako-render            pip3.6  python3           python3.6m-x86_64-config
easy_install-3.6  nosetests              pydoc   python3.6         python3-config
f2py3             nosetests-3.6          pydoc3  python3.6-config  python-config
[raven@jupyterhub ~]$ 
[raven@jupyterhub ~]$ sudo python3 -m pip install notebook
Collecting notebook
  Downloading https://files.pythonhosted.org/packages/c0/66/cfed59f574d03ca5f1b7c5281485a9cc9a0f21342d24e0f057572316dae5/notebook-5.5.0-py2.py3-none-any.whl (8.4MB)
    100% |████████████████████████████████| 8.4MB 123kB/s 
Collecting terminado>=0.8.1 (from notebook)
  Downloading https://files.pythonhosted.org/packages/2e/20/a26211a24425923d46e1213b376a6ee60dc30bcdf1b0c345e2c3769deb1c/terminado-0.8.1-py2.py3-none-any.whl
Requirement already satisfied: tornado>=4 in /opt/rh/rh-python36/root/usr/lib64/python3.6/site-packages (from notebook)
Collecting nbconvert (from notebook)
  Downloading https://files.pythonhosted.org/packages/39/ea/280d6c0d92f8e3ca15fd798bbcc2ea141489f9539de7133d8fe10ea4b049/nbconvert-5.3.1-py2.py3-none-any.whl (387kB)
    100% |████████████████████████████████| 389kB 2.8MB/s 
Collecting jupyter-core>=4.4.0 (from notebook)
  Downloading https://files.pythonhosted.org/packages/1d/44/065d2d7bae7bebc06f1dd70d23c36da8c50c0f08b4236716743d706762a8/jupyter_core-4.4.0-py2.py3-none-any.whl (126kB)
    100% |████████████████████████████████| 133kB 7.1MB/s 
Requirement already satisfied: ipython-genutils in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from notebook)
Requirement already satisfied: jinja2 in /opt/rh/rh-python36/root/usr/lib64/python3.6/site-packages (from notebook)
Collecting ipykernel (from notebook)
  Downloading https://files.pythonhosted.org/packages/ab/3f/cd624c835aa3336a9110d0a99e15070f343b881b7d651ab1375ef226a3ac/ipykernel-4.8.2-py3-none-any.whl (108kB)
    100% |████████████████████████████████| 112kB 7.6MB/s 
Collecting pyzmq>=17 (from notebook)
  Downloading https://files.pythonhosted.org/packages/58/0e/d40ee65acabb0776ccdade96812adc0438051ef6cff1ddbe4da463604867/pyzmq-17.0.0-cp36-cp36m-manylinux1_x86_64.whl (3.1MB)
    100% |████████████████████████████████| 3.1MB 337kB/s 
Collecting nbformat (from notebook)
  Downloading https://files.pythonhosted.org/packages/da/27/9a654d2b6cc1eaa517d1c5a4405166c7f6d72f04f6e7eea41855fe808a46/nbformat-4.4.0-py2.py3-none-any.whl (155kB)
    100% |████████████████████████████████| 163kB 4.5MB/s 
Requirement already satisfied: traitlets>=4.2.1 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from notebook)
Collecting Send2Trash (from notebook)
  Downloading https://files.pythonhosted.org/packages/49/46/c3dc27481d1cc57b9385aff41c474ceb7714f7935b1247194adae45db714/Send2Trash-1.5.0-py3-none-any.whl
Collecting jupyter-client>=5.2.0 (from notebook)
  Downloading https://files.pythonhosted.org/packages/94/dd/fe6c4d683b09eb05342bd2816b7779663f71762b4fa9c2d5203d35d17354/jupyter_client-5.2.3-py2.py3-none-any.whl (89kB)
    100% |████████████████████████████████| 92kB 7.9MB/s 
Collecting ptyprocess; os_name != "nt" (from terminado>=0.8.1->notebook)
  Downloading https://files.pythonhosted.org/packages/ff/4e/fa4a73ccfefe2b37d7b6898329e7dbcd1ac846ba3a3b26b294a78a3eb997/ptyprocess-0.5.2-py2.py3-none-any.whl
Collecting entrypoints>=0.2.2 (from nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/cc/8b/4eefa9b47f1910b3d2081da67726b066e379b04ca897acfe9f92bac56147/entrypoints-0.2.3-py2.py3-none-any.whl
Collecting pandocfilters>=1.4.1 (from nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/4c/ea/236e2584af67bb6df960832731a6e5325fd4441de001767da328c33368ce/pandocfilters-1.4.2.tar.gz
Collecting pygments (from nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/02/ee/b6e02dc6529e82b75bb06823ff7d005b141037cb1416b10c6f00fc419dca/Pygments-2.2.0-py2.py3-none-any.whl (841kB)
    100% |████████████████████████████████| 849kB 1.5MB/s 
Collecting bleach (from nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/30/b6/a8cffbb9ab4b62b557c22703163735210e9cd857d533740c64e1467d228e/bleach-2.1.3-py2.py3-none-any.whl
Collecting mistune>=0.7.4 (from nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/c8/8c/87f4d359438ba0321a2ae91936030110bfcc62fef752656321a72b8c1af9/mistune-0.8.3-py2.py3-none-any.whl
Collecting testpath (from nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/15/19/d7bc380c479a184e4a5a9ce516e4e2a773165f89b445f7cdced83d94de25/testpath-0.3.1-py2.py3-none-any.whl (161kB)
    100% |████████████████████████████████| 163kB 4.2MB/s 
Requirement already satisfied: MarkupSafe>=0.23 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from jinja2->notebook)
Collecting ipython>=4.0.0 (from ipykernel->notebook)
  Downloading https://files.pythonhosted.org/packages/b1/7f/91d50f28af3e3a24342561983a7857e399ce24093876e6970b986a0b6677/ipython-6.4.0-py3-none-any.whl (750kB)
    100% |████████████████████████████████| 757kB 1.7MB/s 
Collecting jsonschema!=2.5.0,>=2.4 (from nbformat->notebook)
  Downloading https://files.pythonhosted.org/packages/77/de/47e35a97b2b05c2fadbec67d44cfcdcd09b8086951b331d82de90d2912da/jsonschema-2.6.0-py2.py3-none-any.whl
Requirement already satisfied: six in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from traitlets>=4.2.1->notebook)
Requirement already satisfied: decorator in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from traitlets>=4.2.1->notebook)
Requirement already satisfied: python-dateutil>=2.1 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from jupyter-client>=5.2.0->notebook)
Collecting html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre (from bleach->nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/a5/62/bbd2be0e7943ec8504b517e62bab011b4946e1258842bc159e5dfde15b96/html5lib-1.0.1-py2.py3-none-any.whl (117kB)
    100% |████████████████████████████████| 122kB 7.6MB/s 
Collecting prompt-toolkit<2 .0.0="">=1.0.15 (from ipython>=4.0.0->ipykernel->notebook)
  Downloading https://files.pythonhosted.org/packages/04/d1/c6616dd03701e7e2073f06d5c3b41b012256e42b72561f16a7bd86dd7b43/prompt_toolkit-1.0.15-py3-none-any.whl (247kB)
    100% |████████████████████████████████| 256kB 3.5MB/s 
Collecting simplegeneric>0.8 (from ipython>=4.0.0->ipykernel->notebook)
  Downloading https://files.pythonhosted.org/packages/3d/57/4d9c9e3ae9a255cd4e1106bb57e24056d3d0709fc01b2e3e345898e49d5b/simplegeneric-0.8.1.zip
Requirement already satisfied: setuptools>=18.5 in /opt/rh/rh-python36/root/usr/lib/python3.6/site-packages (from ipython>=4.0.0->ipykernel->notebook)
Collecting jedi>=0.10 (from ipython>=4.0.0->ipykernel->notebook)
  Downloading https://files.pythonhosted.org/packages/e7/42/074192a165622e645ed4aeade63e76e56b3496a044569b3c6cae3a918352/jedi-0.12.0-py2.py3-none-any.whl (172kB)
    100% |████████████████████████████████| 174kB 4.7MB/s 
Collecting pexpect; sys_platform != "win32" (from ipython>=4.0.0->ipykernel->notebook)
  Downloading https://files.pythonhosted.org/packages/b9/3c/e51a76fe78a877afd9acd95a51e3b7610c0983b19ef5a5dfa11735a619b8/pexpect-4.5.0-py2.py3-none-any.whl (57kB)
    100% |████████████████████████████████| 61kB 9.8MB/s 
Collecting pickleshare (from ipython>=4.0.0->ipykernel->notebook)
  Downloading https://files.pythonhosted.org/packages/9f/17/daa142fc9be6b76f26f24eeeb9a138940671490b91cb5587393f297c8317/pickleshare-0.7.4-py2.py3-none-any.whl
Collecting backcall (from ipython>=4.0.0->ipykernel->notebook)
  Downloading https://files.pythonhosted.org/packages/84/71/c8ca4f5bb1e08401b916c68003acf0a0655df935d74d93bf3f3364b310e0/backcall-0.1.0.tar.gz
Collecting webencodings (from html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre->bleach->nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl
Collecting wcwidth (from prompt-toolkit<2 .0.0="">=1.0.15->ipython>=4.0.0->ipykernel->notebook)
  Downloading https://files.pythonhosted.org/packages/7e/9f/526a6947247599b084ee5232e4f9190a38f398d7300d866af3ab571a5bfe/wcwidth-0.1.7-py2.py3-none-any.whl
Collecting parso>=0.2.0 (from jedi>=0.10->ipython>=4.0.0->ipykernel->notebook)
  Downloading https://files.pythonhosted.org/packages/63/69/0c383765d192006330bfaae27a2c5d0933fb4760c5aacd933b8b19391693/parso-0.2.0-py2.py3-none-any.whl (90kB)
    100% |████████████████████████████████| 92kB 7.8MB/s 
Installing collected packages: ptyprocess, terminado, entrypoints, pandocfilters, pygments, webencodings, html5lib, bleach, mistune, testpath, jupyter-core, jsonschema, nbformat, nbconvert, pyzmq, jupyter-client, wcwidth, prompt-toolkit, simplegeneric, parso, jedi, pexpect, pickleshare, backcall, ipython, ipykernel, Send2Trash, notebook
  Running setup.py install for pandocfilters ... done
  Running setup.py install for simplegeneric ... done
  Running setup.py install for backcall ... done
Successfully installed Send2Trash-1.5.0 backcall-0.1.0 bleach-2.1.3 entrypoints-0.2.3 html5lib-1.0.1 ipykernel-4.8.2 ipython-6.4.0 jedi-0.12.0 jsonschema-2.6.0 jupyter-client-5.2.3 jupyter-core-4.4.0 mistune-0.8.3 nbconvert-5.3.1 nbformat-4.4.0 notebook-5.5.0 pandocfilters-1.4.2 parso-0.2.0 pexpect-4.5.0 pickleshare-0.7.4 prompt-toolkit-1.0.15 ptyprocess-0.5.2 pygments-2.2.0 pyzmq-17.0.0 simplegeneric-0.8.1 terminado-0.8.1 testpath-0.3.1 wcwidth-0.1.7 webencodings-0.5.1
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[raven@jupyterhub ~]$ 

啟動看看(前景)
[raven@jupyterhub ~]$  /opt/rh/rh-python36/root/bin/jupyterhub
[I 2018-05-13 02:07:34.953 JupyterHub app:871] Writing cookie_secret to /home/raven/jupyterhub_cookie_secret
[I 2018-05-13 02:07:35.091 alembic.runtime.migration migration:117] Context impl SQLiteImpl.
[I 2018-05-13 02:07:35.092 alembic.runtime.migration migration:122] Will assume non-transactional DDL.
[I 2018-05-13 02:07:35.131 alembic.runtime.migration migration:327] Running stamp_revision  -> 3ec6993fe20c
[W 2018-05-13 02:07:35.242 JupyterHub app:955] No admin users, admin interface will be unavailable.
[W 2018-05-13 02:07:35.242 JupyterHub app:956] Add any administrative users to `c.Authenticator.admin_users` in config.
[I 2018-05-13 02:07:35.242 JupyterHub app:983] Not using whitelist. Any authenticated user will be allowed.
[I 2018-05-13 02:07:35.270 JupyterHub app:1528] Hub API listening on http://127.0.0.1:8081/hub/
[W 2018-05-13 02:07:35.271 JupyterHub proxy:415] 
    Generating CONFIGPROXY_AUTH_TOKEN. Restarting the Hub will require restarting the proxy.
    Set CONFIGPROXY_AUTH_TOKEN env or JupyterHub.proxy_auth_token config to avoid this message.
    
[W 2018-05-13 02:07:35.271 JupyterHub proxy:456] Running JupyterHub without SSL.  I hope there is SSL termination happening somewhere else...
[I 2018-05-13 02:07:35.271 JupyterHub proxy:458] Starting proxy @ http://*:8000/
02:07:35.434 - info: [ConfigProxy] Proxying http://*:8000 to (no default)
02:07:35.437 - info: [ConfigProxy] Proxy API at http://127.0.0.1:8001/api/routes
02:07:35.710 - info: [ConfigProxy] 200 GET /api/routes 
[W 2018-05-13 02:07:35.713 JupyterHub proxy:304] Adding missing default route
[I 2018-05-13 02:07:35.713 JupyterHub proxy:370] Adding default route for Hub: / => http://127.0.0.1:8081
02:07:35.721 - info: [ConfigProxy] Adding route / -> http://127.0.0.1:8081
02:07:35.722 - info: [ConfigProxy] 201 POST /api/routes/ 
[I 2018-05-13 02:07:35.723 JupyterHub app:1581] JupyterHub is now running at http://:8000/

[I 2018-05-13 02:10:38.860 JupyterHub log:122] 302 GET / → /hub (@::ffff:66.249.82.174) 0.79ms
[I 2018-05-13 02:10:41.684 JupyterHub log:122] 302 GET /hub → /hub/login (@::ffff:66.249.82.174) 0.59ms
[I 2018-05-13 02:10:46.593 JupyterHub log:122] 200 GET /hub/login (@::ffff:66.249.82.176) 54.06ms
[I 2018-05-13 02:10:47.858 JupyterHub log:122] 200 GET /hub/login (@::ffff:111.241.8.20) 1.21ms
02:12:35.730 - info: [ConfigProxy] 200 GET /api/routes
^C
Interrupted
[I 2018-05-13 02:29:53.922 JupyterHub app:1399] Cleaning up single-user servers...
[I 2018-05-13 02:29:53.922 JupyterHub proxy:496] Cleaning up proxy[1591]...
[I 2018-05-13 02:29:53.923 JupyterHub app:1431] ...done
[raven@jupyterhub ~]$ 

這樣就裝完了,不過上面因為還沒設定 Config,因此不能登入。

產生設定檔,並且弄一個 jupyterhub 帳號
[raven@jupyterhub ~]$ sudo mkdir -p /etc/jupyterhub
[raven@jupyterhub ~]$ sudo /opt/rh/rh-python36/root/bin/jupyterhub --generate-config -f /etc/jupyterhub/jupyterhub_config.py
Writing default config to: /etc/jupyterhub/jupyterhub_config.py
[raven@jupyterhub ~]$ sudo useradd jupyterhub
[raven@jupyterhub ~]$ sudo chown -R jupyterhub:jupyterhub /etc/jupyterhub/ 
[raven@jupyterhub ~]$ 

設置帳號與密碼:基本上 JupyterHub 的帳號是 OS 的帳號,但需要允許登入
這裡建一個 aaa 的 OS 帳號,並讓該帳號可以登入 Jupyterhub,密碼也是 OS 的
[raven@jupyterhub ~]$ sudo useradd aaa
[raven@jupyterhub ~]$ sudo passwd aaa
Changing password for user aaa.
New password: 
BAD PASSWORD: The password is a palindrome
Retype new password: 
passwd: all authentication tokens updated successfully.
[raven@jupyterhub ~]$ 
[raven@jupyterhub ~]$ cat << EOF | sudo tee -a /etc/jupyterhub/jupyterhub_config.py
c.Authenticator.whitelist = {'aaa','jupyterhub'}
EOF
[raven@jupyterhub ~]$

讓 Jupyterhub 變成系統服務
[raven@jupyterhub ~]$ cat << EOF | sudo tee /etc/systemd/system/jupyterhub.service
[Unit]
Description=Jupyterhub

[Service]
#Environment=PATH="${PATH}:/opt/rh/rh-python36/root/bin/"
#User=jupyterhub
#ExecStart=/opt/rh/rh-python36/root/usr/bin/jupyterhub --JupyterHub.spawner_class=sudospawner.SudoSpawner
ExecStart=/bin/bash -c 'PATH=${PATH}:/opt/rh/rh-python36/root/bin/;/opt/rh/rh-python36/root/usr/bin/jupyterhub'
WorkingDirectory=/etc/jupyterhub

[Install]
WantedBy=multi-user.target
EOF
[raven@jupyterhub ~]$ sudo systemctl daemon-reload
[raven@jupyterhub ~]$ sudo service jupyterhub start
Redirecting to /bin/systemctl start jupyterhub.service
[raven@jupyterhub ~]$ 

由於使用 PAM 機制作登入管理,最簡易的設定,將 SELinux 停用,並使用 root 作為服務執行帳號(或是讓 jupyterhub 加入 shadow 群組),就可以登入其他帳號
相關 Log 可以查看 journalctl 指令
上述 service file 僅能讓 jupyterhub 帳號登入...


利用 root 帳號執行,並使用 jupyterhub_config.py 的 whitelist 就可以避免 root 用來登入,同時使其他帳號可以登入使用。

基本上使用 anaconda 也是類似意思~
使用 docker 則要另外處理。

參考資料

JupyterHub — JupyterHub 0.8.1 documentation
Installation of Jupyterhub on remote server · jupyterhub/jupyterhub Wiki · GitHub
How to run JupyterHub on Ubuntu? – czxttkl
JupyterHub Documentation - jupyterhub.pdf
sakananote: Jupyterhub with CentOS 7 小記
sakananote: Jupyterhub with openSUSE Leap 42.2 小記
JupyterHub – Linux Cluster
centos - Set PATH for a systemd unit - Unix & Linux Stack Exchange
Optimized R and Python: standard BLAS vs. ATLAS vs. OpenBLAS vs. MKL

沒有留言:

張貼留言