部署文档参考:https://lanjingling.github.io/2016/04/04/graphite-1/
非常不错的文档,只可惜django的版本似乎不和项目兼容,做了许多修改。记载如下:
执行: ./manage.py syncdb
ERROR:Import error cannot import name execute_manager
解决办法: (项目路径下)vim manage.py
from django.core.management import execute_from_command_line
原始文件为:
from django.core.management import execute_manager
注意:修改调用时的函数名
参考资料:https://stackoverflow.com/questions/20906305/import-error-cannot-import-name-execute-manager-in-windows-environment
ERROR: 'module' object has no attribute '__getitem__'
解决办法: (项目路径下)vim manage.py
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "graphite.settings")
import sys
execute_from_command_line(sys.argv)
原始文件为:
if __name__ == "__main__":
execute_from_command_line(settings)
参考资料:https://docs.djangoproject.com/en/1.11/releases/1.4/#updated-default-project-layout-and-manage-py
ERROR:settings.DATABASES is improperly configured
修改配置文件: setting.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'graphite',
'USER': 'root',
'PASSWORD': '1qaz2wsx',
'HOST': '172.25.28.5',
'PORT': '3306',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
}
},
}
原始文件为:
Database settings, sqlite is intended for single-server setups
DATABASE_ENGINE = 'django.db.backends.mysql' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'graphite' # Or path to database file if using sqlite3.
DATABASE_USER = 'root' # Not used with sqlite3.
DATABASE_PASSWORD = '1qaz2wsx' # Not used with sqlite3.
DATABASE_HOST = '172.25.28.8' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '3306' # Set to empty string for default. Not used with sqlite3.
ERROR:Error loading MySQLdb module: No module named MySQLdb
解决办法:easy_install MySQL-python
ERROR:django.db.utils.IntegrityError: (1215, 'Cannot add foreign key constraint')
过会儿再执行,自动就好了,遇到再补吧
ERROR:进程自动退出
[root@HC-25-28-8 graphite]# PYTHONPATH=`pwd`/storage/whisper ./bin/run-graphite-devel-server.py --port=8081 --libs=`pwd`/webapp /opt/graphite 1>/opt/graphite/storage/log/webapp/process.log 2>&1 &
[1] 47763
[root@HC-25-28-8 graphite]#
[1]+ Exit 1 PYTHONPATH=`pwd`/storage/whisper ./bin/run-graphite-devel-server.py --port=8081 --libs=`pwd`/webapp /opt/graphite > /opt/graphite/storage/log/webapp/process.log 2>&1
查看日志发现:(或者直接让其输出在控制台,查看错误)
CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.
修改 /opt/graphite/webapp/graphite 路径下 settings DEBUG= True
ERROR:no module named django.conf.urls.defaults
注意:各个路径下都有,注意删全
cd /opt/graphite/webapp/graphite
find -name urls.py
输出:
./cli/urls.py
./metrics/urls.py
./events/urls.py
./graphlot/urls.py
./whitelist/urls.py
./composer/urls.py
./account/urls.py
./dashboard/urls.py
./version/urls.py
./render/urls.py
./urls.py
./browser/urls.py
修改为:
from django.conf.urls import patterns, url, include
原文本:
from django.conf.urls.defaults import *
参考资料:
https://stackoverflow.com/questions/19962736/django-import-error-no-module-named-django-conf-urls-defaults
ERROR:Module "django.template.loaders.filesystem.load_template_source" does not define a "load_template_source" attribute/class
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
原文本:
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
)
网友评论