前言
根据 https://jupyterhub.readthedocs.io/en/stable/quickstart.html#installation 安装完成后,如果用screen运行会很麻烦,而且每次重启要手动执行,增加服务之后可以自动守护运行。
在jupyterhub中开启ipyparallel集群功能
安装ipyparallel:pip3 install ipyparallel
,GUI界面开启功能:ipcluster nbextension enable
,然后全局开启jupyterhub中的功能:
jupyter nbextension install --sys-prefix --py ipyparallel jupyter nbextension enable --sys-prefix --py ipyparallel jupyter serverextension enable --sys-prefix --py ipyparallel
方法
Jupyterhub
将以下内容写入/etc/systemd/system/jupyterhub.service
,注意配置文件的路径,这里我放在了/root/jupyterhub_config.py
[Unit] Description=Jupyterhub After=syslog.target network.target [Service] User=root Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" ExecStart=/usr/local/bin/jupyterhub -f /root/jupyterhub_config.py [Install] WantedBy=multi-user.target
ipyparallel集群
将以下内容写入/etc/systemd/system/ipcluster.service
[Unit] Description=ipcluster After=syslog.target network.target [Service] User=root Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" ExecStart=/bin/sh -c '/usr/local/bin/ipcluster start' [Install] WantedBy=multi-user.target
将以下内容写入/etc/systemd/system/ipengine.service
[Unit] Description=ipengine After=syslog.target network.target [Service] User=root Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" ExecStart=/bin/sh -c '/usr/local/bin/ipengine start' [Install] WantedBy=multi-user.target
将以下内容写入/etc/systemd/system/ipcontroller.service
[Unit] Description=ipcontroller After=syslog.target network.target [Service] User=root Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" ExecStart=/bin/sh -c '/usr/local/bin/ipcontroller --ip=10.1.100.108 start' [Install] WantedBy=multi-user.target