10: 2020-08-23 (Sun) 03:36:56 iseki |
Cur: 2023-12-04 (Mon) 11:30:44 iseki |
| ** JupyterHub [#mb71944e] | | ** JupyterHub [#mb71944e] |
| - マルチユーザのための [[Jupyter]] サーバー(ユーザ認証機能つき) | | - マルチユーザのための [[Jupyter]] サーバー(ユーザ認証機能つき) |
| + | |
| + | - https://github.com/jupyterhub/jupyterhub |
| + | - https://github.com/gatoniel/jupyterhub 改良版 |
| + | |
| + | - https://jupyterhub.readthedocs.io/en/0.7.2/getting-started.html |
| - https://horomary.hatenablog.com/entry/2019/11/09/181614 | | - https://horomary.hatenablog.com/entry/2019/11/09/181614 |
| + | |
| - see also: ''[[Jupyter]]'' | | - see also: ''[[Jupyter]]'' |
| + | - see also: [[Docker]], [[Podman]] |
| + | - see also: [[Kubernetes]], [[PodmanSpawner]] |
| + | - see also: [[configurable-http-proxy]] |
| + | |
| + | - [[DockerSpawner>./DockerSpawner]] |
| + | - [[LTIDockerSpawner>./LTIDockerSpawner]] |
| + | - [[LTIPodmanSpawner>./LTIPodmanSpawner]] |
| + | |
| + | - [[Moodle+JupyterHub]] |
| + | - [[開発>./devel]] |
| + | - [[API>./API]] |
| #br | | #br |
| | | |
| ** INSTALL [#nfb5f43c] | | ** INSTALL [#nfb5f43c] |
| + | *** Rocky Linux 8 [#g6e6c1d1] |
| + | - [[Detail Log>./RockyLinux8_install]] |
| + | #br |
| + | |
| + | *** pip [#ecfe7cfb] |
| + | #br |
| + | *** conda [#n0e2837f] |
| + | - conda update -c conda-forge jupyterhub -y |
| + | #br |
| + | |
| + | *** for CentOS 8.5 with pip [#l08667b3] |
| + | # yum install python3 |
| + | # pip3 install --upgrade pip |
| + | # yum install npm |
| + | # npm install -g configurable-http-proxy |
| + | # pip install setuptools_rust |
| + | # pip install jupyterhub |
| + | # pip install dockerspawner |
| + | # pip install --upgrade notebook |
| + | # pip install --upgrade jupyterlab |
| + | # jupyterhub --version |
| + | # jupyter --version |
| + | # jupyter notebook --version |
| + | # jupyter lab --version |
| + | #br |
| + | |
| + | *** 2.0.0 with conda [#e269f8c5] |
| + | |
| + | **** Change Log [#qacdfa95] |
| + | - https://jupyterhub.readthedocs.io/en/stable/changelog.html |
| + | #br |
| + | **** Install [#j385e508] |
| + | (base) # conda install -c conda-forge conda==4.11.0 -y |
| + | (base) # conda activate jupyterhub |
| + | (jupyterhub) # conda update -c conda-forge jupyterhub -y |
| + | |
| + | (jupyterhub) # jupyterhub --upgrade-db |
| + | (jupyterhub) # jupyterhub -f ..... |
| + | #br |
| + | |
| + | **** podmanspawner.PodmanSpawner [#nefeece2] |
| + | - おおっ class のサンプルに Podman がある! |
| + | -- と思ったら niklas netter 氏の [[podmanspawner>https://github.com/gatoniel/podmanspawner]] じゃん |
| + | #br |
| + | |
| + | **** websocket モジュールが無いとのことで起動しなくなった. [#x698e062] |
| + | ModuleNotFoundError: No module named 'websocket' |
| + | - conda 環境で websocket をインストール |
| + | |
| + | # conda install -c conda-forge websocket-client |
| + | |
| + | - pip なら pip install websockets |
| + | #br |
| + | |
| + | **** データベースのスキーマが合わないとのことで,起動しなくなった. [#o77e88b0] |
| + | - jupyterhub upgrade-db してもだめなので,/var/lib/jupyterhub 以下を削除 |
| + | #br |
| + | |
| + | *** 1.4.2 [#i2818e12] |
| + | |
| **** conda を使用 [#z4c989ab] | | **** conda を使用 [#z4c989ab] |
| (base) # conda create -n jupyterhub python=3.8 -y | | (base) # conda create -n jupyterhub python=3.8 -y |
| (jupyterhub) # conda install -c conda-forge notebook -y | | (jupyterhub) # conda install -c conda-forge notebook -y |
| (jupyterhub) # conda install -c conda-forge jupyterlab -y | | (jupyterhub) # conda install -c conda-forge jupyterlab -y |
- | (jupyterhub) # conda install -c conda-forge jupyterhub==1.0.0 -y | + | (jupyterhub) # conda install -c conda-forge jupyterhub==1.4.2 -y |
| (jupyterhub) # conda install -c conda-forge voila -y | | (jupyterhub) # conda install -c conda-forge voila -y |
| (jupyterhub) # conda install jupyter_client -y | | (jupyterhub) # conda install jupyter_client -y |
| + | |
| (jupyterhub) # git clone https://github.com/jupyterhub/nativeauthenticator.git | | (jupyterhub) # git clone https://github.com/jupyterhub/nativeauthenticator.git |
| (jupyterhub) # pip install -e nativeauthenticator (認証モジュール:オプション) | | (jupyterhub) # pip install -e nativeauthenticator (認証モジュール:オプション) |
| | | |
| - ディレクトリのパーミッションの設定を忘れずに! | | - ディレクトリのパーミッションの設定を忘れずに! |
| + | #br |
| + | **** pip を使用する. [#d08d0c8f] |
| + | - nodejs: CentOS7 の場合は nodejs はバージョンが古くて,configurable-http-proxy でエラーが出るので,nodejs をバージョンアップする. |
| + | curl -sL https://rpm.nodesource.com/setup_14.x | bash - |
| + | yum remove nodejs npm -y |
| + | yum install nodejs -y |
| + | node -v |
| + | -- nodejs のバージョンがアップしない場合は,/var/tmp/yum-root-* を消す |
| + | -- https://rpm.nodesource.com/setup_##.x は非推奨となった.(2023/12/4) |
| + | --- see https://github.com/nodesource/distributions |
| + | |
| + | npm install -g configurable-http-proxy |
| + | python3 -m pip install jupyterhub |
| + | python3 -m pip install dockerspawner |
| + | python3 -m pip install --upgrade notebook |
| + | python3 -m pip install --upgrade jupyterlab |
| #br | | #br |
| | | |
| # docker pull jupyter/tensorflow-notebook | | # docker pull jupyter/tensorflow-notebook |
| #br | | #br |
| + | |
| + | *** Version Up 1.0.0 -> 1.4.1 [#f7719705] |
| + | # conda install -c conda-forge jupyterhub |
| + | # conda install notebook |
| + | **** バージョンの確認 [#m3c5a1bd] |
| + | - (jupyterhub) # jupyterhub --version |
| + | #br |
| + | |
| + | *** [[LTI Authenticator>LTI]] [#g284e3bf] |
| + | - Moodle と連携する為の 認証モジュール(Moodleの外部サービスを使用) |
| + | - 先に authlib を入れておく. |
| + | -- conda install oauthlib or pip install oauthlib |
| + | |
| + | - v1.2.0 release (2021 9/2) |
| + | -- https://pypi.org/project/jupyterhub-ltiauthenticator/1.2.0/ |
| + | -- Moodle に対して Patch 不要 |
| + | |
| + | (jupyterhub)# pip install --upgrade jupyterhub-ltiauthenticator |
| | | |
| ** 設定 [#idb49705] | | ** 設定 [#idb49705] |
| + | - https://zero-to-jupyterhub.readthedocs.io/en/latest/customizing/index.html |
| + | - https://zero-to-jupyterhub.readthedocs.io/en/latest/administrator/index.html |
| + | |
| - jupyterhub --generate-config を実行すると カレントディレクトリに設定ファイル ''jupyterhub_config.py'' が生成される. | | - jupyterhub --generate-config を実行すると カレントディレクトリに設定ファイル ''jupyterhub_config.py'' が生成される. |
| - 個人的には jupyterhub が /usr/local 以下にある場合は /usr/local/etc/jupyterhub 以下に置く. | | - 個人的には jupyterhub が /usr/local 以下にある場合は /usr/local/etc/jupyterhub 以下に置く. |
| - 設定ファイルは拡張子が .py でないと,読み込まれない場合がある? | | - 設定ファイルは拡張子が .py でないと,読み込まれない場合がある? |
| + | |
| #br | | #br |
| + | |
| *** Authenticator Class (authenticator_class) [#g1e9cdae] | | *** Authenticator Class (authenticator_class) [#g1e9cdae] |
| **** auth.DummyAuthenticator [#g40f4bb4] | | **** auth.DummyAuthenticator [#g40f4bb4] |
| #br | | #br |
| | | |
- | **** LDAP [#n1c54d11] | + | **** [[LDAP]]: ldapauthenticator.LDAPAuthenticator [#n1c54d11] |
| - LDap 認証用. | | - LDap 認証用. |
- | - 書きかけ | |
| - モジュールのInstall | | - モジュールのInstall |
| (jupyterhub) # conda install -c conda-forge jupyterhub-ldapauthenticator -y | | (jupyterhub) # conda install -c conda-forge jupyterhub-ldapauthenticator -y |
| + | |
| + | - jupyterhub_config.py |
| + | 102 # for LDAP |
| + | 103 c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator' |
| + | 104 #c.LDAPAuthenticator.server_address = '202.26.150.*' |
| + | 105 c.LDAPAuthenticator.server_address = '202.26.144.*' |
| + | 106 c.LDAPAuthenticator.use_ssl = True |
| + | 107 |
| + | 108 ## AD: template 付き(ユーザバインド) |
| + | 109 c.LDAPAuthenticator.lookup_dn = False |
| + | 110 c.LDAPAuthenticator.bind_dn_template = [ |
| + | 111 'cn={username},ou=教員,ou=ユーザー,dc=edutuis,dc=local', |
| + | 112 'cn={username},ou=学生,ou=ユーザー,dc=edutuis,dc=local' |
| + | 113 ] |
| + | 114 c.LDAPAuthenticator.user_search_base = 'dc=edutuis,dc=local' |
| + | 115 c.LDAPAuthenticator.user_attribute = 'sAMAccountName' |
| + | 116 |
| + | 117 ## AD: template なし |
| + | 118 #c.LDAPAuthenticator.lookup_dn = True |
| + | 119 #c.LDAPAuthenticator.user_search_base = 'dc=edutuis,dc=local' |
| + | 120 #c.LDAPAuthenticator.user_attribute = 'sAMAccountName' |
| + | 121 #c.LDAPAuthenticator.lookup_dn_search_user = 'cn=ldapauth,cn=users,dc=edutuis,dc=local' |
| + | 122 #c.LDAPAuthenticator.lookup_dn_search_password = '*****' |
| + | 123 #c.LDAPAuthenticator.lookup_dn_user_dn_attribute = 'cn' |
| + | 124 |
| + | 125 ## NSL: username から dn が探せる場合(ユーザバインド) |
| + | 126 #c.LDAPAuthenticator.lookup_dn = False |
| + | 127 #c.LDAPAuthenticator.bind_dn_template = 'cn={username},ou=user,dc=nsl,dc=tuis,dc=ac,dc=jp' |
| + | 128 |
| + | 129 ## NSL: ツリーを検索する場合 |
| + | 130 #c.LDAPAuthenticator.lookup_dn = True |
| + | 131 #c.LDAPAuthenticator.user_search_base = 'ou=user,dc=nsl,dc=tuis,dc=ac,dc=jp' |
| + | 132 #c.LDAPAuthenticator.user_attribute = 'uid' |
| + | 133 #c.LDAPAuthenticator.lookup_dn_search_user = 'cn=Manager' |
| + | 134 #c.LDAPAuthenticator.lookup_dn_search_password = '*******' |
| + | 135 #c.LDAPAuthenticator.lookup_dn_user_dn_attribute = 'cn' |
| + | 136 |
| + | |
| + | **** [[LTI]] モジュール [#m4467ad6] |
| + | |
| + | #br |
| | | |
| *** Server Class [#dded2dd0] | | *** Server Class [#dded2dd0] |
| | | |
| **** dockerspawner.DockerSpawner [#dc30b0cf] | | **** dockerspawner.DockerSpawner [#dc30b0cf] |
- | - [[DockerSpawner>./DockerSpawner]] | + | - [[''DockerSpawner''>./DockerSpawner]] |
- | - https://github.com/jupyterhub/dockerspawner.git | + | - https://github.com/jupyterhub/dockerspawner |
| - サーバでユーザ毎に ''[[Docker]]'' でNotebook コンテナを起動して接続. | | - サーバでユーザ毎に ''[[Docker]]'' でNotebook コンテナを起動して接続. |
| - 作業ホームは /home/jovjan/work 固定(多分 Docker Image固定) | | - 作業ホームは /home/jovjan/work 固定(多分 Docker Image固定) |
| or | | or |
| (jupyterhub) # pip install dockerspawner | | (jupyterhub) # pip install dockerspawner |
| + | |
| + | **** dockerspawner.SystemUserSpawner [#x578909e] |
| + | - [[''SystemUserSpawner''>./SystemUserSpawner]] |
| + | - https://github.com/jupyterhub/dockerspawner/blob/master/dockerspawner/systemuserspawner.py |
| + | |
| + | - dockerspawner.DockerSpawner からの派生クラス |
| + | - DockerSpawner と同じパッケージ? 特にインストールしていないが,既に入っていた. |
| + | - jovyan ではなく,ログインユーザで使用可.ログインユーザのホームディレクトリをマウントする. |
| + | - ただしログインユーザの情報がローカルに取れない場合(LDAPのユーザバインドでログインした場合),ホームディレクトリ等の情報が無いので途中でエラーを起こす. |
| + | -- 作りこめば大丈夫かもしれん. |
| #br | | #br |
| | | |
| - DockerSpawner を使用すると,作業ディレクトリが /home/jovyan/work 固定なのだが? | | - DockerSpawner を使用すると,作業ディレクトリが /home/jovyan/work 固定なのだが? |
| - c.DockerSpawner.notebook_dir 辺りをいじっても変化しない? | | - c.DockerSpawner.notebook_dir 辺りをいじっても変化しない? |
| + | - https://github.com/jupyter/docker-stacks/issues/358 |
| #br | | #br |
| | | |
| ** 実行 [#a826d7f6] | | ** 実行 [#a826d7f6] |
| + | **** 前準備 [#xa875240] |
| + | # cd /etc/pki/tls |
| + | # openssl req -new -newkey rsa:2048 -days 3650 -nodes -keyout private/key.pem -out server.csr |
| + | # openssl x509 -in server.csr -days 3650 -req -signkey private/key.pem -out certs/server.pem |
| + | # vi /usr/local/etc/jupyterhub/jupyterhub_config.py |
| + | |
| + | # mkdir /var/lib/jupyterhub |
| + | |
| + | **** 実行 [#k5a94b0c] |
| (base) # conda activate jupyterhub | | (base) # conda activate jupyterhub |
- | (jupyterhub) # jupyterhub --no-ssl -f /usr/local/etc/jupyterhub/jupyterhub_config.py | + | (jupyterhub) # jupyterhub -f /usr/local/etc/jupyterhub/jupyterhub_config.py |
| | | |
- | **** 使用ポート [#me192c34] | + | - --no-ssl は0.7で廃止された |
- | - 8000 | + | |
- | - 8081 | + | |
| #br | | #br |
| | | |
- | ** Notebook [#i00ecdd5] | + | ** Log [#s553f415] |
- | *** Docker Images [#yceb54d2] | + | *** LC_nblineage [#q1878f8f] |
| + | - https://github.com/NII-cloud-operation/Jupyter-LC_nblineage |
| + | -- lab では動かない! |
| + | #br |
| | | |
- | **** niicloudoperation/notebook [#b9ddd7f8] | + | *** LC_wrapper [#q23dcf44] |
| + | - https://github.com/NII-cloud-operation/Jupyter-LC_wrapper |
| + | #br |
| + | |
| + | ** 情報ソース [#s02d97ba] |
| + | |
| + | *** Notebook [#i00ecdd5] |
| + | |
| + | **** Docker Images [#yceb54d2] |
| + | |
| + | ***** niicloudoperation/notebook [#b9ddd7f8] |
| - docker pull niicloudoperation/notebook | | - docker pull niicloudoperation/notebook |
| #br | | #br |
| + | |
| + | *** Spawner [#v67998b2] |
| + | |
| + | **** [[Docker]] [#e1984289] |
| + | - https://github.com/jupyterhub/dockerspawner |
| + | #br |
| + | |
| + | **** [[Podman]] [#t1db1fc3] |
| + | - https://github.com/gatoniel/podmanspawner |
| + | #br |
| + | |
| + | **** [[Kubernetes]] [#af74888d] |
| + | - https://github.com/jupyterhub/zero-to-jupyterhub-k8s |
| + | - https://zero-to-jupyterhub.readthedocs.io/en/latest/ |
| + | #br |
| + | |
| + | ** DB [#v881917b] |
| + | *** MySQL [#ge9c722d] |
| + | - [[SQLAlchemy]] で PyMySQL ドライバを使用する |
| + | - pool_recycle の設定を忘れずに! |
| + | - charset は urf8mb4 |
| + | #br |
| + | ** NVIDIA [#o78e60f8] |
| + | |
| + | *** Driver [#n52aa03b] |
| + | **** nouveau ドライバ(デフォルトのグラフィックドライバ)を止める [#j9e3e782] |
| + | - lsmod | grep nouveau でドライバ確認 |
| + | - /etc/default/grab のオプションに rd.driver.blacklist=nouveau を追加 |
| + | - カーネル設定ファイルの作り直し |
| + | -- grub2-mkconfig -o /boot/grub2/grub.cfg (RedHat系) |
| + | -- grub-mkconfig -o /boot/grub/grub.cfg (Debian系) |
| + | #br |
| + | **** Driver [#r1aed2e1] |
| + | - nvidia-driver, cuda をインストール |
| + | #br |
| + | |
| + | **** Docker [#t87b07eb] |
| + | - nvidia-container-toolkit が必要 |
| + | -- コンテナ内からホストのGPUを使う |
| + | -- %%nvidia-smi などのコマンドがインストールされる.%% |
| + | #br |
| + | |
| + | *** Tool Kit [#z51a5c81] |
| + | - CUDA Toolkit : https://developer.nvidia.com/cuda-toolkit-archive |
| + | - Tool Kit をインストールするとドライバもインストールされる? (未確認) |
| + | #br |
| + | |
| + | *** Docker [#xa8f93e3] |
| + | - docker run --gpus all nvidia/cuda:12.2.0-devel-ubuntu20.04 nvidia-smi |
| + | -- Failed to initialize NVML: Unknown Error |
| + | -- ホストの /etc/nvidia-container-runtime/config.toml を編集して,no-cgroups = false にする. |
| + | #br |
| + | |
| ** Trouble Shooting [#rf83821d] | | ** Trouble Shooting [#rf83821d] |
| + | *** ltiauthenticator [#s373921d] |
| + | - https://pypi.org/project/jupyterhub-ltiauthenticator/ |
| + | #br |
| + | **** Jupyterhub 4.0.0 [#b81f6caf] |
| + | - 403 : Forbidden '_xsrf' argument missing from POST のエラー |
| + | -- JupyterHub で XSRFのチェックを強化したらしい |
| + | |
| + | - /usr/local/lib/python3.9/site-packages/jupyterhub/handlers/base.py |
| + | -- def check_xsrf_cookie(self) |
| + | --- super().check_xsrf_cookie() で例外発生 |
| + | --- 親は tornado のRequestHandlerか? |
| + | - 2023 5/29 時点でこのバグは修正されている. |
| + | #br |
| + | |
| + | *** JupyterLab [#m9f4d2fd] |
| + | **** JupyterHub をバージョンアップしたら Jupyter Labが起動しなくなった. [#f644f8af] |
| + | - 起動する JupyterHub(ex. 2.0.1)とイメージ内のJupyterHub(ex. 1.4.1)が違うとデフォルトで Jupyter Labが起動しなくなるようだ. |
| + | #br |
| + | |
| + | *** 日本語のBUG [#ece06e7b] |
| + | - 日本語のファイルやディレクトリでコピーなどを行うと errno 13 のエラーが起きる.でもコピーはちゃんと行われる.エラーを消したい. |
| + | #br |
| | | |
| *** [[PAM]] [#cb278bbe] | | *** [[PAM]] [#cb278bbe] |
| (jupyterhub) # conda uninstall jupyterhub | | (jupyterhub) # conda uninstall jupyterhub |
| (jupyterhub) # conda -c conda-forge install jupyterhub==1.0.0 | | (jupyterhub) # conda -c conda-forge install jupyterhub==1.0.0 |
| + | #br |
| + | *** homeディレクトの名前を変えたら,ログインできなくなった [#yf5e6b43] |
| + | - ~/.cache, ~/.jupyter, ~/.local ができているので消す. |
| + | #br |
| + | *** Programing [#uef8ed38] |
| + | **** docker [#g330446b] |
| + | - https://docker-py.readthedocs.io/en/stable/api.html |
| + | #br |
| + | - APIClient 呼び出しメソッド順 |
| + | -- inspect_image |
| + | -- inspect_container |
| + | -- inspect_image |
| + | -- start |
| + | -- port |
| + | #br |
| + | |
| + | **** podman [#u96870cc] |
| #br | | #br |