graphite安装

graphite安装

四月 25, 2018

#####环境准备

1
2
3
# yum install gcc python27-devel.x86_64 python-devel  -y
# yum install cairo pango gdk-pixbuf -y
# yum install libffi libffi-devel -y

#####安装go-carbon

1
2
3
# wget https://github.com/lomik/go-carbon/releases/download/v0.12.0/go-carbon-0.12.0-1.x86_64.rpm
# rpm -ivh go-carbon-0.12.0-1.x86_64.rpm
# /etc/init.d/go-carbon start

#####安装graphite-web

1
2
3
4
5
6
7
# pip install --no-binary=:all: https://github.com/graphite-project/whisper/tarball/master
# pip install --no-binary=:all: https://github.com/graphite-project/graphite-web/tarball/master
# pip install --no-binary=:all: https://github.com/graphite-project/carbon/tarball/master
# pip install whisper
# pip install bottle
# pip install uwsgi
# yum install nginx

#####配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# cd /opt/graphite/conf/
# cp storage-schemas.conf.example storage-schemas.conf
# cat << EOF > /opt/graphite/conf/uwsgi.ini
> [uwsgi]
[uwsgi]
socket = /opt/graphite/conf/uwsgi.sock
workers = 2
#workers = 4 cpu的核心数
master = true
pythonpath = /opt/graphite/webapp/graphite
wsgi-file = /opt/graphite/conf/graphite.wsgi
pidfile = /opt/graphite/conf/uwsgi.pid
daemonize = /opt/graphite/logs/graphite.log
disable-logging = 1
stats = 127.0.0.1:1717
EOF
# cp graphite.wsgi.example graphite.wsgi
# mkdir -p /opt/graphite/logs
# /usr/local/bin/uwsgi --ini /opt/graphite/conf/uwsgi.ini

#####nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
cat << EOF > /etc/nginx/conf.d/graphite.conf
upstream django {
server unix:///opt/graphite/conf/uwsgi.sock; # for a file socket
}
server {
listen 8001;
#server_name .example.com; # substitute your machine's IP address or FQDN
charset utf-8;
client_max_body_size 75M; # adjust to taste

location /static {
alias /opt/graphtie/webapp/content; # your Django project's static files - amend as required
}
location /static/admin {
alias /opt/graphtie/webapp/static/admin; # your Django project's static files - amend as required
}
location / {
auth_basic "Restricted Area";
# auth_basic_user_file /etc/nginx/conf.d/htppasswd;
uwsgi_pass django;
include uwsgi_params; # the uwsgi_params file you installed
}
}

server {
listen 8002;
charset utf-8;
client_max_body_size 75M; # adjust to taste
allow 127.0.0.1;
deny all;
location /static {
alias /opt/graphtie/webapp/content;
}
location /static/admin {
alias /opt/graphite/webapp/static/admin;
}
location / {
uwsgi_pass django;
include uwsgi_params; # the uwsgi_params file you installed
}
}

EOF
# /etc/init.d/nginx start

#####初始化数据库 (有问题)

1
2
3
4
5
6
# find / -name django-admin.py
# PYTHONPATH=/opt/graphite/webapp /usr/local/bin/django-admin.py collectstatic --noinput --settings=graphite.settings
# mv local_settings.py.example local_settings.py
# PYTHONPATH=/opt/graphite/webapp /usr/local/bin/django-admin.py migrate --settings=graphite.settings --run-syncdb
# PYTHONPATH=/opt/graphite/webapp /usr/local/bin/django-admin.py collectstatic --noinput --settings=graphite.settings
# /opt/graphite/bin/run-graphite-devel-server.py --libs=/opt/graphite/webapp/ /opt/graphite/ &

#####grafana

1
2
3
4
# yum install initscripts fontconfig -y
# yum install urw-fonts -y
# rpm -ivh grafana-5.0.4-1.x86_64.rpm
# /etc/init.d/grafana-server start

#####collectd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# yum install collectd -y
# cd /etc/collectd.d/
# cat df.conf
LoadPlugin df
<Plugin df>
IgnoreSelected false
ReportByDevice false
ReportReserved false
ReportInodes false
ValuesPercentage true
</Plugin>
# cat graphite.conf
LoadPlugin write_graphite
<Plugin write_graphite>
<Node "dev">
Host "10.17.0.206"
Port "2003"
Protocol "udp"
LogSendErrors true
Prefix "collectd."
#Postfix "collectd"
SeparateInstances true
StoreRates true
AlwaysAppendDS false
EscapeCharacter "_"
</Node>
</Plugin>
# /etc/init.d/collectd start