使用ポートはjupyter_notebook_config.pyのconf.NotebookApp.portで変更することができます。
Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-7.3"
config.vm.hostname = "jupyter"
config.vm.provider :virtualbox do |vbox|
vbox.name = "jupyter"
vbox.cpus = 4
vbox.memory = 4096
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
# private network
config.vm.network "private_network", ip: "192.168.55.109", :netmask => "255.255.255.0"
# bridge netwrok
config.vm.network "public_network", ip: "192.168.1.109", :netmask => "255.255.255.0"
config.vm.network "forwarded_port", guest:22, host:20022, id:"ssh"
config.vm.provision "shell", inline: <<-SHELL
wget https://repo.continuum.io/archive/Anaconda3-4.4.0-Linux-x86_64.sh
chmod +x Anaconda3-4.4.0-Linux-x86_64.sh
./Anaconda3-4.4.0-Linux-x86_64.sh -b -p /opt/anaconda
source /opt/anaconda/bin/activate
pip install psycopg2
useradd py
sudo -u py sh -c "mkdir ~/.jupyter"
sudo -u py sh -c "cp /vagrant/jupyter_notebook_config.py ~/.jupyter"
cp /vagrant/jupyter.service /etc/systemd/system
sudo systemctl enable jupyter
sudo systemctl start jupyter
echo 'access -> http://192.168.1.109:8080/?token=jupyter'
SHELL
end
jupyter_notebook_config.py
conf = get_config()
conf.NotebookApp.ip = '*'
conf.NotebookApp.open_browser = False
conf.NotebookApp.port = 8080
conf.NotebookApp.token = 'jupyter'
jupyter.service
[Unit]
Description=Jupyter notebook
[Service]
Type=simple
ExecStartPre=source /opt/anaconda/bin/activate
ExecStart=/opt/anaconda/bin/jupyter notebook
User=py
Group=py
WorkingDirectory=/home/py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
○関連情報
・psycopg2に関する他の記事はこちらを参照してください。
0 件のコメント:
コメントを投稿