## Graphite Setup for CentOS #### 参考 * [Install graphite on a CentOS/RHEL server](http://www.linuxsysadmintutorials.com/install-graphite-on-a-centosrhel-server/) * [CentOSにRPMでGraphite+Diamondをインストールする](http://qiita.com/takakiku/items/4dbee4739801cb8f60a2) *** #### 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 の起動 ~~~~ service mysqld start ~~~~ `MySQL` の `root` パスワード等は適宜設定する。 *** #### Graphite-web の設定 ~~~~ 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 ~~~~ *** ## 追記 #### Apache 2.4 の場合には... `graphite-web.conf` を以下のように設定する必要がある。 ~~~~ # Graphite Web Basic mod_wsgi vhost 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} SetHandler None SetHandler None Require all granted ~~~~