Category Archives: Cloud Computing

How to Expand a Boot Disk on a GCE Instance

Google now allows you specify the size of your boot disk larger than 10GB when you create your instance. In any case, if you need to resize your boot disk for any reason, these are the steps I followed.

Here I’ve attached a 250GB blank disk to the instance:

“pv” gives you a progress of the “dd” command. This will take some time. Once it’s finished:

Now we re-partition the disk:

fdisk-expand

Now you could run:

  1. Detach the disk,
  2. Clone the instance and choose this disk as the root disk.
  3. SSH and make sure everything looks good.
  4. Once it looks good, you could delete the original instance and create a new instance with this disk.

Google Cloud Services – How to Use Access Tokens Directly

For whatever reason you can’t use gsutil, gcloud, or a client library, you could request an access token directly. This example uses PHP 5.2 (the PHP client library only works  with PHP 5.3+). Please make sure your instance has access to the correct scopes and that a service account is enabled.
gce-project-access-scope

Related Resources:

  • https://cloud.google.com/compute/docs/metadata?hl=en
  • https://cloud.google.com/compute/docs/authentication

Example Usage of Ruby Client LIbrary for Google Cloud Storage

How to Create a Swap File on Google Compute Engine Virtual Machines

These are the procedures I followed for Ubuntu 14.04 LTS but should work with other Debian distros.

Once you’ve done this you could make this permanent by editing the /etc/fstab file:

If you’re using CentOS 7, Patrick in comments points out:

  1. The fallocate failed if you did not use ‘sudo’.
  2. the ‘swapon’ command failed on the root xfs, moved swap to ext works fine.

How to Setup gcloud Tool on Ubuntu 12.04 LTS

If you see:

CommandException: arg (XXXXX) does not name a directory, bucket, or bucket subdir.

Keep in mind rsync works on directories, cp works on files.

 

ownCloud v5.0 on Eucalyptus Cloud with Ubuntu 12.04 Server installation

Want to host your own DropBox clone? I’m going to go over our setup for hosting our own dropbox clone using owncloud and a server instance from our in house eucalyptus cloud.

Since we are hosting this inside ubuntu 12.04 server edition, most of the installation will be done in the command line.  Open up the command line from within your server and begin.

1. Install the package dependencies required inside ubuntu 12.04 server. (update to latest ubuntu packages first, might have to reboot after upgrade, open a new terminal after upgrade to check for restart messages)
sudo apt-get update && sudo apt-get upgrade && sudo apt-get autoclean && sudo apt-get autoremove && sudo apt-get dist-upgrade
sudo apt-get install apache2 php5 php5-gd php-xml-parser php5-intl php5-sqlite php5-mysql smbclient curl libcurl3 php5-curl

2. Download owncloud (version 5 at this time of writing).
wget http://download.owncloud.org/community/owncloud-5.0.0.tar.bz2

3.  Unzip owncloud and move it to the hosted apache document root. Modify permissions to be accessible for your webserver (we are using apache)
tar xvf owncloud-5.0.0.tar.bz2
sudo mv owncloud /var/www/
sudo chown www-data:www-data -R /var/www/owncloud

4.  Modify apache configuration to host owncloud. (We want to host with SSL for security  so we will be using a self signing certificate).

apache config

sudo a2enmod rewrite headers ssl
openssl genrsa -des3 -out ip-172-31-254-122.key 1024
openssl req -new -newkey rsa:2048 -nodes -keyout ip-172-31-254-122.key -out ip-172-31-254-122.csr
openssl x509 -req -days 365 -in ip-172-31-254-122.csr -signkey ip-172-31-254-122.key -out ip-172-31-254-122.crt
sudo mv ip-172-31-254-122.crt /etc/ssl/certs/
sudo mv ip-172-31-254-122.key /etc/ssl/private

5.   Install mysql or percona database.  (We are using Percona-5.5 and we will be building percona from source.) [or use my script to install]
Because we are installing this on a eucalyptus cloud instance, which has limited hdd storage in root, I will move the mysql data directory to /var/lib/mysql/data

sudo apt-get install build-essential cmake bison ncurses-base ncurses-bin ncurses-runtime ncurses-dev
wget http://www.percona.com/redir/downloads/Percona-Server-5.5/LATEST/source/Percona-Server-5.5.30-rel30.1.tar.gz
cmake -L && cmake . && make && sudo make install
sudo addgroup –system mysql
sudo adduser –system mysql –no-create-home -ingroup mysql
cd /usr/local/mysql
sudo chown -R mysql:mysql .
sudo mkdir /var/lib/mysql
sudo ./scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql
sudo chown -R root .
sudo chown -R mysql data
sudo mkdir /var/run/mysqld
sudo chown -R mysql:mysql /var/run/mysqld
cd /usr/local/mysql/support-files
sudo cp my-large.cnf /etc/my.cnf
sudo chown mysql:mysql /etc/my.cnf

# modify mysql configuration file  using your own custom settings as they vary depending on hardware and preference.
sudo vim /etc/my.cnf 

sudo mkdir /var/log/mysql
sudo chown mysql /var/log/mysql
cd /usr/local/mysql/support-files
sudo cp mysql.server /etc/init.d/mysql
sudo chmod +x /etc/init.d/mysql
sudo update-rc.d mysql defaults
sudo /etc/init.d/mysql restart
mysqladmin -u root password
sudo ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
cd /usr/local/mysql
sudo ./bin/mysql_secure_installation

6.  open web browser and navigate to your owncloud domain or ip and follow the on screen configuration directions.

owncloud install