title | tags | parent | description | author | categories | date | |||||
---|---|---|---|---|---|---|---|---|---|---|---|
Deploy Cassandra on Oracle Cloud (OCI) Linux VM |
|
tutorials |
Set up your environment to run Cassandra in Oracle Cloud Infrastructure. |
olivier |
|
2021-09-21 12:00 |
{% slides 2 %} This tutorial will guide you through the steps needed to set up your environment to run Cassandra in Oracle Cloud Infrastructure.
You should have already deployed a VM 2.1 with Oracle Linux 7.9 (OEL7) in Oracle Cloud Infrastructure (OCI).
- The installation of Oracle Linux 7.9 is using pip3.6 by default
- Python 3.6 or higher is installed
- You have access to root, either directly or via sudo. In OCI, the default user is "opc" and has sudo privileges
Installing JuypterLab is fairly simple:
- Set up python
- Install python components and libraries
Lets start with setting up the Python Environment.
By default, OEL7 runs Python 3. The first step is to install pip
and virtualenv
.
-
Install virtualenv
The next step is to install
virtualenv
.virtualenv
enables us to create isolated sandboxes to develop Python applications without running into module or library conflicts. It's easy to install:sudo pip3.6 install virtualenv
-
Create an environment and enable it
Create an environment called "myvirtualenv" using the following command:
virtualenv -p /usr/bin/python3 myvirtualenv # Activate the env source myvirtualenv/bin/activate
-
Check Python libraries
Running the following command will show what Python modules we have installed at this point:
(myvirtualenv) [opc@lab1 ~]$ pip3 list Package Version ---------- ------- pip 21.1.3 setuptools 57.1.0 wheel 0.36.2 WARNING: You are using pip version 21.1.3; however, version 21.2.1 is available. You should consider upgrading via the '/home/opc/myvirtualenv/bin/python -m pip install --upgrade pip' command.
-
Upgrade your PIP Environment
/home/opc/myvirtualenv/bin/python -m pip install --upgrade pip
-
Install JupyterLab
pip3 install jupyterlab
-
Install Python libraries for Machine Learning or ETL Process
pip install pandas pip install pandarallel pip install dask pip install seaborn pip install matplotlib pip install plotly pip install -lxml==4.6.3 pip install selenium pip install beautifulsoup4 pip install scikit-learn
-
Install other Python Libraries for Kafka Access and WEB Server Access
pip install kafka-python (v2.0.0) pip install Flask pip install gunicorn
-
Install extensiones for Jupyterlab Environment
pip install jupyter_contrib_nbextensions jupyter contrib nbextension install --user jupyter nbextension enable execute_time/ExecuteTime
-
Create a script to automatically instantiate and reboot JupyterLab with the "opc" user.
vi /home/opc/launchjupyterlab.sh
Add the content below. You must use the "myvirtualenv" virtualenv environment you created previously. You can launch Jupyterlab on a specific port (for example: 8001) and listen on your public IP.
#!/bin/bash # Activate myvirtualenv Environment source myvirtualenv/bin/activate cd /home/opc if [ "$1" = "start" ]; then nohup jupyter-lab --ip=0.0.0.0 --port=8001 > ./nohup.log 2>&1 & echo $! > /home/opc/jupyter.pid else kill $(cat /home/opc/jupyter.pid) fi
-
Make the script executable so it can be executed from the JupyterLab service.
chmod 777 /home/opc/launchjupyterlab.sh
-
Connect to the "root" user
sudo -i
-
Create a script to start and stop the "jupyterlab" service
vi /etc/systemd/system/jupyterlab.service
Add the following to launch the "launchjupyterlab.sh" script as the "opc" user
[Unit] Description=Service to start jupyterlab for opc Documentation= [Service] User=opc Group=opc Type=forking WorkingDirectory=/home/opc ExecStart=/home/opc/launchjupyterlab.sh start ExecStop=/home/opc/launchjupyterlab.sh stop [Install] WantedBy=multi-user.target
-
Test Jupyterlab Service
systemctl start jupyterlab systemctl status jupyterlab systemctl enable jupyterlab
Lastly, you'll need to reboot your machine to ensure the jupyterlab script is available on port 8001.
Open port 8001 on your virtual machine VM 2.1 to allow access to JupyterLab using your Public IP.
firewall-cmd --permanent --zone=public --list-ports
firewall-cmd --get-active-zones
firewall-cmd --permanent --zone=public --add-port=8001/tcp
firewall-cmd --reload
If you're running directly on a virtual machine and have a browser installed, it should take you directly into the Jupyter environment. Connect using your public IP with the 8001 port, i.e. "http://xxx.xxx.xxx.xxx:8001/".
You should now see the Python Web environment "Jupyterlab".
{% endslides %}