【发布时间】:2010-09-26 08:51:08
【问题描述】:
我有一个 Django 应用程序,其中包含两个已配置的数据库 first_DB 和 second_DB
配置如下
DATABASES = {
'default': {
'ENGINE' : 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME' : 'emonitor', # Or path to database file if using sqlite3.
'USER' : 'emonitor', # Not used with sqlite3.
'PASSWORD': 'emonitor', # Not used with sqlite3.
'HOST' : '', # Set to empty string for localhost. Not used with sqlite3.
'PORT' : '', # Set to empty string for default. Not used with sqlite3.
},
'nagios': {
'ENGINE' : 'django.db.backends.mysql',
'NAME' : 'nagios',
'USER' : 'emonitor',
'PASSWORD': 'emonitor',
'HOST' : 'nagios.edc',
'PORT' : '',
},
}
nagios 数据库是只读的,这是在路由器模块中配置的。
nagios 数据库在远程机器上
我的应用程序从 nagios 数据库中获取数据并将其插入到我的本地数据库中
如果nagios机器宕机,或者nagios机器上的mysql关闭,django服务器启动出现如下错误
enter code here_mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host 'nagios.edc' (1)")
应用程序不工作
我的理解是 Django 服务器尝试连接到所有已配置的数据库
但即使第二个数据库无法访问,我也想让我的应用程序正常工作
我该怎么做?
【问题讨论】: