flagflag  If you want to see English page, please click "English" Button at Left.
1: 2020-08-18 (火) 20:20:25 iseki ソース 現: 2023-12-04 (月) 11:30:44 iseki ソース
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] 
- (base) conda create -n jupyterhub python=3.8 -y +*** Rocky Linux 8 [#g6e6c1d1] 
- (base) conda activate jupyterhub +- [[Detail Log>./RockyLinux8_install]] 
- (jupyterhub) conda install -c conda-forge notebook -y +#br
- (jupyterhub) conda install -c conda-forge jupyterlab -y +
- (jupyterhub) conda install -c conda-forge jupyterhub -y +
- (jupyterhub) conda install -c conda-forge voila -y +
- (jupyterhub) conda install jupyter_client -y+
- (jupyterhub) git clone https://github.com/jupyterhub/nativeauth​enticator.git +*** pip [#ecfe7cfb] 
- (jupyterhub) pip install -e nativeauthenticator +#br 
- (jupyterhub) pip install dockerspawner+*** conda [#n0e2837f] 
 +- conda update -c conda-forge jupyterhub -y
#br #br
-*** 設定 [#idb49705]+*** 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] 
 + (base) # conda create -n jupyterhub python=3.8 -y 
 + (base) # conda activate jupyterhub 
 + (jupyterhub) # conda install -c conda-forge notebook -y 
 + (jupyterhub) # conda install -c conda-forge jupyterlab -y 
 + (jupyterhub) # conda install -c conda-forge jupyterhub==1.4.2  -y 
 + (jupyterhub) # conda install -c conda-forge voila -y 
 + (jupyterhub) # conda install jupyter_client -y 
 +  
 + (jupyterhub) # git clone https://github.com/jupyterhub/nativeauth​enticator.git 
 + (jupyterhub) # pip install -e nativeauthenticator  (認証モジュール:オプション) 
 + (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 
 + 
 +*** Notebook の Docker イメージ [#s9b5f83a] 
 + # docker pull jupyter/datascience-notebook 
 + # docker pull jupyter/tensorflow-notebook 
 +#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] 
 +- 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 でないと,読み込まれない場合がある?
 +
#br #br
-*** 実行 [#a826d7f6+*** Authenticator Class (authenticator_class) [#g1e9cdae
- (base) conda activate jupyterhub +**** auth.DummyAuthenticator [#g40f4bb4] 
- (jupyterhub) jupyterhub --no-ssl -f /usr/local/etc/jupyterhub/jupyterhub_con​fig.py+- その名の通りダミー.認証無し. 
 +- 全てのユーザを許可する.(一応パスワード入力欄は表示される) 
 +#br 
 +**** jupyterhub.auth.PAMAuthenticator (default) [#n3acea52] 
 +- 認証に[[PAM]]を使用する.恐らくサービスは login 
 +- v1.1.0 にバグあり. [[Trouble Shooting>#rf83821d]] 参照. 
 +#br
-**** 使用ポート [#me192c34+**** nativeauthenticator.NativeAuthenticator [#u43dca72
-- 8000 +- 追加モジュール(オプション) 
-- 8081+- 詳細は検証中
#br #br
 +
 +**** [[LDAP]]: ldapauthenticator.LDAPAuthenticator [#n1c54d11]
 +- LDap 認証用.
 +- モジュールのInstall
 + (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]
 +
 +**** jupyterhub.spawner.LocalProcessSpawner (default)[#ueaf7599]
 +- [[LocalProcessSpawner >./LocalProcessSpawner]]
 +- サーバに,各ユーザの環境でアクセスできる.
 +- Jupiter Notebook はサーバにインストールされている物を使用する.
 +- 通常作業ディレクトリは /home/{username}/notebook   (v1.0.0 はディレクトリ指定にバグが有る模様)
 +- 使用ポートは 8000/tcp, 8081/tcp
 +#br
 +
 +**** jupyterhub.spawner.SimpleLocalProcessSpa​wner [#eb28d681]
 +- 名前がややこしい
 +- 詳細は不明(検証する気はあまりない)
 +#br
 +
 +**** dockerspawner.DockerSpawner [#dc30b0cf]
 +- [[''DockerSpawner''>./DockerSpawner]]
 +- https://github.com/jupyterhub/dockerspaw​ner
 +- サーバでユーザ毎に ''[[Docker]]'' でNotebook コンテナを起動して接続.
 +- 作業ホームは /home/jovjan/work 固定(多分 Docker Image固定)
 +- 使用ポートは 8000/tcp, 8081/tcp, 8001/tcp
 +- Install
 + (jupyterhub) # pip --no-cache-dir install git+https://github.com/jupyterhub/docker​spawner.git
 + or
 + (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
 +
 +**** dockerspawner.SwarmSpawner [#vad945d1]
 +- [[SwarmSpawner>./SwarmSpawner]]
 +- dockerspawner.DockerSpawner からの派生クラス
 +- DockerSpawner と同じパッケージ
 +- クラスタリング用.
 +- コンテナを [[Docker Compose]] で管理し,複数のサーバー上で実行できる.
 +- 使用ポートは 8000/tcp, 8081/tcp, 8001/tcp, 2377/tcp, 7946/tcp, 7946/udp, 4789/udp
 +#br
 +
 +**** niicloudoperation/jupyterhub-singleuser [#ld71d218]
 +- NII開発.自由度低し(個人的感想).[[CoursewareHub]] 用 Server Class
 +- https://github.com/NII-cloud-operation/C​oursewareHub-LC_platform
 +- Document: https://github.com/nii-gakunin-cloud/ocs​-templates
 +- [[dockerspawner.SwarmSpawner>./SwarmSpaw​ner]] からの派生クラス
 +- 検証中
 +- INSTALL
 + (jupyterhub) # git clone https://github.com/NII-cloud-operation/C​oursewareHub-LC_platform.git
 + (jupyterhub) # cd CoursewareHub-LC_platform/jupyterhub/spa​wner
 + (jupyterhub) # pip --no-cache-dir install .
*** jovyan って誰? [#w4a21247] *** jovyan って誰? [#w4a21247]
-- Docker を使用すると,作業ディレクトリが /home/jovyan/work 固定なのだが?+- DockerSpawner を使用すると,作業ディレクトリが /home/jovyan/work 固定なのだが?
- c.DockerSpawner.notebook_dir 辺りをいじっても変化しない? - c.DockerSpawner.notebook_dir 辺りをいじっても変化しない?
 +- https://github.com/jupyter/docker-stacks​/issues/358
 +#br
 +
 +** 実行 [#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
 + (jupyterhub) # jupyterhub -f /usr/local/etc/jupyterhub/jupyterhub_con​fig.py
 +
 +- --no-ssl は0.7で廃止された
 +#br
 +
 +** Log [#s553f415]
 +*** 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]
 +- docker pull niicloudoperation/notebook
 +#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 #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のチェックを強化したらしい
 +
 +- /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: PAM使用時に 再login するとPAMの認証エラーになる. [#cec1cefc] 
 +- 認証モジュールに jupyterhub.auth.PAMAuthenticator を使用した場合,再Loginで失敗 
 +-- c.JupyterHub.authenticator_class = 'jupyterhub.auth.PAMAuthenticator'
- バグだろ. - バグだろ.
- Resolve: jupyterhub_config.py に ''c.PAMAuthenticator.open_sessions = False'' を追加する - Resolve: jupyterhub_config.py に ''c.PAMAuthenticator.open_sessions = False'' を追加する
- see: https://github.com/jupyterhub/jupyterhub​/issues/486 - see: https://github.com/jupyterhub/jupyterhub​/issues/486
 +#br
 +
 +**** swarm モードだと v1.1.0 でPAM認証のエラーを起こす. [#e7458157]
 +- 上記バグもこれか?
 +- 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


トップ   新規 ページ一覧 単語検索 最終更新   ヘルプ   最終更新のRSS 1.0 最終更新のRSS 2.0 最終更新のRSS Atom

サイト内 検索

ログイン

ユーザー名:

パスワード:


パスワード紛失
新規登録

サブ メニュー

ミニカレンダー

前月2024年 5月翌月
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
<今日>

オンライン状況

116 人のユーザが現在オンラインです。 (22 人のユーザが xpwiki を参照しています。)

登録ユーザ: 0
ゲスト: 116

もっと...

アクセスカウンタ

今日 : 1378613786137861378613786
昨日 : 1615016150161501615016150
総計 : 2349307923493079234930792349307923493079234930792349307923493079
Powered by XOOPS Cube 2.1© 2001-2006 XOOPS Cube Project
Design by XoopsDesign.com