Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

部署jupyterhub[0]

Posted on 2023年11月14日2025年5月6日 by

本篇是部署jupyterlab—python网页编程工具的续篇,主要用于解决在一台公共服务器上的多人使用python开发环境的问题。

由于jupyterhub在root权限下获取的python包可以给多个用户使用,因此减少了一部分的冗余下载。

jupyter作为web开发方式,采用BS架构,运用服务器强大的计算能力,较笔记本电脑的性能提升较大。

能够解决多终端编程,统一后端运行环境,将开发和编译在相同环境下执行。

  • 简介

AI辅助

1)简介

2)部署

  • 部署过程(root权限shell)

1)安装依赖

yum install npm nodejs -y
npm install -g configurable-http-proxy
/usr/local/bin/configurable-http-proxy -h #安装后测试

2)安装jupyterhub

yum install python3 python3-pip -y
pip3 install jupyterhub
/usr/local/bin/jupyterhub -h #安装后测试

3)安装jupyter notebook和jupyter lab

pip3 install jupyterlab notebook

4)配置

/usr/local/bin/jupyterhub --generate-config #产生jupyterhub_config.py位于/root下

修改配置如下:

c.JupyterHub.ip = '*'
c.JupyterHub.port = 8000
c.JupyterHub.proxy_cmd = ['/usr/local/bin/configurable-http-proxy',]
c.Spawner.notebook_dir = '~'
c.Authenticator.admin_users = {'root'}

5)登录

firewall-cmd --zone=public --add-port=8000/tcp --permanent 
systemctl restart firewalld
jupyterhub

通过浏览器http://ip:8000访问

6)添加用户

给linux系统添加用户就能给jupyterhub添加用户

adduser tom
passwd tom

7)测试

测试通过。

 

  • 小结

root用户登录会遇到问题,python的包无需复制到其他用户下。

 

补充说明:

1)终端中的中文字符显示错误,主要由于centos8stream本身语言包安装未完整

bash中显示Failed to set locale, defaulting to C.UTF-8

yum install langpacks-en glibc-all-langpacks -y

2)部署自签名证书

openssl genrsa -out vhost.key 4096
openssl req -new -key vhost.key -out vhost.csr
openssl x509 -req -in vhost.csr -out vhost.crt -signkey vhost.key -days 3650

修改配置文件jupyterhub_config.py

c.JupyterHub.ssl_key = '/root/vhost.key'
c.JupyterHub.ssl_cert = '/root/vhost.crt'

重启jupyterhub生效

https://ip:8000访问

3) 配置systemctl

/usr/lib/systemd/system/jupyterhub.service添加如下内容

[Unit]
Description=JupyterHub Service
After=multi-user.target

[Service]
User=root
Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
ExecStart=/usr/local/bin/jupyterhub --config=/root/jupyterhub_config.py
Restart=on-failure
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=jupyterhub

[Install]
WantedBy=multi-user.target

 

 

参考资料:

  1. https://jupyterhub.readthedocs.io/en/stable/quickstart.html
  2. https://sthsf.github.io/wiki/Linux%20Tricks/JupyterHub%20%E9%83%A8%E7%BD%B2%E4%B8%8E%E5%BA%94%E7%94%A8%E6%8C%87%E5%8D%97.html
  3. https://fishercat.top/20200322130/
  4. https://fishercat.top/20200323185/

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT