2020년 5월 11일 월요일

[DEVOPS] AWS 에 jupyter notebook 설치 및 설정 (SSH 웹브라우저 접속)

! ~$ 뒤는 리눅스 명령어


1. jupyter notebook 설치하기

    - apt-get 업데이트
        ~$ sudo apt-get update
    - 파이썬 설치 확인
        ~$ python3
        ~$ exit()
    - 파이썬 관련 라이브러리 설치 도구 파이프 설치
        ~$ sudo apt-get install python3-pip
    - jupyter notebook 설치
        ~$ sudo pip3 install notebook

2. jupyter notebook 설정하기

    - 비밀번호 설정 (웹사이트 비밀번호)
        ~$ python3
        ~$ from notebook.auth import passwd
        ~$ passwd()
        비밀번호 비밀번호 확인 입력을 입력하면 'sha1:4346ef9048f5:~~~' 형태로 입력한
        비밀번호 값을 단방향 암호화하여 출력 해준다. 출력된 내용을 복사하여 메모장에
        임시 저장
        ~$ exit()   -> 파이썬 종료
        ~$ jupyter notebook --generate-config     -> jupyter 설정 파일 생성
        Writing default config to: /home/ubuntu/.jupyter/jupyter_notebook_config.py
        문구화 함게 파일이 생성됨
        ~$ vi /home/ubuntu/.jupyter/jupyter_notebook_config.py
        632 라인 쪽 편집 내용 추가
        632 c = get_config()
        633 c.NotebookApp.password = u'sha1:4346ef9048f5:7e~~~'  -> 비밀번호
        634 c.NotebookApp.ip = 'xxx.xx.xx.xxx' -> 서버 아이피
        635 c.NotebookApp.notebook_dir = '/' -> 루트 디렉토리
        저장 후
        ~$ sudo jupyter-notebook --allow-root

    - SSL 설정 (openssl)
        ~$ cd /home/ubuntu
        ~$ mkdir ssl
        ~$ cd ssl
        ~$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout "xxx.cert"          -out "xxx.pem" -batch -> ssl 관련 파일 생성
        ~$ vi /home/ubuntu/.jupyter/jupyter_notebook_config.py -> 635 라인 밑에 추가
        c.NotebookApp.certfile = u'/home/ubuntu/ssl/xxx.pem'
        c.NotebookApp.keyfile = u'/home/ubuntu/ssl/xxx.cert'
        저장후
        ~$ sudo jupyter-notebook --allow-root

    - service  등록
        ~$ which jupyter-notebook  -> 실행 파일 경로 확인
        ~$ sudo vi /etc/systemd/system/jupyter.service  -> 서비스 파일 생성
       
        내용 입력

        [Unit]
        Description= Jupyer Notebook Server

        [Service]
        Type=simple
        ExecStart=/usr/bin/sudo /usr/local/bin/jupyter-notebook --allow-root --                        config=/home/ubuntu/.jupyter/jupyter_notebook_config.py

        [Install]
        WantedBy=multi-user.target

        저장

        ~$ sudo systemctl daemon-reload - > 데몬 리로드
        ~$ sudo systemctl enable jupyter -> 시작 프로그램등록
        ~$ sudo systemctl start jupyter -> 시작하기
        ~$ sudo systemctl status jupyter -> 상태확인
        ~$ sudo systemctl restart jupyter -> 재시작



댓글 없음:

댓글 쓰기

[lunux]리눅스 폴더별 용량 확인

리눅스 폴더별 용량 확인 조회 하고자 하는 디렉토리 리스트가있는 경로로 이동후 du -h --max-depth=1