Skip to content

Instantly share code, notes, and snippets.

@outmost
Created May 7, 2013 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save outmost/5531737 to your computer and use it in GitHub Desktop.
Save outmost/5531737 to your computer and use it in GitHub Desktop.
Step-by-step guide to installing NodeJS, StatsD and Graphite on the Amazon Linux AMI
# Apply updates
sudo yum update
# Enable Epel Repo
sudo vim /etc/yum.repos.d/epel.repo.
# Under the section marked [epel], change enabled=0 to enabled=1.
# Install packages
sudo yum install python-devel.x86_64 python-pip.noarch mod_wsgi.x86_64 mod_python.x86_64 python-sqlite2.x86_64 bitmap.x86_64 pycairo.x86_64 python-zope-interface.x86_64 python-simplejson.x86_64 django-tagging.noarch python-pip.noarch python-twisted-web.x86_64 bitmap bitmap-fonts gcc-c++.x86_64 openssl-devel.x86_64 git.x86_64 make.x86_64
# Install Graphite etc
sudo pip-python install carbon
sudo pip-python install graphite-web
sudo pip-python install whisper
# Copy example configs to .conf
pushd /opt/graphite/conf
sudo cp carbon.conf.example carbon.conf
sudo cp storage-schemas.conf.example storage-schemas.conf
sudo cp storage-aggregation.conf.example storage-aggregation.conf
sudo cp graphTemplates.conf.example graphTemplates.conf
# Edit storage-schemas.conf
sudo vim storage-schemas.conf
# Add the following to top of config settings
### [stats]
### priority = 110
### pattern = ^stats\..*
### retentions = 10s:7d,1m:21d,15m:91d,1h:5y
# Edit storage-aggregation.conf
sudo vim storage-aggregation.conf
# Add the following to config settings
### [counters]
### pattern = stats.counts.*
### xFilesFactor = 0.0
### aggregationMethod = sum
# Copy important file
sudo cp graphite.wsgi.example graphite.wsgi
# Make WSGI Directory
sudo mkdir /etc/httpd/wsgi
# Configure apache2
sudo vim /etc/httpd/conf/httpd.conf
# Add the following at line 223
### Include "/etc/httpd/vhosts/*.conf"
# Create the new directory
sudo mkdir /etc/httpd/vhosts
# Setup Graphite
sudo vim /etc/httpd/vhosts/graphite-vhost.conf
# Add the following to file
# On Red Hat
WSGISocketPrefix /etc/httpd/wsgi/
<VirtualHost *:80>
ServerName graphite
DocumentRoot "/opt/graphite/webapp"
ErrorLog /opt/graphite/storage/log/webapp/error.log
CustomLog /opt/graphite/storage/log/webapp/access.log common
# I've found that an equal number of processes & threads tends
# to show the best performance for Graphite (ymmv).
WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120
WSGIProcessGroup graphite
WSGIApplicationGroup %{GLOBAL}
WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL}
# XXX You will need to create this file! There is a graphite.wsgi.example
# file in this directory that you can safely use, just copy it to graphite.wgsi
WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi
Alias /content/ /opt/graphite/webapp/content/
<Location "/content/">
SetHandler None
</Location>
# XXX In order for the django admin site media to work you
# must change @CHANGE_ME_TO_DJANGO_ROOT@ to be the path to your django
# installation, which is probably something like:
# /usr/lib/python2.6/site-packages/django
Alias /media/ "@CHANGE_ME_TO_DJANGO_ROOT@/contrib/admin/media/"
<Location "/media/">
SetHandler None
</Location>
# The graphite.wsgi file has to be accessible by apache. It won't
# be visible to clients because of the DocumentRoot though.
<Directory /opt/graphite/conf/>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
# Let the Apache user be the owner of /opt/graphite/
sudo chown -R apache:apache /opt/graphite/
# Restart Apache
sudo /sbin/service httpd restart
# Configure Graphite Web
cd /opt/graphite/webapp/graphite
sudo python manage.py syncdb
# You will be prompted to create an admin user; most people will want to do this.
# Start Carbon, Graphite's data aggregator
cd /opt/graphite/
sudo ./bin/carbon-cache.py start
# Node.js
# Install required packages
sudo yum groupinstall "Development Tools"
# Install Node.js... This takes about 20-30 minutes, get yourself a coffee
cd /tmp
sudo git clone http://github.com/joyent/node.git
cd node
sudo git checkout v0.10.4
sudo ./configure
sudo make
sudo make install
# Make some links
sudo ln -s /usr/local/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/node /usr/lib/node
sudo ln -s /usr/local/bin/npm /usr/bin/npm
sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf
# Install NPM
cd /tmp
sudo wget http://npmjs.org/install.sh
sudo sh install.sh
cd /usr/local/bin/
sudo npm install express
# Install StatsD
cd /tmp
git clone http://github.com/etsy/statsd.git
sudo cp -R /tmp/statsd /opt/graphite
# Start Node.js/StatsD
cd /opt/graphite/statsd
sudo cp exampleConfig.js local.js
# Edit local.js
sudo vim local.js
# Configure the following
### graphitePort: 2003
### graphiteHost: "127.0.0.1"
### port: 8125
# Start things up!
nohup /usr/local/bin/node stats.js local.js &
@sansmischevia
Copy link

Which amazon AMI are you using?

@outmost
Copy link
Author

outmost commented Jun 4, 2013

Hi, sorry for slow reply - this is using the Amazon Linux AMI (64bit)

Amazon Linux AMI 2013.03.1
The Amazon Linux AMI is an EBS-backed, PV-GRUB image. It includes Linux 3.4, AWS tools, and repository access to multiple versions of MySQL, PostgreSQL, Python, Ruby, and Tomcat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment