๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ’ปTech/๐ŸงLinux

[๋ฆฌ๋ˆ…์Šค] JupyterHub ์„ค์น˜ ๋ฐฉ๋ฒ•

by _viper_ 2023. 4. 13.
๋ฐ˜์‘ํ˜•

 


๋ฆฌ๋ˆ…์Šค ํ™˜๊ฒฝ (CentOS 7, Python3.8)์—์„œ JupyterHub ์„ค์น˜ ๋ฐฉ๋ฒ• ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค.

์„ค์น˜ ์ „ Jupyter ์šฉ์–ด ๊ด€๋ จํ•˜์—ฌ ๊ฐ„๋žตํ•˜๊ฒŒ ์ •๋ฆฌ ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

Jupyter Notebook

  • ๋Œ€ํ™”ํ˜• Python Interpreter๋กœ ์›น ํ™˜๊ฒฝ์—์„œ Python ์ฝ”๋“œ ์ž‘์„ฑ ๋ฐ ์‹คํ–‰ํ•˜๋Š” ๊ฐœ๋ฐœ ํ™˜๊ฒฝ(tool)

Jupyter Lab

  • Jupyter Notebook์˜ ์ฐจ์„ธ๋Œ€ ๋ฒ„์ „์œผ๋กœ ์‚ฌ์šฉ์ž ํŽธ์˜ ๊ธฐ๋Šฅ๋“ค์ด ์ถ”๊ฐ€๋จ
  • ๋‹ค์ค‘์ฐฝ ์ง€์›, csv/pdf ๋“ฑ ํŒŒ์ผ๋„ ์—ด ์ˆ˜ ์žˆ์–ด์„œ ๋Œ€์‹œ๋ณด๋“œ์ฒ˜๋Ÿผ ์‚ฌ์šฉ ๊ฐ€๋Šฅ

JupyterHub

  • ๋ฉ€ํ‹ฐ ์‚ฌ์šฉ์ž ํ™˜๊ฒฝ์—์„œ Jupyter Notebook/Lab์„ ์‚ฌ์šฉ


๐Ÿ“– ์„ค์น˜ ๋ฐฉ๋ฒ•

1. os ํŒจํ‚ค์ง€ ์„ค์น˜

yum install –y nodejs
yum install openssl

 

2. nodejs ํŒจํ‚ค์ง€ ์„ค์น˜

 โ—พ ์„ค์น˜ ๊ณผ์ • ์ค‘ nodejs, npm ๋ฒ„์ „์ด ๋„ˆ๋ฌด ๋‚ฎ์•„ ๊ณ„์† install ์‹คํŒจํ•˜์—ฌ ์ตœ์‹  ๋ฒ„์ „์œผ๋กœ ์„ค์น˜ ํ›„ ํ•ด๊ฒฐ

npm install -g configurable-http-proxy

 

3. python ํŒจํ‚ค์ง€ ์„ค์น˜

pip3 install sudospawner
pip3 install jupyterlab

 

4. ๊ณ„์ •/๊ทธ๋ฃน ์ƒ์„ฑ ๋ฐ ๊ถŒํ•œ ์„ค์ •

useradd admin
passwd admin

groupadd jupyterhub
usermod -a -G jupyterhub admin

visudo
-----------------------------------------------------
Cmnd_Alias JUPYTER_CMD = /usr/local/bin/sudospawner
admin ALL=(%jupyterhub) NOPASSWD:JUPYTER_CMD
-----------------------------------------------------

 

 โ—พ ์‚ฌ์šฉ์ž ์ถ”๊ฐ€

useradd user01
passwd user01
usermod -a -G jupyterhub user01

 

5. ์„ค์ • ํŒŒ์ผ ์ƒ์„ฑ ๋ฐ ์ž‘์„ฑ (Ldap ์„ค์ • ํฌํ•จ)

mkdir /etc/jupyterhub
chown admin:admin /etc/jupyterhub

cd /etc/jupyterhub
sudo -u admin /usr/local/bin/jupyterhub --generate-config

vi jupyterhub_config.py
-----------------------------------------------------------------------------------------------
c.JupyterHub.hub_connect_ip = '0.0.0.0'
c.JupyterHub.port = 8000
c.JupyterHub.spawner_class = 'sudospawner.SudoSpawner'
c.SudoSpawner.sudospawner_path = '/usr/local/bin/sudospawner'
c.Spawner.default_url = '/lab'
c.JupyterHub.extra_log_file = '/var/log/jupyterhub/jupyterhub.log'
c.Application.log_format = '[%(asctime)s,%(msecs).03d] [%(levelname)s] [%(name)s] %(message)s'
c.Application.log_level = 0

##Ldap Configuration
c.LDAPAuthenticator.server_address = 'adserver.hadoop.com'
c.LDAPAuthenticator.server_port = 389
c.LDAPAuthenticator.lookup_dn = False
c.LDAPAuthenticator.bind_dn_template = [
"CN={username},OU=Users,OU=BIGDATA,DC=HADOOP,DC=COM",
]
-----------------------------------------------------------------------------------------------

 

6. jupyterhub ์‹คํ–‰ ๋ฐ ์ ‘์† ํ™•์ธ (http://localhost:8000)

jupyterhub -f /etc/jupyterhub/jupyterhub_config.py

 

 

 โ—พ ์‹คํ–‰ ์ค‘ ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋ฉด, sqlite-devel ํŒจํ‚ค์ง€ ์„ค์น˜ ๋ฐ python ์žฌ์„ค์น˜๊ฐ€ ํ•„์š”

Error: No module named '_sqlite3'
1) Install the sqlite-devel package:
    yum install -y sqlite-devel

2) Recompile python from the source:
    ./configure
    make
    make altinstall

 

7. ์ •์ƒ ํ™•์ธ ํ›„ ์„œ๋น„์Šค ๋“ฑ๋ก ๋ฐ ์‹คํ–‰

vi /usr/lib/systemd/system/jupyterhub.service
-------------------------------------------------------------------------------
[Unit]
Description=Jupyterhub

[Service]
User=root
ExecStart=/usr/local/bin/jupyterhub -f /etc/jupyterhub/jupyterhub_config.py
-------------------------------------------------------------------------------

systemctl daemon-reload
systemctl start jupyterhub