#一、先决条件
-------------------
1.Jupyter运行需要基于Python环境,此处使用Anaconda管理Python环境
2.Jupyter为了避免遭受攻击,需要使用jupyter用户启动
useradd jupyter
passwd jupyter 123456
3.安装anaconda
3.1 su jupyter
3.2 wget https://repo.anaconda.com/archive/Anaconda3-5.1.0-Linux-x86_64.sh
3.3 bash Anaconda3-5.1.0-Linux-x86_64.sh (按提示安装即可)
3.4 Please, press ENTER to continue
>>> ENTER
3.5 Do you accept the license terms? [yes|no]
[no] >>> yes
3.6 Anaconda3 will now be installed into this location:
/home/jupyter/anaconda3
选择当前用户目录下安装,回车
3.7 to PATH in your /home/jupyter/.bashrc ? [yes|no]
[no] >>> yes
添加环境变量
3.8 Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]
>>> no
不安装VSCODE
4.验证
4.1 修改/home/${user}/.bashrc,添加如下内容
# added by Anaconda3 installer
export PATH="/home/jupyter/anaconda3/bin:$PATH"
# added by Anaconda3 installer
export PATH="/home/jupyter/anaconda3/bin:$PATH"
4.2 Source 当前用户的.bashrc文件
4.3 执行conda –V,如下表示安装Anaconda成功
4.4 输入python –V,如下表示python环境完成(使用python3)
#二、安装Jupyter
-------------------
1.安装Jupyter Notebook
conda install jupyter
2.检查是否安装成功
2.检查是否安装成功
conda list | grep jupyter
*********************************************************
[jupyter@master02 ~]$ conda list | grep jupyter
# packages in environment at /home/jupyter/anaconda3:
jupyter 1.0.0 py36_4
jupyter_client 5.2.2 py36_0
jupyter_console 5.2.0 py36he59e554_1
jupyter_core 4.4.0 py36h7c827e3_0
jupyterlab 0.31.5 py36_0
jupyterlab_launcher 0.10.2 py36_0
3.安装Jupyter Kernel Gateway
conda install -c conda-forge jupyter_kernel_gateway
3.安装Jupyter Kernel Gateway
conda install -c conda-forge jupyter_kernel_gateway
4.检查是否安装成功
conda list | grep jupyter_kernel_gateway
*********************************************************
[jupyter@master02 ~]$ conda list | grep jupyter_kernel_gateway
jupyter_kernel_gateway 2.2.0 py_0 conda-forge
三、配置Jupyter
-------------------
1.将.Jupyter文件夹放到当前用户下即可完成安装(最新版,从生产上拉下来)
2.包目录介绍
.jupyter/
|--bin (启动、停止脚本)
|--start-gateway.sh
|--start-notebook.sh
|--stop-gateway.sh
|--stop-notebook.sh
|--logs(日志)
|--model(模板)
|--ml(machine-learning使用模板)
|--notebook(notebook使用模板)
|--api_http_mode.ipynb(http_api模板)
|--work(作业目录)
|ml(machine-learning使用模板)
|notebook(notebook使用模板)
|--jupyter_kernel_gateway_config.py(kernel_gateway配置)
|--jupyter_notebook_config.py(notebook配置)
3.修改目录权限
#sudo chown -R jupyter:jupyter /run/
4.生成配置文件
jupyter notebook --generate-config
4.修改配置文件jupyter_notebook_config.py
c.NotebookApp.base_project_url = '/'
c.NotebookApp.ip = '*'
c.NotebookApp.notebook_dir = '/home/jupyter/.jupyter/work'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
c.NotebookApp.token = ""
c.NotebookApp.tornado_settings = { 'headers': { 'Content-Security-Policy': "frame-ancestors 'self' *" } }
c.NotebookApp.terminals_enabled = False
5.修改jupyter_kernel_gateway_config.py
c.KernelGatewayApp.allow_methods = '*'
c.KernelGatewayApp.allow_origin = '*'
c.KernelGatewayApp.api = 'kernel_gateway.notebook_http'
c.KernelGatewayApp.ip = '*'
c.KernelGatewayApp.port = 8889
四、启动Jupyter
-------------------
1.Notebook服务
执行bin/ start-notebook.sh
2.Kernel_Gateway服务
执行bin/start-gateway.sh
3.验证
Notebook: http://ip:8888
Gateway: http://ip:8889(此服务是提供Restfull接口服务,无web页面)