Miniconda İle JupyterHub Kurulumu

Mustafa Kemal Çiftçi
Bentego Teknoloji
Published in
2 min readApr 3, 2024

Anacona ve miniconda arasında temel farklılıklar mevcuttur. Anaconda paketinde miniconda paketinde olmayan 150–250 data bilimine ait kütüphaneler bulunmaktadır. Ayrıca Anaconda Navigator arayüzüne sahiptir. Miniconda özelleştirmeye daha uygundur. Anaconda ve minicondayı komut satırı kodları aynı şekilde kullanabiliriz.

Genel olarak sistem üzerindeki python’a dokunmadan ve daha rahat bir çalışma ortamı sağlığı için tercih edilir. Birden fazla farklı python versiyonları ile ihtiyaca yönelik ortamlar kurulabilir.

Miniconda Kurulumu

Linux sistemlerine kurulum nasıl yapılır ?

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -p /conda_workspace/miniconda3

Conda base ortamı aktif etme ve yeni ortamlar oluşturma

source /conda_workspace/miniconda3/bin/activate
conda create -n myenv python=3.8
# Bu adımda hangi paketleri nereye kurulacağını gösteren bir bilgi ekranı gelecektir.
# Y ile onayladıktan sonra paket kurulumu başlayacaktır.

Jupyter-Hub Kurulumu

# myenv ortamına geçiş yapalım.
source /conda_workspace/miniconda3/bin/activate myenv
conda install -c conda-forge jupyterhub
conda install jupyterlab notebook
conda install -c conda-forge jupyterhub-ldapauthenticator
# Jupyter Hub için config dosyası oluşturma
mkdir jupyter_home
cd jupyter_home
jupyterhub --generate-config

Active Directory (Ldap) Konfigürasyonu

#LDAP ile giriş

# Set the Jupyterhub log file location
c.JupyterHub.extra_log_file = 'jupyter_home/jupyter.log'
# Set the log level by value or name.
c.JupyterHub.log_level = 'DEBUG'
# Enable debug-logging of the single-user server
c.Spawner.debug = True
# Enable debug-logging of the single-user server
c.LocalProcessSpawner.debug = True

#Jupyterhub Main Conf
#jupyterhub'ın çalışacağı ana port set edilir
c.JupyterHub.bind_url = 'http://0.0.0.0:7880'
#jupyterhub'ın çalışacağı hub ip ve port set edilir(yukarıdaki portdan farklı olmalıdır)
c.JupyterHub.hub_bind_url = 'http://localhost:7881'
c.Spawner.start_timeout = 3000
c.Application.log_level = 10
c.JupyterHub.debug_proxy = True
#jupyterhub'ın çalışacağı ana ip set edilir
c.JupyterHub.hub_connect_ip = 'localhost'
c.JupyterHub.hub_ip = 'localhost'
c.JupyterHub.proxy_api_ip = 'localhost'
#c.JupyterHub.proxy_api_port = '7882'
c.ConfigurableHTTPProxy.api_url = 'http://localhost:7882'
c.Spawner.default_url = '/lab'
c.NotebookApp.notebook_dir = 'jupyter_home/jupyter_workspace/{username}'
c.Spawner.notebook_dir = 'jupyter_home/jupyter_workspace/{username}'

c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
#Firmanın LDAP server ip ve port bilgileri girilir
c.LDAPAuthenticator.server_address = 'ldap://ldaphost:389'
c.LDAPAuthenticator.lookup_dn = True
c.LDAPAuthenticator.lookup_dn_search_filter = '({login_attr}={login})'
#Cloudera ou'suna dahil bir adet sistem useri dn olarak girilir
c.LDAPAuthenticator.lookup_dn_search_user = 'CN=binduser,OU=Generic,DC=local'
#Bu kullanıcıya ait password girilir
c.LDAPAuthenticator.lookup_dn_search_password = '********************'
#Jupyterhub web UI'ına ldap userı ile giriş yapabilek kullanıcıların tanımı yapılır.
c.LDAPAuthenticator.user_search_base = 'DC=local'
c.LDAPAuthenticator.user_attribute = 'sAMAccountName'
c.LDAPAuthenticator.lookup_dn_user_dn_attribute = 'sAMAccountName'
c.LDAPAuthenticator.escape_userdn = False
c.Authenticator.admin_users = {'jupyteradmin'}

JupyterHub Unix Serivisi Olarak Başlatılması

## sistem altına jupyterhub servisini ekleme
vim /etc/systemd/system/jupyterhub.service

######

[Unit]
Description=Jupyter Hub Service

[Service]
User=root
WorkingDirectory=jupyter_home/
ExecStart=/bin/bash -c 'cd jupyter_home/ && source /conda_workspace/miniconda3/bin/activate myenv && jupyterhub'


Restart=on-failure
RestartSec=10s

[Install]
WantedBy=multi-user.target

######
## daemon ve rsyslog restartı 
systemctl daemon-reload && systemctl restart rsyslog
## jupyterhub başlatma
systemctl start jupyterhub.service

--

--