一. 配置准備:
- Oracle 雲服務賬號
- 雲主機一台:操作系統 CentOS7
- Xshell 連接
- Chrome 瀏覽器
二. 安裝步驟
- 創建雲主機
- 創建OCI虛擬網絡VCN
新建VCN網絡:配置Security List(打開訪問端口即可):
- 創建計算實例
- 通過Xshell連接到此實例
並通過修改配置文件,允許root用戶的登錄。
- 創建OCI虛擬網絡VCN
- 安裝Python3
創建安裝目錄,下載 Python3.6.5 安裝包,並將壓縮包解壓到對應目錄中
1 mkdir /opt/Python3 2 cd /opt/Python3/ 3 wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz 4 tar -xvf Python-3.6.5.tgz 5 ls -l
安裝 Python3 依賴包
1 yum -y install zlib zlib-devel 2 yum -y install bzip2 bzip2-devel 3 yum -y install ncurses ncurses-devel 4 yum -y install readline readline-devel 5 yum -y install openssl openssl-devel 6 yum -y install openssl-static 7 yum -y install xz lzma xz-devel 8 yum -y install sqlite sqlite-devel 9 yum -y install gdbm gdbm-devel 10 yum -y install tk tk-devel 11 yum -y install gcc
配置Python安裝環境,並編譯、安裝Python3
1 cd Python-3.6.5/ 2 ./configure --with-ssl --prefix=/opt/Python3 3 make 4 make install
配置Python3環境變量
1 [root@demo-instance ~]# vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi# User specific environment and startup programs
export python=/opt/Python3/bin
PATH=$PATH:$HOME/bin:/opt/Python3/bin
export PATH
編輯關聯
1 mv /usr/bin/python /usr/bin/python_bak 2 ln -s /opt/Python3/bin/python3 /usr/bin/python
3 ln -s /opt/Python3/bin/python3 /usr/bin/python3升級pip
1 python -m pip install --upgrade pip
- 安裝Jupyter Notebook
通過pip安裝Jupyter Notebook
1 python3 -m pip install jupyter
2 ln -s /opt/Python3/bin/jupyter /usr/bin/jupyter通過jupyter notebook命令啟動Jupyter服務器,查看是否安裝成功
1 [root@demo-instance Python-3.6.5]# jupyter notebook --allow-root 2 [I 09:03:32.473 NotebookApp] Serving notebooks from local directory: /opt/Python3/Python-3.6.5 3 [I 09:03:32.473 NotebookApp] The Jupyter Notebook is running at: 4 [I 09:03:32.473 NotebookApp] http://localhost:8888/?token=9fb8cc50c87a1f5a35c2d57d0722dc1c0f58f5be892a6532 5 [I 09:03:32.473 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). 6 [W 09:03:32.479 NotebookApp] No web browser found: could not locate runnable browser. 7 [C 09:03:32.479 NotebookApp] 8 9 To access the notebook, open this file in a browser: 10 file:///root/.local/share/jupyter/runtime/nbserver-24125-open.html 11 Or copy and paste one of these URLs: 12 http://localhost:8888/?token=9fb8cc50c87a1f5a35c2d57d0722dc1c0f58f5be892a6532
至此,Jupyter Notebook安裝成功。
- 配置外部訪問
關閉防火牆(CentOS7)
1 systemctl stop firewalld.service 2 systemctl disable firewalld.service
生成Jupyter Notebook配置文件
1 jupyter notebook --generate-config
通過 ipython 創建登錄密碼:
編輯生成的配置文件 /root/.jupyter/jupyter_notebook_config.py,並在文件頭添加如下配置信息:
c.NotebookApp.ip='0.0.0.0' # 就是設置所有ip皆可訪問 c.NotebookApp.password = u'sha1:7b115a66b162:e6bc039abf83eab1947dd9445d9fe408c659e3d2' #前邊保存的密碼信息 c.NotebookApp.open_browser = False #禁止自動打開瀏覽器 c.NotebookApp.port =8888 #隨便指定一個端口,默認為8888
先 reboot 機器,然后使用命令 jupyter nodebook 啟動服務器
通過瀏覽器訪問地址:http://ipaddress:8888/
輸入創建的密碼,即可登錄Jupyter Notebook的工作區:
恭喜你!你可以在任意地方學習Machine Learning啦~~~