Skip to content

Commit

Permalink
folder structure consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-white2 committed Mar 5, 2024
1 parent 93a5542 commit dc4bbdf
Show file tree
Hide file tree
Showing 22 changed files with 1,252 additions and 748 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,139 +1,139 @@
Setting up a RStudio Server running Ubuntu on GCP
9/12/23
========================================================================================================================
1. Creating a VM instance
Navigate to your project
Click on compute engine
VM instances
CREATE INSTANCE
Set the Region and Zone to one that is close to you - make note of the region and zone, they will be important later on
Set the Series and Machine Type
Change Boot disk OS to Ubuntu 22.04 LTS x86/64
Click Allow HTTP and HTTPS traffic
Click Create
2. Create port in firewall to allow access to VM
Navigate to Network Security
click on firewall policies
Create Firewall Rule
Name: rstudio
Target Tags*: http-server
Source IPv4 ranges" 0.0.0.0/0
Protocols and Ports
Check TCP and enter: 8787
Click Create
========================================================================================================================
2. Install dependencies and RStudio Server
Navigate to your project
Navigate to the VM instances page
Open a terminal by selecting the SSH button on the VM you created
Enter the following into the terminal:
1. update packages
sudo apt-get update -y && sudo apt-get upgrade -y
2. Install required dependencies
sudo apt-get install gdebi-core
3. Install base R
sudo apt -y install r-base r-base-dev
4. Install reauired dependencies for tidyverse
sudo apt-get install libcurl4-openssl-dev libssl-dev libxml2-dev libfontconfig1-dev
5. Install reauired dependencies for spatial libraries
sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev libmysqlclient-dev libjq-dev libprotobuf-dev protobuf-compiler -y
6. Install RStudio Server
wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2023.06.2-561-amd64.deb
sudo gdebi rstudio-server-2023.06.2-561-amd64.deb
7. Create a new user and password
sudo adduser master
New password: master
Retype new password: master
Press ENTER for default on all other values
8. Reboot
sudo reboot
EXIT the SSH in browser
========================================================================================================================
3. Setting up GCS Fuse to mount storage buckets as a vm drive
Navigate to the VM instances page
Open a terminal by selecting SSH on the VM you created
Enter the following into the terminal:
export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`
echo "deb https://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install gcsfuse
EXIT the SSH in browser
Stop the VM instance by checking the box and selecting STOP
Click on the activate cloud shell button located on the upper right hand side of the page next to the notifications and support buttons
From the cloud shell change the permissions to give vm access to buckets change the machine name and zone to match yours:
gcloud beta compute instances set-scopes rstudio-template --scopes=storage-full --zone=us-west4-a
When Prompted click on AUTHORIZE
Close the cloud shell by clicking on the X in the upper right hand corner
Start the VM instance by checing the box and selecting START
Navigate to the storage bucket you want to connect to the VM
Copy the name of the bucket.
Navigate to the VM instances page
Open a terminal by selecting SSH on the VM you created
Enter the following into the terminal (be sure to put the copied name of the bucket where it says name-of-bucket):
1. get the uid (enter your username where it says master)
id -u master
2. get the gid (enter your username where is says master)
id - g master
3. create directories
sudo mkdir -p /mnt/name-of-bucket
4. change to allow write permissions
sudo chmod a+w /mnt/name-of-bucket
5. open up and edit the fstab document
sudo nano /etc/fstab
#paste these into the editor on new lines (enter the uid and gid from steps 1 and 2 above)
name-of-bucket /mnt/name-of-bucket gcsfuse rw,_netdev,allow_other,uid=1002,gid=1003,file_mode=0776,dir_mode=0776
6. ctrl o will write to the file, then press enter, then ctrl x to exit
7. sudo reboot
========================================================================================================================
4. Connecting to your Ubuntu desktop VM
Navigate to the VM instances page
Copy the external IP to the clipboard
Open a new browser tab
Paste the ip address into the browser followed by :8787 it should look like the following: 11.111.111.111:8787
Log in using your username and password
Setting up a RStudio Server running Ubuntu on GCP

9/12/23


========================================================================================================================

1. Creating a VM instance

Navigate to your project
Click on compute engine
VM instances
CREATE INSTANCE
Set the Region and Zone to one that is close to you - make note of the region and zone, they will be important later on
Set the Series and Machine Type
Change Boot disk OS to Ubuntu 22.04 LTS x86/64
Click Allow HTTP and HTTPS traffic
Click Create

2. Create port in firewall to allow access to VM
Navigate to Network Security
click on firewall policies
Create Firewall Rule
Name: rstudio
Target Tags*: http-server
Source IPv4 ranges" 0.0.0.0/0
Protocols and Ports
Check TCP and enter: 8787
Click Create



========================================================================================================================

2. Install dependencies and RStudio Server

Navigate to your project
Navigate to the VM instances page
Open a terminal by selecting the SSH button on the VM you created
Enter the following into the terminal:
1. update packages
sudo apt-get update -y && sudo apt-get upgrade -y

2. Install required dependencies
sudo apt-get install gdebi-core

3. Install base R
sudo apt -y install r-base r-base-dev

4. Install reauired dependencies for tidyverse
sudo apt-get install libcurl4-openssl-dev libssl-dev libxml2-dev libfontconfig1-dev

5. Install reauired dependencies for spatial libraries
sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev libmysqlclient-dev libjq-dev libprotobuf-dev protobuf-compiler -y

6. Install RStudio Server
wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2023.06.2-561-amd64.deb
sudo gdebi rstudio-server-2023.06.2-561-amd64.deb

7. Create a new user and password
sudo adduser master
New password: master
Retype new password: master
Press ENTER for default on all other values

8. Reboot
sudo reboot

EXIT the SSH in browser

========================================================================================================================

3. Setting up GCS Fuse to mount storage buckets as a vm drive


Navigate to the VM instances page
Open a terminal by selecting SSH on the VM you created
Enter the following into the terminal:

export GCSFUSE_REPO=gcsfuse-`lsb_release -c -s`

echo "deb https://packages.cloud.google.com/apt $GCSFUSE_REPO main" | sudo tee /etc/apt/sources.list.d/gcsfuse.list

curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

sudo apt-get update

sudo apt-get install gcsfuse

EXIT the SSH in browser
Stop the VM instance by checking the box and selecting STOP
Click on the activate cloud shell button located on the upper right hand side of the page next to the notifications and support buttons
From the cloud shell change the permissions to give vm access to buckets change the machine name and zone to match yours:

gcloud beta compute instances set-scopes rstudio-template --scopes=storage-full --zone=us-west4-a

When Prompted click on AUTHORIZE
Close the cloud shell by clicking on the X in the upper right hand corner
Start the VM instance by checing the box and selecting START

Navigate to the storage bucket you want to connect to the VM
Copy the name of the bucket.


Navigate to the VM instances page
Open a terminal by selecting SSH on the VM you created
Enter the following into the terminal (be sure to put the copied name of the bucket where it says name-of-bucket):

1. get the uid (enter your username where it says master)
id -u master

2. get the gid (enter your username where is says master)
id - g master

3. create directories
sudo mkdir -p /mnt/name-of-bucket

4. change to allow write permissions
sudo chmod a+w /mnt/name-of-bucket


5. open up and edit the fstab document
sudo nano /etc/fstab

#paste these into the editor on new lines (enter the uid and gid from steps 1 and 2 above)
name-of-bucket /mnt/name-of-bucket gcsfuse rw,_netdev,allow_other,uid=1002,gid=1003,file_mode=0776,dir_mode=0776

6. ctrl o will write to the file, then press enter, then ctrl x to exit

7. sudo reboot
========================================================================================================================

4. Connecting to your Ubuntu desktop VM

Navigate to the VM instances page
Copy the external IP to the clipboard
Open a new browser tab
Paste the ip address into the browser followed by :8787 it should look like the following: 11.111.111.111:8787
Log in using your username and password
Loading

0 comments on commit dc4bbdf

Please sign in to comment.