Trouble setting up db on new Graphite install

Asked by Blue Jakester on 2016-08-08

I'm following the documentation here http://graphite.readthedocs.io/en/latest/install.html

New install on Centos 3.10.0-229.20.1.el7.x86_64 #1 SMP Tue Nov 3 19:10:07 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

I used the pip install method and got all the way to the Webapp Database Setup section here:

http://graphite.readthedocs.io/en/latest/config-database-setup.html

After resolving some issues like installing South I reached this point and am stuck. Any advice would be greatly appreciated. Thanks.

# pwd
/opt/graphite
# echo $GRAPHITE_ROOT
/opt/graphite
# ll
total 12
drwxr-xr-x 2 root root 4096 Aug 3 14:48 bin
drwxr-xr-x 2 root root 4096 Aug 3 14:48 conf
drwxr-xr-x 3 root root 77 Aug 3 14:48 examples
drwxr-xr-x 8 root root 4096 Aug 3 14:48 lib
drwxrwxr-x 6 apache apache 52 Aug 3 14:44 storage
drwxr-xr-x 4 root root 35 Aug 3 15:37 webapp
# PYTHONPATH=$GRAPHITE_ROOT/webapp django-admin.py migrate --settings=graphite.settings --run-syncdb
Unknown command: 'migrate'
Type 'django-admin.py help' for usage.

During my search for answers in this forum I found some different syntax and tried it, but got this error:

# django-admin.py syncdb --settings=graphite.settings
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/django/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 231, in execute
    self.validate()
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 266, in validate
    num_errors = get_validation_errors(s, app)
  File "/usr/lib/python2.7/site-packages/django/core/management/validation.py", line 30, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/usr/lib/python2.7/site-packages/django/db/models/loading.py", line 158, in get_app_errors
    self._populate()
  File "/usr/lib/python2.7/site-packages/django/db/models/loading.py", line 67, in _populate
    self.load_app(app_name)
  File "/usr/lib/python2.7/site-packages/django/db/models/loading.py", line 88, in load_app
    models = import_module('.models', app_name)
  File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/opt/graphite/webapp/graphite/events/models.py", line 6, in <module>
    from tagging.managers import ModelTaggedItemManager
  File "/usr/lib/python2.7/site-packages/tagging/managers.py", line 6, in <module>
    from django.db.models.query import QuerySet, parse_lookup
ImportError: cannot import name parse_lookup

Question information

Language:
English Edit question
Status:
Solved
For:
Graphite Edit question
Assignee:
No assignee Edit question
Solved by:
Blue Jakester
Solved:
2016-08-09
Last query:
2016-08-09
Last reply:
2016-08-09
Denis Zhdanov (deniszhdanov) said : #1

What's Django and Graphite version do you use?

Blue Jakester (bluejakester) said : #2

# python
Python 2.7.5 (default, Nov 20 2015, 02:00:19)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
1.4
>>>

I used this command to install graphite and just ran it again. Is 0.10.0 the version? If not I'm not certain how to check version. Thanks.

# pip install https://github.com/graphite-project/ceres/tarball/master
Collecting https://github.com/graphite-project/ceres/tarball/master
  Downloading https://github.com/graphite-project/ceres/tarball/master
  Requirement already satisfied (use --upgrade to upgrade): ceres==0.10.0 from https://github.com/graphite-project/ceres/tarball/master in /usr/lib/python2.7/site-packages

Denis Zhdanov (deniszhdanov) said : #3

Yes, Graphite is 0.10.0, current master. Problem that's 'bleeding edge' code, not now it's pinned to Django 1.9 - https://github.com/graphite-project/graphite-web/blob/master/requirements.txt

Please install Django 1.9 or install graphite from 0.9.x branch - using https://github.com/graphite-project/graphite-web/tree/0.9.x or 0.9.15 package, it's in EPEL - https://www.unixmen.com/install-graphite-centos-7/

Jason Dixon (jason-dixongroup) said : #4

Although it's not *literally* pinned to 1.9, we definitely encourage users to run the newest Django with graphite-web HEAD. There have been a lot of impacting changes to Django since 1.7+ which makes it a real headache to document for our users if we *don't do this*.

The alternative is to debug this yourself by reading the deprecated Django 1.4 docs and identifying the correct setup steps. :-P

Blue Jakester (bluejakester) said : #5

Thanks for the help. I did this:

# pip install Django==1.9
Collecting Django==1.9
  Downloading Django-1.9-py2.py3-none-any.whl (6.6MB)
    100% |████████████████████████████████| 6.6MB 182kB/s
Installing collected packages: Django
  Found existing installation: Django 1.4
    DEPRECATION: Uninstalling a distutils installed project (Django) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling Django-1.4:
      Successfully uninstalled Django-1.4
Successfully installed Django-1.9

and now get this error:

# PYTHONPATH=$GRAPHITE_ROOT/webapp django-admin.py migrate --settings=graphite.settings --run-syncdb
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/django/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 324, in execute
    django.setup()
  File "/usr/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/usr/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/opt/graphite/webapp/graphite/events/models.py", line 6, in <module>
    from tagging.managers import ModelTaggedItemManager
  File "/usr/lib/python2.7/site-packages/tagging/managers.py", line 6, in <module>
    from django.db.models.query import QuerySet, parse_lookup
ImportError: cannot import name parse_lookup

Blue Jakester (bluejakester) said : #6

Installed graphite-web.0.9.15 from epel 7 repo you recommended. Getting different errors on syncdb now (bottom of post)

# yum install graphite-web.0.9.15
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.spro.net
 * epel: linux.mirrors.es.net
 * extras: centos.eecs.wsu.edu
 * updates: centos.eecs.wsu.edu
No package graphite-web.0.9.15 available.
Error: Nothing to do
# yum install graphite-web-0.9.15
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.spro.net
 * epel: linux.mirrors.es.net
 * extras: centos.eecs.wsu.edu
 * updates: centos.eecs.wsu.edu
Resolving Dependencies
--> Running transaction check
---> Package graphite-web.noarch 0:0.9.15-1.el7 will be installed
--> Processing Dependency: python-whisper >= 0.9.15 for package: graphite-web-0.9.15-1.el7.noarch
--> Processing Dependency: python-django >= 1.3 for package: graphite-web-0.9.15-1.el7.noarch
--> Processing Dependency: pyparsing for package: graphite-web-0.9.15-1.el7.noarch
--> Processing Dependency: django-tagging for package: graphite-web-0.9.15-1.el7.noarch
--> Processing Dependency: dejavu-serif-fonts for package: graphite-web-0.9.15-1.el7.noarch
--> Processing Dependency: dejavu-sans-fonts for package: graphite-web-0.9.15-1.el7.noarch
--> Running transaction check
---> Package Django.noarch 0:1.4-1mgc30 will be obsoleted
---> Package dejavu-sans-fonts.noarch 0:2.33-6.el7 will be installed
--> Processing Dependency: dejavu-fonts-common = 2.33-6.el7 for package: dejavu-sans-fonts-2.33-6.el7.noarch
---> Package dejavu-serif-fonts.noarch 0:2.33-6.el7 will be installed
---> Package pyparsing.noarch 0:1.5.6-9.el7 will be installed
---> Package python-django.noarch 0:1.6.11-5.el7 will be obsoleting
--> Processing Dependency: python-django-bash-completion = 1.6.11-5.el7 for package: python-django-1.6.11-5.el7.noarch
---> Package python-django-tagging.noarch 0:0.3.1-11.el7 will be installed
---> Package python-whisper.noarch 0:0.9.15-1.el7 will be installed
--> Running transaction check
---> Package dejavu-fonts-common.noarch 0:2.33-6.el7 will be installed
---> Package python-django-bash-completion.noarch 0:1.6.11-5.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================
 Package Arch Version Repository Size
=======================================================================================================================================================================
Installing:
 graphite-web noarch 0.9.15-1.el7 epel 1.8 M
 python-django noarch 1.6.11-5.el7 epel 4.0 M
     replacing Django.noarch 1.4-1mgc30
Installing for dependencies:
 dejavu-fonts-common noarch 2.33-6.el7 base 64 k
 dejavu-sans-fonts noarch 2.33-6.el7 base 1.4 M
 dejavu-serif-fonts noarch 2.33-6.el7 base 776 k
 pyparsing noarch 1.5.6-9.el7 base 94 k
 python-django-bash-completion noarch 1.6.11-5.el7 epel 16 k
 python-django-tagging noarch 0.3.1-11.el7 epel 58 k
 python-whisper noarch 0.9.15-1.el7 epel 42 k

Transaction Summary
=======================================================================================================================================================================
Install 2 Packages (+7 Dependent packages)

Total download size: 8.2 M
Is this ok [y/d/N]: y
Downloading packages:
(1/9): dejavu-sans-fonts-2.33-6.el7.noarch.rpm | 1.4 MB 00:00:01
(2/9): dejavu-serif-fonts-2.33-6.el7.noarch.rpm | 776 kB 00:00:00
(3/9): pyparsing-1.5.6-9.el7.noarch.rpm | 94 kB 00:00:00
(4/9): graphite-web-0.9.15-1.el7.noarch.rpm | 1.8 MB 00:00:01
(5/9): python-django-1.6.11-5.el7.noarch.rpm | 4.0 MB 00:00:00
(6/9): python-django-bash-completion-1.6.11-5.el7.noarch.rpm | 16 kB 00:00:00
(7/9): python-django-tagging-0.3.1-11.el7.noarch.rpm | 58 kB 00:00:00
(8/9): python-whisper-0.9.15-1.el7.noarch.rpm | 42 kB 00:00:00
(9/9): dejavu-fonts-common-2.33-6.el7.noarch.rpm | 64 kB 00:00:05
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.5 MB/s | 8.2 MB 00:00:05
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : dejavu-fonts-common-2.33-6.el7.noarch 1/10
  Installing : dejavu-sans-fonts-2.33-6.el7.noarch 2/10
  Installing : dejavu-serif-fonts-2.33-6.el7.noarch 3/10
  Installing : python-django-bash-completion-1.6.11-5.el7.noarch 4/10
  Installing : python-django-1.6.11-5.el7.noarch 5/10
  Installing : python-django-tagging-0.3.1-11.el7.noarch 6/10
  Installing : pyparsing-1.5.6-9.el7.noarch 7/10
  Installing : python-whisper-0.9.15-1.el7.noarch 8/10
  Installing : graphite-web-0.9.15-1.el7.noarch 9/10
  Erasing : Django-1.4-1mgc30.noarch 10/10
warning: file /usr/lib/python2.7/site-packages/Django-1.4-py2.7.egg-info: remove failed: No such file or directory
  Verifying : graphite-web-0.9.15-1.el7.noarch 1/10
  Verifying : python-whisper-0.9.15-1.el7.noarch 2/10
  Verifying : dejavu-sans-fonts-2.33-6.el7.noarch 3/10
  Verifying : dejavu-fonts-common-2.33-6.el7.noarch 4/10
  Verifying : dejavu-serif-fonts-2.33-6.el7.noarch 5/10
  Verifying : python-django-tagging-0.3.1-11.el7.noarch 6/10
  Verifying : python-django-1.6.11-5.el7.noarch 7/10
  Verifying : pyparsing-1.5.6-9.el7.noarch 8/10
  Verifying : python-django-bash-completion-1.6.11-5.el7.noarch 9/10
  Verifying : Django-1.4-1mgc30.noarch 10/10

Installed:
  graphite-web.noarch 0:0.9.15-1.el7 python-django.noarch 0:1.6.11-5.el7

Dependency Installed:
  dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7 dejavu-serif-fonts.noarch 0:2.33-6.el7
  pyparsing.noarch 0:1.5.6-9.el7 python-django-bash-completion.noarch 0:1.6.11-5.el7 python-django-tagging.noarch 0:0.3.1-11.el7
  python-whisper.noarch 0:0.9.15-1.el7

Replaced:
  Django.noarch 0:1.4-1mgc30

Complete!
#

==============Different errors now========

# pwd
/opt/graphite
# PYTHONPATH=$GRAPHITE_ROOT/webapp django-admin.py migrate --settings=graphite.settings --run-syncdb
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/django/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/usr/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 9, in <module>
    from django.apps import apps
  File "/usr/lib/python2.7/site-packages/django/apps/__init__.py", line 1, in <module>
    from .config import AppConfig
  File "/usr/lib/python2.7/site-packages/django/apps/config.py", line 4, in <module>
    from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
ImportError: cannot import name AppRegistryNotReady
# django-admin.py syncdb --settings=graphite.settings
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/django/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/usr/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 9, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal, emit_pre_sync_signal
  File "/usr/lib/python2.7/site-packages/django/core/management/sql.py", line 9, in <module>
    from django.db import models
  File "/usr/lib/python2.7/site-packages/django/db/models/__init__.py", line 7, in <module>
    from django.db.models.manager import Manager
  File "/usr/lib/python2.7/site-packages/django/db/models/manager.py", line 58, in <module>
    class Manager(six.with_metaclass(RenameManagerMethods)):
  File "/usr/lib/python2.7/site-packages/django/utils/six.py", line 778, in __new__
    return meta(name, bases, d)
  File "/usr/lib/python2.7/site-packages/django/utils/deprecation.py", line 39, in __new__
    for base in inspect.getmro(new_class):
AttributeError: 'module' object has no attribute 'getmro'

Jason Dixon (jason-dixongroup) said : #7

Did you remove the database before re-trying your migration?

Blue Jakester (bluejakester) said : #8

No. I didn't think a database had been created. Where might it be? Nothing found with 'find':

# find /opt/graphite -name *.db -print
#

Blue Jakester (bluejakester) said : #9

I wanted to summarize what I've done so far to try and resolve the db initialization problem. Any additional advice would be greatly apprciated.

* installed Django version 1.9 (was running 1.4)
* installed graphite-web version 0.9.15

Now receiving the following when I try to initialize the db:

# pwd
/opt/graphite

# PYTHONPATH=$GRAPHITE_ROOT/webapp django-admin.py migrate --settings=graphite.settings --run-syncdb
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/django/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/usr/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 9, in <module>
    from django.apps import apps
  File "/usr/lib/python2.7/site-packages/django/apps/__init__.py", line 1, in <module>
    from .config import AppConfig
  File "/usr/lib/python2.7/site-packages/django/apps/config.py", line 4, in <module>
    from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
ImportError: cannot import name AppRegistryNotReady
# django-admin.py syncdb --settings=graphite.settings
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/django/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/usr/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 9, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal, emit_pre_sync_signal
  File "/usr/lib/python2.7/site-packages/django/core/management/sql.py", line 9, in <module>
    from django.db import models
  File "/usr/lib/python2.7/site-packages/django/db/models/__init__.py", line 7, in <module>
    from django.db.models.manager import Manager
  File "/usr/lib/python2.7/site-packages/django/db/models/manager.py", line 58, in <module>
    class Manager(six.with_metaclass(RenameManagerMethods)):
  File "/usr/lib/python2.7/site-packages/django/utils/six.py", line 778, in __new__
    return meta(name, bases, d)
  File "/usr/lib/python2.7/site-packages/django/utils/deprecation.py", line 39, in __new__
    for base in inspect.getmro(new_class):
AttributeError: 'module' object has no attribute 'getmro'

Thanks

Just to confirm, you have matching versions of graphite-web and whisper installed?

Blue Jakester (bluejakester) said : #11

Thanks for the help Jason. Yes, same version, 0.9.15

# rpm -qa | grep whisper
python-whisper-0.9.15-1.el7.noarch
You have new mail in /var/spool/mail/root

Denis Zhdanov (deniszhdanov) said : #12

IIRC 0.9.15 is not compaible with Django 1.9 too. If you want to continue with 0.9.15 you should stick to EPEL Django version, I think it's 1.4

Blue Jakester (bluejakester) said : #13

Success! Thanks Denis.

I re-installed Django with this command:

# pip install Django==1.4
Collecting Django==1.4
  Downloading Django-1.4.tar.gz (7.6MB)
    100% |████████████████████████████████| 7.6MB 136kB/s
Building wheels for collected packages: Django
  Running setup.py bdist_wheel for Django ... done
  Stored in directory: /root/.cache/pip/wheels/6c/ca/0d/021df844c41aac7878225b9dd09ea49708bdc95073cd033be3
Successfully built Django
Installing collected packages: Django
  Found existing installation: Django 1.6.12
    DEPRECATION: Uninstalling a distutils installed project (Django) has been deprecated and will be removed in a future version. This is due to the fact that uninstaling a distutils project will only partially uninstall the project.
    Uninstalling Django-1.6.12:
      Successfully uninstalled Django-1.6.12
Successfully installed Django-1.9

Even though it reported version 1.9 I reran the syncdb command and it worked. See below. So I'm moving on to the next task in the install docs.

Thanks everyone for the help.

# django-admin.py syncdb --settings=graphite.settings
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 url_shortener_link
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 'root'):
E-mail address: xxxxxxx#xxxxx.com
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

# ls -l storage
total 68
-rw-r--r-- 1 root root 69632 Aug 9 10:06 graphite.db
drwxr-xr-x 2 apache apache 6 Aug 3 14:44 lists
drwxr-xr-x 3 apache apache 19 Aug 3 14:48 log
drwxr-xr-x 2 apache apache 6 Aug 3 14:44 rrd
drwxr-xr-x 2 apache apache 6 Aug 3 14:44 whisper
#