zoukankan      html  css  js  c++  java
  • 使用conda部署jupyterhub以及ladp验证的安装

    前提:机器安装有conda环境

    官方文档:http://jupyterhub.readthedocs.io/en/stable/quickstart.html

    1.安装conda3

    jupyterhub需要python3环境,python3现在在conda官网之上是配置的conda3,默认现在kylin中环境为conda2,对应着python2,同时/usr/hdp/hdp-select需要py2环境

    所以原有机器的anaconda2环境不能变动

    官网下载安装anaconda3,官网下载安装>>官网地址

    wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64.sh
    

    然后运行sh脚本即可

    conda可以独立创建python3环境,但是会影响到其它组件的安装等,而且spark-sqlhive也均需要py2环境

    2.安装jupyterhub

    [root@10-112-41-157 .jupyterhub]# conda install -c conda-forge jupyterhub
    [root@10-112-41-157 .jupyterhub]# conda install notebook
    

    如果执行jupyterhub没有的话,查看/letv/usr/local/anaconda2/envs/jupyterhub_python3/bin目录,如果也没有jupyterhub,则重新执行conda install -c conda-forge jupyterhub命令,可能openssl没有安装成功

    3.jupyterhub安装检查

    [root@10-127-220-93 .conda]#jupyterhub -h
    

    4.生成config文件

    [root@10-127-220-93 .conda]# jupyterhub --generate-config
    

    注意:jupyterhub_config.py文件会在当时执行路径下生成,注意生成之后具体位置的存放,可以直接在/root目录下新建一个隐藏目录,本文中mkdir /root/.jupyterhub

    5.加入ladp的验证

    安装pip install jupyterhub-ldapauthenticator插件,具体github参考https://github.com/jupyterhub/ldapauthenticator

    [root@10-112-41-157 .jupyterhub]# conda install -c conda-forge jupyterhub-ldapauthenticator 
    

    在jupyterhub_config.py文件中查找c.JupyterHub.authenticator_class

    加入以下配置文件

    c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
    c.LDAPAuthenticator.server_address = 'ldap.letv.cn'
    c.LDAPAuthenticator.lookup_dn = False
    c.LDAPAuthenticator.user_search_base = 'OU=letv,DC=letv,DC=local'
    c.LDAPAuthenticator.user_attribute = 'sAMAccountName'
    c.LDAPAuthenticator.escape_userdn = False
    c.LDAPAuthenticator.bind_dn_template = '{username}@le.com'
    

    6.其它配置文件的改动

    [root@10-112-41-157 .jupyterhub]# grep ^[^#] jupyterhub_config.py 
    c.JupyterHub.authenticator_class = 'ldapauthenticator.LDAPAuthenticator'
    c.LDAPAuthenticator.server_address = 'ldap.letv.cn'
    c.LDAPAuthenticator.lookup_dn = False
    c.LDAPAuthenticator.user_search_base = 'OU=letv,DC=letv,DC=local'
    c.LDAPAuthenticator.user_attribute = 'sAMAccountName'
    c.LDAPAuthenticator.escape_userdn = False
    c.LDAPAuthenticator.bind_dn_template = '{username}@le.com'
    c.JupyterHub.port = 80
    c.Spawner.default_url = '/lab'
    
    • 1.jupyterhub的默认端口为8000,上述例子的参数c.JupyterHub.port改为80即可

    • 2.默认进入jupyterhub的页面为/tree?,将c.Spawner.default_url改为/lab即可

    • 3.jupyterhub默认为非交互模式,所以/etc/profile的环境变量对jupyterhub web中的环境不受影响,所以需要设定/etc/bashrc的值,同时/root/.bashrc中的值在初始安装anaconda3的时候,可能会有写入,注意对整个环境变量的影响,可注释

    文中各环境变量为

    [root@10-112-41-157 .jupyterhub]# cat /etc/profile
    以上略
    export ANACONDA2_HOME=/usr/local/anaconda2
    export JAVA_HOME=/usr/local/java
    export ANACONDA3_HOME=/letv/anaconda3
    export PYSPARK_PYTHON=$ANACONDA2_HOME/bin/python
    export PYSPARK_DRIVER_PYTHON=$ANACONDA2_HOME/bin/python
    export SPARK_HOME=/usr/hdp/current/spark2-client
    export PYTHONPATH=$SPARK_HOME/python:$SPARK_HOME/python/lib/py4j-0.10.4-src.zip
    export PATH=$JAVA_HOME/bin:$ANACONDA2_HOME/bin:$PATH
    
    [root@10-112-41-157 .jupyterhub]# cat /etc/bashrc 
    以上略
    export ANACONDA2_HOME=/usr/local/anaconda2
    export JAVA_HOME=/usr/local/java
    export ANACONDA3_HOME=/letv/anaconda3
    export PYSPARK_PYTHON=$ANACONDA2_HOME/bin/python
    export PYSPARK_DRIVER_PYTHON=$ANACONDA2_HOME/bin/python
    export SPARK_HOME=/usr/hdp/current/spark2-client
    export PYTHONPATH=$SPARK_HOME/python:$SPARK_HOME/python/lib/py4j-0.10.4-src.zip
    export PATH=$JAVA_HOME/bin:$ANACONDA2_HOME/bin:$PATH
    
    [root@10-112-41-157 .jupyterhub]# cat /root/.bashrc
    # .bashrc
    
    # User specific aliases and functions
    
    alias rm='rm -i'
    alias cp='cp -i'
    alias mv='mv -i'
    
    # Source global definitions
    if [ -f /etc/bashrc ]; then
    	. /etc/bashrc
    fi
    
    # added by Anaconda3 installer
    #export PATH="/letv/anaconda3/bin:$PATH"
    

    7.启动jupyterhub

    [root@10-112-41-157 .jupyterhub]# /letv/anaconda3/bin/python /letv/anaconda3/bin/jupyterhub --debug &
    

    因为jupyterhub需要py3环境,而系统环境又必须为py2,所以直接指定jupyterhub启动环境为py3

    8.ladp用户登录访问后显示httpd 500

    需要在linux系统中使用useradd创建ladp用户,登陆web页面之后,然后start service即可

  • 相关阅读:
    【记录】Excel 中VLOOPUP 使用心得
    【记录】Mybatis-plus中Page插件 快速进行分页操作
    【记录】mybatis-plus 更新字段的三种策略解析
    Instant Client连接数据库
    python3安装沙盒环境
    redis配置哨兵模式
    redis主从配置
    mongodb4.2主从(副本集附仲裁节点)部署带认证模式
    主从数据不一致导出同步错误(主库删除记录,从库不存在)
    批量执行redis命令
  • 原文地址:https://www.cnblogs.com/marility/p/9412816.html
Copyright © 2011-2022 走看看