2

Running graphite under apache httpd, with slqite database, I have the correct folder permissions

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

and

[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 also seems to have gone fine

[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

and the local-settings.py file is as follows

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': ''
    }
}

I still get this error

[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

not sure what is missing in this configuration

2 Answers 2

4

The owner and group were checked of the parent, i.e. /var/lib/graphite. It turned out that both were _graphite instead of apache. Changing the owner and group to _graphite and restarting apache2:

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

solved the issue on Ubuntu Xenial.

1

From the graphite installation documents:

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

In my case, since I'm using the RPM installation of Graphite on CentOS, the graphite.db file is located here:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .