Skip to content

Instantly share code, notes, and snippets.

@inokappa
Last active November 21, 2017 17:59
Show Gist options
  • Save inokappa/2be2ad0af6527b6749df to your computer and use it in GitHub Desktop.
Save inokappa/2be2ad0af6527b6749df to your computer and use it in GitHub Desktop.
Graphite Setup for CentOS

Graphite Setup for CentOS

参考


epel リポジトリの追加

sudo rpm --import http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/RPM-GPG-KEY-EPEL-6
cd /tmp/
wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6-8.noarch.rpm

パッケージのインストール

sudo yum install graphite-web graphite-web-selinux mysql mysql-server MySQL-python python-carbon

環境に応じては epel リポジトリが無効になっている場合があるので以下のように epel リポジトリを有効にしてインストールする。

sudo yum install --enablerepo=epel graphite-web graphite-web-selinux mysql mysql-server MySQL-python python-carbon

MySQL の起動

sudo service mysqld start

MySQLroot パスワード等は適宜設定する。


Graphite-web の設定

sudo su -
cp /etc/graphite-web/local_settings.py /etc/graphite-web/local_settings.py.bk
cat << EOT >> /etc/graphite-web/local_settings.py
GRAPHITE_ROOT = '/usr/share/graphite'
CONF_DIR = '/etc/graphite-web'
STORAGE_DIR = '/var/lib/graphite-web'
CONTENT_DIR = '/usr/share/graphite/webapp/content'
WHISPER_DIR = '/var/lib/carbon/whisper/'
RRD_DIR = '/var/lib/carbon/rrd'
LOG_DIR = '/var/log/graphite-web/'

DATABASES = {
  'default': {
    'NAME': 'graphite',
    'ENGINE': 'django.db.backends.mysql',
    'USER': 'graphite',
    'PASSWORD': 'complexpassw0rd',
    'HOST': 'localhost',
    'PORT': '3306',
  }
}
EOT

MySQL に Graphite-web のユーザーやデータベースを設定する

mysql -e "CREATE USER 'graphite'@'localhost' IDENTIFIED BY 'complexpassw0rd';" -u root
mysql -e "GRANT ALL PRIVILEGES ON graphite.* TO 'graphite'@'localhost';" -u root
mysql -e "CREATE DATABASE graphite;" -u root
mysql -e 'FLUSH PRIVILEGES;' -u root

Graphite-web の初期設定を行う

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

幾つか質問されるので適宜答える。


Carbon と Apache を起動する(自動起動も有効にする)

/etc/init.d/carbon-cache start
/etc/init.d/httpd start
chkconfig carbon-cache on
chkconfig mysqld on
chkconfig httpd on

追記

Grafana 2.0.0 Beta3

sudo su -
yum install initscripts fontconfig
cd ~
wget https://grafanarel.s3.amazonaws.com/builds/grafana-2.0.0_beta3-1.x86_64.rpm
yum localinstall grafana-2.0.0_beta3-1.x86_64.rpm
/etc/init.d/grafana-server start
chkconfig grafana-server on

Apache 2.4 の場合には...

graphite-web.conf を以下のように設定する必要がある。

# Graphite Web Basic mod_wsgi vhost

<VirtualHost *:80>

    ServerName graphite-web
    DocumentRoot "/usr/share/graphite/webapp"
    ErrorLog /var/log/httpd/graphite-web-error.log
    CustomLog /var/log/httpd/graphite-web-access.log common
    Alias /media/ "/usr/lib/python2.6/site-packages/django/contrib/admin/media/"

    WSGIScriptAlias / /usr/share/graphite/graphite-web.wsgi
    WSGIImportScript /usr/share/graphite/graphite-web.wsgi process-group=%{GLOBAL} application-group=%{GLOBAL}

    <Location "/content/">
        SetHandler None
    </Location>

    <Location "/media/">
        SetHandler None
    </Location>

    <Directory "/usr/share/graphite/">
      Require all granted
    </Directory>

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