Datacenter

Create a local Datacenter using Raspberry Pi

Hardware

 

Note: Steps 1, 2 and 3 are also covered by visiting https://www.raspberrypi.org/help/noobs-setup/

Step 1 – Format Micro SD card

  1. Download and install the SDFormatter application from https://www.sdcard.org/downloads/formatter_4/index.html
  2. Insert the SD card (micro SD inside its adapter) and note the name e.g. NO NAME
  3. Open the SDFormatter application
    NOTE: Make sure you have selected the SD Card you wish to format and 
    not something else
  4. Select “Overwrite format” (you can also specify a new name if you wish to e.g. RP3S1)
  5. Click “Format”
    NOTE: The formatting can take time so be patient

Step 2 – Installing NOOBS

  1. Download NOOBS from https://www.raspberrypi.org/downloads/
  2. Extract the file e.g. will get a NOOBS_v_1_9_1 folder
  3. Drag all the files in the NOOBS folder and drop them onto the formatted SD card drive
  4. Safely remove the micro sd card and slot it into the Raspberry Pi

Step 3 – Installing Raspbian as the OS

  1. Plug in the keyboard, mouse, and monitor cables into the Raspberry Pi
  2. Plug the USB power cable into the Raspberry Pi
  3. Once the Raspberry Pi has booted select “Raspbian” and click “Install”
  4. Once the install is complete the UI will be display
  5. Configure the name and localisation
    • Menu > Preferences > Raspberry Pi configuration
    • Set Hostname e.g. RP3S1
    • Set Timezone and Wifi Country
NOTE: 
- The default login for Raspbian is username pi with the password raspberry
- Use sudo before commands to allow pi user to perform actions as root
- Use sudo su root to change to root user
- To update to the latest Raspbian perform the following in a terminal
  1. sudo apt-get update
  2. sudo apt-get dist-upgrade

Step 4 – Static IP for Raspberry Pi 3

NOTE: Since the Raspberry Pi 3 comes with wireless connectivity, 
the below is only setting a static ip when connected to WiFi. 
For ethernet replace wlan0 with eth0. 
Both can also be specified but with a different ip_address of course!
  1. Open a terminal window
  2. Enter “sudo route -n” to determine the Gateway (routers) e.g. 192.168.1.1
  3. Enter “cat /etc/resolv.conf” to determine the Domain name server(s) e.g. 192.168.1.1
  4. Enter “sudo nano /etc/dhcpcd.conf” and append to the end of the file
    # Added for static ip configuration
    interface wlan0
    static ip_address=192.168.1.31
    static routers=192.168.1.1
    static domain_name_servers=192.168.1.1
  5. Enter “sudo reboot” to reboot the Raspberry Pi
  6. Enter “sudo ifconfig” in a terminal window and confirm that the inet address for wlan0 is the static ip address stated in step 4

Step 5 – Remote access to Raspberry Pi GUI

NOTE: The below steps can also be found 
here https://www.raspberrypi.org/documentation/remote-access/vnc/README.md
  1. Open a terminal on your Raspberry Pi or connect to it via ssh
  2. Run sudo apt-get install tightvncserver
  3. Run tightvncserver and enter a password (max 8 characters). Can ignore the view-only password by replying with n
  4. Run vncserver :2 -geometry 1920×1080 -depth 24 to start a vnc session on display two (:2)

Create a script to run vncserver (so you don’t have to remember the command each time)

  1. Create a file called startvncserver.sh under /home/pi containing
    #!/bin/sh
    vncserver :2 -geometry 1920x1080 -depth 24 -dpi 96
  2. Run chmod +x startvncserver.sh to make the file executable
  3. Now ./startvncserver.sh can be used to start the vnc server
On the client you can install realvnc to connect to the raspberry pi.
For Mac you can also follow these instructions to access a raspberry pi 
remotely.

Step 6 – Increase swap size

  1. Run sudo nano /etc/dphys-swapfile

  2. Edit CONF_SWAPSIZE to have value of 1024
  3. Save and exit the file
  4. Stop and start the swapfile service:
    • Run sudo /etc/init.d/dphys-swapfile stop
    • Run sudo /etc/init.d/dphys-swapfile start (NOTE: This may take some time to complete)
  5. Run free -m to check the swap size value