Graphite抛出无法打开数据库文件
tail -f /etc/httpd/logs/error_log
这是setting.py文件配置
DATABASES = {
'default': {
'NAME': '/opt/graphite/webapp/test.db',
'ENGINE': 'django.db.backends.sqlite3',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': ''
}
}
完成
python manage.py syncdb
该文件存在于以下位置
[root@bash graphite]# ls -l /opt/graphite/webapp/test.db
-rw-rw-rw- 1 nobody nobody 65536 Nov 11 22:22 /opt/graphite/webapp/test.db
它会抛出错误
[Tue Nov 11 22:24:15 2014] [error] File "/usr/lib/python2.6/site-packages/django/db/backends/util.py", line 53, in execute
[Tue Nov 11 22:24:15 2014] [error] return self.cursor.execute(sql, params)
[Tue Nov 11 22:24:15 2014] [error] File "/usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py", line 452, in execute
[Tue Nov 11 22:24:15 2014] [error] return Database.Cursor.execute(self, query, params)
[Tue Nov 11 22:24:15 2014] [error] OperationalError: unable to open database file
答案 0 :(得分:5)
检查您正在执行python manage.py syncdb
的用户的权利。
此用户必须具有读取和写入文件/opt/graphite/webapp/test.db
还可以读取,写入和执行文件夹/opt/graphite/webapp/
尝试此命令(从用户执行,启动python manage.py syncdb
,可能是当前用户)
sudo chown `whoami`:`whoami` /opt/graphite/webapp/test.db # change owner
sudo chmod o+rw /opt/graphite/webapp/test.db # add rights
sudo chown `whoami`:`whoami` /opt/graphite/webapp/
sudo chmod o+rwx /opt/graphite/webapp/