美文网首页
远程访问aws jupyter notebook超时

远程访问aws jupyter notebook超时

作者: Greensue86 | 来源:发表于2018-11-02 13:21 被阅读0次

      在AWS申请服务器后,连接超时。试了很多方法,都没有成功,困扰了我很久。现在分享一下解决方法。

    jupyter notebook远程服务器设置

    jupyter官网服务端设置教程 网上也有很多教程,最好还是以官网为准。下面给出不设置ssl简易的jupyter配置

    1.设置jupyter 登录密码

    有两种方式,一种直接使用jupyter命令自动将密码保存在jupyter_notebook_config.json中,另一种通过from notebook.auth import passwd先生成密码哈希值再在jupyter_notebook_config.py文件中手动配置。这里选择第一种自动配置。注意:如果两种方法都使用的话,按照官网的说法,第一种会覆盖第二种方法的密码。

    $ jupyter notebook password
    Enter password:  ****
    Verify password: ****
    [NotebookPasswordApp] Wrote hashed password to /Users/you/.jupyter/jupyter_notebook_config.json
    

    2.生成jupyter_notebook_config.py

    $ jupyter notebook --generate-config
    

    选择覆盖原有的文件,生成的文件默认是全部注释的。

    3.配置jupyter_notebook_config.py

    vim ~/.jupyter/jupyter_notebook_config.py
    

    修改后如下:

    c.NotebookApp.ip = '*'   #所有ip均可访问
    c.NotebookApp.open_browser = False   #服务器端没有浏览器,所以设置为False
    c.NotebookApp.port = 8888 #端口不一定为8888,可随意设置
    

    4.启动jupyter

    $ jupyter notebook
    

    出现下面的提示:

    [I 02:43:49.989 NotebookApp] [nb_conda_kernels] enabled, 20 kernels found
    [W 02:43:50.195 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
    [I 02:43:50.213 NotebookApp] Loading IPython parallel extension
    [I 02:43:50.240 NotebookApp] JupyterLab beta preview extension loaded from /home/ec2-user/anaconda3/lib/python3.6/site-packages/jupyterlab
    [I 02:43:50.240 NotebookApp] JupyterLab application directory is /home/ec2-user/anaconda3/share/jupyter/lab
    [I 02:43:50.417 NotebookApp] [nb_conda] enabled
    [I 02:43:50.420 NotebookApp] Serving notebooks from local directory: /home/ec2-user
    [I 02:43:50.420 NotebookApp] 0 active kernels
    [I 02:43:50.421 NotebookApp] The Jupyter Notebook is running at:
    [I 02:43:50.421 NotebookApp] http://ip-172-31-xx-xx:8888/
    [I 02:43:50.421 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    

    5.在本地浏览器登录远程jupyter

    在本地浏览器输入

    xx.xx.xx.xx:8888       #xx.xx.xx.xx为aws实例的公开ipv4地址,而非jupyter显示的172-31-xx-xx,如上面的倒数第二行。
    

    问题

    登录不成功,连接超时。

    思考

    如何和服务器产生连接呢?所以想ping一下服务器。

    ping 54.249.xx.xx
    

    显示

    Request timeout for icmp_seq 0
    Request timeout for icmp_seq 1
    Request timeout for icmp_seq 2
    Request timeout for icmp_seq 3
    

    与服务器连接不成功,在网上搜索ping aws不成功的原因,找到原因如下面的链接:

    https://www.zhihu.com/question/30711594/answer/164335112
    

    是安全组设置的问题,困扰我两天的问题终于解决,感谢作者的分享。下次在碰到类似的问题,一定要先想本地和终端产生连接的原因。中间自己在虚拟机的服务器搭建了jupyter,用上面的方法配置能够在本地服务器正常登陆。所以问题一定处在aws的配置上面。最后通过ping确定为安全组设置的问题。至此该问题解决。

    相关文章

      网友评论

          本文标题:远程访问aws jupyter notebook超时

          本文链接:https://www.haomeiwen.com/subject/aonqxqtx.html