From ba2cafc65ec6120481b41bb62dae68c8c7edee91 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 20 Sep 2016 16:13:34 +0300 Subject: [PATCH 1/6] Update tarball instructions --- .../Install-MariaDB-MaxScale-Using-a-Tarball.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md b/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md index 6dd5cd3c8..ac2682979 100644 --- a/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md +++ b/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md @@ -18,7 +18,9 @@ The required steps are as follows: $ cd maxscale $ chown -R maxscale var -Creating the symbolic link is necessary, since MariaDB MaxScale has been built with with the assumption that its base-directory is `/usr/local/maxscale`. It also makes it easy to switch between different versions of MariaDB MaxScale that have been installed side by side in `/usr/local`; just make the symbolic link point to another installation. +Creating the symbolic link is necessary, since MariaDB MaxScale has been built with with the assumption that its base-directory, that is, the directory under which all its sub-directories are found, is `/usr/local/maxscale`. + +The symbolic link also makes it easy to switch between different versions of MariaDB MaxScale that have been installed side by side in `/usr/local`; just make the symbolic link point to another installation. The following step is to create the MariaDB MaxScale configuration file `/etc/maxscale.cnf`. The file `etc/maxscale.cnf.template` can be used as a base. Please refer to [Configuration Guide](Configuration-Guide.md) for details. @@ -41,16 +43,12 @@ The next step is to create the MaxScale configuration file `maxscale-x.y.z/etc/m When the configuration file has been created, MariaDB MaxScale can be started. $ cd maxscale-x.y.z - $ LD_LIBRARY_PATH=lib/maxscale bin/maxscale -d --basedir=. + $ bin/maxscale -d --basedir=. -With the flag `--basedir`, MariaDB MaxScale is told where the `bin`, `etc`, `lib` -and `var` directories are found. Unless it is specified, MariaDB MaxScale assumes -the directories are found in `/usr/local/maxscale` and the configuration -file in `/etc`. +With the flag `--basedir`, MariaDB MaxScale is told where the `bin`, `etc`, `lib` and `var` directories are found. Unless it is specified, MariaDB MaxScale assumes the directories are found in `/usr/local/maxscale` and the configuration file in `/etc`. -It is also possible to specify the directories and the location of the -configuration file individually. Invoke MaxScale like +It is also possible to specify the directories and the location of the configuration file individually. Invoke MaxScale like - $ LD_LIBRARY_PATH=lib/maxscale bin/maxscale --help + $ bin/maxscale --help to find out the appropriate flags. From f6888ef2056478b5a38f2f54eae72d3c8a5ac381 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 21 Sep 2016 09:40:15 +0300 Subject: [PATCH 2/6] Install all /var directories The /var/lib/maxscale directory wasn't installed and tarballs didn't have any /var directories. --- CMakeLists.txt | 3 ++- cmake/package_tgz.cmake | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 148b915ce..b37d03670 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -370,8 +370,9 @@ endif() # NOTE: If you make changes here, ensure they are compatible with the # situation in gwdirs.h.in. -if (NOT CMAKE_INSTALL_PREFIX EQUAL "/usr") +if (NOT PACKAGE) install(DIRECTORY DESTINATION var/cache/maxscale) install(DIRECTORY DESTINATION var/log/maxscale) install(DIRECTORY DESTINATION var/run/maxscale) + install(DIRECTORY DESTINATION var/lib/maxscale) endif() diff --git a/cmake/package_tgz.cmake b/cmake/package_tgz.cmake index f99417748..d96756502 100644 --- a/cmake/package_tgz.cmake +++ b/cmake/package_tgz.cmake @@ -12,6 +12,12 @@ set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib" CACHE PATH "" FORCE) set(CMAKE_INSTALL_DATADIR /share CACHE PATH "" FORCE) set(CPACK_GENERATOR "TGZ") +# Include the var directories in the tarball +install(DIRECTORY DESTINATION var/cache/maxscale) +install(DIRECTORY DESTINATION var/log/maxscale) +install(DIRECTORY DESTINATION var/run/maxscale) +install(DIRECTORY DESTINATION var/lib/maxscale) + if(DISTRIB_SUFFIX) set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}.${DISTRIB_SUFFIX}") else() From bd60fbde7ecf6b002f8702538c07af0d89a1a529 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 21 Sep 2016 10:53:08 +0300 Subject: [PATCH 3/6] Create dummy files in /var directories for tar.gz packages These files allow seemingly empty directories to be installed on various platforms. Some platforms had problems installing empty directories. --- cmake/package_tgz.cmake | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmake/package_tgz.cmake b/cmake/package_tgz.cmake index d96756502..06ccf201e 100644 --- a/cmake/package_tgz.cmake +++ b/cmake/package_tgz.cmake @@ -13,10 +13,15 @@ set(CMAKE_INSTALL_DATADIR /share CACHE PATH "" FORCE) set(CPACK_GENERATOR "TGZ") # Include the var directories in the tarball -install(DIRECTORY DESTINATION var/cache/maxscale) -install(DIRECTORY DESTINATION var/log/maxscale) -install(DIRECTORY DESTINATION var/run/maxscale) -install(DIRECTORY DESTINATION var/lib/maxscale) +# +# On some platforms with certain CMake versions, installing empty directories +# with tarballs does not work. As a workaround, the .cmake-tgz-workaround file +# is installed into the would-be empty directories. +file(WRITE ${CMAKE_BINARY_DIR}/.cmake-tgz-workaround "") +install(FILES ${CMAKE_BINARY_DIR}/.cmake-tgz-workaround DESTINATION var/cache/maxscale) +install(FILES ${CMAKE_BINARY_DIR}/.cmake-tgz-workaround DESTINATION var/log/maxscale) +install(FILES ${CMAKE_BINARY_DIR}/.cmake-tgz-workaround DESTINATION var/run/maxscale) +install(FILES ${CMAKE_BINARY_DIR}/.cmake-tgz-workaround DESTINATION var/lib/maxscale) if(DISTRIB_SUFFIX) set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}.${DISTRIB_SUFFIX}") From 578f21e757d68806d1812a25bdc81c8ccc6c20d9 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 21 Sep 2016 10:08:19 +0300 Subject: [PATCH 4/6] MXS-874: Clear closed state before reconnecting to a server The backend reference states should be cleared when a reconnection attempt is made. Should the creation of a new DCB succeed, the backend should no longer be closed. --- server/modules/routing/readwritesplit/readwritesplit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index 07b768e8b..ac5a8781d 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -2889,6 +2889,8 @@ bool connect_server(backend_ref_t *bref, SESSION *session, bool execute_history) if (bref->bref_dcb != NULL) { + bref_clear_state(bref, BREF_CLOSED); + if (!execute_history || execute_sescmd_history(bref)) { /** Add a callback for unresponsive server */ From 4422cd87ebb4790fb41f3b15aa4d1c3aa355d721 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 21 Sep 2016 12:48:38 +0300 Subject: [PATCH 5/6] Update tarball installation instructions The /var/[log|lib|run|cache]/maxscale directory must be created manually. --- ...nstall-MariaDB-MaxScale-Using-a-Tarball.md | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md b/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md index ac2682979..25ec59a86 100644 --- a/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md +++ b/Documentation/Getting-Started/Install-MariaDB-MaxScale-Using-a-Tarball.md @@ -14,14 +14,28 @@ The required steps are as follows: $ sudo useradd -g maxscale maxscale $ cd /usr/local $ sudo tar -xzvf maxscale-x.y.z.OS.tar.gz - $ sudo ln -s maxscale-x.y.z maxscale + $ sudo ln -s maxscale-x.y.z.OS maxscale $ cd maxscale - $ chown -R maxscale var + $ sudo chown -R maxscale var Creating the symbolic link is necessary, since MariaDB MaxScale has been built with with the assumption that its base-directory, that is, the directory under which all its sub-directories are found, is `/usr/local/maxscale`. The symbolic link also makes it easy to switch between different versions of MariaDB MaxScale that have been installed side by side in `/usr/local`; just make the symbolic link point to another installation. +In addition, the first time you install MariaDB MaxScale from a tarball you need to create the following directories: + + $ sudo mkdir /var/log/maxscale + $ sudo mkdir /var/lib/maxscale + $ sudo mkdir /var/run/maxscale + $ sudo mkdir /var/cache/maxscale + +and make `maxscale` the owner of them: + + $ sudo chown maxscale /var/log/maxscale + $ sudo chown maxscale /var/lib/maxscale + $ sudo chown maxscale /var/run/maxscale + $ sudo chown maxscale /var/cache/maxscale + The following step is to create the MariaDB MaxScale configuration file `/etc/maxscale.cnf`. The file `etc/maxscale.cnf.template` can be used as a base. Please refer to [Configuration Guide](Configuration-Guide.md) for details. When the configuration file has been created, MariaDB MaxScale can be started. @@ -42,10 +56,10 @@ The next step is to create the MaxScale configuration file `maxscale-x.y.z/etc/m When the configuration file has been created, MariaDB MaxScale can be started. - $ cd maxscale-x.y.z + $ cd maxscale-x.y.z.OS $ bin/maxscale -d --basedir=. -With the flag `--basedir`, MariaDB MaxScale is told where the `bin`, `etc`, `lib` and `var` directories are found. Unless it is specified, MariaDB MaxScale assumes the directories are found in `/usr/local/maxscale` and the configuration file in `/etc`. +With the flag `--basedir`, MariaDB MaxScale is told where the `lib`, `etc` and `var` directories are found. Unless it is specified, MariaDB MaxScale assumes the `lib` directory is found in `/usr/local/maxscale`, and the `var` and `etc` directories in `/`. It is also possible to specify the directories and the location of the configuration file individually. Invoke MaxScale like From 0882541c8095e6c1888743be394c1f5877dc0870 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Wed, 21 Sep 2016 13:49:54 +0300 Subject: [PATCH 6/6] Make the default directories configurable The default directories can now be changed at build time. This allows tarballs to look for libraries in a more sensible place. --- cmake/install_layout.cmake | 21 +++++++++++++++++++++ cmake/package_tgz.cmake | 6 ++++-- server/include/gwdirs.h.in | 37 +++++++++++++++++++------------------ 3 files changed, 44 insertions(+), 20 deletions(-) diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake index a14ef05c5..4e3095e8e 100644 --- a/cmake/install_layout.cmake +++ b/cmake/install_layout.cmake @@ -9,3 +9,24 @@ set(MAXSCALE_DOCDIR ${CMAKE_INSTALL_DOCDIR}/maxscale CACHE PATH "Documentation i # These are the only hard-coded absolute paths set(MAXSCALE_VARDIR /var CACHE PATH "Data file path (usually /var/)") set(MAXSCALE_CONFDIR /etc CACHE PATH "Configuration file installation path (/etc/)") + +# Default values for directories and subpaths where files are searched. These +# are used in `server/include/gwdirs.h.in`. + +set(DEFAULT_PID_SUBPATH "run/maxscale" CACHE PATH "Default PID file subpath") +set(DEFAULT_LOG_SUBPATH "log/maxscale" CACHE PATH "Default log subpath") +set(DEFAULT_DATA_SUBPATH "lib/maxscale" CACHE PATH "Default datadir subpath") +set(DEFAULT_LIB_SUBPATH "${MAXSCALE_LIBDIR}" CACHE PATH "Default library subpath") +set(DEFAULT_CACHE_SUBPATH "cache/maxscale" CACHE PATH "Default cache subpath") +set(DEFAULT_LANG_SUBPATH "lib/maxscale" CACHE PATH "Default language file subpath") +set(DEFAULT_EXEC_SUBPATH "${MAXSCALE_BINDIR}" CACHE PATH "Default executable subpath") +set(DEFAULT_CONFIG_SUBPATH "etc" CACHE PATH "Default configuration subpath") + +set(DEFAULT_PIDDIR ${MAXSCALE_VARDIR}/${DEFAULT_PID_SUBPATH} CACHE PATH "Default PID file directory") +set(DEFAULT_LOGDIR ${MAXSCALE_VARDIR}/${DEFAULT_LOG_SUBPATH} CACHE PATH "Default log directory") +set(DEFAULT_DATADIR ${MAXSCALE_VARDIR}/${DEFAULT_DATA_SUBPATH} CACHE PATH "Default datadir path") +set(DEFAULT_LIBDIR ${CMAKE_INSTALL_PREFIX}/${DEFAULT_LIB_SUBPATH}/ CACHE PATH "Default library path") +set(DEFAULT_CACHEDIR ${MAXSCALE_VARDIR}/${DEFAULT_CACHE_SUBPATH} CACHE PATH "Default cache directory") +set(DEFAULT_LANGDIR ${MAXSCALE_VARDIR}/${DEFAULT_LANG_SUBPATH} CACHE PATH "Default language file directory") +set(DEFAULT_EXECDIR ${CMAKE_INSTALL_PREFIX}/${DEFAULT_EXEC_SUBPATH} CACHE PATH "Default executable directory") +set(DEFAULT_CONFIGDIR /${DEFAULT_CONFIG_SUBPATH} CACHE PATH "Default configuration directory") diff --git a/cmake/package_tgz.cmake b/cmake/package_tgz.cmake index 06ccf201e..cd30b7ce2 100644 --- a/cmake/package_tgz.cmake +++ b/cmake/package_tgz.cmake @@ -2,14 +2,16 @@ message(STATUS "Generating tar.gz packages") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) set(MAXSCALE_BINDIR /bin CACHE PATH "" FORCE) -set(MAXSCALE_LIBDIR /lib CACHE PATH "" FORCE) +set(MAXSCALE_LIBDIR /lib/maxscale CACHE PATH "" FORCE) set(MAXSCALE_SHAREDIR /share CACHE PATH "" FORCE) set(MAXSCALE_DOCDIR /share CACHE PATH "" FORCE) set(MAXSCALE_VARDIR /var CACHE PATH "" FORCE) set(MAXSCALE_CONFDIR /etc CACHE PATH "" FORCE) set(CMAKE_INSTALL_PREFIX "/" CACHE PATH "" FORCE) -set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib" CACHE PATH "" FORCE) +set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib/maxscale/" CACHE PATH "" FORCE) set(CMAKE_INSTALL_DATADIR /share CACHE PATH "" FORCE) +set(DEFAULT_LIB_SUBPATH /lib/maxscale CACHE PATH "" FORCE) +set(DEFAULT_LIBDIR "/usr/local/maxscale/lib/maxscale" CACHE PATH "" FORCE) set(CPACK_GENERATOR "TGZ") # Include the var directories in the tarball diff --git a/server/include/gwdirs.h.in b/server/include/gwdirs.h.in index 0a2c0dab1..d607b021d 100644 --- a/server/include/gwdirs.h.in +++ b/server/include/gwdirs.h.in @@ -21,30 +21,31 @@ EXTERN_C_BLOCK_BEGIN -// NOTE: If you make changes here, ensure they are compatible with the -// situation in /CMakeLists.txt, where directories are installed. -#define MXS_DEFAULT_PID_SUBPATH "run/maxscale" -#define MXS_DEFAULT_LOG_SUBPATH "log/maxscale" -#define MXS_DEFAULT_DATA_SUBPATH "lib/maxscale" -#define MXS_DEFAULT_LIB_SUBPATH "@MAXSCALE_LIBDIR@" -#define MXS_DEFAULT_CACHE_SUBPATH "cache/maxscale" -#define MXS_DEFAULT_LANG_SUBPATH "lib/maxscale" -#define MXS_DEFAULT_EXEC_SUBPATH "@MAXSCALE_BINDIR@" -#define MXS_DEFAULT_CONFIG_SUBPATH "etc" +/** + * All of the following DEFAULT_* variables are defined in cmake/install_layout.cmake + */ +#define MXS_DEFAULT_PID_SUBPATH "@DEFAULT_PID_SUBPATH@" +#define MXS_DEFAULT_LOG_SUBPATH "@DEFAULT_LOG_SUBPATH@" +#define MXS_DEFAULT_DATA_SUBPATH "@DEFAULT_DATA_SUBPATH@" +#define MXS_DEFAULT_LIB_SUBPATH "@DEFAULT_LIB_SUBPATH@" +#define MXS_DEFAULT_CACHE_SUBPATH "@DEFAULT_CACHE_SUBPATH@" +#define MXS_DEFAULT_LANG_SUBPATH "@DEFAULT_LANG_SUBPATH@" +#define MXS_DEFAULT_EXEC_SUBPATH "@DEFAULT_EXEC_SUBPATH@" +#define MXS_DEFAULT_CONFIG_SUBPATH "@DEFAULT_CONFIG_SUBPATH@" /** Default file locations, configured by CMake */ static const char* default_cnf_fname = "maxscale.cnf"; -static const char* default_configdir = "/" MXS_DEFAULT_CONFIG_SUBPATH; +static const char* default_configdir = "@DEFAULT_CONFIGDIR@"; /*< This should be changed to just /run eventually, * the /var/run folder is an old standard and the newer FSH 3.0 * uses /run for PID files.*/ -static const char* default_piddir = "@MAXSCALE_VARDIR@/" MXS_DEFAULT_PID_SUBPATH; -static const char* default_logdir = "@MAXSCALE_VARDIR@/" MXS_DEFAULT_LOG_SUBPATH; -static const char* default_datadir = "@MAXSCALE_VARDIR@/" MXS_DEFAULT_DATA_SUBPATH; -static const char* default_libdir = "@CMAKE_INSTALL_PREFIX@/" MXS_DEFAULT_LIB_SUBPATH; -static const char* default_cachedir = "@MAXSCALE_VARDIR@/" MXS_DEFAULT_CACHE_SUBPATH; -static const char* default_langdir = "@MAXSCALE_VARDIR@/" MXS_DEFAULT_LANG_SUBPATH; -static const char* default_execdir = "@CMAKE_INSTALL_PREFIX@/" MXS_DEFAULT_EXEC_SUBPATH; +static const char* default_piddir = "@DEFAULT_PIDDIR@"; +static const char* default_logdir = "@DEFAULT_LOGDIR@"; +static const char* default_datadir = "@DEFAULT_DATADIR@"; +static const char* default_libdir = "@DEFAULT_LIBDIR@"; +static const char* default_cachedir = "@DEFAULT_CACHEDIR@"; +static const char* default_langdir = "@DEFAULT_LANGDIR@"; +static const char* default_execdir = "@DEFAULT_EXECDIR@"; static char* configdir = NULL; static char* logdir = NULL;