flagflag  
9: 2020-08-21 (Fri) 18:40:40 iseki source Cur: 2023-12-04 (Mon) 11:30:44 iseki source
Line 1: Line 1:
** 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/20​19/11/09/181614 - https://horomary.hatenablog.com/entry/20​19/11/09/181614
 +
 +- 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/sta​ble/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/gaton​iel/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
Line 10: Line 88:
 (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 -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/nativeauth​enticator.git  (jupyterhub) # git clone https://github.com/jupyterhub/nativeauth​enticator.git
 (jupyterhub) # pip install -e nativeauthenticator  (認証モジュール:オプション)  (jupyterhub) # pip install -e nativeauthenticator  (認証モジュール:オプション)
 (jupyterhub) # pip install dockerspawner  (jupyterhub) # pip install dockerspawner
 +
 +- ディレクトリのパーミッションの設定を忘れずに!
 +#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/distributi​ons
 +
 + 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
Line 23: Line 119:
 # 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-ltia​uthenticator/1.2.0/
 +-- Moodle に対して Patch 不要
 +
 + (jupyterhub)# pip install --upgrade jupyterhub-ltiauthenticator
** 設定 [#idb49705] ** 設定 [#idb49705]
 +- https://zero-to-jupyterhub.readthedocs.i​o/en/latest/customizing/index.html
 +- https://zero-to-jupyterhub.readthedocs.i​o/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]
Line 36: Line 155:
**** jupyterhub.auth.PAMAuthenticator (default) [#n3acea52] **** jupyterhub.auth.PAMAuthenticator (default) [#n3acea52]
- 認証に[[PAM]]を使用する.恐らくサービスは login - 認証に[[PAM]]を使用する.恐らくサービスは login
-- バグあり. [[Trouble Shooting>#rf83821d]] 参照.+- v1.1.0 にバグあり. [[Trouble Shooting>#rf83821d]] 参照.
#br #br
Line 44: Line 163:
#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_us​er = 'cn=ldapauth,cn=users,dc=edutuis,dc=loca​l'
 + 122 #c.LDAPAuthenticator.lookup_dn_search_pa​ssword = '*****'
 + 123 #c.LDAPAuthenticator.lookup_dn_user_dn_a​ttribute = '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_us​er = 'cn=Manager'
 + 134 #c.LDAPAuthenticator.lookup_dn_search_pa​ssword = '*******'
 + 135 #c.LDAPAuthenticator.lookup_dn_user_dn_a​ttribute = 'cn'
 + 136
 +
 +**** [[LTI]] モジュール [#m4467ad6]
 +
 +#br
*** Server Class [#dded2dd0] *** Server Class [#dded2dd0]
Line 56: Line 215:
- サーバに,各ユーザの環境でアクセスできる. - サーバに,各ユーザの環境でアクセスできる.
- Jupiter Notebook はサーバにインストールされている物を使用する. - Jupiter Notebook はサーバにインストールされている物を使用する.
-- 通常作業ディレクトリは /home/{username}/notebook   (notebook は設定による)+- 通常作業ディレクトリは /home/{username}/notebook   (v1.0.0 はディレクトリ指定にバグが有る模様) 
 +- 使用ポートは 8000/tcp, 8081/tcp
#br #br
Line 65: Line 225:
**** dockerspawner.DockerSpawner [#dc30b0cf] **** dockerspawner.DockerSpawner [#dc30b0cf]
-- [[DockerSpawner>./DockerSpawner]] +- [[''DockerSpawner''>./DockerSpawner]] 
-- https://github.com/jupyterhub/dockerspaw​ner.git+- https://github.com/jupyterhub/dockerspaw​ner
- サーバでユーザ毎に ''[[Docker]]'' でNotebook コンテナを起動して接続. - サーバでユーザ毎に ''[[Docker]]'' でNotebook コンテナを起動して接続.
- 作業ホームは /home/jovjan/work 固定(多分 Docker Image固定) - 作業ホームは /home/jovjan/work 固定(多分 Docker Image固定)
 +- 使用ポートは 8000/tcp, 8081/tcp, 8001/tcp
- Install - Install
 (jupyterhub) # pip --no-cache-dir install git+https://github.com/jupyterhub/docker​spawner.git  (jupyterhub) # pip --no-cache-dir install git+https://github.com/jupyterhub/docker​spawner.git
 or  or
 (jupyterhub) # pip install dockerspawner  (jupyterhub) # pip install dockerspawner
 +
 +**** dockerspawner.SystemUserSpawner [#x578909e]
 +- [[''SystemUserSpawner''>./SystemUserSpaw​ner]]
 +- https://github.com/jupyterhub/dockerspaw​ner/blob/master/dockerspawner/systemuser​spawner.py
 +
 +- dockerspawner.DockerSpawner からの派生クラス
 +- DockerSpawner と同じパッケージ? 特にインストールしていないが,既に入っていた.
 +- jovyan ではなく,ログインユーザで使用可.ログインユーザのホームディレクトリをマウントする.
 +- ただしログインユーザの情報がローカルに取れない場合(LDAPのユーザバインドでログインした場合),ホームディレクトリ等の情報が無いので途中でエラーを起こす.
 +-- 作りこめば大丈夫かもしれん.
#br #br
Line 80: Line 251:
- DockerSpawner と同じパッケージ - DockerSpawner と同じパッケージ
- クラスタリング用. - クラスタリング用.
-- コンテナを Docker-Compose で管理し,複数のサーバー上で実行できる.+- コンテナを [[Docker Compose]] で管理し,複数のサーバー上で実行できる. 
 +- 使用ポートは 8000/tcp, 8081/tcp, 8001/tcp, 2377/tcp, 7946/tcp, 7946/udp, 4789/udp
#br #br
Line 97: Line 269:
- 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_con​fig.py
 + 
 + # mkdir /var/lib/jupyterhub
 +
 +**** 実行 [#k5a94b0c]
 (base) # conda activate jupyterhub  (base) # conda activate jupyterhub
- (jupyterhub) # jupyterhub --no-ssl -f /usr/local/etc/jupyterhub/jupyterhub_con​fig.py+ (jupyterhub) # jupyterhub -f /usr/local/etc/jupyterhub/jupyterhub_con​fig.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/J​upyter-LC_nblineage 
 +-- lab では動かない! 
 +#br 
 + 
 +*** LC_wrapper [#q23dcf44] 
 +- https://github.com/NII-cloud-operation/J​upyter-LC_wrapper 
 +#br 
 + 
 +** 情報ソース [#s02d97ba] 
 + 
 +*** Notebook [#i00ecdd5] 
 + 
 +**** Docker Images [#yceb54d2]
-**** niicloudoperation/notebook [#b9ddd7f8]+***** niicloudoperation/notebook [#b9ddd7f8]
- docker pull niicloudoperation/notebook - docker pull niicloudoperation/notebook
#br #br
 +
 +*** Spawner [#v67998b2]
 +
 +**** [[Docker]] [#e1984289]
 +- https://github.com/jupyterhub/dockerspaw​ner
 +#br
 +
 +**** [[Podman]] [#t1db1fc3]
 +- https://github.com/gatoniel/podmanspawne​r
 +#br
 +
 +**** [[Kubernetes]] [#af74888d]
 +- https://github.com/jupyterhub/zero-to-ju​pyterhub-k8s
 +- https://zero-to-jupyterhub.readthedocs.i​o/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-toolki​t-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.tom​l を編集して,no-cgroups = false にする.
 +#br
 +
** Trouble Shooting [#rf83821d] ** Trouble Shooting [#rf83821d]
 +*** ltiauthenticator [#s373921d]
 +- https://pypi.org/project/jupyterhub-ltia​uthenticator/
 +#br
 +**** Jupyterhub 4.0.0 [#b81f6caf]
 +- 403 : Forbidden  '_xsrf' argument missing from POST  のエラー
 +-- JupyterHub で XSRFのチェックを強化したらしい
-*** JupyterHub: PAM使用時に 再login するとPAMの認証エラーになる. [#cec1cefc]+- /usr/local/lib/python3.9/site-packages/j​upyterhub/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] 
 + 
 +**** JupyterHub: PAM使用時に 再login するとPAMの認証エラーになる. [#cec1cefc]
- 認証モジュールに jupyterhub.auth.PAMAuthenticator を使用した場合,再Loginで失敗 - 認証モジュールに jupyterhub.auth.PAMAuthenticator を使用した場合,再Loginで失敗
-- c.JupyterHub.authenticator_class = 'jupyterhub.auth.PAMAuthenticator' -- c.JupyterHub.authenticator_class = 'jupyterhub.auth.PAMAuthenticator'
Line 123: Line 393:
- see: https://github.com/jupyterhub/jupyterhub​/issues/486 - see: https://github.com/jupyterhub/jupyterhub​/issues/486
#br #br
-*** swarm モードだと v1.1.0 でPAM認証のエラーを起こす. [#e7458157]+ 
 +**** swarm モードだと v1.1.0 でPAM認証のエラーを起こす. [#e7458157] 
 +- 上記バグもこれか?
- 1.0.0 に戻す. - 1.0.0 に戻す.
--- pip --no-cache install jupyterhub==1.0.0+ (jupyterhub) # conda uninstall jupyterhub 
 + (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/stab​le/api.html 
 +#br 
 +- APIClient 呼び出しメソッド順 
 +-- inspect_image 
 +-- inspect_container 
 +-- inspect_image 
 +-- start 
 +-- port 
 +#br 
 + 
 +**** podman [#u96870cc]
#br #br


Front page   New List of Pages Search Recent changes   Help   RSS of recent changes (RSS 1.0) RSS of recent changes (RSS 2.0) RSS of recent changes (RSS Atom)

Site Search

Login

Username:

Password:


Lost Password?
Register now!!

Sub Menu

mini Calendar

Last MonthMay 2024Next Month
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Today

Who's Online

33 user(s) are online (3 user(s) are browsing xpwiki)

Members: 0
Guests: 33

more...

Access Counter

Today : 1190119011901190
Yesterday : 5790579057905790
Total : 2365398623653986236539862365398623653986236539862365398623653986
Powered by XOOPS Cube 2.1© 2001-2006 XOOPS Cube Project
Design by XoopsDesign.com