Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Friday, April 11, 2014

How to install collectd & graphite on Ubuntu and CentOS

This post is a direct approach to install collectd & graphite on Ubuntu, by direct I mean using the available repositories:

Requeriments

- Ubuntu 13.10 installed and configured with standard repositories
- CentOS 6.3 + EPEL repository configured
- Login as root

Ubuntu guide

(i) Install collectd daemon:

# apt-get install collectd

(here you may modify the collectd config file and select the metrics to harvest)

(ii) Install apache2 & graphite, disable default site and enable graphite site:

# apt-get install apache2 libapache2-mod-wsgi
# apt-get install graphite-carbon graphite-web

(iii) Config graphite site, disable default site and enable graphite site:

# cd /etc/apache2/sites-available/
# ln -s /usr/share/graphite-web/apache2-graphite.conf
# a2dissite 000-default
# a2ensite apache2-graphite

(iv) Initial graphite DB creation:

# cd /usr/share/pyshared/graphite
# python manage.py syncdb

(v) Configure carbon cache:

# nano /etc/default/graphite-carbon

(and change flag to true)

CARBON_CACHE_ENABLED=true

(vi) Setup carbon-cache to autostart, then start it:

# chkconfig --levels 235 carbon-cache on
# /etc/init.d/carbon-cache start

(vii) Setup collectd to autostart:

# chkconfig --levels 235 collectd on
# /etc/init.d/collectd start

(viii) Restart apache2:

# service apache2 restart

CentOS guide

(i) Install & config collectd daemon:

# yum install collectd pyhton-bucky httpd
# cp /etc/collectd.conf /etc/collectd.conf.org

(here you may modify the collectd config file and select the sts to harvest)

(ii) Install apache2 & graphite, config apache to autostart:

# yum install graphite-web python-carbon
# chkconfig --levels 235 httpd on
# /etc/init.d/httpd start

(iii) Initial graphite DB creation:

# cd /usr/lib/python2.6/site-packages/graphite
# python manage.py syncdb

(iv) configure carbon cache:

# chkconfig --levels 235 carbon-cache on
# /etc/init.d/carbon-cache start

(v) restart apache:

# /etc/init.d/httpd restart

(vii) Setup collectd to autostart:

# chkconfig --levels 235 collectd on
# /etc/init.d/collectd start


At this point you are already collecting metrics!
Enjoy it!




Wednesday, February 8, 2012

What are the size of Ubuntu and Debian repositories?

Before mirroring a complete Ubuntu / Debian repository on your hard drive, you want for sure have an estimation of the "weight" of all packages.

This script computes the total size of various Debian-based repositories by means of downloading the Packages.gz and making a sum of the size of every package. Of course, there are many shared packages between different versions of the same Linux distro. So this script will compute the max possible size.

Enjoy it!

I got the following results:..

Summary [Feb 9, 2012]

UBUNTU TOTAL SIZE = 466993 MB [456 GB] *

DEBIAN TOTAL SIZE = 184712 MB [180 GB] **
DEBIAN-SECURITY TOTAL SIZE = 22148 MB [21 GB] **
DEBIAN-VOLATILE TOTAL SIZE = 489 MB [0 GB]  **

TOTAL SIZE: ~658 GB

* Considering lucid, maverick, natty, oneiric and precise, with i386 and amd64 architectures, and the components main, multiverse, restricted and universe
** Considering  lenny and squeeze with i386, amd64, armel and arm architectures, and the components main, contrib and non-free

Tuesday, January 10, 2012

Creating a portable MySQL in CentOS 6 and Ubuntu 11.10 Linux from sources

This is a how to create a portable MySQL installation on GNU/Linux from the sources. It applies to:

  • MySQL 5.5.19
  • CentOS 6.x / Ubuntu 11.10 Oneiric Ocelot
At the end of this guide you will obtain a portable MySQL installation on a target directory with it's own databases, binaries, logs, pid files, etc.  Consider always the use of a permission preserving packaging (like TAR) for moving the installation between systems or removable storages.

Requirements


Steps

  1. Define some environment variables to make the installation smoothly:
  2. $ TARGET=$HOME/mysql
    $ BASEDIR=$TARGET/usr/local/mysql
    $ DATADIR=$TARGET/usr/local/mysql/data
    $ PORT=9797
    $ VERSION=5.5.19
    
  3. Install cmake, ncurses and bison:
    • On CentOS:
    • $ sudo yum install cmake ncurses-devel bison
      
    • On Ubuntu:
    • $ sudo apt-get install cmake libncurses5-dev bison 
      
  4. Unpack and make (NOTE: mysql-5.5.19.tar.gz is already downloaded in /tmp)
  5. $ pushd /tmp
    $ tar zxvf mysql-${VERSION}.tar.gz
    $ cd mysql-${VERSION}
    $ cmake .
    $ make 
    
  6. Install into target directory
  7. $ mkdir -p $TARGET
    $ make install DESTDIR="$TARGET"
    
  8. Create system databases
  9. $ pushd $BASEDIR
    $ scripts/mysql_install_db --user=$USER \
      --basedir=$BASEDIR \
      --datadir=$DATADIR \
      --ldata=$DATADIR
    $ mkdir -p $TARGET/var/run/mysql
    $ mkdir -p $TARGET/var/log/mysql
    $ popd
    $ popd
    

Post install steps

  • Running the portable MySQL (NOTE: bind-address is settled to 0.0.0.0, it means listening on all network interfaces, you can change it to 127.0.0.1 for local connections only or to an specific network interfaces address like 192.168.122.45)
  • $ $BASEDIR/bin/mysqld_safe --user=$USER \
      --basedir=$BASEDIR \
      --datadir=$DATADIR \
      --pid-file=$TARGET/var/run/mysql/mysql.pid \
      --skip-syslog \
      --log-error=$TARGET/var/log/mysql/mysql.err \
      --port=$PORT \
      --socket=$TARGET/var/run/mysqld/mysqld.sock \
      --ledir=$BASEDIR/bin \
      --mysqld=mysqld \
      --bind-address=0.0.0.0
    
  • Connecting locally (via socket) to the portable MySQL
  • $ $BASEDIR/bin/mysql -u root --socket=$TARGET/var/run/mysqld/mysqld.sock
    
  • Creating a sample database and granting all privileges to a user
  • $ $BASEDIR/bin/mysql -u root --socket=$TARGET/var/run/mysqld/mysqld.sock <<EOT
    create database alfresco;
    grant all privileges on alfresco.* to alfresco@'%' identified by 'alfresco';
    EOT
    
  • Connecting remotely to the created database (NOTE: verify firewall settings on the server before connecting remotely)
  • $ mysql -u alfresco -h SERVER --port=9797 -p alfresco
    
  • Changing the root password
  • $ $BASEDIR/bin/mysqladmin -u root password 'root' --socket=$TARGET/var/run/mysqld/mysqld.sock
    

Tuesday, October 4, 2011

Various Java VM on my Debian / Ubuntu. What can I do?

The situation
Many of us prefer Sun JVM (Oracle now) for historical or non-historical reasons. Many of us also prefer Debian, Ubuntu and/or even Red Hat. But when we go and install LibreOffice (for example), via apt-get other powerful player arrives: openjdk. I don't want to discuss which JVM implementation is the most "appropriate" for us, you or them. There is a fact, many JVM can and should coexists pacifically.

But the question persists
- After installing various Java-dependant packages on my GNU/Linux OS preferred distribution, and I issue the javac command, which JVM compiler is invoked? 
- How can I set my preferred Java implementation per command basis?

The solution
The Debian alternatives system is devoted to solve the problem of choosing the default preferred implementation of various kinds of programs: text editors, mail agents, JVM, etc.

The options are settled via update-alternatives in a terminal and there is also a graphical version called galternatives.


The Example
This script sets various' Sun JVM (Oracle now) commands as the default alternatives for: java packaging, java VM, java compiler, javadoc, etc. It runs update-alternatives command several times, one per java command.