graphite安装(一键搞定版)

article/2025/9/20 17:03:19

一、python部分:

0、系统:

$ cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 

1、检查系统python是否2.7以上(最新graphite需要python至少2.7):

$ python -V
Python 2.7.5

2、安装pip:

yum install python-pip
$ pip -V
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

这里安装后的版本是8,后面还需要再升级一下pip,因为安装cairocffi时需要。

二、下载相关源码、并且安装:

1、git下载graphite相关源码下载、安装:

cd /opt
下载源码:
git clone https://github.com/graphite-project/graphite-web.git
git clone https://github.com/graphite-project/carbon.git
git clone https://github.com/graphite-project/whisper.git然后通过python setup.py install安装:
cd /opt/graphite-web 
python setup.py install 
cd carbon
python setup.py install
cd whisper
python setup.py install

这时在/opt下多了一个graphite目录,/opt目录如下

drwxr-xr-x  9 root root 4096 Sep 17 10:30 carbon
drwxr-xr-x  9 root root   92 Sep 17 11:22 graphite
drwxr-xr-x 11 root root 4096 Sep 17 10:29 graphite-web
drwxr-xr-x  3 root root   19 Sep 17 09:32 soft
drwxr-xr-x  6 root root 4096 Sep 17 10:30 whisper

2、检查依赖:

cd /opt/graphite-web
$ python check-dependencies.py
[REQUIRED] Unable to import the 'cairocffi' module, attempting to fall back to pycairo
[REQUIRED] Unable to import the 'cairo' module, do you have pycairo installed for python 2?
[REQUIRED] Unable to import the 'django' module, do you have Django installed for python 2?
[REQUIRED] Unable to import the 'pytz' module, do you have pytz module installed for python 2?
[REQUIRED] Unable to import the 'pyparsing' module, do you have pyparsing module installed for python 2?
[REQUIRED] Unable to import the 'tagging' module, do you have django-tagging installed for python 2?
[OPTIONAL] Unable to import the 'memcache' module, do you have python-memcached installed for python 2? This feature is not required but greatly improves performance.
[OPTIONAL] Unable to import the 'ldap' module, do you have python-ldap installed for python 2? Without python-ldap, you will not be able to use LDAP authentication in the graphite webapp.
[OPTIONAL] Unable to import the 'txamqp' module, this is required if you want to use AMQP as an input to Carbon. Note that txamqp requires python 2.5 or greater.
[OPTIONAL] Unable to import the 'python-rrdtool' module, this is required for reading RRD.
[OPTIONAL] Unable to import the 'whitenoise' module. This is useful for serving static files.
[OPTIONAL] Unable to import the 'pyhash' module. This is useful for fnv1_ch hashing support.
6 optional dependencies not met. Please consider the optional items before proceeding.
5 necessary dependencies not met. Graphite will not function until these dependencies are fulfilled.

3、安装依赖cairocffi:

1)pip install cairocffi安装,会遇到如下问题:

$ pip install cairocffi 
Collecting cairocffiDownloading https://files.pythonhosted.org/packages/62/be/ad4d422b6f38d99b09ad6d046ab725e8ccac5fefd9ca256ca35a80dbf3c6/cairocffi-0.9.0.tar.gz (84kB)100% |████████████████████████████████| 92kB 85kB/s Complete output from command python setup.py egg_info:Package libffi was not found in the pkg-config search path.Perhaps you should add the directory containing `libffi.pc'to the PKG_CONFIG_PATH environment variableNo package 'libffi' foundPackage libffi was not found in the pkg-config search path.Perhaps you should add the directory containing `libffi.pc'to the PKG_CONFIG_PATH environment variableNo package 'libffi' foundPackage libffi was not found in the pkg-config search path.Perhaps you should add the directory containing `libffi.pc'to the PKG_CONFIG_PATH environment variableNo package 'libffi' foundPackage libffi was not found in the pkg-config search path.Perhaps you should add the directory containing `libffi.pc'to the PKG_CONFIG_PATH environment variableNo package 'libffi' foundPackage libffi was not found in the pkg-config search path.Perhaps you should add the directory containing `libffi.pc'to the PKG_CONFIG_PATH environment variableNo package 'libffi' foundc/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory#include <Python.h>^compilation terminated.Traceback (most recent call last):File "<string>", line 1, in <module>File "/tmp/pip-build-YUSkTq/cairocffi/setup.py", line 51, in <module>'test': ['pytest-runner', 'pytest-cov'],File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup_setup_distribution = dist = klass(attrs)File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 265, in __init__self.fetch_build_eggs(attrs.pop('setup_requires'))File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 289, in fetch_build_eggsparse_requirements(requires), installer=self.fetch_build_eggFile "/usr/lib/python2.7/site-packages/pkg_resources.py", line 618, in resolvedist = best[req.key] = env.best_match(req, self, installer)File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 862, in best_matchreturn self.obtain(req, installer) # try and download/installFile "/usr/lib/python2.7/site-packages/pkg_resources.py", line 874, in obtainreturn installer(requirement)File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 339, in fetch_build_eggreturn cmd.easy_install(req)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 623, in easy_installreturn self.install_item(spec, dist.location, tmpdir, deps)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 653, in install_itemdists = self.install_eggs(spec, download, tmpdir)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 849, in install_eggsreturn self.build_and_install(setup_script, setup_base)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1130, in build_and_installself.run_setup(setup_script, setup_base, args)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1118, in run_setupraise DistutilsError("Setup script exited with %s" % (v.args[0],))distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-YUSkTq/cairocffi/
You are using pip version 8.1.2, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

解决:根据提示,我们需要升级pip。

$ pip install --upgrade pip
$ pip -V
pip 18.0 from /usr/lib/python2.7/site-packages/pip (python 2.7)

2)继续pip install cairocffi安装,可能会遇到如下问题:

$ pip install cairocffi
Collecting cairocffiUsing cached https://files.pythonhosted.org/packages/62/be/ad4d422b6f38d99b09ad6d046ab725e8ccac5fefd9ca256ca35a80dbf3c6/cairocffi-0.9.0.tar.gzComplete output from command python setup.py egg_info:Package libffi was not found in the pkg-config search path.Perhaps you should add the directory containing `libffi.pc'to the PKG_CONFIG_PATH environment variableNo package 'libffi' foundPackage libffi was not found in the pkg-config search path.Perhaps you should add the directory containing `libffi.pc'to the PKG_CONFIG_PATH environment variableNo package 'libffi' foundPackage libffi was not found in the pkg-config search path.Perhaps you should add the directory containing `libffi.pc'to the PKG_CONFIG_PATH environment variableNo package 'libffi' foundPackage libffi was not found in the pkg-config search path.Perhaps you should add the directory containing `libffi.pc'to the PKG_CONFIG_PATH environment variableNo package 'libffi' foundPackage libffi was not found in the pkg-config search path.Perhaps you should add the directory containing `libffi.pc'to the PKG_CONFIG_PATH environment variableNo package 'libffi' foundc/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory#include <Python.h>^compilation terminated.Traceback (most recent call last):File "<string>", line 1, in <module>File "/tmp/pip-install-RHjhWE/cairocffi/setup.py", line 51, in <module>'test': ['pytest-runner', 'pytest-cov'],File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup_setup_distribution = dist = klass(attrs)File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 265, in __init__self.fetch_build_eggs(attrs.pop('setup_requires'))File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 289, in fetch_build_eggsparse_requirements(requires), installer=self.fetch_build_eggFile "/usr/lib/python2.7/site-packages/pkg_resources.py", line 618, in resolvedist = best[req.key] = env.best_match(req, self, installer)File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 862, in best_matchreturn self.obtain(req, installer) # try and download/installFile "/usr/lib/python2.7/site-packages/pkg_resources.py", line 874, in obtainreturn installer(requirement)File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 339, in fetch_build_eggreturn cmd.easy_install(req)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 623, in easy_installreturn self.install_item(spec, dist.location, tmpdir, deps)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 653, in install_itemdists = self.install_eggs(spec, download, tmpdir)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 849, in install_eggsreturn self.build_and_install(setup_script, setup_base)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1130, in build_and_installself.run_setup(setup_script, setup_base, args)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1118, in run_setupraise DistutilsError("Setup script exited with %s" % (v.args[0],))distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-RHjhWE/cairocffi/

解决:

$ yum install libffi-devel

3)继续安装,可能会遇到如下问题:

$ pip install cairocffi
Collecting cairocffiUsing cached https://files.pythonhosted.org/packages/62/be/ad4d422b6f38d99b09ad6d046ab725e8ccac5fefd9ca256ca35a80dbf3c6/cairocffi-0.9.0.tar.gzComplete output from command python setup.py egg_info:c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory#include <Python.h>^compilation terminated.Traceback (most recent call last):File "<string>", line 1, in <module>File "/tmp/pip-install-uMxkrR/cairocffi/setup.py", line 51, in <module>'test': ['pytest-runner', 'pytest-cov'],File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup_setup_distribution = dist = klass(attrs)File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 265, in __init__self.fetch_build_eggs(attrs.pop('setup_requires'))File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 289, in fetch_build_eggsparse_requirements(requires), installer=self.fetch_build_eggFile "/usr/lib/python2.7/site-packages/pkg_resources.py", line 618, in resolvedist = best[req.key] = env.best_match(req, self, installer)File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 862, in best_matchreturn self.obtain(req, installer) # try and download/installFile "/usr/lib/python2.7/site-packages/pkg_resources.py", line 874, in obtainreturn installer(requirement)File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 339, in fetch_build_eggreturn cmd.easy_install(req)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 623, in easy_installreturn self.install_item(spec, dist.location, tmpdir, deps)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 653, in install_itemdists = self.install_eggs(spec, download, tmpdir)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 849, in install_eggsreturn self.build_and_install(setup_script, setup_base)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1130, in build_and_installself.run_setup(setup_script, setup_base, args)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1118, in run_setupraise DistutilsError("Setup script exited with %s" % (v.args[0],))distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-uMxkrR/cairocffi/

解决:

yum install python-devel

至此,一般就可以成功安装cairocffi了。

$ pip install cairocffi
Collecting cairocffiUsing cached https://files.pythonhosted.org/packages/62/be/ad4d422b6f38d99b09ad6d046ab725e8ccac5fefd9ca256ca35a80dbf3c6/cairocffi-0.9.0.tar.gz
Collecting cffi>=1.1.0 (from cairocffi)Downloading https://files.pythonhosted.org/packages/14/dd/3e7a1e1280e7d767bd3fa15791759c91ec19058ebe31217fe66f3e9a8c49/cffi-1.11.5-cp27-cp27mu-manylinux1_x86_64.whl (407kB)100% |████████████████████████████████| 409kB 128kB/s 
Collecting pycparser (from cffi>=1.1.0->cairocffi)Downloading https://files.pythonhosted.org/packages/8c/2d/aad7f16146f4197a11f8e91fb81df177adcc2073d36a17b1491fd09df6ed/pycparser-2.18.tar.gz (245kB)100% |████████████████████████████████| 256kB 137kB/s 
Installing collected packages: pycparser, cffi, cairocffiRunning setup.py install for pycparser ... doneRunning setup.py install for cairocffi ... done
Successfully installed cairocffi-0.9.0 cffi-1.11.5 pycparser-2.18

4)有的时候,在上面依赖都解决后安装时会遇到网络问题:

$ pip install cairocffi
Collecting cairocffiUsing cached https://files.pythonhosted.org/packages/62/be/ad4d422b6f38d99b09ad6d046ab725e8ccac5fefd9ca256ca35a80dbf3c6/cairocffi-0.9.0.tar.gzComplete output from command python setup.py egg_info:Installed /tmp/pip-install-TFaywH/cairocffi/cffi-1.11.5-py2.7-linux-x86_64.eggSearching for pycparserReading https://pypi.python.org/simple/pycparser/Best match: pycparser 2.18Downloading https://files.pythonhosted.org/packages/8c/2d/aad7f16146f4197a11f8e91fb81df177adcc2073d36a17b1491fd09df6ed/pycparser-2.18.tar.gz#sha256=99a8ca03e29851d96616ad0404b4aad7d9ee16f25c9f9708a11faf2810f7b226Traceback (most recent call last):File "<string>", line 1, in <module>File "/tmp/pip-install-TFaywH/cairocffi/setup.py", line 51, in <module>'test': ['pytest-runner', 'pytest-cov'],File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup_setup_distribution = dist = klass(attrs)File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 265, in __init__self.fetch_build_eggs(attrs.pop('setup_requires'))File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 289, in fetch_build_eggsparse_requirements(requires), installer=self.fetch_build_eggFile "/usr/lib/python2.7/site-packages/pkg_resources.py", line 618, in resolvedist = best[req.key] = env.best_match(req, self, installer)File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 862, in best_matchreturn self.obtain(req, installer) # try and download/installFile "/usr/lib/python2.7/site-packages/pkg_resources.py", line 874, in obtainreturn installer(requirement)File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 339, in fetch_build_eggreturn cmd.easy_install(req)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 611, in easy_installself.local_indexFile "/usr/lib/python2.7/site-packages/setuptools/package_index.py", line 598, in fetch_distributionreturn dist.clone(location=self.download(dist.location, tmpdir))File "/usr/lib/python2.7/site-packages/setuptools/package_index.py", line 515, in downloadfound = self._download_url(scheme.group(1), spec, tmpdir)File "/usr/lib/python2.7/site-packages/setuptools/package_index.py", line 762, in _download_urlreturn self._attempt_download(url, filename)File "/usr/lib/python2.7/site-packages/setuptools/package_index.py", line 768, in _attempt_downloadheaders = self._download_to(url, filename)File "/usr/lib/python2.7/site-packages/setuptools/package_index.py", line 662, in _download_tofp = self.open_url(url)File "/usr/lib/python2.7/site-packages/setuptools/package_index.py", line 716, in open_url% (url, v.reason))distutils.errors.DistutilsError: Download error for https://files.pythonhosted.org/packages/8c/2d/aad7f16146f4197a11f8e91fb81df177adcc2073d36a17b1491fd09df6ed/pycparser-2.18.tar.gz#sha256=99a8ca03e29851d96616ad0404b4aad7d9ee16f25c9f9708a11faf2810f7b226: [Errno 101] Network is unreachable----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-TFaywH/cairocffi/

解决:

根据报错中的连接地址手工下载pycparser-2.18.tar.gz,然后解压python setup.py install 执行后即可;还有可能cffi-1.11.5.tar.gz无法下载,同样根据报错连接地址手工下载,然后解压python setup.py install 执行后即可。

5)安装完pip install cairocffi后,再次执行$ python check-dependencies.py 检查依赖:

$ python check-dependencies.py
Traceback (most recent call last):File "check-dependencies.py", line 31, in <module>import cairocffi as cairoFile "/usr/lib/python2.7/site-packages/cairocffi/__init__.py", line 41, in <module>cairo = dlopen(ffi, 'cairo', 'cairo-2', 'cairo-gobject-2')File "/usr/lib/python2.7/site-packages/cairocffi/__init__.py", line 38, in dlopenraise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2

我们发现报错了,在安装cairocffi之前还没有报错。解决如下:

yum install cairo-devel

再次执行

$ python check-dependencies.py 
[REQUIRED] Unable to import the 'django' module, do you have Django installed for python 2?
[REQUIRED] Unable to import the 'pytz' module, do you have pytz module installed for python 2?
[REQUIRED] Unable to import the 'pyparsing' module, do you have pyparsing module installed for python 2?
[REQUIRED] Unable to import the 'tagging' module, do you have django-tagging installed for python 2?
[OPTIONAL] Unable to import the 'memcache' module, do you have python-memcached installed for python 2? This feature is not required but greatly improves performance.
[OPTIONAL] Unable to import the 'ldap' module, do you have python-ldap installed for python 2? Without python-ldap, you will not be able to use LDAP authentication in the graphite webapp.
[OPTIONAL] Unable to import the 'txamqp' module, this is required if you want to use AMQP as an input to Carbon. Note that txamqp requires python 2.5 or greater.
[OPTIONAL] Unable to import the 'python-rrdtool' module, this is required for reading RRD.
[OPTIONAL] Unable to import the 'whitenoise' module. This is useful for serving static files.
[OPTIONAL] Unable to import the 'pyhash' module. This is useful for fnv1_ch hashing support.
6 optional dependencies not met. Please consider the optional items before proceeding.
4 necessary dependencies not met. Graphite will not function until these dependencies are fulfilled.

4、安装其他依赖:

1)django:

查看官网 https://graphite.readthedocs.io/en/latest/install.html#dependencies ,至少需要django1.8

pip install Django==1.8

2)安装pytz:

pip install pytz
Collecting pytzDownloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB)100% |████████████████████████████████| 512kB 242kB/s 
Installing collected packages: pytz
Successfully installed pytz-2018.5

3)安装pyparsing:

$ pip install pyparsing
Collecting pyparsingDownloading https://files.pythonhosted.org/packages/6a/8a/718fd7d3458f9fab8e67186b00abdd345b639976bc7fb3ae722e1b026a50/pyparsing-2.2.0-py2.py3-none-any.whl (56kB)100% |████████████████████████████████| 61kB 131kB/s 
Installing collected packages: pyparsing
Successfully installed pyparsing-2.2.0

4)安装jdango-tagging:

$ pip install django-tagging
Collecting django-taggingDownloading https://files.pythonhosted.org/packages/5e/fc/9d095602bf5d2edcbc2c5721e3d243028544575a145d84ca1ec50f7e2fc1/django_tagging-0.4.6-py2.py3-none-any.whl
Installing collected packages: django-tagging
Successfully installed django-tagging-0.4.6

然后再次检查依赖:

$ python check-dependencies.py 
[OPTIONAL] Unable to import the 'memcache' module, do you have python-memcached installed for python 2? This feature is not required but greatly improves performance.
[OPTIONAL] Unable to import the 'ldap' module, do you have python-ldap installed for python 2? Without python-ldap, you will not be able to use LDAP authentication in the graphite webapp.
[OPTIONAL] Unable to import the 'txamqp' module, this is required if you want to use AMQP as an input to Carbon. Note that txamqp requires python 2.5 or greater.
[OPTIONAL] Unable to import the 'python-rrdtool' module, this is required for reading RRD.
[OPTIONAL] Unable to import the 'whitenoise' module. This is useful for serving static files.
[OPTIONAL] Unable to import the 'pyhash' module. This is useful for fnv1_ch hashing support.
6 optional dependencies not met. Please consider the optional items before proceeding.
3 necessary dependencies not met. Graphite will not function until these dependencies are fulfilled.

三、配置:

1、重命名配置文件:

进入到/opt/graphite/conf目录下,里面有很多例子,我们需要把后缀example去掉

cd /opt/graphite/conf
cp aggregation-rules.conf.example aggregation-rules.conf
cp blacklist.conf.example blacklist.conf
cp carbon.conf.example carbon.conf
cp carbon.amqp.conf.example carbon.amqp.conf
cp relay-rules.conf.example relay-rules.conf
cp rewrite-rules.conf.example rewrite-rules.conf
cp storage-schemas.conf.example storage-schemas.conf
cp storage-aggregation.conf.example storage-aggregation.conf
cp whitelist.conf.example whitelist.conf

2、启动carbon-cache:

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

1)启动报错:

$ ./carbon-cache.py start
Traceback (most recent call last):File "./carbon-cache.py", line 28, in <module>from carbon.util import run_twistd_plugin  # noqaFile "/opt/graphite/lib/carbon/util.py", line 15, in <module>from twisted.python.util import initgroups
ImportError: No module named twisted.python.util

解决:安装twisted

$ pip install twisted
Collecting twistedDownloading https://files.pythonhosted.org/packages/90/50/4c315ce5d119f67189d1819629cae7908ca0b0a6c572980df5cc6942bc22/Twisted-18.7.0.tar.bz2 (3.1MB)100% |████████████████████████████████| 3.1MB 133kB/s 
Collecting zope.interface>=4.4.2 (from twisted)Downloading https://files.pythonhosted.org/packages/ac/8a/657532df378c2cd2a1fe6b12be3b4097521570769d4852ec02c24bd3594e/zope.interface-4.5.0.tar.gz (151kB)100% |████████████████████████████████| 153kB 89kB/s 
Collecting constantly>=15.1 (from twisted)Downloading https://files.pythonhosted.org/packages/b9/65/48c1909d0c0aeae6c10213340ce682db01b48ea900a7d9fce7a7910ff318/constantly-15.1.0-py2.py3-none-any.whl
Collecting incremental>=16.10.1 (from twisted)Downloading https://files.pythonhosted.org/packages/f5/1d/c98a587dc06e107115cf4a58b49de20b19222c83d75335a192052af4c4b7/incremental-17.5.0-py2.py3-none-any.whl
Collecting Automat>=0.3.0 (from twisted)Downloading https://files.pythonhosted.org/packages/a3/86/14c16bb98a5a3542ed8fed5d74fb064a902de3bdd98d6584b34553353c45/Automat-0.7.0-py2.py3-none-any.whl
Collecting hyperlink>=17.1.1 (from twisted)Downloading https://files.pythonhosted.org/packages/a7/b6/84d0c863ff81e8e7de87cff3bd8fd8f1054c227ce09af1b679a8b17a9274/hyperlink-18.0.0-py2.py3-none-any.whl
Collecting PyHamcrest>=1.9.0 (from twisted)Downloading https://files.pythonhosted.org/packages/9a/d5/d37fd731b7d0e91afcc84577edeccf4638b4f9b82f5ffe2f8b62e2ddc609/PyHamcrest-1.9.0-py2.py3-none-any.whl (52kB)100% |████████████████████████████████| 61kB 61kB/s 
Collecting attrs>=17.4.0 (from twisted)Downloading https://files.pythonhosted.org/packages/3a/e1/5f9023cc983f1a628a8c2fd051ad19e76ff7b142a0faf329336f9a62a514/attrs-18.2.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /usr/lib/python2.7/site-packages (from zope.interface>=4.4.2->twisted) (0.9.8)
Collecting six (from Automat>=0.3.0->twisted)Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting idna>=2.5 (from hyperlink>=17.1.1->twisted)Downloading https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl (58kB)100% |████████████████████████████████| 61kB 19kB/s 
Installing collected packages: zope.interface, constantly, incremental, attrs, six, Automat, idna, hyperlink, PyHamcrest, twistedRunning setup.py install for zope.interface ... doneRunning setup.py install for twisted ... done
Successfully installed Automat-0.7.0 PyHamcrest-1.9.0 attrs-18.2.0 constantly-15.1.0 hyperlink-18.0.0 idna-2.7 incremental-17.5.0 six-1.11.0 twisted-18.7.0 zope.interface-4.5.0

2)在pip install twisted的时候,有可能网络问题无法下载依赖:

Collecting twistedRetrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x3357a50>: Failed to establish a new connection: [Errno 110] Connection timed out',)': /packages/90/50/4c315ce5d119f67189d1819629cae7908ca0b0a6c572980df5cc6942bc22/Twisted-18.7.0.tar.bz2Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x3357d50>: Failed to establish a new connection: [Errno 110] Connection timed out',)': /packages/90/50/4c315ce5d119f67189d1819629cae7908ca0b0a6c572980df5cc6942bc22/Twisted-18.7.0.tar.bz2Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x3357f50>: Failed to establish a new connection: [Errno 110] Connection timed out',)': /packages/90/50/4c315ce5d119f67189d1819629cae7908ca0b0a6c572980df5cc6942bc22/Twisted-18.7.0.tar.bz2Downloading https://files.pythonhosted.org/packages/90/50/4c315ce5d119f67189d1819629cae7908ca0b0a6c572980df5cc6942bc22/Twisted-18.7.0.tar.bz2 (3.1MB)100% |████████████████████████████████| 3.1MB 5.2MB/s Complete output from command python setup.py egg_info:Traceback (most recent call last):File "<string>", line 1, in <module>File "/tmp/pip-install-QrXqMw/twisted/setup.py", line 20, in <module>setuptools.setup(**_setup["getSetupArgs"]())File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup_setup_distribution = dist = klass(attrs)File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 265, in __init__self.fetch_build_eggs(attrs.pop('setup_requires'))File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 289, in fetch_build_eggsparse_requirements(requires), installer=self.fetch_build_eggFile "/usr/lib/python2.7/site-packages/pkg_resources.py", line 618, in resolvedist = best[req.key] = env.best_match(req, self, installer)File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 862, in best_matchreturn self.obtain(req, installer) # try and download/installFile "/usr/lib/python2.7/site-packages/pkg_resources.py", line 874, in obtainreturn installer(requirement)File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 339, in fetch_build_eggreturn cmd.easy_install(req)File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 611, in easy_installself.local_indexFile "/usr/lib/python2.7/site-packages/setuptools/package_index.py", line 598, in fetch_distributionreturn dist.clone(location=self.download(dist.location, tmpdir))File "/usr/lib/python2.7/site-packages/setuptools/package_index.py", line 515, in downloadfound = self._download_url(scheme.group(1), spec, tmpdir)File "/usr/lib/python2.7/site-packages/setuptools/package_index.py", line 762, in _download_urlreturn self._attempt_download(url, filename)File "/usr/lib/python2.7/site-packages/setuptools/package_index.py", line 768, in _attempt_downloadheaders = self._download_to(url, filename)File "/usr/lib/python2.7/site-packages/setuptools/package_index.py", line 662, in _download_tofp = self.open_url(url)File "/usr/lib/python2.7/site-packages/setuptools/package_index.py", line 716, in open_url% (url, v.reason))distutils.errors.DistutilsError: Download error for https://files.pythonhosted.org/packages/8f/26/02c4016aa95f45479eea37c90c34f8fab6775732ae62587a874b619ca097/incremental-17.5.0.tar.gz#sha256=7b751696aaf36eebfab537e458929e194460051ccad279c72b755a167eebd4b3: [Errno 101] Network is unreachable----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-QrXqMw/twisted/

解决:根据报错提示连接地址,手动下载incremental-17.5.0.tar.gz,然后python setup.py install

至此,可以成功启动carbon。

$ ./carbon-cache.py start
Starting carbon-cache (instance a)

检查进程:

#netstat -nap | grep 2003

发送数据:

# yum install nc
echo "carbon.agents.graphite-tutorial.metricsReceived 28198 `date +%s`" | nc localhost 2003

3、同步数据:

1)第一种方式:

cd /opt/graphite-web/webapp/
cp manage.py /opt/graphite/webapp/
cd /opt/graphite/webapp/
$ python manage.py syncdb

在执行过程中可以设置用户名密码(用于在web界面上登录)

:通过源码安装graphite,manage.py没有被放到/opt/graphite/下,需要手动拷贝过去。

2)第二种方式:

PYTHONPATH=/opt/graphite/webapp django-admin.py migrate --settings=graphite.settings --run-syncdb
Could not import graphite.local_settings, using defaults!
/opt/graphite/webapp/graphite/settings.py:332: UserWarning: SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better securitywarn('SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security')
Operations to perform:Synchronize unmigrated apps: functions, render, staticfiles, whitelist, metrics, composer, browserApply all migrations: account, sessions, admin, tags, auth, url_shortener, contenttypes, dashboard, events, tagging
Synchronizing apps without migrations:Creating tables...Running deferred SQL...Installing custom SQL...
Running migrations:Rendering model states... DONEApplying contenttypes.0001_initial... OKApplying auth.0001_initial... OKApplying account.0001_initial... OKApplying admin.0001_initial... OKApplying contenttypes.0002_remove_content_type_name... OKApplying auth.0002_alter_permission_name_max_length... OKApplying auth.0003_alter_user_email_max_length... OKApplying auth.0004_alter_user_username_opts... OKApplying auth.0005_alter_user_last_login_null... OKApplying auth.0006_require_contenttypes_0002... OKApplying dashboard.0001_initial... OKApplying events.0001_initial... OKApplying sessions.0001_initial... OKApplying tagging.0001_initial... OKApplying tagging.0002_on_delete... OKApplying tagging.0003_adapt_max_tag_length... OKApplying tags.0001_initial... OKApplying url_shortener.0001_initial... OK

注:执行django-admin.py syncdb --settings=graphite.settings提示找不到syncdb,原因是django 1.7以后需要使用 migrate

四、启动graphite:

graphite指的是一个大的技术集合,她依赖了carbon、whisper、graphite-web三个组件,上面我们已经把carbon启动了。这一步启动graphite其实指的是启动graphite-web,graphite-web是一个python写的web项目,使用了djiango框架。此外,graphite-web除了提供界面外,还提供了很多restful的api接口(比如查询数据、聚合数据等)

1、最简单的方式启动:

# cd /opt/graphite
# PYTHONPATH=`pwd`/storage/whisper ./bin/run-graphite-devel-server.py --port=8085 --libs=`pwd`/webapp /opt/graphite 1>/opt/graphite/storage/log/webapp/process.log 2>&1 &
# tail -f /opt/graphite/storage/log/webapp/process.log

1)可能会遇到如下错误:

Traceback (most recent call last):File "/usr/lib64/python2.7/wsgiref/handlers.py", line 85, in runself.result = application(self.environ, self.start_response)File "/usr/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__response = self.get_response(request)File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in get_responseresponse = self.handle_uncaught_exception(request, resolver, sys.exc_info())File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 264, in handle_uncaught_exceptionif resolver.urlconf_module is None:File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", line 396, in urlconf_moduleself._urlconf_module = import_module(self.urlconf_name)File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module__import__(name)File "/opt/graphite/webapp/graphite/urls.py", line 22, in <module>url('^render', include('graphite.render.urls')),File "/usr/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 33, in includeurlconf_module = import_module(urlconf_module)File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module__import__(name)File "/opt/graphite/webapp/graphite/render/urls.py", line 16, in <module>from . import viewsFile "/opt/graphite/webapp/graphite/render/views.py", line 28, in <module>from graphite.storage import extractForwardHeadersFile "/opt/graphite/webapp/graphite/storage.py", line 27, in <module>from graphite.readers import MultiReaderFile "/opt/graphite/webapp/graphite/readers/__init__.py", line 4, in <module>from graphite.readers.whisper import WhisperReader, GzippedWhisperReader  # noqa # pylint: disable=unused-importFile "/opt/graphite/webapp/graphite/readers/whisper.py", line 9, in <module>from scandir import scandir, stat  # noqa # pylint: disable=unused-import
ImportError: No module named scandir

解决:

pip install scandir

2)再次启动,可能会遇到如下错误:

ImportError: No module named urllib3
解决:
pip install urllib3

3)解决上面依赖后,即可成功启动graphite-web:

我们看启动命令是通过默认的run-graphite-devel-server.py启动python web程序,同时指定了8085端口。在高版本的graphite-web中,通过这种方式启动,在浏览器中输入http:ip:8085,无法访问静态图片、页面等。查看日志,发现404

[17/Sep/2018 03:23:02]"GET / HTTP/1.1" 200 598
[17/Sep/2018 03:23:02]"GET /browser/header HTTP/1.1" 200 1166
[17/Sep/2018 03:23:02]"GET /composer? HTTP/1.1" 200 1643
[17/Sep/2018 03:23:03]"GET /static/img/carbon-fiber.png HTTP/1.1" 404 101
[17/Sep/2018 03:23:03]"GET /static/img/graphite-logo.png HTTP/1.1" 404 102
[17/Sep/2018 03:23:03]"GET /static/js/ext/resources/css/ext-all.css HTTP/1.1" 404 113
[17/Sep/2018 03:23:03]"GET /static/js/browser.js HTTP/1.1" 404 94
[17/Sep/2018 03:23:03]"GET /static/js/composer_widgets.js HTTP/1.1" 404 103
[17/Sep/2018 03:23:03]"GET /static/js/ext/ext-all.js HTTP/1.1" 404 98
[17/Sep/2018 03:23:03]"GET /static/js/ext/adapter/ext/ext-base.js HTTP/1.1" 404 111
[17/Sep/2018 03:23:03]"GET /static/js/composer.js HTTP/1.1" 404 95
[17/Sep/2018 03:23:03]"GET /static/js/completer.js HTTP/1.1" 404 96
[17/Sep/2018 03:23:03]"GET /static/js/ext/ext-all.js HTTP/1.1" 404 98
[17/Sep/2018 03:23:03]"GET /static/js/browser.js HTTP/1.1" 404 94
[17/Sep/2018 03:23:03]"GET /static/js/composer_widgets.js HTTP/1.1" 404 103
[17/Sep/2018 03:23:03]"GET /static/js/composer.js HTTP/1.1" 404 95
[17/Sep/2018 03:23:03]"GET /static/js/completer.js HTTP/1.1" 404 96

我们通过下面命令来收集静态信息:

$  PYTHONPATH=/opt/graphite/webapp django-admin.py collectstatic --noinput --settings=graphite.settings

$  PYTHONPATH=/opt/graphite/webapp django-admin.py collectstatic --noinput --settings=graphite.settings
/opt/graphite/webapp/graphite/settings.py:332: UserWarning: SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better securitywarn('SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security')
Copying '/opt/graphite/webapp/content/js/browser.js'
Copying '/opt/graphite/webapp/content/js/completer.js'
Copying '/opt/graphite/webapp/content/js/composer.js'
Copying '/opt/graphite/webapp/content/js/composer_widgets.js'
Copying '/opt/graphite/webapp/content/js/dashboard.js'
Copying '/opt/graphite/webapp/content/js/ext/ext-all-debug.js'
Copying '/opt/graphite/webapp/content/js/ext/ext-all.js'
Copying '/opt/graphite/webapp/content/js/ext/resources/images/default/gradient-bg.gif'
....

执行该命令后会在/opt/graphite下生成static目录,里面包含了js、css、html等内容,如下:

$ pwd
/opt/graphite/static
$ ll
drwxr-xr-x 5 root root   35 Sep 17 11:22 admin
drwxr-xr-x 4 root root  156 Sep 17 11:22 css
drwxr-xr-x 2 root root   53 Sep 17 11:22 html
drwxr-xr-x 2 root root 4096 Sep 17 11:22 img
drwxr-xr-x 4 root root  125 Sep 17 11:22 js

执行了这个让然无法访问静态文件,我们通过uwsgi方式来解决。

2、启动方式二:

除了上面的方式启动graphite-web,还可以用下面的方式:

PYTHONPATH=/opt/graphite/webapp/ django-admin.py runserver 10.39.12.24:8085 --settings=graphite.settings

这里使用了djanggo-admin,本质和上面的一样。同样,也是无法访问到静态资源。

3、使用uwsgi+nginx方式启动

上面两种方式都是测试环境上来启动的,生产环境大都是Nginx作为web服务器(nginx来部署graphite),这里需要安装下载uwsgi。本人对python不是很熟悉,大致上理解为:上面两种像是通过内置jetty来启动java-web项目;这种方式是通过tomcat部署java-web项目,我们可以通过设置tomcat的参数来优化java-web。

1)安装nginx:

2)安装uwsgi:

$ pip install uwsgi
Collecting uwsgiDownloading https://files.pythonhosted.org/packages/a2/c9/a2d5737f63cd9df4317a4acc15d1ddf4952e28398601d8d7d706c16381e0/uwsgi-2.0.17.1.tar.gz (800kB)100% |████████████████████████████████| 808kB 739kB/s 
Installing collected packages: uwsgiRunning setup.py install for uwsgi ... done
Successfully installed uwsgi-2.0.17.1

3)配置uwsgi文件:

vim /opt/graphite/webapp/graphite.ini(这个文件不存在)

[uwsgi]
post-buffering = 65536
buffer-size = 65536
chdir=/opt/graphite/webapp/
module=graphite.wsgi
master=true
pidfile=/var/run/graphite.pid
vacuum=true
max-requests=20000
daemonize=/opt/graphite/storage/log/webapp/access.log
processes=32
harakiri=10
harakiri-verbose=true
socket=127.0.0.1:9090
stats=127.0.0.1:1716
listen=1024

注意:在graphite运行一段时间之后可能会出现大量超时的情况,此时需要适当的增加processes数量,但是有一点极其关键需要增加process回收参数设置:harakiri-verbose=true表示超时回收机制,harakiri=10表示超时10即回收

4)配置nginx:

location / {#root   html;#index  index.html index.htm;uwsgi_pass 127.0.0.1:9090;include uwsgi_params;}location /static/ {alias /opt/graphite/webapp/content/;index index.html index.html;
}

5)启动nginx,然后通过http://ip 即可访问到graphite-web界面了。

6)grafana连接graphite:

  • 如果通过前两种方式启动的graphite-web,那么在grafana的datasource中设置http://ip:8085;
  • 如果通过nginx+uwsgi启动的graphite-web,那么在grafana的DataSource中设置http://ip/ 即可。

注:grafana本质上是通过graphite-web提供的restful-api来获取graphite中carbon存储的数据,然后再展示到界面上。
 

参考:

https://graphite.readthedocs.io/en/latest/install-source.html

https://blog.csdn.net/weixin_39922154/article/details/79132147

http://www.infoq.com/cn/articles/graphite-intro

https://my.oschina.net/u/1263964/blog/711998

https://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/tutorials/Django_and_nginx.html

 


http://chatgpt.dhexx.cn/article/RP0UEODv.shtml

相关文章

graphite http api

Render API Graphite web 提供了/render API用来生成图片和获取原始数据。这个API通过查询字符串支持各种参数。参数之间通过&进行分割&#xff0c;如下所示&#xff1a; &namevalue 你可以通过访问 http://GRAPHITE_HOST:GRAPHITE_PORT/render 这个url来确认这个A…

sitespeed+graphite+grafana

最近在看性能UI performance testing 的工具 其中一个是 sitespeed。 sitespeed.io 是 一款可监视和衡量网站前端性能的开源工具。 1. 开 源 2 . 支持事务模 拟 3 . 自动性能分析&#xff0c;形成可视化报 告 4 . 提供的 docker 镜像已搭建完成监控系统&#xff0c;满足…

在Ubuntu18.04使用Docker安装graphite

安装docker apt install docker.io 参照graphite官网&#xff0c;运行docker docker run -d \--name graphite \--restartalways \-p 80:80 \-p 2003-2004:2003-2004 \-p 2023-2024:2023-2024 \-p 8125:8125/udp \-p 8126:8126 \graphiteapp/graphite-statsd 查看docker&am…

graphite

Graphite 是一个用于采集网站实时信息并进行统计的开源项目&#xff0c;可用于采集多种网站服务运行状态信息。Graphite服务平均每分钟有4800次更新操作。实践已经 证实要监测网站发发生什么是非常有用的&#xff0c;它的简单文本协议和绘图功能可以方便地即插即 用的方式用于任…

Graphite详解

Graphite详解 作者&#xff1a;chszs&#xff0c;未经博主允许不得转载。经许可的转载需注明作者和博客主页&#xff1a;http://blog.csdn.net/chszs Graphite是一个开源实时的、显示时间序列度量数据的图形系统。Graphite并不收集度量数据本身&#xff0c;而是像一个数据库&…

时序数据库-Graphite

Graphite就属于一种时序数据库&#xff0c;作用是存储和聚合监控数据并绘制图标&#xff0c;不负责数据的收集。之所以想写一篇关于Graphite的博文主要是因为这是我接触到的另一种新型数据库&#xff0c;其特点和功能让人眼前一亮。但是需要强调的是&#xff0c;这里所谓的时序…

Graphite介绍

Graphite详解 https://www.2cto.com/kf/201603/494435.html Graphite是一个开源实时的、显示时间序列度量数据的图形系统。Graphite并不收集度量数据本身&#xff0c;而是像一个数据库&#xff0c;通过其后端接收度量数据&#xff0c;然后以实时方式查询、转换、组合这些度量数…

http中的XFF(X-Forwarded-For)

详细知识请移步大佬网页

攻防世界-xff_referer

题目 访问题目场景 抓包看看&#xff0c;打开场景&#xff0c;页面提示我们ip必须是123.123.123.123&#xff0c;我们就想到burpsuite抓包&#xff0c;添加上X-Forwarded-For:123.123.123.123 GET / HTTP/1.1 Host: 223.112.5.156:54671 X-Forwarded-For:123.123.123.123 User-…

XCTF2-web xff_referer

xff_referer 题目描述 X老师告诉小宁其实xff和referer是可以伪造的。 进入场景 提示对ip地址进行了限制 根据题目的描述&#xff0c;可以推测是伪造xff和referer。 根据要求构造xff和referer 轻松获得flag xff x-forwarded-for简称XFF&#xff0c;是http协议的一个扩展…

攻防世界-WEB:xff_referer

题目&#xff1a;https://adworld.xctf.org.cn/challenges/problem-set-index?id25&rwNmOdr1679149714756 题目描述&#xff1a;X老师告诉小宁其实xff和referer是可以伪造的。 根据题目描述&#xff0c;那就是考验xff和referer知识。 知识补充&#xff1a; XFF X-Forwarde…

day28 SQL注入HTTP头XFFCOOKIEPOST请求

前言 #知识点&#xff1a; 1、数据请求方式-GET&POST&COOKIE等 2、常见功能点请求方式-用户登录&IP记录等 3、黑盒白盒注入测试要点-SQLMAP注入参数 #补充点&#xff1a; 黑盒测试&#xff1a;功能点分析 1、后台要记录操作访问IP IP要进行代码的获取&#…

NGINX动态XFF黑名单配置

通过XFF地址动态限制访问 方案特点&#xff1a; 无需reloadAPI管理 NGINX PLUS的KEYVAL是可以通过API进行管理的内部可持久化kv存储。 KEYVAL查找XFF地址是否在黑白名单中&#xff0c;来实现访问控制。 KEYVAL存放黑白名单列表&#xff1a; 定义键值为1为白名单定义键值为…

xff-referer伪造ip地址和域名

layout: post title: “xff-referer伪造ip地址和域名” categories: [ctf] tags: [xff referer] 最新版的BurpSuite与以前版本不同&#xff0c;将raw headers hex这些二级导航栏去掉&#xff0c;改在了右侧显示&#xff0c;需要Add伪造ip和域名的时候&#xff0c;在该部分右侧底…

[CTF/网络安全] 攻防世界 xff_referer 解题详析

[CTF/网络安全] 攻防世界 xff_referer 解题详析 XFF及refererXFF格式referer格式姿势总结 题目描述&#xff1a;X老师告诉小宁其实xff和referer是可以伪造的。 XFF及referer X-Forwarded-For&#xff08;简称 XFF&#xff09;是一个 HTTP 请求头部字段&#xff0c;它用于表示 …

XCTF攻防世界练习区-web题-xff_referer

0x08 XFF Referer 【题目描述】 X老师告诉小宁其实xff和referer是可以伪造的。 【目标】 掌握有关X-Forwarded-For和Referer的知识: (1)X-Forwarded-For:简称XFF头,它代表客户端,也就是HTTP的请求端真实的IP,只有在通过了HTTP 代理或者负载均衡服务器时才会添加该项。…

ctf之xff_referer伪造

xff&#xff1a;xff 是http的拓展头部&#xff0c;作用是使Web服务器获取访问用户的IP真实地址&#xff08;可伪造&#xff09;。由于很多用户通过代理服务器进行访问&#xff0c;服务器只能获取代理服务器的IP地址&#xff0c;而xff的作用在于记录用户的真实IP&#xff0c;以及…

Web安全原理剖析(十一)——XFF注入攻击

目录 2.14 XFF注入2.14 XFF注入代码分析 2.14 XFF注入 XFF注入攻击的测试地址&#xff1a;http://127.0.0.1/sqli/xff.php。 X-Forwarded-for简称XFF头&#xff0c;它代表客户端真实的IP&#xff0c;通过修改X-Forwarded-for的值可以伪造客户端IP。通过Burp Suite住区数据包内容…

攻防世界web新手关之xff_referer

xff&#xff1a; 很多HTTP代理会在HTTP协议头中添加X-Forwarded-For头&#xff0c;用来追踪请求的来源。 X-Forwarded-For的格式如下&#xff1a; X-Forwarded-For: client1, proxy1, proxy2 X-Forwarded-For包含多个IP地址&#xff0c;每个值通过逗号空格分开&#xff0c;最…

攻防世界xff和refereer

终于把攻防世界里面WEB安全的难度一的题做完了&#xff08;一些个我认为比较难的题后面也会写个博客&#xff09;&#xff0c;开始做难度二题。 ----------------------------------------------------------------------------开始正经 原题&#xff1a;攻防世界 这个题难度…