Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Ubuntu 14.04 Set Static IP address

Posted on Friday, September 26, 2014






It looks like setting up a static IP address in Ubuntu 14.04 has changed since 12.04/10.04.    Here are some notes on how to set your static IP address in Ubuntu 14.04.






Ubuntu Upstart job with java jar

Posted on Saturday, February 1, 2014


This article covers setting up an Upstart Job on an Ubuntu 12.04 server. This upstart job will start/stop a program packaged in a jar file.

For lots of details on upstart you can go to http://upstart.ubuntu.com/cookbook/ [1]

iostat and IOPS

Posted on Monday, January 6, 2014


iostat is command for monitoring devices (Hard Drives) attached to the system.  This is another tool I feel a little foolish for just discovering.

iostat is a good tool to discover actual IOPS (Operations per second) http://en.wikipedia.org/wiki/IOPS [1]
I recently was tasked with making an RDS amazon server with a set IOPS on its hard drive.  AWS offers guaranteed IOPS speed for a higher price.  It’s a very useful feature to guarantee speed on your Database.

I wanted to test our current "Live" database to see what IOPS it is currently using.  I found a few calculator sites out there to figure out our theoretical IOPS on the database server such as http://wintelguy.com/raidperf.pl [2].  We got an estimate of ~400 IOPS.  This number made me feel good, since the smallest IOPS you can buy on AWS is 1,000 and increment by 1,000.

This estimated rate is not the actual live rate, just an estimate of capacity.  I wanted to see what the actual rate we were using is.

iostat command

The iostat command is no longer installed by default on Ubuntu (my linux flavor of choice).

To install it run

> sudo apt-get install sysstat



Run the iostat command and read it


> iostat






These stats show the statistics since start up.   


The tps = IOPS.    Since this machine was rebooted (many many months ago it has averaged 247 IOPS real usage)


What if I want to see more recent statistics?

Here is a command I ran


> iostat -dm 10 3


What this says is "-d" only display utilization report
"-m" says convert read/write to MiB

The next number, in this case 10, is the interval to look at.   10 is 10 seconds.

The final number, in this case 3, is the count number.   Check 3 times.

So If I run this command I will see something like this



The first number displayed is the average since the server was last started.   The following number is the average over 10 seconds.

If I leave off the last number and run


> iostat -dm 10


iostat will just continue to get the results every 10 seconds.


This is exactly what I was looking for and I am not going to go into any more detail on iostat.  If you need more detail I would suggest first reading all of http://www.percona.com/live/mysql-conference-2013/sites/default/files/slides/Monitoring-Linux-IO.pdf [3]





References
[1]        Wikipedia IOPS page
                Accessed 01/2014
[2]        Raid Performance Calculator
                Accessed 01/2014
[3]        Monitoring IO Performance using iostat & pt-diskstats
Accessed 01/2014


Installing Java 7 on ubuntu 12.10 (fixed)

Posted on Saturday, August 17, 2013


I recently had an issue with my guide on getting Oracle's Java 7 installed on Ubuntu 12.10.   sudo apt-get install python-software-properties no longer seems to add the "add-apt-repository" command line tool.  Instead you need to use sudo apt-get install software-properties-common.   Michal mentioned this change at http://linuxg.net/how-to-fix-error-sudo-add-apt-repository-command-not-found/ [1] in a comment.

AWS create vsftpd (FTP) server

Posted on Friday, June 21, 2013


I recently had to create a vsftpd (FTP) server on an Amazon aws virtual server running Ubuntu 12.10.

There are some issues with the default vsftpd tool that installs with apt-get on Ubuntu 12.10 (version 2.x… not sure which one off the top of my head).   It will not allow virtual users access to their root directories.   I wrote up a guide in May-2013 that showed how to get around this by writing to a sub directory, but that just does not feel right.

So this guide will go over how to do it properly and with a virtual AWS machine.


Installing Wordpress on nginx / Ubuntu

Posted on Monday, June 10, 2013


I have done several installs of wordpress using apache and php. Typically using this simple set of apt-get commands to install all the tools I need for apache/php


> sudo apt-get install apache2
> sudo apt-get install php5-mysql
> sudo apt-get install libapache2-mod-php5
> sudo apt-get install imagemagick
> sudo apt-get install php5-imagick
> sudo a2enmod rewrite


But now I am getting impressed with nginx I like the configuration files better and its overall faster than apache (or so I have been told).


Installing vsftpd on ubuntu 12.10

Posted on Monday, May 27, 2013



This post has been superseded by a new post at


http://www.whiteboardcoder.com/2013/06/aws-create-vsftpd-ftp-server.html




I recently was asked to set up an ftp server for a client.  I had some partial old notes on setting up a vsftpd server on Ubuntu 12.10 but they were incomplete and not much help to me.   So I had to make this guide.

My goal is to set up a vsftpd server and use virtual users using PAM authentication.  

Amazon AWS Fix cloud-init in Ubuntu 12.10

Posted on Monday, April 15, 2013



This guide goes over fixing one bug in the cloud-init feature in Ubuntu 12.10.  The issue is this, when creating a user and giving them a password their password becomes "locked"


In the cloud-init version 0.7 installed with Ubuntu 12.10 AMIs there is a bug if you are trying to set the password for a user it becomes locked.   
The bug and its fix are covered here https://bugs.launchpad.net/cloud-init/+bug/1096423 [1]  So it has been fixed but the fix is not on the Ubuntu 12.10 AMI images yet (And I do not think it ever will be).   So here is my process for putting this fix into a 12.10 AMI and making your own AMI to use.


Linux shuf command

Posted on Tuesday, March 12, 2013




At least 2-3 times a year I come across a very useful linux command line tool that I think to myself… "How did I not know about this tool, it's so useful!"

This is command 'shuf'  is  one of those tools.

The need


I was writing a simple bash script last night to simply use curl to test out a restful service I am working on.    It’s a restful service that accepts a POST of a JSON file.   I wanted some of the number values in the JSON post to be randomized,  something like 12.34   22.14  some floaty looking number within a narrow range.

Doing a quick google search I came across the command line tool shuf.

Here are a couple of main pages detailing shuf  http://linux.die.net/man/1/shuf [1]


Here are some basic examples of what it can do.


> shuf -i 10-20


Will generate a list of the integers 10 to 20 inclusive and shuffle them up.



Or for my purposes I just wanted 1 number


> shuf -i 10-20 -n 1



Does the same thing but returns you  a number in the shuffled list



> shuf -i 10-20 -n 3



Returns 3 numbers

For my base script I wanted to create a random number like 12.21  (it was not important that it be really random)



#!/bin/bash


for ((i = 0; i < 20; i++))
do
   num=`shuf -i 1-20 -n 1`.`shuf -i 1-99 -n 1`
   echo $num
done






Here are the results of the program running.


[1]        shuf(1) - Linux man page
                Accessed 03/2013
[2]        shuf — generate random permutations
                Accessed 03/2013

Installing Java 7 on ubuntu 12.10

Posted on Friday, March 1, 2013



This post has an error its been superseded by this post
http://www.whiteboardcoder.com/2013/08/installing-java-7-on-ubuntu-1210-fixed.html

Here are the commands to install Java 7 from Ubuntu 12.04 server.


>  sudo apt-get purge openjdk*
>  sudo apt-get install python-software-properties
>  sudo add-apt-repository ppa:webupd8team/java
>  sudo apt-get update
>  sudo apt-get install oracle-java7-installer
>  java -version









References
NA

Ubuntu 12.04 Setting a Static IP

Posted on Sunday, January 6, 2013



I have several virtual machines running Ubuntu at my home that have static IPs for various reasons.   Prior to Ubuntu 12.04 I would simply edit /etc/network/interfaces to something like this.



auto lo
iface lo inet loopback
#
#
auto eth0
iface eth0 inet static
      address 192.168.0.100
      netmask 255.255.255.0
      broadcast 192.168.1.255
      gateway 192.168.0.1


But in Ubuntu 12.04 this does not work, well it works but you can no longer access anything.  apt-get no longer works, ping no longer works, wget no longer works.


Unable to Resolve Host IP

Posted on Thursday, December 20, 2012



Unable to Resolve Host IP


Every so often I get this error from the command line from ubuntu 12.04 LTS in the Amazon AWS cloud.


unable to resolve host ip-XX-X-XX-XXX






AWS setting up command line tools in Ubuntu

Posted on Tuesday, October 23, 2012



I use the amazon command line tools a lot, its often a quicker way to accomplish things quickly versus the AWS web interface,  though the AWS web interface has gotten a lot better over the past few years)


In this guide I am going to show how to set up the command lines tools using Ubuntu, I have another (slightly different guide for Cygwin)


This guide of course assumes you already have an Amazon AWS account.

Installing Java 7 on Ubuntu 12.04

Posted on Friday, October 12, 2012










Looks like Oracle has finally pulled the plug on using apt-get to install Java6.  According to this site
https://lists.ubuntu.com/archives/ubuntu-security-announce/2012-January/001554.html [1] the java package will no longer be available for easy apt-get downloads...

I used to be able to 


Edit /etc/apt/sources.list.


       > sudo pico /etc/apt/sources.list


Add the following at the bottom


deb http://archive.canonical.com/ lucid partner


Run this from the command line


       >  sudo apt-get update


      Run this from the command line to install Java


       >  sudo apt-get install sun-java6-jdk



But that no longer works...  Here are the steps I tool to install Java7 on my Ubuntu server.

Installing Git server on Ubuntu 12.04

Posted on Wednesday, August 15, 2012



Installing Git server on Ubuntu 12.04


I am familiar with using subversion, but my new job calls for using Git so I this is my attempt to set us a Git server on Ubuntu and use it.  First the main site for Git is http://git-scm.com/ [1] 

If you are new to Git, like I am, the Git folks have a wonderful free online book at http://git-scm.com/book [2].   And if you want to get right to it the section on setting up a server is at http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server
(I took a of information from this guide)

Starting from a fresh install of Ubuntu 10.04 server with openssh
installed.

First create a git user

Install Postgres 9.1 on Ubuntu 10.04 (LTS)

Posted on Wednesday, April 11, 2012



I recently had to install postgres 9.1 on Ubuntu 10.04 server.  Currently it is not available via apt-get.  

So poking around I found 2 good sites showing how to accomplish this task  http://netadminlinux.blogspot.com/2011/11/installing-postgresql-91-on-ubuntu-1104.html [1] and


ESXi 5 vSphere Ubuntu VM, adding a second hard drive

Posted on Thursday, April 5, 2012



I have an Ubuntu 10.04 Desktop running as a VM image in an ESXi 5 server.  I want to add a second hard drive to it format it and mount it.  Here is a simple how to.

First open up vSphere Client and login to your ESXi 5 server.


VMware Ubuntu image lost eth0 after moving it

Posted on Monday, March 26, 2012



So you just cloned or moved an Ubuntu machine using the VMware Converter or some other tools, and now it lost its access to the internet and you are wondering why?  After all it’s a clone it should be the same right?

According to this post http://communities.vmware.com/thread/46069 [1] answered by nick.couchman

Some of the newer Linux distributions have a tendency to tie ethernet devices to MAC addresses.  When you generate a new UUID, the MAC address changes, and the distribution doesn't know where to find the interface because the eth0 device that is loaded by the driver differs in MAC address from the device listed in the configuration.  You can try going to /etc/sysconfig/network or /etc/sysconfig/network-scripts and editing the eth0 configuration file.  If a MAC address is listed, compare the MAC address listed in the configuration with the one listed in the ifconfig output.  If they differ, try changing the one in the configuration to match the ifconfig output and reboot.


So now that you find yourself in this situation how do you fix it?


Confirming the problem


First let’s run some commands to confirm the problem


       > ifconfig


My result is


This is missing the eth0 link.

Install Java 7 on Ubuntu 10.04 now that apt-get no longer works

Posted on Saturday, February 25, 2012


Installing Java 7 on Ubuntu 10.04

Looks like Oracle has finally pulled the plug on using apt-get to install Java6.  According to this site
https://lists.ubuntu.com/archives/ubuntu-security-announce/2012-January/001554.html [1] the java package will no longer be available for easy apt-get downloads...

I used to be able to 


Edit /etc/apt/sources.list.


      > sudo pico /etc/apt/sources.list


Add the following at the bottom


deb http://archive.canonical.com/ lucid partner


Run this from the command line


      >    sudo apt-get update


      Run this from the command line to install Java


      >    sudo apt-get install sun-java6-jdk



But that no longer works...  Here are the steps I tool to install Java7 on my Ubuntu server.


Installing Joomla 1.7 on Ubuntu 10.04 server

Posted on Monday, January 16, 2012



These are my quick notes on installing Joomla on an Ubuntu 10.04 Server.  This assumes you already have the Ubuntu server up and running and know how to use a command line.


Install/Setup MySQL


Install mysql on this server


       > sudo apt-get install mysql-server