■公式サイト
①Jupyter Project Documentation
②JupyterHub(公式ドキュメント)
■概要
上記②に下記のように記載
・Four subsystems make up JupyterHub:
-
a Hub (tornado process) that is the heart of JupyterHub
-
a configurable http proxy (node-http-proxy) that receives the requests from the client’s browser
-
multiple single-user Jupyter notebook servers (Python/IPython/tornado) that are monitored by Spawners
-
an authentication class that manages how users can access the system
Besides these central pieces, you can add optional configurations through a config.py file and manage users kernels on an admin panel.
■インストーラ―ダウンロード
上記②のInstallationリンクをクリックする。
prerequisit
上記のprerequisitによると、python3.5以上とnodejsとnpm
が必要とのこと。
・python3インストール
[centos7copy]$ yum install -y python3
・nodejsとnpmインストール
こちらを猿真似
[centos7copy]$ curl -sL https://rpm.nodesource.com/setup_8.x | sudo bash -
================================================================================
================================================================================
DEPRECATION WARNING
Node.js 8.x LTS Carbon is no longer actively supported!
You will not receive security or critical stability updates for this version.
You should migrate to a supported version of Node.js as soon as possible.
Use the installation script that corresponds to the version of Node.js you
wish to install. e.g.
* https://deb.nodesource.com/setup_10.x ― Node.js v10 LTS "Dubnium"
* https://deb.nodesource.com/setup_12.x ― Node.js v12 LTS "Erbium" (recommended)
* https://deb.nodesource.com/setup_14.x ― Node.js v14 LTS "Fermium"
* https://deb.nodesource.com/setup_15.x ― Node.js v15 "Fifteen"
Please see https://github.com/nodejs/Release for details about which
version may be appropriate for you.
----(略)----
→がっつりnodejsするわけじゃないからええねん。
[centos7copy]$ ll /etc/yum.repos.d/
total 56
-rw-r--r--. 1 root root 824 Apr 16 2020 bareos.repo
-rw-r--r--. 1 root root 1664 Apr 8 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Apr 8 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Apr 8 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 Apr 8 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Apr 8 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Apr 8 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 7577 Apr 8 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 616 Apr 8 2020 CentOS-x86_64-kernel.repo
-rw-r--r--. 1 root root 951 Aug 31 23:15 epel.repo
-rw-r--r--. 1 root root 1050 Oct 3 2017 epel-testing.repo
-rw-r--r--. 1 root root 201 Aug 15 22:11 mongodb-org-4.4.repo
-rw-r--r--. 1 root root 472 Jan 5 2018 nodesource-el7.repo
[centos7copy]$ cat /etc/yum.repos.d/nodesource-el7.repo
[nodesource]
name=Node.js Packages for Enterprise Linux 7 - $basearch
baseurl=https://rpm.nodesource.com/pub_8.x/el/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
[nodesource-source]
name=Node.js for Enterprise Linux 7 - $basearch - Source
baseurl=https://rpm.nodesource.com/pub_8.x/el/7/SRPMS
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
gpgcheck=1
[centos7copy]$ yum install -y nodejs
[centos7copy]$ node -v
v8.17.0
installation
[centos7copy]$ python3 -m pip install jupyterhub
→いろんなものがいっぱいインストールされた
[centos7copy]$ npm install -g configurable-http-proxy
----ここから脱線-----
※npmでインストールされたパッケージの場所は/usr/lib/node_modules
[centos7copy]$ ll /usr/lib/node_modules
total 8
drwxr-xr-x. 5 root root 4096 Nov 1 23:00 configurable-http-proxy
drwxr-xr-x. 9 root root 4096 Nov 1 22:48 npm
configurable-http-proxyはindividual serversへのリクエストをルーティングするリバースプロキシ参照
----ここまで脱線-----
[centos7copy]$ python3 -m pip install notebook
→いろんなものがいっぱいインストールされた
[centos7copy]$ jupyterhub -V
1.2.1
[centos7copy]$ configurable-http-proxy -V
4.2.2
[centos7copy]$ jupyterhub -h
Start a multi-user Jupyter Notebook server
Spawns a configurable-http-proxy and multi-user Hub, which authenticates users
and spawns single-user Notebook servers on behalf of users.
Subcommands
-----------
Subcommands are launched as `jupyterhub cmd [args]`. For information on using
subcommand 'cmd', do: `jupyterhub cmd -h`.
token
Generate an API token for a user
upgrade-db
Upgrade your JupyterHub state database to the current version.
Options
-------
Arguments that take values are actually convenience aliases to full
Configurables, whose aliases are listed on the help line. For more information
on full configurables, see '--help-all'.
--debug
set log level to logging.DEBUG (maximize logging output)
--generate-config
generate default config file
--generate-certs
generate certificates used for internal ssl
--no-db
disable persisting state database to disk
--upgrade-db
Automatically upgrade the database if needed on startup.
Only safe if the database has been backed up.
Only SQLite database files will be backed up automatically.
--no-ssl
[DEPRECATED in 0.7: does nothing]
--base-url=<URLPrefix> (JupyterHub.base_url)
Default: '/'
The base URL of the entire application.
Add this to the beginning of all JupyterHub URLs. Use base_url to run
JupyterHub within an existing website.
.. deprecated: 0.9
Use JupyterHub.bind_url
-y <Bool> (JupyterHub.answer_yes)
Default: False
Answer yes to any questions (e.g. confirm overwrite)
--ssl-key=<Unicode> (JupyterHub.ssl_key)
Default: ''
Path to SSL key file for the public facing interface of the proxy
When setting this, you should also set ssl_cert
--ssl-cert=<Unicode> (JupyterHub.ssl_cert)
Default: ''
Path to SSL certificate file for the public facing interface of the proxy
When setting this, you should also set ssl_key
--url=<Unicode> (JupyterHub.bind_url)
Default: 'http://:8000'
The public facing URL of the whole JupyterHub application.
This is the address on which the proxy will bind. Sets protocol, ip,
base_url
--ip=<Unicode> (JupyterHub.ip)
Default: ''
The public facing ip of the whole JupyterHub application (specifically
referred to as the proxy).
This is the address on which the proxy will listen. The default is to listen
on all interfaces. This is the only address through which JupyterHub should
be accessed by users.
.. deprecated: 0.9
Use JupyterHub.bind_url
--port=<Int> (JupyterHub.port)
Default: 8000
The public facing port of the proxy.
This is the port on which the proxy will listen. This is the only port
through which JupyterHub should be accessed by users.
.. deprecated: 0.9
Use JupyterHub.bind_url
--pid-file=<Unicode> (JupyterHub.pid_file)
Default: ''
File to write PID Useful for daemonizing JupyterHub.
--log-file=<Unicode> (JupyterHub.extra_log_file)
Default: ''
DEPRECATED: use output redirection instead, e.g.
jupyterhub &>> /var/log/jupyterhub.log
--log-level=<Enum> (Application.log_level)
Default: 30
Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')
Set the log level by value or name.
-f <Unicode> (JupyterHub.config_file)
Default: 'jupyterhub_config.py'
The config file to load
--config=<Unicode> (JupyterHub.config_file)
Default: 'jupyterhub_config.py'
The config file to load
--db=<Unicode> (JupyterHub.db_url)
Default: 'sqlite:///jupyterhub.sqlite'
url for the database. e.g. `sqlite:///jupyterhub.sqlite`
To see all available configurables, use `--help-all`
Examples
--------
generate default config file:
jupyterhub --generate-config -f /etc/jupyterhub/jupyterhub_config.py
spawn the server on 10.0.1.2:443 with https:
jupyterhub --ip 10.0.1.2 --port 443 --ssl-key my_ssl.key --ssl-cert my_ssl.cert
[centos7copy]$ configurable-http-proxy -h
Usage: configurable-http-proxy [options]
Options:
-V, --version output the version number
--ip <ip-address> Public-facing IP of the proxy
--port <n> (defaults to 8000) Public-facing port of the proxy
--ssl-key <keyfile> SSL key to use, if any
--ssl-cert <certfile> SSL certificate to use, if any
--ssl-ca <ca-file> SSL certificate authority, if any
--ssl-request-cert Request SSL certs to authenticate clients
--ssl-reject-unauthorized Reject unauthorized SSL connections (only meaningful if --ssl-request-cert is given)
--ssl-protocol <ssl-protocol> Set specific SSL protocol, e.g. TLSv1_2, SSLv3
--ssl-ciphers <ciphers> `:`-separated ssl cipher list. Default excludes RC4
--ssl-allow-rc4 Allow RC4 cipher for SSL (disabled by default)
--ssl-dhparam <dhparam-file> SSL Diffie-Helman Parameters pem file, if any
--api-ip <ip> Inward-facing IP for API requests (default: "localhost")
--api-port <n> Inward-facing port for API requests (defaults to --port=value+1)
--api-ssl-key <keyfile> SSL key to use, if any, for API requests
--api-ssl-cert <certfile> SSL certificate to use, if any, for API requests
--api-ssl-ca <ca-file> SSL certificate authority, if any, for API requests
--api-ssl-request-cert Request SSL certs to authenticate clients for API requests
--api-ssl-reject-unauthorized Reject unauthorized SSL connections (only meaningful if --api-ssl-request-cert is given)
--client-ssl-key <keyfile> SSL key to use, if any, for proxy to client requests
--client-ssl-cert <certfile> SSL certificate to use, if any, for proxy to client requests
--client-ssl-ca <ca-file> SSL certificate authority, if any, for proxy to client requests
--client-ssl-request-cert Request SSL certs to authenticate clients for API requests
--client-ssl-reject-unauthorized Reject unauthorized SSL connections (only meaningful if --client-ssl-request-cert is given)
--default-target <host> Default proxy target (proto://host[:port])
--error-target <host> Alternate server for handling proxy errors (proto://host[:port])
--error-path <path> Alternate server for handling proxy errors (proto://host[:port])
--redirect-port <redirect-port> Redirect HTTP requests on this port to the server on HTTPS
--redirect-to <port> Redirect HTTP requests from --redirect-port to this port
--pid-file <pid-file> Write our PID to a file
--no-x-forward Don't add 'X-forward-' headers to proxied requests
--no-prepend-path Avoid prepending target paths to proxied requests
--no-include-prefix Don't include the routing prefix in proxied requests
--auto-rewrite Rewrite the Location header host/port in redirect responses
--change-origin Changes the origin of the host header to the target URL
--protocol-rewrite <proto> Rewrite the Location header protocol in redirect responses to the specified protocol
--custom-header <header> Custom header to add to proxied requests. Use same option for multiple headers (--custom-header k1:v1 --custom-header k2:v2) (default: {})
--insecure Disable SSL cert verification
--host-routing Use host routing (host as first level of path)
--statsd-host <host> Host to send statsd statistics to
--statsd-port <port> Port to send statsd statistics to
--statsd-prefix <prefix> Prefix to use for statsd statistics
--log-level <loglevel> Log level (debug, info, warn, error) (default: "info")
--timeout <n> Timeout (in millis) when proxy drops connection for a request.
--proxy-timeout <n> Timeout (in millis) when proxy receives no response from target.
--storage-backend <storage-class> Define an external storage class. Defaults to in-MemoryStore.
-h, --help display help for command
Start the Hub server
[centos7copy]$ jupyterhub &
[1] 24629
[centos7copy]$ [I 2020-11-01 23:10:50.068 JupyterHub app:2332] Running JupyterHub version 1.2.1
[I 2020-11-01 23:10:50.068 JupyterHub app:2363] Using Authenticator: jupyterhub.auth.PAMAuthenticator-1.2.1
[I 2020-11-01 23:10:50.068 JupyterHub app:2363] Using Spawner: jupyterhub.spawner.LocalProcessSpawner-1.2.1
[I 2020-11-01 23:10:50.068 JupyterHub app:2363] Using Proxy: jupyterhub.proxy.ConfigurableHTTPProxy-1.2.1
[I 2020-11-01 23:10:50.070 JupyterHub app:1457] Writing cookie_secret to /root/jupyterhub_cookie_secret
[I 2020-11-01 23:10:50.086 alembic.runtime.migration migration:155] Context impl SQLiteImpl.
[I 2020-11-01 23:10:50.086 alembic.runtime.migration migration:162] Will assume non-transactional DDL.
[I 2020-11-01 23:10:50.093 alembic.runtime.migration migration:517] Running stamp_revision -> 4dc2d5a8c53c
[I 2020-11-01 23:10:50.131 JupyterHub proxy:461] Generating new CONFIGPROXY_AUTH_TOKEN
[W 2020-11-01 23:10:50.132 JupyterHub app:1687] No admin users, admin interface will be unavailable.
[W 2020-11-01 23:10:50.132 JupyterHub app:1689] Add any administrative users to `c.Authenticator.admin_users` in config.
[I 2020-11-01 23:10:50.132 JupyterHub app:1718] Not using allowed_users. Any authenticated user will be allowed.
[I 2020-11-01 23:10:50.166 JupyterHub app:2402] Initialized 0 spawners in 0.001 seconds
[W 2020-11-01 23:10:50.169 JupyterHub proxy:643] Running JupyterHub without SSL. I hope there is SSL termination happening somewhere else...
[I 2020-11-01 23:10:50.169 JupyterHub proxy:646] Starting proxy @ http://:8000
23:10:50.290 [ConfigProxy] info: Proxying http://*:8000 to (no default)
23:10:50.292 [ConfigProxy] info: Proxy API at http://127.0.0.1:8001/api/routes
[centos7copy]$ lsof -p 24629
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
jupyterhu 24629 root cwd DIR 8,2 4096 786433 /root
jupyterhu 24629 root rtd DIR 8,2 4096 2 /
jupyterhu 24629 root txt REG 8,2 11336 950063 /usr/bin/python3.6
jupyterhu 24629 root mem REG 8,2 99952 938690 /usr/lib64/libelf-0.176.so
jupyterhu 24629 root mem REG 8,2 19896 919961 /usr/lib64/libattr.so.1.1.0
jupyterhu 24629 root mem REG 8,2 88776 925306 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
jupyterhu 24629 root mem REG 8,2 338672 932093 /usr/lib64/libdw-0.176.so
jupyterhu 24629 root mem REG 8,2 43712 925847 /usr/lib64/librt-2.17.so
jupyterhu 24629 root mem REG 8,2 20048 925890 /usr/lib64/libcap.so.2.22
jupyterhu 24629 root mem REG 8,2 86464 922057 /usr/lib64/libnss_myhostname.so.2
jupyterhu 24629 root mem REG 8,2 31344 919315 /usr/lib64/libnss_dns-2.17.so
jupyterhu 24629 root mem REG 8,2 61560 925844 /usr/lib64/libnss_files-2.17.so
jupyterhu 24629 root mem REG 8,2 753280 920020 /usr/lib64/libsqlite3.so.0.8.6
jupyterhu 24629 root mem REG 8,2 85808 308130 /usr/lib64/python3.6/lib-dynload/_sqlite3.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 23968 919943 /usr/lib64/libcap-ng.so.0.0.0
jupyterhu 24629 root mem REG 8,2 127184 919944 /usr/lib64/libaudit.so.1.0.0
jupyterhu 24629 root mem REG 8,2 61680 921942 /usr/lib64/libpam.so.0.83.1
jupyterhu 24629 root mem REG 8,2 46632 1049058 /usr/local/lib64/python3.6/site-packages/cffi.libs/libffi-806b1a9d.so.6.0.4
jupyterhu 24629 root mem REG 8,2 853792 1049056 /usr/local/lib64/python3.6/site-packages/_cffi_backend.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 27069 170066 /usr/local/lib64/python3.6/site-packages/cryptography/hazmat/bindings/_padding.abi3.so
jupyterhu 24629 root mem REG 8,2 16400 308147 /usr/lib64/python3.6/lib-dynload/resource.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 26680 308141 /usr/lib64/python3.6/lib-dynload/mmap.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 19496 308138 /usr/lib64/python3.6/lib-dynload/fcntl.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 1802435 1048984 /usr/local/lib64/python3.6/site-packages/_ruamel_yaml.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 20064 934647 /usr/lib64/libuuid.so.1.3.0
jupyterhu 24629 root mem REG 8,2 32328 919951 /usr/lib64/libffi.so.6.0.1
jupyterhu 24629 root mem REG 8,2 134000 308105 /usr/lib64/python3.6/lib-dynload/_ctypes.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 35640 308104 /usr/lib64/python3.6/lib-dynload/_csv.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 174576 919648 /usr/lib64/libtinfo.so.5.9
jupyterhu 24629 root mem REG 8,2 234720 919640 /usr/lib64/libncursesw.so.5.9
jupyterhu 24629 root mem REG 8,2 85872 308106 /usr/lib64/python3.6/lib-dynload/_curses.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 29384 1048606 /usr/local/lib64/python3.6/site-packages/tornado/speedups.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 69120 1048777 /usr/local/lib64/python3.6/site-packages/sqlalchemy/cresultproxy.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 36712 1048782 /usr/local/lib64/python3.6/site-packages/sqlalchemy/cutils.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 58048 1048786 /usr/local/lib64/python3.6/site-packages/sqlalchemy/cprocessors.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 899576 308152 /usr/lib64/python3.6/lib-dynload/unicodedata.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 38875 23836 /usr/local/lib64/python3.6/site-packages/markupsafe/_speedups.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 402000 308110 /usr/lib64/python3.6/lib-dynload/_decimal.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 26008 308151 /usr/lib64/python3.6/lib-dynload/termios.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 110968 308108 /usr/lib64/python3.6/lib-dynload/_datetime.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 51592 308115 /usr/lib64/python3.6/lib-dynload/_json.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 26728 308136 /usr/lib64/python3.6/lib-dynload/binascii.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 118576 308131 /usr/lib64/python3.6/lib-dynload/_ssl.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 59976 308093 /usr/lib64/python3.6/lib-dynload/_asyncio.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 7448 308121 /usr/lib64/python3.6/lib-dynload/_opcode.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 16752 308123 /usr/lib64/python3.6/lib-dynload/_posixsubprocess.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 17008 308120 /usr/lib64/python3.6/lib-dynload/_multiprocessing.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 20576 308124 /usr/lib64/python3.6/lib-dynload/_random.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 13608 308094 /usr/lib64/python3.6/lib-dynload/_bisect.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 98176 308127 /usr/lib64/python3.6/lib-dynload/_sha3.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 47480 308095 /usr/lib64/python3.6/lib-dynload/_blake2.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 402384 919745 /usr/lib64/libpcre.so.1.2.0
jupyterhu 24629 root mem REG 8,2 155744 922449 /usr/lib64/libselinux.so.1
jupyterhu 24629 root mem REG 8,2 109976 925846 /usr/lib64/libresolv-2.17.so
jupyterhu 24629 root mem REG 8,2 15688 920528 /usr/lib64/libkeyutils.so.1.5
jupyterhu 24629 root mem REG 8,2 67104 931658 /usr/lib64/libkrb5support.so.0.1
jupyterhu 24629 root mem REG 8,2 210784 921017 /usr/lib64/libk5crypto.so.3.1
jupyterhu 24629 root mem REG 8,2 15856 921269 /usr/lib64/libcom_err.so.2.1
jupyterhu 24629 root mem REG 8,2 967760 921023 /usr/lib64/libkrb5.so.3.3
jupyterhu 24629 root mem REG 8,2 320720 921013 /usr/lib64/libgssapi_krb5.so.2.2
jupyterhu 24629 root mem REG 8,2 2521144 921037 /usr/lib64/libcrypto.so.1.0.2k
jupyterhu 24629 root mem REG 8,2 470376 921039 /usr/lib64/libssl.so.1.0.2k
jupyterhu 24629 root mem REG 8,2 27080 308113 /usr/lib64/python3.6/lib-dynload/_hashlib.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 13224 308139 /usr/lib64/python3.6/lib-dynload/grp.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 157424 919770 /usr/lib64/liblzma.so.5.2.2
jupyterhu 24629 root mem REG 8,2 38944 308117 /usr/lib64/python3.6/lib-dynload/_lzma.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 68192 919877 /usr/lib64/libbz2.so.1.0.6
jupyterhu 24629 root mem REG 8,2 23056 308096 /usr/lib64/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 90248 919757 /usr/lib64/libz.so.1.2.7
jupyterhu 24629 root mem REG 8,2 34528 308154 /usr/lib64/python3.6/lib-dynload/zlib.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 58024 308134 /usr/lib64/python3.6/lib-dynload/array.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 106056 308129 /usr/lib64/python3.6/lib-dynload/_socket.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 132240 308122 /usr/lib64/python3.6/lib-dynload/_pickle.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 52664 308132 /usr/lib64/python3.6/lib-dynload/_struct.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 33536 308148 /usr/lib64/python3.6/lib-dynload/select.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 51320 308140 /usr/lib64/python3.6/lib-dynload/math.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 22904 308114 /usr/lib64/python3.6/lib-dynload/_heapq.cpython-36m-x86_64-linux-gnu.so
jupyterhu 24629 root mem REG 8,2 106172832 138666 /usr/lib/locale/locale-archive
jupyterhu 24629 root mem REG 8,2 2156240 919299 /usr/lib64/libc-2.17.so
jupyterhu 24629 root mem REG 8,2 1136944 925841 /usr/lib64/libm-2.17.so
jupyterhu 24629 root mem REG 8,2 14424 919333 /usr/lib64/libutil-2.17.so
jupyterhu 24629 root mem REG 8,2 19248 925840 /usr/lib64/libdl-2.17.so
jupyterhu 24629 root mem REG 8,2 142144 919325 /usr/lib64/libpthread-2.17.so
jupyterhu 24629 root mem REG 8,2 3131840 950054 /usr/lib64/libpython3.6m.so.1.0
jupyterhu 24629 root mem REG 8,2 163312 919292 /usr/lib64/ld-2.17.so
jupyterhu 24629 root DEL REG 8,2 168780 /tmp/#168780
jupyterhu 24629 root mem REG 8,2 26970 919615 /usr/lib64/gconv/gconv-modules.cache
jupyterhu 24629 root 0u CHR 136,2 0t0 5 /dev/pts/2
jupyterhu 24629 root 1u CHR 136,2 0t0 5 /dev/pts/2 ←標準出力が端末にひもづいてる
jupyterhu 24629 root 2u CHR 136,2 0t0 5 /dev/pts/2 ←標準エラー出力が端末にひもづいてる
jupyterhu 24629 root 3u a_inode 0,10 0 8534 [eventpoll]
jupyterhu 24629 root 4u unix 0xffff9aefe9abf2c0 0t0 423325 socket
jupyterhu 24629 root 5u unix 0xffff9aefe9abd0c0 0t0 423326 socket
jupyterhu 24629 root 6u REG 8,2 4096 168780 /tmp/#168780 (deleted)
jupyterhu 24629 root 7u IPv4 423383 0t0 TCP localhost:tproxy (LISTEN)
[centos7copy]$ netstat -naptl | grep 24629
tcp 0 0 127.0.0.1:8081 0.0.0.0:* LISTEN 24629/python3
[centos7copy]$ pstree -p 24629
[centos7copy]$ ls -1 /usr/local/bin/jupyter*|while read line;do echo ---$line---;file $line;done
---/usr/local/bin/jupyter---
/usr/local/bin/jupyter: Python script, ASCII text executable
---/usr/local/bin/jupyter-bundlerextension---
/usr/local/bin/jupyter-bundlerextension: Python script, ASCII text executable
---/usr/local/bin/jupyterhub---
/usr/local/bin/jupyterhub: Python script, ASCII text executable
---/usr/local/bin/jupyterhub-singleuser---
/usr/local/bin/jupyterhub-singleuser: Python script, ASCII text executable
---/usr/local/bin/jupyter-kernel---
/usr/local/bin/jupyter-kernel: Python script, ASCII text executable
---/usr/local/bin/jupyter-kernelspec---
/usr/local/bin/jupyter-kernelspec: Python script, ASCII text executable
---/usr/local/bin/jupyter-migrate---
/usr/local/bin/jupyter-migrate: Python script, ASCII text executable
---/usr/local/bin/jupyter-nbconvert---
/usr/local/bin/jupyter-nbconvert: Python script, ASCII text executable
---/usr/local/bin/jupyter-nbextension---
/usr/local/bin/jupyter-nbextension: Python script, ASCII text executable
---/usr/local/bin/jupyter-notebook---
/usr/local/bin/jupyter-notebook: Python script, ASCII text executable
---/usr/local/bin/jupyter-run---
/usr/local/bin/jupyter-run: Python script, ASCII text executable
---/usr/local/bin/jupyter-serverextension---
/usr/local/bin/jupyter-serverextension: Python script, ASCII text executable
---/usr/local/bin/jupyter-troubleshoot---
/usr/local/bin/jupyter-troubleshoot: Python script, ASCII text executable
---/usr/local/bin/jupyter-trust---
/usr/local/bin/jupyter-trust: Python script, ASCII text executable
■初期設定
Get StartedのConfiguration Basicsから順にやってみる
Generate a default config fileに書かれてるデフォルトコンフィグファイルを生成する
[centos7copy]$ jupyterhub --generate-config
Writing default config to: jupyterhub_config.py
→カレントディレクトリにjupyterhub_config.pyが作られた。
[centos7copy]$ wc -l jupyterhub_config.py
1061 jupyterhub_config.py
推奨されてる通り移動する。
[centos7copy]$ mv jupyterhub_config.py /etc/
コンフィグの設定を適用してjupyterhubデーモンを起動する場合は、
jupyterhub -f /path/to/jupyterhub_config.py
また、コマンドラインオプションでデーモンを制御する場合は、例えば、
jupyterhub --ip 10.0.1.2 --port 443 --ssl-key my_ssl.key --ssl-cert my_ssl.cert
のようにする。
[centos7copy]$ jupyterhub -f /etc/jupyterhub_config.py &
[1] 48067
[centos7copy]$ [I 2020-11-02 00:25:32.029 JupyterHub app:2332] Running JupyterHub version 1.2.1
[I 2020-11-02 00:25:32.030 JupyterHub app:2363] Using Authenticator: jupyterhub.auth.PAMAuthenticator-1.2.1
[I 2020-11-02 00:25:32.030 JupyterHub app:2363] Using Spawner: jupyterhub.spawner.LocalProcessSpawner-1.2.1
[I 2020-11-02 00:25:32.030 JupyterHub app:2363] Using Proxy: jupyterhub.proxy.ConfigurableHTTPProxy-1.2.1
[I 2020-11-02 00:25:32.031 JupyterHub app:1412] Loading cookie_secret from /root/jupyterhub_cookie_secret
[I 2020-11-02 00:25:32.050 JupyterHub proxy:461] Generating new CONFIGPROXY_AUTH_TOKEN
[W 2020-11-02 00:25:32.051 JupyterHub app:1687] No admin users, admin interface will be unavailable.
[W 2020-11-02 00:25:32.051 JupyterHub app:1689] Add any administrative users to `c.Authenticator.admin_users` in config.
[I 2020-11-02 00:25:32.051 JupyterHub app:1718] Not using allowed_users. Any authenticated user will be allowed.
[I 2020-11-02 00:25:32.088 JupyterHub app:2402] Initialized 0 spawners in 0.002 seconds
[W 2020-11-02 00:25:32.090 JupyterHub proxy:643] Running JupyterHub without SSL. I hope there is SSL termination happening somewhere else...
[I 2020-11-02 00:25:32.091 JupyterHub proxy:646] Starting proxy @ http://:8000
00:25:32.226 [ConfigProxy] info: Proxying http://*:8000 to (no default)
00:25:32.228 [ConfigProxy] info: Proxy API at http://127.0.0.1:8001/api/routes
[centos7copy]$
[centos7copy]$ 00:25:38.347 [ConfigProxy] info: 200 GET /api/routes
[I 2020-11-02 00:25:38.348 JupyterHub app:2647] Hub API listening on http://127.0.0.1:8081/hub/
00:25:38.351 [ConfigProxy] info: 200 GET /api/routes
[I 2020-11-02 00:25:38.352 JupyterHub proxy:320] Checking routes
[I 2020-11-02 00:25:38.352 JupyterHub proxy:400] Adding default route for Hub: / => http://127.0.0.1:8081
00:25:38.354 [ConfigProxy] info: Adding route / -> http://127.0.0.1:8081
00:25:38.354 [ConfigProxy] info: Route added / -> http://127.0.0.1:8081
00:25:38.355 [ConfigProxy] info: 201 POST /api/routes/
[I 2020-11-02 00:25:38.355 JupyterHub app:2722] JupyterHub is now running at http://:8000
■接続してみる
[centos7copy]$ setenforce 0
[centos7copy]$ iptables -F
ブラウザから、http://192.168.19.201:8000にアクセス。
pam認証がデフォルトとのことなので、OSに居るユーザ「dagyah」に/etc/shadowのパスワードでログイン
■logファイル
[centos7copy]$ cat -n /etc/jupyterhub_config.py | grep -i log | grep -vi login
9 ## The date format used by logging formatters for %(asctime)s
10 #c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'
12 ## The Logging format template
13 #c.Application.log_format = '[%(name)s]%(highlevel)s %(message)s'
15 ## Set the log level by value or name.
16 #c.Application.log_level = 30
183 ## log all database transactions. This has A LOT of output
238 # jupyterhub &>> /var/log/jupyterhub.log
239 #c.JupyterHub.extra_log_file = ''
241 ## Extra log handlers to set on JupyterHub logger
242 #c.JupyterHub.extra_log_handlers = []
388 ## Specify path to a logo image to override the Jupyter logo in the banner.
389 #c.JupyterHub.logo_file = ''
482 ## Shuts down all user servers on logout
483 #c.JupyterHub.shutdown_on_logout = False
577 # ensure the correct client IP addresses are recorded in the logs instead of the
599 # Spawner(LoggingConfigurable) configuration
682 ## Enable debug-logging of the single-user server
885 # Authenticator(LoggingConfigurable) configuration
893 # - Use the admin panel to see list of users logged in
904 ## Set of usernames that are allowed to log in.
906 # Use this with supported authenticators to restrict which users can log in.
936 ## Set of usernames that are not allowed to log in.
938 # Use this with supported authenticators to restrict which users can not log in.
1020 # user logs in again.
[centos7copy]$ cat -n /etc/jupyterhub_config.py
----(略)----
236 ## DEPRECATED: use output redirection instead, e.g. ←非推奨とのこと
237 #
238 # jupyterhub &>> /var/log/jupyterhub.log
239 #c.JupyterHub.extra_log_file = '' ←こっちでlogを指定する。
240
241 ## Extra log handlers to set on JupyterHub logger
242 #c.JupyterHub.extra_log_handlers = []
----(略)----
※非推奨だけど下記のようにログ取得もできる。
[centos7copy]$ jupyterhub -f /etc/jupyterhub_config.py >> /var/log/jupyterhub.log 2>&1 &
■logローテーション
上記のc.JupyterHub.extra_log_fileにログを書き込んでrenameした後もログが書き込まれるか?
[centos7copy]$ cp -p /etc/jupyterhub_config.py /etc/jupyterhub_config.py.org
[centos7copy]$ vi /etc/jupyterhub_config.py
----(編集)----
[centos7copy]$ diff /etc/jupyterhub_config.py{.org,}
239a240
> c.JupyterHub.extra_log_file = '/tmp/chinko.log'
・jupyterhubをバックグラウンド実行してるterminalにて下記によりjupyterhubを終了
[centos7copy]$ kill %1
----(略)----
・jupyterhubを再起動
[centos7copy]$ jupyterhub -f /etc/jupyterhub_config.py &
----(略)----
→以前ターミナルには標準出力と標準エラー出力が出力されているw
[centos7copy]$ ll /tmp/chinko.log
-rw-r--r--. 1 root root 1806 Nov 15 23:11 /tmp/chinko.log
[centos7copy]$ head -2 /tmp/chinko.log
[I 2020-11-15 23:11:46.804 JupyterHub app:2332] Running JupyterHub version 1.2.1
[I 2020-11-15 23:11:46.805 JupyterHub app:2363] Using Authenticator: jupyterhub.auth.PAMAuthenticator-1.2.1
[centos7copy]$ tail -2 /tmp/chinko.log
[I 2020-11-15 23:11:58.559 JupyterHub proxy:400] Adding default route for Hub: / => http://127.0.0.1:8081
[I 2020-11-15 23:11:58.563 JupyterHub app:2722] JupyterHub is now running at http://:8000
・ログエントリを追記してみる。
[centos7copy]$ curl -X POST -d 'unko=unchi' http://127.0.0.1:8081
----(略)----
[centos7copy]$ tail -1 /tmp/chinko.log
[W 2020-11-15 23:20:40.084 JupyterHub log:181] 405 POST / (@127.0.0.1) 1.32ms
・ログファイルをリネームしてみる
[centos7copy]$ mv /tmp/chinko.log{,old}
[centos7copy]$ ll /tmp/chinko.log*
-rw-r--r--. 1 root root 2332 Nov 15 23:21 /tmp/chinko.logold
[centos7copy]$ curl -X POST -d 'unko=unchi' http://127.0.0.1:8081
----(略)----
[centos7copy]$ ll /tmp/chinko.log*
-rw-r--r--. 1 root root 2421 Nov 15 23:23 /tmp/chinko.logold
[centos7copy]$ tail -3 /tmp/chinko.logold
[W 2020-11-15 23:20:40.084 JupyterHub log:181] 405 POST / (@127.0.0.1) 1.32ms ←リネーム前のエントリ
[I 2020-11-15 23:21:58.575 JupyterHub proxy:320] Checking routes
[W 2020-11-15 23:23:40.296 JupyterHub log:181] 405 POST / (@127.0.0.1) 1.80ms ←リネーム後のエントリ
→ログファイル名をリネームしてもリネーム前のログファイルにログを追記したので、jupyterhubのログローテーション時にはデーモンの再起動かリロードが必要
[centos7copy]$ jupyterhub --help | grep -i reload;echo $?
1
リロードできないっぽい。
グレイスフルリスタートとかあるのかな?よくわかんないけど。apacheとかnginxをかましてフロントエンドリバースプロキシでやるしかない臭い。
ちなみに、jupyterhub_config.pyの「c.JupyterHub.extra_log_file」パラメータでログファイルを指定しても下記のように、起動したptsに標準出力と標準エラー出力が紐づいている。
[centos7copy]$ ps -ef | grep jupyterhu[b]
root 81721 4962 0 23:11 pts/1 00:00:00 /usr/bin/python3 /usr/local/bin/jupyterhub -f /etc/jupyterhub_config.py
[centos7copy]$ lsof -p 81721 | egrep [012]u
jupyterhu 81721 root 0u CHR 136,1 0t0 4 /dev/pts/1
jupyterhu 81721 root 1u CHR 136,1 0t0 4 /dev/pts/1
jupyterhu 81721 root 2u CHR 136,1 0t0 4 /dev/pts/1




