真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

graphite在centos7上的部署搭建

Graphite安裝筆記

實(shí)驗(yàn)環(huán)境: CentOS7.5 x64

目前成都創(chuàng)新互聯(lián)公司已為成百上千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)站空間、網(wǎng)站托管、服務(wù)器租用、企業(yè)網(wǎng)站設(shè)計(jì)、普蘭網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。

部署python的程序推薦使用virtualenv這列的虛擬環(huán)境來進(jìn)行,防止污染系統(tǒng)自帶的python包。

?

安裝一些必要的rpm包

yum install cairo? --另外的2個(gè)包 cairo-devel pycairo 可以不用安裝

安裝virtualenv

yum install python-pip

pip install virtualenv

激活虛擬環(huán)境

virtualenv /opt/graphite

source /opt/graphite/bin/activate

安裝graphite全套組件

export PYTHONPATH="/opt/graphite/lib/:/opt/graphite/webapp/"

pip install --no-binary=:all: https://github.com/graphite-project/whisper/tarball/master

pip install --no-binary=:all: https://github.com/graphite-project/carbon/tarball/master

?

pip install --no-binary=:all: https://github.com/graphite-project/graphite-web/tarball/master

如果這步提示某個(gè)依賴包版本不對(duì),我們可以先人工執(zhí)行下pip安裝依賴包。下面提供了一個(gè)正常運(yùn)行的graphite上看到的pip包清單:

attrs==19.1.0

Automat==0.7.0

cachetools==3.1.1

cairocffi==0.9.0

cffi==1.12.3

constantly==15.1.0

Django==1.11.24

django-tagging==0.4.3

gunicorn==19.9.0

hyperlink==19.0.0

idna==2.8

incremental==17.5.0

pycparser==2.19

PyHamcrest==1.9.0

pyparsing==2.4.2

pytz==2019.2

scandir==1.10.0

six==1.12.0

Twisted==19.7.0

txAMQP==0.8.2

urllib3==1.25.3

whisper==1.2.0

zope.interface==4.6.0

初始化

cd /opt/graphite/webapp/graphite

cp local_settings.py.example local_settings.py

?

vim local_settings.py修改如下3行代碼:

CONF_DIR = '/opt/graphite/conf'

STORAGE_DIR = '/opt/graphite/storage'

STATIC_ROOT = '/opt/graphite/webapp/content'

LOG_DIR = '/opt/graphite/storage/log/webapp'

?

初始化下數(shù)據(jù),不然后面啟動(dòng)graphite后會(huì)提示no such user 這類報(bào)錯(cuò)

cd? /opt/graphite/webapp

PYTHONPATH=/opt/graphite/webapp django-admin.py migrate --settings=graphite.settings --run-syncdb??##如果上面第一步時(shí)候沒有yum install cairo的話,這步會(huì)報(bào)錯(cuò)

?

拷貝graphite的配置文件

cd /opt/graphite/conf/

?

cp carbon.conf.example carbon.conf

cp storage-schemas.conf.example storage-schemas.conf? ?一般會(huì)改動(dòng)這個(gè)文件里面的配置,達(dá)到自定義key存儲(chǔ)周期

cp relay-rules.conf.example relay-rules.conf

cp dashboard.conf.example dashboard.conf

cp graphTemplates.conf.example graphTemplates.conf

cp blacklist.conf.example? blacklist.conf

cp aggregation-rules.conf.example aggregation-rules.conf

cp storage-aggregation.conf.example storage-aggregation.conf

啟動(dòng)graphite套件

/opt/graphite/bin/carbon-relay.py start

/opt/graphite/bin/carbon-cache.py start

?

ss -lntp | egrep carbon

LISTEN???? 0????? 50?????????? *:7002???????????????????? *:*??????????????? ???users:(("carbon-cache.py",pid=48433,fd=11))

LISTEN???? 0????? 50?????????? *:2013???????????????????? *:*?????????????????? users:(("carbon-relay.py",pid=37683,fd=13))

LISTEN???? 0????? 50?????????? *:2014???????????????????? *:*?????????????????? users:(("carbon-relay.py",pid=37683,fd=15))

LISTEN???? 0????? 50?????????? *:2003???????????????????? *:*?????????????????? users:(("carbon-cache.py",pid=48433,fd=13))

LISTEN???? 0????? 50?????????? *:2004???????????????????? *:*?????????????????? users:(("carbon-cache.py",pid=48433,fd=14))

?

/opt/graphite/bin/run-graphite-devel-server.py --port=8085 --libs=/opt/graphite/webapp /opt/graphite?前臺(tái)啟動(dòng)

啟動(dòng)打點(diǎn)測(cè)試進(jìn)程

python /opt/graphite/examples/example-client.py

安裝nginx

yum install nginx

cd /etc/nginx/conf.d

cat graphite.conf? 內(nèi)容如下:

upstream graphite {

??? server 127.0.0.1:8085 fail_timeout=0;

}

?

server {

??? listen 80 default_server;

?

??? server_name _;

?

??? root /opt/graphite/webapp;

?

??? access_log /var/log/nginx/graphite.access.log;

??? error_log? /var/log/nginx/graphite.error.log;

?

??? location = /favicon.ico {

??????? return 204;

??? }

?

??? # serve static content from the "content" directory

??? location /static {

??????? alias /opt/graphite/webapp/content;

??????? expires max;

??? }

?

??? location / {

??????? try_files $uri @graphite;

??? }

?

??? location @graphite {

??????? proxy_pass_header Server;

??????? proxy_set_header Host $http_host;

??????? proxy_redirect off;

??????? proxy_set_header X-Real-IP $remote_addr;

??????? proxy_set_header X-Scheme $scheme;

??????? proxy_connect_timeout 10;

??????? proxy_read_timeout 10;

??????? proxy_pass http://graphite;

??? }

}

?

創(chuàng)建nginx相關(guān)文件

touch /var/log/nginx/graphite.access.log

touch /var/log/nginx/graphite.error.log

chmod 640 /var/log/nginx/graphite.*

chown nginx.nginx /var/log/nginx/graphite.*

?

啟動(dòng)nginx

nginx -t

systemctl start nginx

訪問 192.168.2.4/ 如下圖

graphite在centos7上的部署搭建

可以看到已經(jīng)有數(shù)據(jù)采集到了。

?

?

我們可以到grafana里面配下graphite的數(shù)據(jù)源,然后展示數(shù)據(jù),類似如下:

graphite在centos7上的部署搭建

啟動(dòng)brubeck(前臺(tái))? 【一款類似statsd的工具,只是不需要nodejs環(huán)境】

yum install jansson jansson-devel

yum install libmicrohttpd libmicrohttpd-devel

?

git clone https://github.com/github/brubeck.git

?

cd brubeck/

./script/bootstrap

?

?

mkdir /usr/local/brubeck/

?

cp brubeck /usr/local/brubeck/

vim /usr/local/brubeck/brubeck.json? 增加配置文件如下:

?

{

? "sharding" : false,

? "server_name" : "prod-devops-graphite-01",

? "dumpfile" : "/var/lib/brubeck.dump",

? "capacity" : 15,

? "expire" : 20,

? "http" : ":8000",

?

? "backends" : [

??? {

????? "type" : "carbon",

????? "address" : "localhost",

????? "port" : 2003,

????? "frequency" : 10

??? }

? ],

?

? "samplers" : [

??? {

????? "type" : "statsd",

????? "address" : "0.0.0.0",

????? "port" : 8135,

????? "workers" : 8,

? ????"multisock" : true,

????? "multimsg" : 8

??? }

? ]

}

?

【brubeck監(jiān)聽在8135端口上,用于接收業(yè)務(wù)方的打點(diǎn)。2003 端口指的是carbon-cache的端口】

?

./brubeck --config brubeck.json??前臺(tái)啟動(dòng)進(jìn)程

測(cè)試打點(diǎn)到brubeck

echo "db.dba.dble2.front_conn:11111|g" | nc -u -w1 127.0.0.1 8135

修改graphite存儲(chǔ)數(shù)據(jù)的周期

cd /opt/graphite/conf

vim storage-schemas.conf

# Schema definitions for Whisper files. Entries are scanned in order,

# and first match wins. This file is scanned for changes every 60 seconds.

#

#? [name]

#? pattern = regex

#? retentions = timePerPoint:timeToStore, timePerPoint:timeToStore, ...

?

# Carbon's internal metrics. This entry should match what is specified in

# CARBON_METRIC_PREFIX and CARBON_METRIC_INTERVAL settings

[carbon]

pattern = ^carbon\.

retentions = 60:90d

?

[service-sla]

pattern = ^service.sla-pct.*

retentions = 10s:2d,1min:8d,10min:365d

?

[service1-rule]

pattern = ^service1\.timers\.Rule.*

retentions = 10s:5min,1min:1h,10min:7d

?

[service1-ic]

pattern = ^service1\.counters\.IC.*

retentions = 10s:24h,1min:7d

?

[logstash]

pattern = service1\.counters\.logstash.*

retentions = 10s:24h,1min:7d

?

[service1-timers]

pattern = ^service1\.timers\.*

retentions = 10s:5min,1min:1h,10min:1d,1h:365d

?

[service]

pattern = ^service1.*

retentions = 10s:24h,1min:6d,10min:365d

[counter]

pattern = ^.*\.counters\..*

retentions = 10s:24h,1min:7d,10min:30d

?

[timers]

pattern = ^.*\.timers\..*

retentions = 10s:5min,1min:1h,10min:1d,1h:30d

?

[db]

pattern = ^db\.*

retentions = 1min:30d

?

[default_10s_for_1hour]

pattern = .*

retentions = 10s:1h

?

vim storage-aggregation.conf? 內(nèi)容如下:

[min]

pattern = \.min$

xFilesFactor = 0.01

aggregationMethod = min

?

[max]

pattern = \.max$

xFilesFactor = 0.01

aggregationMethod = max

?

[all_sum]

pattern = \.sum$

xFilesFactor = 0.01

aggregationMethod = sum

?

[all_count]

pattern = \.count$

xFilesFactor = 0.01

aggregationMethod = sum

?

[service1_gauges]

pattern = ^service1.gauges

xFilesFactor = 0.01

aggregationMethod = last

?

[service1_counters]

pattern = ^service1\.counters

xFilesFactor = 0.01

aggregationMethod = sum

?

[service1]

pattern = ^service1.*

xFilesFactor = 0.01

?

[default_average]

pattern = .*

xFilesFactor = 0.01

aggregationMethod = average

?

注意,? 修改為上面的2個(gè)文件后, 我們需要重啟 carbon-cache進(jìn)程才能生效。

建議:

1、graphite-web進(jìn)程,建議通過supervisor來控制啟停。

2、個(gè)人認(rèn)為brubeck比statsd更好使,例如有些機(jī)器上可能不便于部署nodejs環(huán)境

?


本文題目:graphite在centos7上的部署搭建
路徑分享:http://weahome.cn/article/gepids.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部