Last active
June 30, 2017 08:47
-
-
Save theriverman/16f06f13962aa6767b68d4f93c8f5074 to your computer and use it in GitHub Desktop.
Postgresql Auto-fallback (initial)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATABASES = { | |
"follower": { | |
"ENGINE": "django.db.backends.postgresql", | |
"NAME": "follower", | |
"USER": "root", | |
"HOST": "54.34.65.24", | |
"PORT": "3306", | |
}, | |
"default": { | |
"ENGINE": "django.db.backends.postgresql", | |
"NAME": "application", | |
"USER": "root", | |
"HOST": "54.34.65.23", | |
"PORT": "3306", | |
}, | |
} | |
___________________________________________________________ | |
Replace the target database in common.py (try migrating database settings to local.py) | |
sed -Ei 's/psql/psql-slave/g' psql_setting #Master to Slave | |
sed -Ei 's/psql-slave/psql/g' psql_setting #Slave to Master | |
# Exact match: | |
sed -i 's/\<$basename\>/${basename}_yesterday/g' file.txt | |
https://stackoverflow.com/questions/26608906/django-multiple-databases-fallback-to-master-if-slave-is-down |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment