使用apache和nginx部署graphite的相关配置

写在前面

我们在测试的时候,可以使用下面的命令来启动graphite

django-admin runserver 172.16.81.101:8000 --settings=graphite.settings

但是这种启动方式只可用于测试,生产环境下,启动graphite不能用这种方式。

生产环境下需要使用apache或者nginx来部署graphite。

下面我就来介绍一下,要使用apache或者nginx来部署graphite,应该怎么对graphite和apache(nginx)进行配置。

使用apache部署graphite的相关配置

1:修改/opt/graphite文件夹以及文件夹下所有文件的用户和组为apache

#chown apache:apache /opt/graphite

2:生成graphite.wsgi文件

#cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi

3:生成graphite-vhost.conf文件

#cp /opt/graphite/examples/example-graphite-vhost.conf /usr/local/apache2/conf/extra/ graphite-vhost.conf

4:修改apache的配置文件httpd.conf

修改运行apache的用户和组为apache:

在httpd.conf配置文件里面增加下面一条配置信息

5:修改/usr/local/apache2/conf/extra/ graphite-vhost.conf配置文件:

把下面这条配置放开

增加监听端口

修改graphite静态文件路径:

重启apache /usr/local/apache2/bin/apachectl restart

使用浏览器访问 http://ip:8080/就可以看到graphite-web的界面了,如下所示:

 

使用nginx部署graphite的相关配置

1:在/opt/graphite/webapp文件夹下创建graphite.ini文件,这个是uwsgi要使用的配置文件,内容如下:

[uwsgi]
post-buffering = 32768
buffer-size = 32768
chdir=/opt/graphite/webapp/
module=graphite.wsgi
master=true
pidfile=/var/run/graphite.pid
vacuum=true
max-requests=10000
daemonize=/opt/graphite/storage/log/webapp/access.log
processes=4
socket=172.16.81.101:9090
stats=127.0.0.1:1716
listen=1024

使用命令uwsgi -i graphite.ini启动uwsgi,然后浏览器访问http://ip:9090/,如果可以看到graphite-web的界面,说明这个配置文件是没问题的。

这个配置文件也可以是xml格式的,如下所示:

<uwsgi>
    <socket>:8077</socket>
    <chdir>/opt/graphite/webapp</chdir>
    <module>wsgi</module>
    <processes>4</processes> <!-- 进程数 --> 
    <daemonize>uwsgi.log</daemonize>
</uwsgi>

如果是xml格式的配置文件,那么启动uwsgi的命令是uwsgi -x graphite.xml

uwsgi其实也是一个web服务器,可以用来启动django项目。之所以还要使用nginx,主要是使用nginx来处理静态文件的请求。

2:配置nginx.conf文件,打开配置文件/usr/local/nginx/conf/nginx.conf,修改下面两处地方:

uwsgi_pass这项配置内容必须跟上面graphite.ini配置文件里面的socket配置项保持一致。静态文件请求nginx来处理,如果是非静态文件请求,会通过uwsgi_pass这个配置转给uwsgi来处理。

这个是配置graphite静态文件的路径。

重启nginx

使用浏览器访问 http://ip:80/就可以看到graphite-web的界面了。

转载于:https://my.oschina.net/u/1263964/blog/711998

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值