Skip to content
liuyu105 edited this page Mar 19, 2017 · 3 revisions

环境依赖

  • Python2.7
  • Django1.7

你可以通过此手册完成基础环境配置

Clone 代码

$ mkdir -p /opt/opencmdb
$ cd /opt/opencmdb && git clone https://github.com/oysterclub/open-cmdb.git
$ cd open-cmdb;

配置virtualenv

$ mkdir -p /opt/opencmdb/envs
$ virtualenv -p /usr/local/bin/python2.7 /opt/opencmdb/envs
$ source /opt/opencmdb/envs/bin/activate

安装资源包

$ pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

初始化数据库

$ mysql -uroot -p
mysql> CREATE DATABASE opencmdb CHARACTER SET='utf8';
mysql> GRANT ALL PRIVILEGES ON opencmdb.* to opencmdb@127.0.0.1 IDENTIFIED BY 'opencmdb' WITH GRANT OPTION;

修改local_settings.py

建议本地都配置修改local_settings,从而不影响到系统settings的配置。

$ vim /opt/opencmdb/open-cmdb/local_settings.py
LOCAL_SETTINGS = True
from base.settings import *

DEBUG = True
TEMPLATE_DEBUG = DEBUG
DATABASES.update({
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'opencmdb',                      # Or path to database file if using sqlite3.
        'USER': 'root',                     # Not used with sqlite3.
        'PASSWORD': 'opencmdb',                  # Not used with sqlite3.
        'HOST': '127.0.0.1',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '3306',                      # Set to empty string for default. Not used with sqlite3.
        'OPTIONS':{'init_command': 'SET storage_engine=INNODB',
            'charset': 'utf8', }
    },
})

初始化数据库

$ python ./manage.py migrate

创建本地管理员

$ python ./manage.py createsuperuser --username=admin --email=admin@example.com

运行服务

$ python manage.py runserver