Build jupyter notebook on remote server (CentOS)

Build jupyter notebook on remote server (CentOS)

Thing you want to do

――I want to do this and that of the company with Python --Operate GitLab (aggregate and post issues) --In addition to engineers, people who do not have a development environment also use it (managers and management people) ――This time, I will use a library collection called Anaconda.

OS Version

[root@XXX ~]# cat /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)

Installation of Anaconda

Anaconda Installer Download

--If you want to specify the version, you can select it from Repository.

[root@XXX tmp]# cd /tmp
[root@XXX tmp]# curl https://repo.anaconda.com/archive/Anaconda3-5.3.1-Linux-x86_64.sh -O

Install

[root@XXX tmp]# bash ./Anaconda3-5.3.1-Linux-x86_64.sh 
--Interactive format excerpt below

Please, press ENTER to continue
>>> *Enter male

Do you approve the license terms? [yes|no]
>>>yes 

Anaconda3 will now be installed into this location:
/root/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/root/anaconda3] >>> *Enter male

Do you wish the installer to initialize Anaconda3
in your /root/.bashrc ? [yes|no]
[no] >>> yes

read bashrc

[root@XXX tmp]# source ~/.bashrc

Anaconda Version Confirmation

[root@XXX tmp]# anaconda -V
anaconda Command line client (version 1.7.2)

install jupyter

--Already in jupyter when you put Anaconda --If you want to use it only locally, check the Path and then suddenly check the startup and OK.

Jupyter Vesion confirmation

[root@XXX tmp]# jupyter --version
4.4.0

Path confirmation

[root@XXX tmp]# jupyter --path
config:
    /root/.jupyter
    /root/anaconda3/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /root/.local/share/jupyter
    /root/anaconda3/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /run/user/0/jupyter

Allow access from non-local PCs (optional)

――The point is to start operation before a scary person asks, "Is this security okay?" (Digression) --If you have a sense of speed (?) (Digression) ――I think it's okay to tell the director appropriately, such as preparing a Web Page that collects statistics on GitLab issues (digression). --If you are worried, let's allow only a specific ip in the setting

passwd settings in ipython

--You will be asked for your password when you access it from your browser

--Pytnon's library for interactively hashing passwords

[root@XXX ~]# ipython
Python 3.7.0 (default, Jun 28 2018, 13:15:42) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from notebook.auth import passwd

In [2]: passwd()
Enter password: 
Verify password: 
Out[2]: 'sha1:8e9f3XXXXXXXXXXXXXXXXXXXXXXXX'

In [3]: exit

Create config file

--Created with cmd, but the contents are commented out, and if nothing is set, it will work by default (should) --Since there are many contents, if you want to make a simple setting file, you can create the following path file with touch and handwrite the setting.

[root@XXX tmp]# jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py

config file settings

--The following is described in /root/.jupyter/jupyter_notebook_config.py

c = get_config()
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888 #Defalt
c.NotebookApp.password = u'sha1:8e9f3XXXXXXXXXXXXXXXXXXXXXXXX'
c.NotebookApp.notebook_dir = '/root/jupyter_files/'

Port open

--This and what you wrote in jupyter_notebook_config.py

[root@XXX ~]# firewall-cmd --add-port=8888/tcp --zone=public --permanent
success
[root@XXX ~]# firewall-cmd --add-service=http --zone=public --permanent
success
[root@XXX ~]# firewall-cmd --reload
success
[root@XXX ~]# firewall-cmd --list-ports --zone=public
8888/tcp

Start confirmation

--Speaking jupyter notebook to complete

[root@XXX ~]# jupyter notebook 
#If you are logged in as root, you need the ↓ option
[root@XXX ~]# jupyter notebook --allow-root
[I 10:17:31.193 NotebookApp] JupyterLab extension loaded from /root/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 10:17:31.194 NotebookApp] JupyterLab application directory is /root/anaconda3/share/jupyter/lab
[I 10:17:31.196 NotebookApp] Serving notebooks from local directory: /root/jupyter_files
[I 10:17:31.197 NotebookApp] The Jupyter Notebook is running at:
[I 10:17:31.197 NotebookApp] http://${hostname} or 127.0.0.1):8888/

--If connections from other hosts are not allowed, localhost will be displayed, so I suspect Typo (commandment). --The c.NotebookApp.ip ='*' in "jupyter_notebook_config.py" may become c.NoebookApp.ip ='*'

[I 10:17:31.197 NotebookApp] The Jupyter Notebook is running at:
[I 10:17:31.197 NotebookApp] http://localhost:8888/

Service registration

--If you leave the console closed or Ctrl + C, jupyter will also end, so run it as a service.

Unit definition file creation

[root@XXX ~]# touch /etc/systemd/system/notebook.service

Unit definition file editing

[root@XXX ~]# vi /etc/systemd/system/notebook.service

--ʻExecStart` command requires option for root --For details, refer to the startup confirmation section above.

[Unit]
Description = Jupyter Notebook

[Service]
Type=simple
PIDFile=/var/run/jupyter-notebook.pid
ExecStart=/root/anaconda3/bin/jupyter notebook    # `$ which jupyter`Confirm with
WorkingDirectory=/root   #Home directory of users who have installed Anaconda(Immediately after login`$pwd`) 
User=root   #Username that introduced Anaconda`$ id`
Group=root  #Group name to which the user who introduced Anaconda belongs
Restart=always

[Install]
WantedBy = multi-user.target

Check if the Unit is registered

[root@XXX ~]# $ systemctl list-unit-files --type=service

Start as a service

#Start-up
[root@XXX ~]# systemctl start notebook 
#Start confirmation
[root@XXX ~]# systemctl status notebook
#Set to start automatically at startup
[root@XXX ~]# systemctl enable notebook

reference

Reference when you cannot connect from the outside

-Is jupyter watching the port --Firewall settings and confirmation

Predecessors

-Basic settings -[Make it a service]([https://qiita.com/hiroseabook/items/1da01ea439b01c1eb48c#5-systemd-%E3%81%A7-jupyternotebook-%E3%82%92%E3%82%B5%E3% 83% BC% E3% 83% 93% E3% 82% B9% E5% 8C% 96% E3% 81% 99% E3% 82% 8B](https://qiita.com/hiroseabook/items/1da01ea439b01c1eb48c#5 -systemd-makes -jupyter notebook- a service))

Recommended Posts

Build jupyter notebook on remote server (CentOS)
Start jupyter notebook on GPU server (remote server)
Run Jupyter notebook on a remote server
Enable Jupyter Notebook with conda on remote server
Make Jupyter Notebook a service on CentOS
Remotely open Jupyter notebook launched on the server
[CentOS 7.3] Build an FTP server on the ESXi host
High charts on Jupyter notebook
View PDF on Jupyter Notebook
Run Jupyter Notebook on windows
<Python> Build a dedicated server for Jupyter Notebook data analysis
Build a python environment on CentOS 7.7 for your home server
Formatting with autopep8 on Jupyter notebook
Run azure ML on jupyter notebook
Try running Jupyter Notebook on Mac
Build a python3 environment on CentOS7
Build an NFS server on Arch Linux
Try SVM with scikit-learn on Jupyter Notebook
Build a simple WebDAV server on Linux
Clone the github repository on jupyter notebook
Build a Samba server on Arch Linux
GPU check of PC on jupyter notebook
Build WordPress on CentOS 8 in LAMP environment
Display histogram / scatter plot on Jupyter Notebook
Build a web server on your Chromebook
Use vim keybindings on Docker-launched Jupyter Notebook
Build CentOS 8 on ESXi 6.7 with minimal configuration
Build a proxy server with nginx on multiple remote servers using Ansible
Install matplotlib and display graph on Jupyter Notebook
Stray build Python-3.8.5 on CentOS without root privileges
Jupyter Notebook memo
[Jupyter Notebook / Lab] 3 ways to debug on Jupyter [Pdb]
Introducing Jupyter Notebook
Build a python environment with ansible on centos6
Powerful Jupyter Notebook
I tried launching jupyter nteract on heroku server
Golang on jupyter
Simply display a line graph on Jupyter Notebook
Jupyter on AWS
Settings when using Jupyter Notebook under Proxy server
Jupyter notebook password
Build Jupyter Hub
Jupyter Notebook memo
Build a PYNQ environment on Ultra96 V2 and log in to Jupyter Notebook
Try Apache Spark on Jupyter Notebook (on local Docker
Build CentOS8 LAMP
jupyter notebook does not start on mac fish
Steps to attach and debug from VS Code to Jupyter Lab on a remote server
Easily launch jupyter notebook on AWS and access locally
Run Tensorflow from Jupyter Notebook on Bash on Ubuntu on Windows
Monitor the training model with TensorBord on Jupyter Notebook
Try basic operations for Pandas DataFrame on Jupyter Notebook
[Part 2] Let's build a web server on EC2 Linux
Build Apache HTTP Server and Wildfly on Oracle Linux 8
EC2 provisioning with Vagrant + Jupyter (IPython Notebook) on Docker
Stray build of Python 3 on Sakura's rental server (Note)
How to view progress bar on Jupyter Notebook to see progress
Hello X3DOM on Jupyter
Install Faiss on CentOS 7
Get started Jupyter Notebook
Install numba on CentOS 7.2