Advertisement
Guest User

DB separation

a guest
Feb 8th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.52 KB | None | 0 0
  1. From 351cb81298c5b5393427958d1663cf1d3ddb370b Mon Sep 17 00:00:00 2001
  2. From: Michael Arnaldi <mike@mymoneyex.com>
  3. Date: Mon, 8 Feb 2016 16:29:26 +0100
  4. Subject: [PATCH] Separating OVN NB and SB databases. Run dbs in separate
  5. processes on ovn-northd start.
  6.  
  7. Signed-off-by: Michael Arnaldi <mike@mymoneyex.com>
  8. ---
  9. ovn/utilities/ovn-ctl | 59 ++++++++++++++++++++++++++++++++---------------
  10. ovn/utilities/ovn-nbctl.c | 2 +-
  11. ovn/utilities/ovn-sbctl.c | 3 ++-
  12. 3 files changed, 43 insertions(+), 21 deletions(-)
  13.  
  14. diff --git a/ovn/utilities/ovn-ctl b/ovn/utilities/ovn-ctl
  15. index b171934..85c4199 100755
  16. --- a/ovn/utilities/ovn-ctl
  17. +++ b/ovn/utilities/ovn-ctl
  18. @@ -31,30 +31,38 @@ done
  19. ## ----- ##
  20.  
  21. upgrade_ovn_dbs () {
  22. - ovn_dbs=$(ovs-appctl -t ovsdb-server ovsdb-server/list-dbs 2>/dev/null)
  23. - for db in $ovn_dbs; do
  24. - case $db in
  25. - OVN*)
  26. - action "Removing $db from ovsdb-server" \
  27. - ovs-appctl -t ovsdb-server ovsdb-server/remove-db $db
  28. - ;;
  29. - esac
  30. - done
  31. - upgrade_db "$DB_NB_FILE" "$DB_NB_SCHEMA"
  32. - upgrade_db "$DB_SB_FILE" "$DB_SB_SCHEMA"
  33. - for db in $DB_NB_FILE $DB_SB_FILE; do
  34. - action "Adding $db to ovsdb-server" \
  35. - ovs-appctl -t ovsdb-server ovsdb-server/add-db $db || exit 1
  36. - done
  37. + upgrade_db "$DB_NB_FILE" "$DB_NB_SCHEMA" 1>/dev/null 2>/dev/null
  38. + upgrade_db "$DB_SB_FILE" "$DB_SB_SCHEMA" 1>/dev/null 2>/dev/null
  39. +}
  40. +
  41. +stop_ovsdb_ovn () {
  42. + if [ -f $DB_NB_PID ]; then
  43. + kill -9 $(cat $DB_NB_PID) 1>/dev/null 2>/dev/null
  44. + rm -f $DB_NB_PID 1>/dev/null 2>/dev/null
  45. + fi
  46. + if [ -f $DB_SB_PID ]; then
  47. + kill -9 $(cat $DB_SB_PID) 1>/dev/null 2>/dev/null
  48. + rm -f $DB_SB_PID 1>/dev/null 2>/dev/null
  49. + fi
  50. +}
  51. +
  52. +start_ovsdb_ovn () {
  53. + mkdir -p $OVN_DB_DIR
  54. + mkdir -p $OVN_DB_DIR/run
  55. +
  56. + ovsdb-server --detach -vconsole:off --remote=punix:$DB_NB_SOCK --remote=ptcp:$DB_NB_PORT --pidfile=$DB_NB_PID $DB_NB_FILE
  57. + ovsdb-server --detach -vconsole:off --remote=punix:$DB_SB_SOCK --remote=ptcp:$DB_SB_PORT --pidfile=$DB_SB_PID $DB_SB_FILE
  58. }
  59.  
  60. start_northd () {
  61. # We expect ovn-northd to be co-located with ovsdb-server handling both the
  62. # OVN_Northbound and OVN_Southbound dbs.
  63. + stop_ovsdb_ovn
  64. upgrade_ovn_dbs
  65. + start_ovsdb_ovn
  66.  
  67. set ovn-northd
  68. - set "$@" -vconsole:emer -vsyslog:err -vfile:info
  69. + set "$@" -vconsole:emer -vsyslog:err -vfile:info --ovnnb-db=unix:$DB_NB_SOCK --ovnsb-db=unix:$DB_SB_SOCK
  70. OVS_RUNDIR=${OVN_RUNDIR} start_daemon "$OVN_NORTHD_PRIORITY" "$OVN_NORTHD_WRAPPER" "$@"
  71. }
  72.  
  73. @@ -70,6 +78,7 @@ start_controller () {
  74.  
  75. stop_northd () {
  76. OVS_RUNDIR=${OVN_RUNDIR} stop_daemon ovn-northd
  77. + stop_ovsdb_ovn
  78. }
  79.  
  80. stop_controller () {
  81. @@ -95,12 +104,24 @@ restart_controller () {
  82. ## ---- ##
  83.  
  84. set_defaults () {
  85. - DB_SOCK=$rundir/db.sock
  86. - DB_NB_FILE=$dbdir/ovnnb.db
  87. - DB_SB_FILE=$dbdir/ovnsb.db
  88. + OVN_DB_DIR=$rundir/ovn
  89. +
  90. + DB_NB_SOCK=$OVN_DB_DIR/run/db_nb.sock
  91. + DB_NB_PID=$OVN_DB_DIR/run/db_nb.pid
  92. + DB_NB_PORT=6651
  93. +
  94. + DB_SB_SOCK=$OVN_DB_DIR/run/db_sb.sock
  95. + DB_SB_PID=$OVN_DB_DIR/run/db_sb.pid
  96. + DB_SB_PORT=6652
  97. +
  98. + DB_NB_FILE=$OVN_DB_DIR/db/ovnnb.db
  99. + DB_SB_FILE=$OVN_DB_DIR/db/ovnsb.db
  100. +
  101. DB_NB_SCHEMA=$datadir/ovn-nb.ovsschema
  102. DB_SB_SCHEMA=$datadir/ovn-sb.ovsschema
  103.  
  104. + DB_SOCK=$rundir/db.sock
  105. +
  106. OVN_NORTHD_PRIORITY=-10
  107. OVN_NORTHD_WRAPPER=
  108. OVN_CONTROLLER_PRIORITY=-10
  109. diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
  110. index 324a0a4..62adfba 100644
  111. --- a/ovn/utilities/ovn-nbctl.c
  112. +++ b/ovn/utilities/ovn-nbctl.c
  113. @@ -142,7 +142,7 @@ nbctl_default_db(void)
  114. if (!def) {
  115. def = getenv("OVN_NB_DB");
  116. if (!def) {
  117. - def = ctl_default_db();
  118. + def = xasprintf("unix:%s/ovn/run/db_nb.sock", ovs_rundir());
  119. }
  120. }
  121. return def;
  122. diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c
  123. index b428a35..15b3ea3 100644
  124. --- a/ovn/utilities/ovn-sbctl.c
  125. +++ b/ovn/utilities/ovn-sbctl.c
  126. @@ -28,6 +28,7 @@
  127. #include <unistd.h>
  128.  
  129. #include "db-ctl-base.h"
  130. +#include "dirs.h"
  131.  
  132. #include "command-line.h"
  133. #include "compiler.h"
  134. @@ -154,7 +155,7 @@ sbctl_default_db(void)
  135. if (!def) {
  136. def = getenv("OVN_SB_DB");
  137. if (!def) {
  138. - def = ctl_default_db();
  139. + def = xasprintf("unix:%s/ovn/run/db_sb.sock", ovs_rundir());
  140. }
  141. }
  142. return def;
  143. --
  144. 2.4.9 (Apple Git-60)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement