基于ARMV7的ubuntu系统python3安装graphite

之前一直是在我自己的pc上的ubuntu安装graphite,安装过程十分简单

 

 

1、sudo curl -sSL https://get.docker.com/ | sh  安装docker

2、sudo apt-get update

3、sudo service docker start

4、sudo docker run -d --name graphite --restart=always -p 8080:80 -p 2003-2004:2003-2004 -p 2023-2024:2023-2024 -p 8125:8125/udp -p 8126:8126 graphiteapp/graphite-statsd

5、浏览器127.0.0.1:8080 访问

后来因为教研室在做项目,所以要在armv7上的ubuntu系统中安装graphite,之前一直按照最开始的方法安装graphite,但是graphite容器总是显示的是restarting的状态,在网上找了很多办法不行,如果有办法解决这种方法的话,麻烦大家指教一下~

这种方法不行之后,我采用官网的pip方法安装graphite,在此我使用python3的环境下安装的graphite,因为graphite-web中很多东西是在python3的环境下才能安装,所以为了避免混乱,就直接都采用python3的环境.(在新板子上全程使用python2.7的环境)

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

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

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

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

注意:这里的--no-binary=:all:我在安装的时候去掉了,还有在安装carbon的时候应该需要安装apt-get install python-dev(在新板子上没有去掉)

到此安装过程结束,接下来进行配置

1、把/opt/graphite/conf 下的.example结尾的文件 重命名或者拷贝命名(去掉.example)

sudo cp carbon.conf.example carbon.conf

sudo cp storage-schemas.conf.example storage-schemas.conf

sudo cp graphite.wsgi.example graphite.wsgi

2、为apache添加Graphite的虚拟主机

sudo cp /opt/graphite/examples/example-graphite-vhost.conf /etc/apache2/sites-available/graphite-vhost.conf

编辑修改监听端口为8080以及一个WSGISocketPrefix的默认目录

sudo vim /etc/apache2/sites-available/graphite-vhost.conf

WSGISocketPrefix /var/run/apache2/wsgi  (不要忘记这一步啊啊啊啊啊啊)

(这一块要注意的是配置文件中有以下一段代码


    LoadModule wsgi_module modules/mod_wsgi.so

但是在/etc/apache2/目录下是没有这个modules文件夹的,这样就会导致apache直接不能start,所以在改目录下建立文件夹,并且在"/usr/local/lib/python2.7/dist-packages/mod_wsgi-4.4.21-py2.7-linux-aarch64.egg/mod_wsgi/server/mod_wsgi.so"中将mod_wsgi.so文件复制在modules里边!!)

并且还得在/etc/apache2/ports.conf中listen80改为8080

/etc/apache2/sites-enable下建立该配置文件的软链

cd /etc/apache2/sites-enabled

sudo ln -s ../sites-available/graphite-vhost.conf graphite-vhost.conf

(我在这块出现了很多的问题,主要是找不到mod_wsgi.so这个文件,在网上查找资料之后,发现apache2需要先配置一下,django框架才能跑起来

apache2+mod_wsgi+django配置:

apt-get install apache2-dev python2.7-dev #python2.7

wget -c  https://github.com/GrahamDumpleton/mod_wsgi/archive/4.4.21.tar.gz

tar zxfv 4.4.21.tar.gz

cd mod_wsgi-4.4.21/

./configure  对mod_wsgi包进行编译

make

make install

编译成功之后就会发现,mod_wsgi.so文件出现了(在"/usr/local/lib/python2.7/dist-packages/mod_wsgi-4.4.21-py2.7-linux-aarch64.egg/mod_wsgi/server/mod_wsgi.so"中)

sudo /etc/init.d/apache2 start    开启apache服务器

3、初始化数据库

cd /opt/graphite/webapp/graphite/

sudo python manage.py migrate 

在这块运行上边的命令一直出现no module named graphite.settings,原因就是没有执行最开始的第一步export PYTHONPATH="/opt/graphite/lib/:/opt/graphite/webapp/")

我安装的graphite-web是没找到manage.py的文件,后来我自己在别的项目里边找到了一个,改了一个graphite-web自己的,反正是可以用的,大家可以参考一下:

manage.py

(manage.py文件在通过使用source方法的时候找到了自动生成的manage.py,手动复制到该目录底下就好)

#!/usr/bin/env python
import os
import sys


if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "graphite.settings")
    os.environ.setdefault('GRAPHITE_SETTINGS_MODULE', 'graphite.local_settings')

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

sudo chown -R www-data:www-data /opt/graphite/storage/ 
sudo cp local_settings.py.example local_settings.py
sudo /etc/init.d/apache2 restart #重启apache

4、启动Carbon

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

在启动carbon这里也会遇到新的问题,

启动carbon之后会出现TypeError: NewBase must define encode的问题, pip install six --upgrade之后再重启就好

启动carbon之后可能会出现

An error has occurred: b"twisted.internet.error.CannotListenError: Couldn't listen on 0.0.0.0:7002: [Errno 98] Address alre"

Please look at log file for more information.

的问题,这是说说明7002这个端口被占用,所以先lsof -i:7002,然后kill掉就行

最后就是访问ip+:8080访问graphite-web,遗憾的是我的web还是有问题,我没找到解决方法,但是我安装grafana链接graphite数据源发现是可以收集到指标的,就是graphite-web这边有问题,主页出了右上角有documentation,dashboard等,dashboard点进去是drop to merge,试了把debug=true去掉注释,还试了修改增加Alias /content/ /opt/graphite/webapp/content/到 /etc/apache2/sites-enabled/graphite.conf并且注释掉Alias /static/ /opt/graphite/webapp/content/还是不行,希望哪位大佬指教一下!!

最后,基于armv7(arm64) ubuntu(debian)下的diamond,grafana安装请见下篇文章。

 

问题1、在安装graphite-web的时候出现安装cairocffi时失败,此时采用pip install cairocffi==0.6,安装时会出现ERROR: Package libffi was not found in the pkg-config search path.使用apt-get install  libffi-dev解决该问题

问题2、出现所有服务打开但是收集不到数据,需要重新启动carbon和apache的服务

你可能感兴趣的:(基于ARMV7的ubuntu系统python3安装graphite)