Graphite SQLite3 DatabaseError: tentativa de escrever um banco de dados somente leitura

2

Executando grafite sob o httpd apache, com banco de dados slqite, eu tenho as permissões de pasta corretas

[root@liaan55 httpd]# ls -ltr /var/lib | grep graphite
drwxr-xr-x. 2 apache        apache        4096 Aug 23 19:36 graphite-web

e

[root@liaan55 httpd]# ls -ltr /var/lib/graphite-web/
total 68
-rw-r--r--. 1 apache apache 65536 Aug 23 19:46 graphite.db

syncdb também parece ter corrido bem

[root@liaan55 httpd]# sudo -su apache
bash-4.1$ whoami
apache
bash-4.1$ python /usr/lib/python2.6/site-packages/graphite/manage.py syncdb
/usr/lib/python2.6/site-packages/graphite/settings.py:231: UserWarning: SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security
  warn('SECRET_KEY is set to an unsafe default. This should be set in local_settings.py for better security')
/usr/lib/python2.6/site-packages/django/conf/__init__.py:75: DeprecationWarning: The ADMIN_MEDIA_PREFIX setting has been removed; use STATIC_URL instead.
  "use STATIC_URL instead.", DeprecationWarning)
/usr/lib/python2.6/site-packages/django/core/cache/__init__.py:82: DeprecationWarning: settings.CACHE_* is deprecated; use settings.CACHES instead.
  DeprecationWarning
Creating tables ...
Creating table account_profile
Creating table account_variable
Creating table account_view
Creating table account_window
Creating table account_mygraph
Creating table dashboard_dashboard_owners
Creating table dashboard_dashboard
Creating table events_event
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_session
Creating table django_admin_log
Creating table django_content_type
Creating table tagging_tag
Creating table tagging_taggeditem

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'apache'): root
E-mail address: [email protected]
Password: 
Password (again): 
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
bash-4.1$ exit

e o arquivo local-settings.py é o seguinte

STORAGE_DIR = '/var/lib/graphite-web'

INDEX_FILE = '/var/lib/graphite-web/index' 

DATABASES = {
    'default': {
        'NAME': '/var/lib/graphite-web/graphite.db',
        'ENGINE': 'django.db.backends.sqlite3',
        'USER': '',
        'PASSWORD': '',
        'HOST': '',
        'PORT': ''
    }
}

Ainda recebo este erro

[Sat Aug 23 19:47:17 2014] [error] [client 10.42.33.238]   File "/usr/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py", line 344, in execute
[Sat Aug 23 19:47:17 2014] [error] [client 10.42.33.238]     return Database.Cursor.execute(self, query, params)
[Sat Aug 23 19:47:17 2014] [error] [client 10.42.33.238] DatabaseError: attempt to write a readonly database

não tenho certeza do que está faltando nessa configuração

    
por Anadi Misra 23.08.2014 / 16:30

2 respostas

4

O proprietário e o grupo foram verificados do pai, ou seja, /var/lib/graphite . Descobriu-se que ambos eram _graphite em vez de apache . Alterando o proprietário e o grupo para _graphite e reiniciando apache2 :

user@host:~$ sudo chown _graphite:_graphite /var/lib/graphite/graphite.db 
user@host:~$ sudo service apache2 restart

resolveu o problema no Ubuntu Xenial.

    
por 20.08.2016 / 23:54
1

A partir dos documentos instalação de grafite :

If you encounter problems with access to the database file, you may need to change ownership of the database file to the same user that owns the Apache processes. If your distribution has apache run as user ‘nobody’:

sudo chown nobody:nobody /opt/graphite/storage/graphite.db

No meu caso, como estou usando a instalação RPM do Graphite no CentOS, o arquivo graphite.db está localizado aqui:

-rw-r--r-- 1 apache apache 69632 Sep 30 08:02 /var/lib/graphite-web/graphite.db
    
por 30.09.2014 / 17:09