1、安装

安装首先打开官网帮助文档,一般安装都是参考官方最新版安装文档。帮助文档地址如下。

JupyterHub 官方安装帮助文档

我安装用的系统: ubuntu20.04

我的安装经验:安装前先进入管理员权限 命令为su 输入密码即可进入,必须进入管理员,不然安装户使用时会出现权限问题。安装python模块时速度如果很慢可以用其他镜像源安装,如下这样使用,体验飞一样的速度。

python3 -m pip install jupyterhub -i https://pypi.douban.com/simple


官方安装方法大致如下。

先决条件

在安装 JupyterHub 之前,您需要:

在运行单用户笔记本服务器(可能与集线器在同一系统上或不在同一系统上)之前,您将需要:

安装

JupyterHub 可以安装pip(和代理npm)或conda

点,npm:

python3 -m pip install jupyterhub
npm install -g configurable-http-proxy
python3 -m pip install jupyterlab notebook  # needed if running the notebook servers in the same environment

conda(一个命令安装 jupyterhub 和代理):

conda install -c conda-forge jupyterhub  # installs jupyterhub and proxy
conda install jupyterlab notebook  # needed if running the notebook servers in the same environment

测试您的安装。如果已安装,这些命令应返回包的帮助内容:

jupyterhub -h
configurable-http-proxy -h

启动 Hub 服务器

要启动 Hub 服务器,请运行以下命令:

jupyterhub

在您的浏览器中访问http://localhost:8000,并使用您的 Unix 凭据登录。

允许多个用户登录Hub 服务器,您必须 jupyterhub特权用户身份启动,例如 root:

sudo jupyterhub

2、环境配置

配置没有太大心得,也是按照官方文档配置的,按照官方配置文档一步一步配置即可。

JupyterHub 官方环境配置帮助

我的配置文件如下。

# 设置3-2
# ------------------------------------------------------------------------------

# configurable_http_proxy 代理设置
c.ConfigurableHTTPProxy.should_start = True #允许hub启动代理 可以不写,默认的,为False 就需要自己去 启动configurable-http-proxy
c.ConfigurableHTTPProxy.api_url = 'http://localhost:8001' # proxy与hub与代理通讯,这应该是默认值不行也行

# 对外登录设置的ip
c.JupyterHub.ip = '192.168.99.2'
c.JupyterHub.port = 8001
c.PAMAuthenticator.encoding = 'utf8'

# 用户名单设置,默认身份验证方式PAM与NUIX系统用户管理层一致,root用户可以添加用户test1,test2等等,非root用户,sudo useradd test1/test2 不起作用,目前我不知道sudo useradd 和 root下 useradd本质区别*(没有特意学过linux,一切只靠用时百度)
# c.Authenticator.allowed_users = {'test1', 'test2'}
c.Authenticator.admin_users = {'root'}  # 管理员用户
c.DummyAuthenticator.password = "xs301302"  # 初始密码设置
c.JupyterHub.admin_access = True  # 则管理员有权在各自计算机上以其他用户身份登录,以进行调试
c.LocalAuthenticator.create_system_users=True  # 此选项通常用于 JupyterHub 的托管部署,以避免在启动服务之前手动创建所有用户

# 设置每个用户的 book类型 和 工作目录(创建.ipynb文件自动保存的地方)
c.Spawner.notebook_dir = '~'
c.Spawner.default_url = '/lab'
c.Spawner.args = ['--allow-root'] 

# 为jupyterhub 添加额外服务,用于处理闲置用户进程。使用时不好使安装一下:pip install jupyterhub-ilde-culler
c.JupyterHub.services = [
    {
        'name': 'idle-culler',
        'command': ['python3', '-m', 'jupyterhub_idle_culler', '--timeout=3600'],
        'admin':True # 1.5.0 需要服务管理员权限,去kill 部分闲置的进程notebook, 2.0版本已经改了,可以只赋给 idel-culler 部分特定权限,roles
    }
]

3、进入管理员用户和创建新用户

安装完成在管理员系统下输入 jupyterhub -f jupyterhub_config.py 启动

如果启动有问题,再多读几遍官方安装和配置文档重新配置或安装。

启动后再浏览器中输入弹出的配置地址,地址在启动日志中有,也就是自己配置文件中的地址。

 

 

 

 

 

 

 

 

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐