Jupyter Notebook and JupyterHub
Jupyter Notebook Install#
Install kerberos package to connect to HDFS or Kerberos Kafka
Download miniconda and setup
Install required packages
Edit config file
JupyterHub Install#
Install packages and dependencies
python -m venv /data1/jupyterhub/
source /data1/jupyterhub/bin/activate
/data1/jupyterhub/bin/python -m pip install wheel ipywidgets jupyterhub==4.1.5 jupyterlab==4.2.0 jupyterhub-ldapauthenticator==1.3.2 pyspark==3.0.1 mysqlclient spylon-kernel
/data1/jupyterhub/bin/python -m pip install --no-cache-dir --no-deps -r requirements.txt
Edit config file
mkdir -p /data1/jupyterhub/etc/jupyterhub/
cd /data1/jupyterhub/etc/jupyterhub/
/data1/jupyterhub/bin/jupyterhub --generate-config
------add the following for LDAP setting------
c.LDAPAuthenticator.server_address = 'ldaps://adldaps.in.com:636'
c.LDAPAuthenticator.use_ssl = True
c.LDAPAuthenticator.lookup_dn = False
c.LDAPAuthenticator.server_port = 636
c.LDAPAuthenticator.valid_username_regex = '^[a-z][.a-z0-9_-]*$'
c.LDAPAuthenticator.lookup_dn_search_filter = '({login_attr}={login})'
c.LDAPAuthenticator.lookup_dn_search_user = 'username
c.LDAPAuthenticator.lookup_dn_search_password = 'password'
c.LDAPAuthenticator.tls_strategy = 'on_connect'
c.LDAPAuthenticator.user_search_base = 'OU=FTE,OU=USERS,OU=CORPORATE,OU=,DC=in,DC=,DC=com'
c.LDAPAuthenticator.user_attribute = 'sAMAccountName'
c.LDAPAuthenticator.lookup_dn_user_dn_attribute = 'cn'
c.LDAPAuthenticator.escape_userdn = False
c.LDAPAuthenticator.bind_dn_template = '{username}@abc.com'
c.LDAPAuthenticator.debug = True
c.LDAPAuthenticator.admin_users = {'manishkumar'}
Create a systemd service
sudo mkdir -p /data1/jupyterhub/etc/systemd
vim /data1/jupyterhub/etc/systemd/jupyterhub.service
----add the following in jupyterhub.service----
[Unit]
Description=JupyterHub
After=syslog.target network.target
[Service]
User=root
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/data1/jupyterhub/bin"
ExecStart=/data1/jupyterhub/bin/jupyterhub -f /data1/jupyterhub/etc/jupyterhub/jupyterhub_config.py --ip IP --port=18888
[Install]
WantedBy=multi-user.target
----create symlink for the service----
sudo ln -s /data1/jupyterhub/etc/systemd/jupyterhub.service /etc/systemd/system/jupyterhub.service
----start the service----
sudo systemctl daemon-reload
sudo systemctl enable jupyterhub.service
sudo systemctl start jupyterhub.service
sudo systemctl status jupyterhub.service
For SSL
/data1/jupyterhub/bin/jupyterhub -f /data1/jupyterhub/etc/jupyterhub/jupyterhub_config.py --ip ServerIP --port=18888
/data1/jupyterhub/bin/jupyterhub -f /data1/jupyterhub/etc/jupyterhub/jupyterhub_config.py --ip ServerIP --port 443 --ssl-key /data1/jupyterhub/etc/jupyterhub/my_ssl.key --ssl-cert /data1/jupyterhub/etc/jupyterhub/my_ssl.cert