Installation and deployment of Graphite programming interfaces on CentOS 6

Source: Internet
Author: User
Tags centos create database

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, the load status of the Unix operating system. The Graphite server requires 4800 update operations every minute. Graphite uses simple text protocols and plotting functions to conveniently use them on any operating system.

Environment introduction:

OS: CentOS6.5 x86_64 Minimal

1. Install the EPEL Extension Library

# Yum install-y epel-release

# Sed-I s/# baseurl =/g/etc/yum. repos. d/epel. repo
# Sed-I s/records list =/# records list =/g/etc/yum. repos. d/epel. repo

# Yum clean all

2. Install the required system kits
Yum install-y python-devel python-pip
Yum groupinstall-y 'development tool'

3. Install and configure Graphite-related software (MySQL can be configured separately and use an independent server)
# Yum install-y graphite-web-selinux mysql-server MySQL-python

# Mysql_secure_installation

Set root password? [Y/n] Y
New password: graphite
Re-enter new password: graphite
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
# Mysql-uroot-pgraphite

Mysql> create database graphite;
Mysql> grant all privileges on graphite. * TO 'graphite '@ 'localhost' identified by 'graphite ';
Mysql> flush privileges;
Mysql> exit;
# Vi/etc/graphite-web/local_settings.py

DATABASES = {
'Default ':{
'Name': 'Graphite ',
'Engine': 'Django. db. backends. Mysql ',
'User': 'Graphite ',
'Password': 'Graphite ',
 }
}
#/Usr/lib/python2.6/site-packages/graphite/manage. py syncdb

Wocould you like to create one now? (Yes/no): yes
Username (leave blank to use 'root'): root
E-mail address: guosuiyu@gmail.com
Password: graphite
Password (again): graphite
4. Start the Apache service as the Graphite Web server
#/Etc/init. d/httpd start

5. Install the underlying drawing and data collection software.
# Yum install-y python-carbon python-whisper

6. Start the data collection process
#/Etc/init. d/carbon-cache start

7. Update the configuration and keep all data in the metrics directory for 90 days (only one day is retained by default, that is to say, the data drawing before one day is not visible)
# Vi/etc/carbon/storage-schemas.conf

[Carbon]
Priority= 101
Pattern = ^ carbon \.
Retentions = 60: 90d

[Default_1min_for_90days]
Priority= 100
Pattern = .*
Retentions = 60: 90d
Send some test data
# Python/usr/share/doc/graphite-web-0.9.12/example-client.py

Sending message
--------------------------------------------------------------------------------
System. loadavg_1min 0.01 1446086849
System. loadavg_5min 0.03 1446086849
System. loadavg_15min 0.05 1446086849
8. View the current server process
# Netstat-lntp

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
Tcp 0 0 0.0.0.0: 80 0.0.0.0: * LISTEN 2131/httpd
Tcp 0 0 0.0.0.0: 2003 0.0.0.0: * LISTEN 2210/python
Tcp 0 0 0.0.0.0: 2004 0.0.0.0: * LISTEN 2210/python
Tcp 0 0 0.0.0.0: 22 0.0.0.0: * LISTEN 1566/sshd
Tcp 0 0 127.0.0.1: 25 0.0.0.0: * LISTEN 976/master
Tcp 0 0 0.0.0.0: 7002 0.0.0.0: * LISTEN 2210/python
Tcp 0 0 0.0.0.0: 3306 0.0.0.0: * LISTEN 2063/mysqld
9. Generate 24-hour simulation data to experience the drawing function of Graphite.
Install nc commands
# Yum install-y nc

Create a script to generate simulated data
# Vi feed_random_data.sh

#! /Bin/bash
#
# Generate random pageview data and feed Graphite

Tree_path = metrics. random. pageview
Time_period_hours = 24

Now_timestamp = $ (date + % s)
Minutes_number = $ ($ {time_period_hours} * 60 ))

Echo $ {minutes_number}
Timestamp = $ ($ {now_timestamp}-$ {minutes_number} * 60 ))
For I in $ (seq 1 $ {minutes_number}); do
Echo "echo $ {tree_path }$ ($ RANDOM % 5000) $ {timestamp} | nc localhost 2003"
Echo $ {tree_path} $ ($ RANDOM % 5000) $ {timestamp} | nc localhost 2003
Let timestamp + = 60
Done
Run the script to feed the data to Graphite. The fixed format when using the nc Command is:

Echo directory structure numeric timestamp | nc server address service port
For example:

Echo metrics. random. pageview 3680 1446095415 | nc localhost 2003
# Chmod + x feed_random_data.sh
#./Feed_random_data.sh

Of course, you can also refer to the above example-client.py script, using Python to feed data.

Then, open Graphite Web and you will see the drawing as follows:

 

After logging on to the account root/graphite, you can create a Dashboard to put multiple drawings together for easy viewing:
Graphite also supports generating images through APIs for our convenience, as shown below:
Api url: http://graphite.readthedocs.org/en/latest/render_api.html
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.