Install Graphite in Ubuntu 14.04
What is Graphite
?
First, let's take a look at how Baidu encyclopedia introduces
Graphite is a Python-written web application that uses the django framework. Graphite is used to collect all the server's real-time statuses, user request information, Memcached hit rate, and RabbitMQ Message Server Status, for the Load Status of Unix operating systems, the Graphite server requires about 4800 update operations per minute. Graphite uses simple text protocols and plotting functions for convenient use on any operating system.
What Baidu encyclopedia says is clear,Graphite
It is used to monitor systems, such as operating systems and cache service systems. But how can we obtain the monitoring data?Graphite
It is not responsible. It is only responsible for displaying where data comes from, and you only need to give it according to its data format,Graphite
You can use a pretty page to show it to you, but don't worry,graphite
A series of packages providedAPI
You don't have to worry about how to store the data, just send the data to it. So well, how can I install it?
Don't worry, things are not so perfect,Graphite
W is not supportedindows
ThereforeWindows
OfCoder
It is a little lost, but it doesn't matter. I believe there is a solution as a programmer. These are all small things.
EnterGraphite
World!
Install
Operating System: Ubuntu 14.04
Python: 2.7.6
Install
graphite
Environment
Graphite
The supported environments are as follows:
* A UNIX-like Operating System
* Python 2.6 or greater
* Pycairo
* Django 1.4 or greater
* Django-tagging 0.3.1 or greater
* Twisted 8.0 or greater (10.0 + recommended)
* Zope-interface (often included in Twisted package dependency)
* Pytz
* Fontconfig and at least one font package (a system package usually)
* A wsgi server and web server. Popular choices are:
* Apache with mod_wsgi
* Gunicorn with nginx
* UWSGI with nginx
Ubuntu
Already installedpython
So you do not need to install it again. You only need to ensure that the version is later than or equal to 2.6. Here we select the serverApache
If you have already installed it, you do not need to install it. You only need to install the WSGI module.libapache2-mod-wsgi
.
The following are the commands for installing all the supported environments. We recommend that you install them one by one to check whether each installation is successful.
$sudo apt-get update$ sudo apt-get install apache2 libapache2-mod-wsgi python-django python-twisted python-cairo python-pip python-django-tagging
Install
Graphite
Three major components
- Whisper (database)
- Carbon (monitoring data, default port 2003, external program StatsD transmits sample data to Graphite through this port)
- Graphite-web (web UI)
Usepip
Command to quickly install
$sudo pip install whisper$sudo pip install carbon$sudo pip install graphite-web
After the installation is complete, the/opt/graphite directory is used by default.
Then usePip
Installpytz
For conversionTIME_ZONE
, Which will be introduced later
$ sudo pip install pytz
Configuration
graphite
Go to the/opt/graphite/conf directory and useExample Configuration
$ sudo cp carbon.conf.example carbon.conf $ sudo cp storage-schemas.conf.example storage-schemas.conf $ sudo cp graphite.wsgi.example graphite.wsgi
Is
apache
Add
Graphite
Virtual Host
Installgraphite
Will generate/opt/graphite/example
Folder, which contains a configured VM file to copy itApache
Place the configuration file of the VM. The default value is the/etc/apache2/sites-available folder.
$sudo cp /opt/graphite/example/example-graphite-vhost.conf /etc/apache2/sites-available/graphite-vhost.conf
Then, edit the default directory of listening port 8008 and WSGISocketPrefix as follows:
Create a soft link for this configuration file under/etc/apache2/sites-enable
$cd /etc/apache2/sites-enable$sudo ln -s ../sites-available/graphite-vhost.conf graphite-vhost.conf
Initialize Database
Initializationgraphite
Required database, modifystorage
Permission, which is created by copyinglocal_settings.py
File (in the middle, you will be asked if you want to create a superuser, select no, and change <User Name> to your current Ubuntu user name to allow carbon to write data to the whisper Database, in fact, users can also be specified in carbon. Update: graphite requires admin permission to create User Graph. Therefore, superuser is very important. You can use python manage. create py createsuperuser ):
$ Cd/opt/graphite/webapp/graphite/$ sudo python manage. py syncdb $ sudo chown-R <User Name>: <User Name>/opt/graphite/storage/$ sudo cp local_settings.py.example local_settings.py $ sudo/etc/init. d/apache2 restart # restart apache
The username in the above Code isApache
Corresponding user, generallywww-data
, Which can be obtained using the following code:apache
Ofweb
Root directory (default: var/www/html)control.php
<?php echo exec("whoami");?>
Access through a browserhttp://localhost/control.php
You can see the corresponding user name
Start Carbon
$ cd /opt/graphite/$ sudo ./bin/carbon-cache.py start
Access http: // localhost: 8008 in the browser. The following page shows that the configuration is successful.
If there is an error page with no access permission, you can modify it.Apache
In the configuration file/etc/pache2/apache2.conf, locate the location in, comment out Require all denied, and restartApache
Access again.
Modify
Graphite
Default Time Zone
Open/opt/graphite/webapp/graphite/setting. py and findTIME_ZONE
The default value is UTC and is changed to Asia/Shanghai.
And then findUSE_TZ
If not, add it at the end of the file and set it to True.
Send data
graphite
There are many ways to send Data. For details, refer to the official Feeding In Your Data documentation. In addition, you can use the/opt/graphite/examplesSocket
Sample examples-client.py for sending data.
Graphite official documentation: Graphite official documentation
Install Graphite in CentOS 5.5