Merge remote-tracking branch 'origin/develop' into MXS-122
Conflicts: server/core/CMakeLists.txt server/core/dcb.c server/include/dcb.h server/include/server.h server/modules/protocol/mysql_backend.c
This commit is contained in:
commit
4c38e2224b
133
CMakeLists.txt
133
CMakeLists.txt
@ -6,20 +6,27 @@ endif()
|
||||
|
||||
message(STATUS "CMake version: ${CMAKE_VERSION}")
|
||||
|
||||
include(macros.cmake)
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/macros.cmake)
|
||||
enable_testing()
|
||||
|
||||
# Packaging builds install to /usr and other builds to /usr/local
|
||||
if(PACKAGE)
|
||||
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Prefix prepended to install directories.")
|
||||
endif()
|
||||
|
||||
# Set default values for cache entries and set the MaxScale version
|
||||
set_variables()
|
||||
set_maxscale_version()
|
||||
|
||||
set(CMAKE_INSTALL_PREFIX "/usr/local/mariadb-maxscale" CACHE PATH "Prefix prepended to install directories.")
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
project(MaxScale)
|
||||
|
||||
#Disabled for now pending evaluation
|
||||
# Set the installation layout
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/install_layout.cmake)
|
||||
|
||||
#Do the platform check
|
||||
include(cmake/CheckPlatform.cmake)
|
||||
|
||||
check_deps()
|
||||
@ -37,7 +44,7 @@ if(NOT CURL_FOUND)
|
||||
message(FATAL_ERROR "Failed to locate dependency: libcurl")
|
||||
endif()
|
||||
|
||||
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/modules)
|
||||
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/${MAXSCALE_LIBDIR})
|
||||
|
||||
# Make sure the release notes for this release are present if it is a stable one
|
||||
if(${MAXSCALE_VERSION} MATCHES "-stable")
|
||||
@ -49,10 +56,12 @@ if(${MAXSCALE_VERSION} MATCHES "-stable")
|
||||
endif()
|
||||
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/server/include)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/server/include/version.h.in ${CMAKE_BINARY_DIR}/server/include/version.h)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/server/test/maxscale_test.h.in ${CMAKE_BINARY_DIR}/server/include/maxscale_test.h)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/postinst.in ${CMAKE_BINARY_DIR}/postinst)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/postrm.in ${CMAKE_BINARY_DIR}/postrm)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/server/include/version.h.in ${CMAKE_BINARY_DIR}/server/include/version.h @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/server/include/gwdirs.h.in ${CMAKE_BINARY_DIR}/server/include/gwdirs.h @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/server/test/maxscale_test.h.in ${CMAKE_BINARY_DIR}/server/include/maxscale_test.h @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/postinst.in ${CMAKE_BINARY_DIR}/postinst @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/postrm.in ${CMAKE_BINARY_DIR}/postrm @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/server/test/maxscale_test.cnf ${CMAKE_BINARY_DIR}/maxscale.cnf @ONLY)
|
||||
|
||||
set(FLAGS "-Wall -Wno-unused-variable -Wno-unused-function -fPIC" CACHE STRING "Compilation flags")
|
||||
set(DEBUG_FLAGS "-ggdb -pthread -pipe -Wformat -fstack-protector --param=ssp-buffer-size=4" CACHE STRING "Debug compilation flags")
|
||||
@ -70,7 +79,7 @@ if(CMAKE_VERSION VERSION_GREATER 2.6)
|
||||
endif()
|
||||
|
||||
|
||||
IF(DEFINED OLEVEL )
|
||||
IF(DEFINED OLEVEL)
|
||||
if((OLEVEL GREATER -1) AND (OLEVEL LESS 4) )
|
||||
set(FLAGS "${FLAGS} -O${OLEVEL}" CACHE STRING "Compilation flags" FORCE)
|
||||
message(STATUS "Optimization level at: ${OLEVEL}")
|
||||
@ -128,7 +137,7 @@ if(NOT WITHOUT_MAXADMIN)
|
||||
add_subdirectory(client)
|
||||
endif()
|
||||
|
||||
|
||||
# Generate text versions of some documents
|
||||
execute_process(COMMAND perl ${CMAKE_SOURCE_DIR}/Documentation/format.pl
|
||||
${CMAKE_SOURCE_DIR}/Documentation/Changelog.md
|
||||
${CMAKE_BINARY_DIR}/Changelog.txt)
|
||||
@ -138,23 +147,26 @@ ${CMAKE_SOURCE_DIR}/Documentation/Release-Notes/MaxScale-1.1-Release-Notes.md
|
||||
execute_process(COMMAND perl ${CMAKE_SOURCE_DIR}/Documentation/format.pl
|
||||
${CMAKE_SOURCE_DIR}/Documentation/Upgrading-To-MaxScale-1.1.0.md
|
||||
${CMAKE_BINARY_DIR}/UpgradingToMaxScale110.txt)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/Changelog.txt DESTINATION .)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/ReleaseNotes.txt DESTINATION .)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/UpgradingToMaxScale110.txt DESTINATION .)
|
||||
|
||||
message(STATUS "Installing MaxScale to: ${CMAKE_INSTALL_PREFIX}/")
|
||||
|
||||
install(FILES server/MaxScale_template.cnf DESTINATION etc)
|
||||
install(FILES server/MaxScale_BinlogServer_template.cnf DESTINATION etc)
|
||||
install(FILES ${ERRMSG} DESTINATION mysql)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/COPYRIGHT DESTINATION .)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/README DESTINATION .)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION .)
|
||||
install(DIRECTORY DESTINATION log)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/Changelog.txt DESTINATION ${MAXSCALE_SHAREDIR})
|
||||
install(FILES ${CMAKE_BINARY_DIR}/ReleaseNotes.txt DESTINATION ${MAXSCALE_SHAREDIR})
|
||||
install(FILES ${CMAKE_BINARY_DIR}/UpgradingToMaxScale110.txt DESTINATION ${MAXSCALE_SHAREDIR})
|
||||
install(FILES server/maxscale_template.cnf DESTINATION ${MAXSCALE_SHAREDIR})
|
||||
install(FILES server/maxscale_binlogserver_template.cnf DESTINATION ${MAXSCALE_SHAREDIR})
|
||||
install(FILES ${ERRMSG} DESTINATION ${MAXSCALE_VARDIR}/lib/maxscale
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/COPYRIGHT DESTINATION ${MAXSCALE_SHAREDIR})
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/README DESTINATION ${MAXSCALE_SHAREDIR})
|
||||
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION ${MAXSCALE_SHAREDIR})
|
||||
install(FILES etc/lsyncd_example.conf DESTINATION ${MAXSCALE_SHAREDIR})
|
||||
install(FILES Documentation/maxscale.1 DESTINATION ${CMAKE_INSTALL_DATADIR}/man/man1)
|
||||
|
||||
|
||||
# Install startup scripts and ldconfig files
|
||||
if(WITH_SCRIPTS)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/maxscale.conf.in ${CMAKE_BINARY_DIR}/maxscale.conf @ONLY)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/maxscale.service.in ${CMAKE_BINARY_DIR}/maxscale.service @ONLY)
|
||||
if(DEB_BASED)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/etc/ubuntu/init.d/maxscale.in ${CMAKE_BINARY_DIR}/maxscale @ONLY)
|
||||
else()
|
||||
@ -163,45 +175,44 @@ if(WITH_SCRIPTS)
|
||||
if(PACKAGE)
|
||||
message(STATUS "maxscale.conf will unpack to: /etc/ld.so.conf.d")
|
||||
message(STATUS "startup scripts will unpack to to: /etc/init.d")
|
||||
message(STATUS "systemd service files will unpack to to: /usr/lib/systemd/system")
|
||||
install(FILES ${CMAKE_BINARY_DIR}/maxscale DESTINATION ${MAXSCALE_SHAREDIR}
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf DESTINATION ${MAXSCALE_SHAREDIR}
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/maxscale.service DESTINATION ${MAXSCALE_SHAREDIR}
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
else()
|
||||
install(FILES ${CMAKE_BINARY_DIR}/maxscale DESTINATION /etc/init.d
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf DESTINATION /etc/ld.so.conf.d
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/maxscale.service DESTINATION /usr/lib/systemd/system
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
message(STATUS "Installing maxscale.conf to: /etc/ld.so.conf.d")
|
||||
message(STATUS "Installing startup scripts to: /etc/init.d")
|
||||
message(STATUS "Installing systemd service files to: /usr/lib/systemd/system")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Only do packaging if configured
|
||||
if(PACKAGE)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/maxscale DESTINATION .
|
||||
|
||||
# Install the files copied by the postinst script into the share folder
|
||||
install(FILES ${CMAKE_BINARY_DIR}/maxscale DESTINATION ${MAXSCALE_SHAREDIR}
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf DESTINATION .
|
||||
install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf DESTINATION ${MAXSCALE_SHAREDIR}
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/postinst DESTINATION .
|
||||
install(FILES ${CMAKE_BINARY_DIR}/postinst DESTINATION ${MAXSCALE_SHAREDIR}
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/postrm DESTINATION .
|
||||
install(FILES ${CMAKE_BINARY_DIR}/postrm DESTINATION ${MAXSCALE_SHAREDIR}
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
if(${CMAKE_VERSION} VERSION_LESS 2.8.12)
|
||||
message(WARNING "CMake version is ${CMAKE_VERSION}. Building of packages requires version 2.8.12 or greater.")
|
||||
else()
|
||||
# See if we are on a RPM-capable or DEB-capable system
|
||||
find_program(RPMBUILD rpmbuild)
|
||||
find_program(DEBBUILD dpkg-buildpackage)
|
||||
set(CPACK_GENERATOR "TGZ")
|
||||
if(NOT ( ${RPMBUILD} STREQUAL "RPMBUILD-NOTFOUND" ) )
|
||||
message(STATUS "Generating RPM packages")
|
||||
set(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
|
||||
endif()
|
||||
|
||||
if(NOT ( ${DEBBUILD} STREQUAL "DEBBUILD-NOTFOUND" ) )
|
||||
set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
|
||||
execute_process(COMMAND dpgk --print-architecture OUTPUT_VARIABLE DEB_ARCHITECTURE)
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DEB_ARCHITECTURE})
|
||||
set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
||||
message(STATUS "Generating DEB packages for ${DEB_ARCHITECTURE}")
|
||||
endif()
|
||||
|
||||
# Generic CPack configuration variables
|
||||
set(CPACK_STRIP_FILES FALSE)
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MaxScale")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${MAXSCALE_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${MAXSCALE_VERSION_MINOR}")
|
||||
@ -212,39 +223,39 @@ if(PACKAGE)
|
||||
set(CPACK_PACKAGE_VENDOR "MariaDB Corporation Ab")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/etc/DESCRIPTION)
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/postinst;{CMAKE_BINARY_DIR}/postrm")
|
||||
set(CPACK_RPM_PACKAGE_RELEASE ${MAXSCALE_BUILD_NUMBER})
|
||||
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_BINARY_DIR}/postinst)
|
||||
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_BINARY_DIR}/postrm)
|
||||
set(CPACK_RPM_PACKAGE_NAME "maxscale")
|
||||
set(CPACK_RPM_PACKAGE_VENDOR "MariaDB Corporation Ab")
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "GPLv2")
|
||||
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/etc /etc/ld.so.conf.d /etc/init.d /etc/rc.d/init.d")
|
||||
set(CPACK_RPM_SPEC_MORE_DEFINE "%define ignore \#")
|
||||
set(CPACK_RPM_USER_FILELIST "%ignore /etc/init.d")
|
||||
set(CPACK_RPM_USER_FILELIST "%ignore /etc/ld.so.conf.d")
|
||||
set(CPACK_RPM_USER_FILELIST "%ignore /etc")
|
||||
|
||||
# See if we are on a RPM-capable or DEB-capable system
|
||||
find_program(RPMBUILD rpmbuild)
|
||||
find_program(DEBBUILD dpkg-buildpackage)
|
||||
set(CPACK_GENERATOR "TGZ")
|
||||
|
||||
if(NOT ( ${RPMBUILD} STREQUAL "RPMBUILD-NOTFOUND" ) )
|
||||
include(cmake/package_rpm.cmake)
|
||||
message(STATUS "Generating RPM packages")
|
||||
elseif(NOT ( ${DEBBUILD} STREQUAL "DEBBUILD-NOTFOUND" ) )
|
||||
include(cmake/package_deb.cmake)
|
||||
message(STATUS "Generating DEB packages for ${DEB_ARCHITECTURE}")
|
||||
endif()
|
||||
|
||||
include(CPack)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_custom_target(buildtests
|
||||
COMMAND ${CMAKE_COMMAND} -DDEPS_OK=Y -DBUILD_TESTS=Y -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DWITH_SCRIPTS=N ${CMAKE_SOURCE_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -DBUILD_TESTS=Y -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DWITH_SCRIPTS=N ${CMAKE_SOURCE_DIR}
|
||||
COMMAND make
|
||||
COMMENT "Building test suite..." VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(testall
|
||||
COMMAND ${CMAKE_COMMAND} -DDEPS_OK=Y -DBUILD_TESTS=Y -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DWITH_SCRIPTS=N ${CMAKE_SOURCE_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR} -DBUILD_TESTS=Y -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DWITH_SCRIPTS=N -DMAXSCALE_VARDIR=${CMAKE_BINARY_DIR}
|
||||
COMMAND make install
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/server/test/MaxScale_test.cnf ${CMAKE_BINARY_DIR}/etc/MaxScale.cnf
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/testall.cmake
|
||||
COMMENT "Running full test suite..." VERBATIM)
|
||||
|
||||
add_custom_target(testcore
|
||||
COMMAND ${CMAKE_COMMAND} -DDEPS_OK=Y -DBUILD_TESTS=Y -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DWITH_SCRIPTS=N ${CMAKE_SOURCE_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR} -DBUILD_TESTS=Y -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DWITH_SCRIPTS=N -DMAXSCALE_VARDIR=${CMAKE_BINARY_DIR}
|
||||
COMMAND make install
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/server/test/MaxScale_test.cnf ${CMAKE_BINARY_DIR}/etc/MaxScale.cnf
|
||||
COMMAND ctest -R Internal
|
||||
COMMENT "Running core test suite..." VERBATIM)
|
||||
|
||||
@ -274,7 +285,7 @@ endif()
|
||||
# Testall target with Valgrind
|
||||
if(VALGRIND_FOUND)
|
||||
add_custom_target(testall-valgrind
|
||||
COMMAND ${CMAKE_COMMAND} -DDEPS_OK=Y -DBUILD_TESTS=Y -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DWITH_SCRIPTS=N ${CMAKE_SOURCE_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -DBUILD_TESTS=Y -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DWITH_SCRIPTS=N ${CMAKE_SOURCE_DIR}
|
||||
COMMAND make install
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/server/test/MaxScale_test.cnf ${CMAKE_BINARY_DIR}/etc/MaxScale.cnf
|
||||
COMMAND /bin/sh -c "valgrind --track-fds=yes --leak-check=full --show-leak-kinds=all --log-file=${CMAKE_BINARY_DIR}/valgrind.log ${CMAKE_BINARY_DIR}/bin/maxscale -c ${CMAKE_BINARY_DIR} &>/dev/null"
|
||||
|
@ -1,37 +1,25 @@
|
||||
Installation and startup
|
||||
|
||||
Untar the binary distribution in the desired location,
|
||||
e.g. /usr/local/mariadb
|
||||
e.g. /usr/local/mariadb-maxscale
|
||||
|
||||
Alternatively build from the source code using the instructions
|
||||
in the README file and execute make install.
|
||||
in the [Building MaxScale from Source Code](../Getting-Started/Building-MaxScale-from-Source-Code.md) document.
|
||||
|
||||
Simply set the environment variable MAXSCALE_HOME to point to the
|
||||
MaxScale directory, found inside the path into which the files have been copied,
|
||||
e.g. MAXSCALE_HOME=/usr/local/mariadb-maxscale
|
||||
|
||||
Also you will need to optionally set LD_LIBRARY_PATH to include the 'lib' folder,
|
||||
found inside the path into which the files have been copied,
|
||||
e.g. LD_LIBRARY_PATH=/usr/local/mariadb-maxscale/lib
|
||||
|
||||
Because we need the libmysqld library for parsing we must create a
|
||||
valid my.cnf file to enable the library to be used. Copy the my.cnf
|
||||
to $MAXSCALE_HOME/mysql/my.cnf.
|
||||
|
||||
To start MaxScale execute the command 'maxscale' from the bin folder,
|
||||
e.g. /usr/local/mariadb-maxscale/bin/maxscale
|
||||
You can start MaxScale using `service maxscale start` or `systemctl start maxscale` if you installed the init.d scripts
|
||||
or by manually starting the process from the bin folder of the installation directory.
|
||||
|
||||
Configuration
|
||||
|
||||
You need to edit the file MaxScale.cnf in $MAXSCALE_HOME/etc, you should
|
||||
define the set of server definitions you require, with the addresses
|
||||
and ports of those servers. Also define the listening ports for your
|
||||
various services.
|
||||
You need to create or edit the maxscale.cnf file in the /etc folder.
|
||||
Define the services you wish to provide, the set of server definitions
|
||||
you require, with the addresses and ports of those servers and also
|
||||
define the listening ports for your various services.
|
||||
|
||||
In order to view the internal activity of the gateway you can telnet to
|
||||
In order to view the internal activity of MaxScale you can either use
|
||||
the maxadmin client interface with the cli routing module or telnet to
|
||||
the port defined for the telnet listener. Initially you may login with
|
||||
the user name of "admin" and the password "mariadb". Once connected type
|
||||
help for an overview of the commands and help <command> for the more
|
||||
detailed help on commands. Use the add user command to add a new user,
|
||||
this will also remove the admin/mariadb user.
|
||||
|
||||
this will also remove the admin/mariadb user. For a detailed guide about using the MaxAdmin interface, take a look at the [MaxAdmin](../Reference/MaxAdmin.md) guide.
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
- [MaxAdmin](Reference/MaxAdmin.md)
|
||||
- [MaxScale HA with Corosync-Pacemaker](Reference/MaxScale-HA-with-Corosync-Pacemaker.md)
|
||||
- [MaxScale HA with Lsyncd](Reference/MaxScale-HA-with-lsyncd.md)
|
||||
- [How Errors are Handled in MaxScale](Reference/How-errors-are-handled-in-MaxScale.md)
|
||||
- [Debug and Diagnostic Support](Reference/Debug-And-Diagnostic-Support.md)
|
||||
|
||||
|
@ -4,7 +4,7 @@ You will need a number of tools and libraries in order to achieve this.
|
||||
|
||||
* cmake version 2.8.12 or later
|
||||
|
||||
* gcc recommended version 4.4.7 or later
|
||||
* gcc recommended version 4.4.7 or later (MariaDB 10 libraries require gcc 4.7 or newer)
|
||||
|
||||
* libaio
|
||||
|
||||
@ -28,7 +28,7 @@ You will need to install all of the following packages for all versions of RHEL,
|
||||
|
||||
```
|
||||
gcc gcc-c++ ncurses-devel bison glibc-devel cmake libgcc perl make libtool
|
||||
openssl-devel libaio libaio-devel librabbitmq-devel
|
||||
openssl-devel libaio libaio-devel librabbitmq-devel libcurl-devel pcre-devel
|
||||
```
|
||||
|
||||
In addition, if you wish to to build an RPM package include:
|
||||
@ -68,7 +68,7 @@ These packages are required on all versions of Ubuntu and Debian.
|
||||
|
||||
```
|
||||
build-essential libssl-dev libaio-dev ncurses-dev bison
|
||||
cmake perl libtool librabbitmq-dev
|
||||
cmake perl libtool librabbitmq-dev libcurl-dev libpcre3-dev
|
||||
```
|
||||
|
||||
If you want to build a DEB package, you will also need:
|
||||
|
@ -27,16 +27,16 @@ connection failover| When a connection currently being used between MaxScale and
|
||||
|
||||
The MaxScale configuration is read from a file which can be located in a number of placing, MaxScale will search for the configuration file in a number of locations.
|
||||
|
||||
1. If the environment variable `MAXSCALE_HOME` is set then MaxScale will look for a configuration file called `MaxScale.cnf` in the directory `$MAXSCALE_HOME/etc`.
|
||||
1. Location given with the --configdir=<path> command line argument
|
||||
|
||||
2. If `MAXSCALE_HOME` is not set or the configuration file is not in the location above MaxScale will look for a file in `/etc/MaxScale.cnf`.
|
||||
|
||||
Alternatively MaxScale can be started with the `-c` flag and the path of the MaxScale home directory tree.
|
||||
2. MaxScale will look for a configuration file called `maxscale.cnf` in the directory `/etc/maxscale.cnf`
|
||||
|
||||
An explicit path to a configuration file can be passed by using the `-f` option to MaxScale.
|
||||
|
||||
The configuration file itself is based on the ".ini" file format and consists of various sections that are used to build the configuration, these sections define services, servers, listeners, monitors and global settings.
|
||||
|
||||
Please see the section about [Protocol Modules](#protocol-modules) for more details about MaxScale and the default directories where modules will be searched for.
|
||||
|
||||
### Global Settings
|
||||
|
||||
The global settings, in a section named `[MaxScale]`, allow various parameters that affect MaxScale as a whole to be tuned. Currently the only setting that is supported is the number of threads to use to handle the network traffic. MaxScale will also accept the section name of `[gateway]` for global settings. This is for backward compatibility with versions prior to the naming of MaxScale.
|
||||
@ -101,6 +101,54 @@ log_debug=1
|
||||
|
||||
To disable the log use the value 0 and to enable it use the value 1.
|
||||
|
||||
#### `logdir`
|
||||
|
||||
Set the directory where the logfiles are stored. The folder needs to be both readable and writable by the user running MaxScale.
|
||||
|
||||
```
|
||||
logdir=/tmp/
|
||||
```
|
||||
|
||||
#### `datadir`
|
||||
|
||||
Set the directory where the data files used by MaxScale are stored. Modules can write to this directory and for example the binlogrouter uses this folder as the default location for storing binary logs.
|
||||
|
||||
```
|
||||
datadir=/home/user/maxscale_data/
|
||||
```
|
||||
|
||||
#### `libdir`
|
||||
|
||||
Set the directory where MaxScale looks for modules. The library directory is the only directory that MaxScale uses when it searches for modules. If you have custom modules for MaxScale, make sure you have them in this folder.
|
||||
|
||||
```
|
||||
libdir=/home/user/lib64/
|
||||
```
|
||||
|
||||
#### `cachedir`
|
||||
|
||||
Configure the directory MaxScale uses to store cached data. An example of cached data is the authentication data fetched from the backend servers. MaxScale stores this in case a connection to the backend server is not possible.
|
||||
|
||||
```
|
||||
cachedir=/tmp/maxscale_cache/
|
||||
```
|
||||
|
||||
#### `piddir`
|
||||
|
||||
Configure the directory for the PID file for MaxScale. This file contains the Process ID for the running MaxScale process.
|
||||
|
||||
```
|
||||
piddir=/tmp/maxscale_cache/
|
||||
```
|
||||
|
||||
#### `language`
|
||||
|
||||
Set the folder where the errmsg.sys file is located in. MaxScale will look for the errmsg.sys file installed with MaxScale from this folder.
|
||||
|
||||
```
|
||||
language=/home/user/lang/
|
||||
```
|
||||
|
||||
### Service
|
||||
|
||||
A service represents the database service that MaxScale offers to the clients. In general a service consists of a set of backend database servers and a routing algorithm that determines how MaxScale decides to send statements or route connections to those backend servers.
|
||||
@ -193,7 +241,7 @@ Query OK, 0 rows affected (0.00 sec)
|
||||
|
||||
#### `passwd`
|
||||
|
||||
The passwd parameter provides the password information for the above user and may be either a plain text password or it may be an encrypted password. See the section on encrypting passwords for use in the MaxScale.cnf file. This user must be capable of connecting to the backend database and executing these SQL statements to load database names and grants from the backends:
|
||||
The passwd parameter provides the password information for the above user and may be either a plain text password or it may be an encrypted password. See the section on encrypting passwords for use in the maxscale.cnf file. This user must be capable of connecting to the backend database and executing these SQL statements to load database names and grants from the backends:
|
||||
|
||||
* `SELECT user, host, password,Select_priv FROM mysql.user`.
|
||||
* `SELECT user, host, db FROM mysql.db`
|
||||
@ -278,6 +326,62 @@ Example:
|
||||
connection_timeout=300
|
||||
```
|
||||
|
||||
### Service and SSL
|
||||
|
||||
This section describes configuration parameters for services that control the SSL/TLS encryption method and the various certificate files involved in it. To enable SSL, you must configure the `ssl` parameter with either `enabled` or `required` and provide the three files for `ssl_cert`, `ssl_key` and `ssl_ca_cert`. After this, MySQL connections to this service can be encrypted with SSL.
|
||||
|
||||
#### `ssl`
|
||||
|
||||
This enables SSL connections to the service. If this parameter is set to either `required` or `enabled` and the three certificate files can be found (these are explained afterwards), then client connections will be encrypted with SSL. If the parameter is `enabled` then both SSL and non-SSL connections can connect to this service. If the parameter is set to `required` then only SSL connections can be used for this service and non-SSL connections will get an error when they try to connect to the service.
|
||||
|
||||
#### `ssl_key`
|
||||
|
||||
The SSL private key the service should use. This will be the private key that is used as the server side private key during a client-server SSL handshake. This is a required parameter for SSL enabled services.
|
||||
|
||||
#### `ssl_cert`
|
||||
|
||||
The SSL certificate the service should use. This will be the public certificate that is used as the server side certificate during a client-server SSL handshake. This is a required parameter for SSL enabled services.
|
||||
|
||||
#### `ssl_ca_cert`
|
||||
|
||||
This is the Certificate Authority file. It will be used to verify that both the client and the server certificates are valid. This is a required parameter for SSL enabled services.
|
||||
|
||||
### `ssl_version`
|
||||
|
||||
This parameter controls the level of encryption used. Accepted values are:
|
||||
* SSLv3
|
||||
* TLSv10
|
||||
* TLSv11
|
||||
* TLSv12
|
||||
* MAX
|
||||
|
||||
### `ssl_cert_verification_depth`
|
||||
|
||||
The maximum length of the certificate authority chain that will be accepted. Accepted values are positive integers.
|
||||
|
||||
```
|
||||
# Example
|
||||
ssl_cert_verification_depth=10
|
||||
```
|
||||
|
||||
Example SSL enabled service configuration:
|
||||
|
||||
```
|
||||
[ReadWriteSplitService]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=server1,server2,server3
|
||||
user=myuser
|
||||
passwd=mypasswd
|
||||
ssl=required
|
||||
ssl_cert=/home/markus/certs/server-cert.pem
|
||||
ssl_key=/home/markus/certs/server-key.pem
|
||||
ssl_ca_cert=/home/markus/certs/ca.pem
|
||||
ssl_version=TLSv12
|
||||
```
|
||||
|
||||
This configuration requires all connections to be encrypted with SSL. It also specifies that TLSv1.2 should be used as the encryption method. The paths to the server certificate files and the Certificate Authority file are also provided.
|
||||
|
||||
### Server
|
||||
|
||||
Server sections are used to define the backend database servers that can be formed into a service. A server may be a member of one or more services within MaxScale. Servers are identified by a server name which is the section name in the configuration file. Servers have a type parameter of server, plus address port and protocol parameters.
|
||||
@ -318,7 +422,7 @@ The monitor has a username and password that is used to connect to all servers f
|
||||
monitorpw=mymonitorpasswd
|
||||
```
|
||||
|
||||
The monpasswd parameter may be either a plain text password or it may be an encrypted password. See the section on encrypting passwords for use in the MaxScale.cnf file.
|
||||
The monpasswd parameter may be either a plain text password or it may be an encrypted password. See the section on encrypting passwords for use in the maxscale.cnf file.
|
||||
|
||||
### Listener
|
||||
|
||||
@ -467,7 +571,7 @@ Individual servers may define override values for the user and password the moni
|
||||
|
||||
#### `passwd`
|
||||
|
||||
The password parameter may be either a plain text password or it may be an encrypted password. See the section on encrypting passwords for use in the `MaxScale.cnf` file.
|
||||
The password parameter may be either a plain text password or it may be an encrypted password. See the section on encrypting passwords for use in the `maxscale.cnf` file.
|
||||
|
||||
#### `monitor_interval`
|
||||
|
||||
@ -540,7 +644,7 @@ Default value is `2`. Write Timeout is the timeout in seconds for each attempt t
|
||||
|
||||
## Protocol Modules
|
||||
|
||||
The protocols supported by MaxScale are implemented as external modules that are loaded dynamically into the MaxScale core. These modules reside in the directory `$MAXSCALE_HOME/modules`, if the environment variable `$MAXSCALE_HOME` is not set it defaults to `/usr/local/mariadb-maxscale`. It may also be set by passing the `-c` option on the MaxScale command line.
|
||||
The protocols supported by MaxScale are implemented as external modules that are loaded dynamically into the MaxScale core. These modules reside in the directory `/usr/lib64/maxscale`. The location can be overridden with the `libdir=PATH` parameter under the `[maxscale]` section. It may also be set by passing the `-B PATH` or `--libdir=PATH` option on the MaxScale command line.
|
||||
|
||||
### MySQLClient
|
||||
|
||||
@ -1024,7 +1128,7 @@ MariaDB [mysql]> grant REPLICATION CLIENT on *.* to 'maxscalemon'@'maxscalehost'
|
||||
Query OK, 0 rows affected (0.00 sec)
|
||||
```
|
||||
|
||||
MySQL monitor fetches the `@@server_id` variable and other informations from `SHOW SLAVE STATUS` in order to compute the replication topology tree that may include intermediate master servers, called relay servers.
|
||||
MySQL monitor fetches the `@@server_id` variable and other information from `SHOW SLAVE STATUS` in order to compute the replication topology tree that may include intermediate master servers, called relay servers.
|
||||
|
||||
The *Master* server used by router modules is the so called "root master": a server that has the `SERVER_MASTER` status bit set and it's at the lowest level of the replication depth.
|
||||
|
||||
@ -1036,7 +1140,7 @@ Please note, those two options are not enabled by default.
|
||||
|
||||
### galeramon
|
||||
|
||||
The Galeramon monitor is a simple router designed for use with MySQL Galera cluster. To execute the galeramon monitor an entry as shown below should be added to the MaxScale configuration file.
|
||||
The Galeramon monitor is a simple monitor designed for use with MySQL Galera cluster. To execute the galeramon monitor an entry as shown below should be added to the MaxScale configuration file.
|
||||
|
||||
```
|
||||
[Galera Monitor]
|
||||
@ -1259,7 +1363,7 @@ before being sent to the server. Note that the text in the match string is case-
|
||||
|
||||
The **tee** filter is a filter module for MaxScale that acts as a "plumbing" fitting in the MaxScale filter toolkit. It can be used in a filter pipeline of a service to make a copy of requests from the client and dispatch a copy of the request to another service within MaxScale.
|
||||
|
||||
The configuration block for the **tee** filter requires the minimal filter parameters in its section within the `MaxScale.cnf` file that defines the filter to load and the service to send the duplicates to.
|
||||
The configuration block for the **tee** filter requires the minimal filter parameters in its section within the `maxscale.cnf` file that defines the filter to load and the service to send the duplicates to.
|
||||
|
||||
```
|
||||
[ArchiveFilter]
|
||||
@ -1274,7 +1378,7 @@ In addition parameters may be added to define patterns to match against to eithe
|
||||
|
||||
The top filter is a filter module for MaxScale that monitors every SQL statement that passes through the filter. It measures the duration of that statement, the time between the statement being sent and the first result being returned. The top N times are kept, along with the SQL text itself and a list sorted on the execution times of the query is written to a file upon closure of the client session.
|
||||
|
||||
The configuration block for the **top** filter requires the minimal filter options in its section within the `MaxScale.cnf` file, stored in `$MAXSCALE_HOME/etc/MaxScale.cnf`.
|
||||
The configuration block for the **top** filter requires the minimal filter options in its section within the `maxscale.cnf` file, stored in `/etc/maxscale.cnf`.
|
||||
|
||||
```
|
||||
[MyLogFilter]
|
||||
@ -1288,20 +1392,26 @@ In addition parameters may be added to define patterns to match against to eithe
|
||||
|
||||
## Encrypting Passwords
|
||||
|
||||
Passwords stored in the MaxScale.cnf file may optionally be encrypted for added security. This is done by creation of an encryption key on installation of MaxScale. Encryption keys may be created manually by executing the maxkeys utility with the argument of the filename to store the key.
|
||||
Passwords stored in the maxscale.cnf file may optionally be encrypted for added security. This is done by creation of an encryption key on installation of MaxScale. Encryption keys may be created manually by executing the maxkeys utility with the argument of the filename to store the key. The default location MaxScale stores the keys is `/var/lib/maxscale`.
|
||||
|
||||
maxkeys $MAXSCALE_HOME/etc/.secrets
|
||||
```
|
||||
# Usage: maxkeys [PATH]
|
||||
maxkeys /var/lib/maxscale/
|
||||
```
|
||||
|
||||
Changing the encryption key for MaxScale will invalidate any currently encrypted keys stored in the MaxScale.cnf file.
|
||||
Changing the encryption key for MaxScale will invalidate any currently encrypted keys stored in the maxscale.cnf file.
|
||||
|
||||
### Creating Encrypted Passwords
|
||||
|
||||
Encrypted passwords are created by executing the maxpasswd command with the password you require to encrypt as an argument. The environment variable `MAXSCALE_HOME` must be set, or MaxScale must be installed in the default location before maxpasswd can be executed.
|
||||
Encrypted passwords are created by executing the maxpasswd command with the location of the .secrets file and the password you require to encrypt as an argument.
|
||||
|
||||
maxpasswd MaxScalePw001
|
||||
61DD955512C39A4A8BC4BB1E5F116705
|
||||
```
|
||||
# Usage: maxpasswd PATH PASSWORD
|
||||
maxpasswd /var/lib/maxscale/ MaxScalePw001
|
||||
61DD955512C39A4A8BC4BB1E5F116705
|
||||
```
|
||||
|
||||
The output of the maxpasswd command is a hexadecimal string, this should be inserted into the MaxScale.cnf file in place of the ordinary, plain text, password. MaxScale will determine this as an encrypted password and automatically decrypt it before sending it the database server.
|
||||
The output of the maxpasswd command is a hexadecimal string, this should be inserted into the maxscale.cnf file in place of the ordinary, plain text, password. MaxScale will determine this as an encrypted password and automatically decrypt it before sending it the database server.
|
||||
|
||||
```
|
||||
[Split Service]
|
||||
@ -1382,7 +1492,7 @@ and short notations
|
||||
|
||||
## Error Reporting
|
||||
|
||||
MaxScale is designed to be executed as a service, therefore all error reports, including configuration errors, are written to the MaxScale error log file. MaxScale will log to a set of files in the directory `$MAXSCALE_HOME/log`, the only exception to this is if the log directory is not writable, in which case a message is sent to the standard error descriptor.
|
||||
MaxScale is designed to be executed as a service, therefore all error reports, including configuration errors, are written to the MaxScale error log file. By default, MaxScale will log to a set of files in the directory `/var/log/maxscale`, the only exception to this is if the log directory is not writable, in which case a message is sent to the standard error descriptor.
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
|
@ -59,14 +59,13 @@ As well as the four major configuration choices outlined above there are also ot
|
||||
MaxScale consists of a core executable and a number of modules that implement
|
||||
the different protocols and routing algorithms. These modules are built as
|
||||
shared objects that are loaded on demand. In order for MaxScale to find these
|
||||
modules it will search using a predescribed search path. The rules are:
|
||||
modules it will search using a configurable search path. The priority of these paths are:
|
||||
|
||||
1. Look in the current directory for the module
|
||||
2. Look in $MAXSCALE_HOME/modules
|
||||
3. Look in /usr/local/mariadb-maxscale/modules
|
||||
|
||||
Configuration is read by default from the file $MAXSCALE_HOME/etc/MaxScale.cnf, /etc/MaxScale.cnf. An example file is included in in the installation and can be found in the etc/ folder within the MaxScale installation. The default value of MAXSCALE_HOME can be overridden by using the -c flag on the command line. This should be immediately followed by the path to the MaxScale home directory. The -f flag can be used on the command line to set the name and the location of the configuration file. Without path expression the file is read from \$MAXSCALE_HOME/etc directory.
|
||||
1. Look in the directory defined with --libdir=PATH during startup
|
||||
2. Look in the directory defined with libdir=PATH in the configuration file under the [maxscale] section
|
||||
3. Look in default directory in /usr/lib64/maxscale
|
||||
|
||||
Configuration is read by default from the file /etc/maxscale.cnf. An example file is included in in the installation and can be found in the /usr/share/maxscale folder within the MaxScale installation. The -f flag can be used on the command line to set the name and the location of the configuration file. The -C flag can be used to set the directory where the configuration file is searched for. Without the -f or -C flags, the file is read from the /etc directory.
|
||||
|
||||
## Administration Of MaxScale
|
||||
|
||||
|
@ -1679,7 +1679,7 @@ Loaded 34 users.
|
||||
|
||||
## Reload config
|
||||
|
||||
The reload config command can be used to force MaxScale to re-read the MaxScale.cnf and update itself to the latest configuration defined in that configuration file. It is also possible to force the reading of the configuration file by sending a HangUp signal (SIGHUP) to the maxscale process.
|
||||
The reload config command can be used to force MaxScale to re-read the maxscale.cnf and update itself to the latest configuration defined in that configuration file. It is also possible to force the reading of the configuration file by sending a HangUp signal (SIGHUP) to the maxscale process.
|
||||
|
||||
**MaxScale>** reload config
|
||||
|
||||
@ -1711,7 +1711,7 @@ User admin already exists.
|
||||
|
||||
**MaxScale>**** **
|
||||
|
||||
If you should forget or lose the the account details you may simply remove the passwd file in $MAXSCALE_HOME/etc and the system will revert to the default behavior with admin/mariadb as the account.
|
||||
If you should forget or lose the the account details you may simply remove the passwd file in /var/cache/maxscale and the system will revert to the default behavior with admin/mariadb as the account.
|
||||
|
||||
## Enable/disable log
|
||||
|
||||
@ -1745,7 +1745,7 @@ MaxScale generates output of its behavior to four distinct logs, error, messages
|
||||
|
||||
## Log contents
|
||||
|
||||
By default all log files are located in : $MAXSCALE_HOME/log and named as :
|
||||
By default all log files are located in : /var/log/maxscale and named as :
|
||||
|
||||
skygw_errW.log, skygw_msgX.log, skygw_traceY.log and skygw_debugZ.log
|
||||
|
||||
@ -1789,7 +1789,7 @@ MariaDB Corporation MaxScale /home/jdoe/bin/develop/log/skygw_msg1.log Tue Dec
|
||||
|
||||
2014-12-09 14:47:05 Log directory : /home/jdoe/bin/develop/log
|
||||
|
||||
2014-12-09 14:47:05 Configuration file : /home/jdoe/bin/develop/etc/MaxScale.cnf
|
||||
2014-12-09 14:47:05 Configuration file : /home/jdoe/bin/develop/etc/maxscale.cnf
|
||||
|
||||
2014-12-09 14:47:05 Initialise CLI router module V1.0.0.
|
||||
|
||||
@ -1837,7 +1837,7 @@ MariaDB Corporation MaxScale /home/jdoe/bin/develop/log/skygw_msg1.log Tue Dec
|
||||
|
||||
### Trace log
|
||||
|
||||
Trace log includes information about available servers and their states, client sessions, queries being executed, routing decisions and other routing related data. Trace log can be found from the same directory with other logs but it is physically stored elsewhere, to OSs shared memory to reduce the latency caused by logging. The location of physical file is : /dev/shm/<pid>/skygw_traceX.log where ‘X’ is the same sequence number as in the file name in the $MAXSCALE_HOME/log directory.
|
||||
Trace log includes information about available servers and their states, client sessions, queries being executed, routing decisions and other routing related data. Trace log can be found from the same directory with other logs but it is physically stored elsewhere, to OSs shared memory to reduce the latency caused by logging. The location of physical file is : /dev/shm/<pid>/skygw_traceX.log where ‘X’ is the same sequence number as in the file name in the /var/log/maxscale directory.
|
||||
|
||||
Individual trace log entry looks similar to those in other logs but there is some difference too. Some log entries include a number within square brackets to specify which client session they belong to. For example:
|
||||
|
||||
@ -1923,11 +1923,11 @@ In the log, session’s life cycle is covered by annotating its beginning and th
|
||||
|
||||
The log files are located in
|
||||
|
||||
$MAXSCALE_HOME/log
|
||||
/var/log/maxscale
|
||||
|
||||
by default. If, however, trace and debug logs are enabled, only a soft link is created there. MaxScale process creates a directory under
|
||||
|
||||
/dev/shm/<pid>
|
||||
/dev/shm/maxscale.<pid>
|
||||
|
||||
where it stores the physical trace and debug log files. Link and physical files share the same name. These logs consume the main memory of the host they run on so it is important to archive or remove them periodically to avoid unnecessary main-memory consumption.
|
||||
|
||||
|
@ -15,7 +15,7 @@ name-value pairs.
|
||||
Routing queries to a server:
|
||||
-- maxscale route to [master | slave | server <server name>]
|
||||
|
||||
The name of the server is the same as in MaxScale.cnf
|
||||
The name of the server is the same as in maxscale.cnf
|
||||
|
||||
Creating a name-value pair:
|
||||
-- maxscale <param>=<value>
|
||||
|
@ -591,7 +591,7 @@ Some monitors provide a replication heartbeat mechanism that monitors the delay
|
||||
MaxScale> enable heartbeat "MySQL Monitor"
|
||||
MaxScale>
|
||||
|
||||
Please note that changes made via this interface will not persist across restarts of MaxScale. To make a permanent change edit the MaxScale.cnf file.
|
||||
Please note that changes made via this interface will not persist across restarts of MaxScale. To make a permanent change edit the maxscale.cnf file.
|
||||
|
||||
Enabling the replication heartbeat mechanism will add the display of heartbeat information in the show server output
|
||||
|
||||
@ -786,11 +786,11 @@ Two commands are provided to change the logging levels within MaxScale, disable
|
||||
MaxScale> disable log debug
|
||||
MaxScale>
|
||||
|
||||
Please note that changes made via this interface will not persist across restarts of MaxScale. To make a permanent change edit the MaxScale.cnf file.
|
||||
Please note that changes made via this interface will not persist across restarts of MaxScale. To make a permanent change edit the maxscale.cnf file.
|
||||
|
||||
## Reloading The Configuration
|
||||
|
||||
A command, reload config, is available that will cause MaxScale to reload the MaxScale.cnf configuration file.
|
||||
A command, reload config, is available that will cause MaxScale to reload the maxscale.cnf configuration file.
|
||||
|
||||
## Shutting Down MaxScale
|
||||
|
||||
@ -798,7 +798,7 @@ The MaxScale server may be shutdown using the shutdown maxscale command.
|
||||
|
||||
# Configuring MaxScale to Accept MaxAdmin Connections
|
||||
|
||||
In order to allow the use of the MaxAdmin client interface the service must be added to the MaxScale.cnf file of the Maxscale server. The CLI service itself must be added and a listener for the maxscaled protocol.
|
||||
In order to allow the use of the MaxAdmin client interface the service must be added to the maxscale.cnf file of the Maxscale server. The CLI service itself must be added and a listener for the maxscaled protocol.
|
||||
|
||||
The default entries required are shown below.
|
||||
|
||||
|
184
Documentation/Reference/MaxScale-HA-with-lsyncd.md
Normal file
184
Documentation/Reference/MaxScale-HA-with-lsyncd.md
Normal file
@ -0,0 +1,184 @@
|
||||
# MaxScale HA with Lsyncd
|
||||
|
||||
***This guide was written for lsyncd 2.1.5.***
|
||||
|
||||
This document guides you in setting up multiple MaxScale instances and synchronizing the configuration files with lsyncd. Lsyncd is a rsync wrapper which can synchronize files across the network. The lsyncd daemon uses a configuration file to control the files to synchronize and the remote targets where these files are synchronized to.
|
||||
|
||||
Copying the configuration file and running the lsyncd daemon on all the hosts keeps all the configuration files in sync. Modifications in the configuration file on one of the hosts will be copied on the other hosts. This allows adinistrators to easily provide a highly available, disaster resistant MaxScale installation with up-to-date configuration files on all the hosts.
|
||||
|
||||
### Requirements
|
||||
You will need:
|
||||
|
||||
* Access to the remote hosts.
|
||||
* MaxScale installed on all systems
|
||||
* Configured maxscale.cnf file in /etc
|
||||
* SSH daemon and clients installed on all hosts
|
||||
|
||||
The installation and configuration of MaxScale is covered in other documents.
|
||||
|
||||
## Creating SSH keys
|
||||
|
||||
For lsyncd to work, we will need to either use an existing set of SSH keys or to create a new set of keys. The creation and copying of keys needs to be repeated on all of the hosts.
|
||||
|
||||
If you already have a SSH key generated, you can skip this next step and go to the Copying Keys part.
|
||||
|
||||
### Generating keys
|
||||
|
||||
To generate a new set of SSH keys, we will use `ssh-keygen`.
|
||||
|
||||
```
|
||||
[root@localhost ~]# ssh-keygen
|
||||
Generating public/private rsa key pair.
|
||||
Enter file in which to save the key (/root/.ssh/id_rsa):
|
||||
Enter passphrase (empty for no passphrase):
|
||||
Enter same passphrase again:
|
||||
Your identification has been saved in /root/.ssh/id_rsa.
|
||||
Your public key has been saved in /root/.ssh/id_rsa.pub.
|
||||
The key fingerprint is:
|
||||
f4:99:0a:cc:d4:ac:ea:ed:ff:0d:bb:e5:87:3e:38:df root@localhost.localdomain
|
||||
The key's randomart image is:
|
||||
+--[ RSA 2048]----+
|
||||
| |
|
||||
| o |
|
||||
| . + |
|
||||
| + o . o |
|
||||
| = S + |
|
||||
| . . . |
|
||||
| . . .... |
|
||||
| . . o*o.. |
|
||||
| ..o...+==oE |
|
||||
+-----------------+
|
||||
|
||||
```
|
||||
|
||||
The keys will be generated in the .ssh folder and will automatically be used by ssh.
|
||||
|
||||
### Copying keys
|
||||
|
||||
To copy the SSH keys to the remote host we will use `ssh-copy-id`.
|
||||
|
||||
Use the username and host of the remote server you wish to synchronize MaxScale's configuration files to. For example, if the server's address is 192.168.122.100 and the user we use for synchronization us `user` we can use the following command.
|
||||
|
||||
```
|
||||
ssh-copy-id user@192.168.122.100
|
||||
```
|
||||
|
||||
Repeat the last command with the usernames and addresses of all the remote hosts you want to synchronize the configuration files to.
|
||||
|
||||
## Installing lsyncd
|
||||
|
||||
You will need to install lsyncd on all of the hosts for changes in the configuration file on one of the nodes to be synchronized to the other nodes.
|
||||
|
||||
You can install lsyncd with either a package manager or by building from source code. This guide demonstrates installation using a package manager and those looking to build lsyncd from source should refer to its documentation: https://github.com/axkibe/lsyncd/wiki/Manual-to-Lsyncd-2.1.x
|
||||
|
||||
Installing with Yum:
|
||||
|
||||
```
|
||||
yum install lsyncd
|
||||
```
|
||||
|
||||
Installing with Apt:
|
||||
|
||||
```
|
||||
apt-get install lsyncd
|
||||
```
|
||||
|
||||
## Creating the Lsyncd configuration file
|
||||
|
||||
Lsyncd uses a configuration file to determine where to read files from and where to synchronize them if changes in them occur. Lsyncd is written in Lua and the configuration file is also valid Lua code.
|
||||
|
||||
Here is an example configuration file with descriptions on the meaning of the values in it.
|
||||
|
||||
```
|
||||
-- Lsyncd will log to these two files.
|
||||
settings{
|
||||
logfile = "/var/log/maxscale/maxscale-ha.log",
|
||||
statusFile = "/var/log/maxscale/maxscale-ha-status.log"
|
||||
}
|
||||
|
||||
-- Copy and paste the sync section and change the host value to add new remote targets.
|
||||
sync{
|
||||
default.rsyncssh,
|
||||
|
||||
-- This is where the maxscale.cnf file is copied from.
|
||||
source="/etc",
|
||||
|
||||
-- This is the user and host where the maxscale.cnf is copied to.
|
||||
-- Change this to the user and destination host where you want maxscale.cnf to be synchronized to.
|
||||
host="user@192.168.122.100",
|
||||
|
||||
-- This is where the maxscale.cnf is copied to on the remote host.
|
||||
targetdir="/etc",
|
||||
|
||||
-- This is an optional section which defines a custom SSH port. Uncomment to enable.
|
||||
-- ssh={port=2222},
|
||||
|
||||
-- These are values passed to rsync. Only change these if you know what you are doing.
|
||||
rsync={
|
||||
compress=true,
|
||||
_extra = {[[--filter=+ *maxscale.cnf]],
|
||||
[[--filter=- **]]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The most important part is the `sync` section which defines a target for synchronization. The `default.rsyncssh` tells lsyncd to synchronize files using SSH.
|
||||
|
||||
The `source` parameter tells lsyncd where to read the files from. This should be the location of the maxscale.cnf file. The `host` parameter defines the host where the files should be synchronized to and the user account lsyncd should use when synchronizing the files. The `targetdir` parameter defines the local directory on the remote target where the files should be synchronized to. This value should be the location on the remote host where the maxscale.cnf file is searched from. By default, this is the `/etc` folder.
|
||||
|
||||
The optional `ssh` parameter and its sub-parameter `port`define a custom port for the SSH connection. Most users do not need this parameterer. The `rsycn` parameter contains an arra of options that are passed to the rsycn executable. These should not be changed unless you specifically know what you are doing. For more information on the options passed to rsync read the rsync(1) manpage.
|
||||
|
||||
You can add multiple remote targets by defining multiple `sync` sections. Here is an example with two sync sections defining different hosts that have MaxScale installed and whose configuration files should be kep in sync.
|
||||
|
||||
```
|
||||
settings{
|
||||
logfile = "/var/log/maxscale/maxscale-ha.log",
|
||||
statusFile = "/var/log/maxscale/maxscale-ha-status.log"
|
||||
}
|
||||
|
||||
sync{
|
||||
default.rsyncssh,
|
||||
source="/etc",
|
||||
host="maxuser@192.168.0.50",
|
||||
targetdir="/etc",
|
||||
rsync={
|
||||
compress=true,
|
||||
_extra = {[[--filter=+ *maxscale.cnf]],
|
||||
[[--filter=- **]]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sync{
|
||||
default.rsyncssh,
|
||||
source="/etc",
|
||||
host="syncuser@192.168.122.105",
|
||||
targetdir="/etc",
|
||||
rsync={
|
||||
compress=true,
|
||||
_extra = {[[--filter=+ *maxscale.cnf]],
|
||||
[[--filter=- **]]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Starting Lsyncd
|
||||
|
||||
Starting lsyncd can be done from the command line or through a init script. To start syncd from the command like, execute the `lsyncd` command and pass the configuration file as the only parameter.
|
||||
|
||||
By default lsyncd will search for the configuration file in `/etc/lsyncd.conf`. By placing the configuration file we created in the `/etc` folder, we can start lsyncd with the following command.
|
||||
|
||||
```
|
||||
service lsyncd start
|
||||
```
|
||||
|
||||
Here is an example which start lsyncd and reads the configuration options from the `lsyncd.cnf` file.
|
||||
|
||||
```
|
||||
lsyncd lsyncd.cnf
|
||||
```
|
||||
|
||||
For more information on the lsyncd executable and its options, please see the --help output of lsyncd or the lsyncd(1) manpage.
|
15
Documentation/Reference/MaxScale-and-SSL.md
Normal file
15
Documentation/Reference/MaxScale-and-SSL.md
Normal file
@ -0,0 +1,15 @@
|
||||
# MaxScale and SSL
|
||||
|
||||
MaxScale supports client side SSL connections. Enabling is done on a per service basis and each service has its own set of certificates.
|
||||
|
||||
## SSL Options
|
||||
|
||||
Here are the options which relate to SSL and certificates.
|
||||
Parameter|Values |Description
|
||||
---------|-----------|--------
|
||||
ssl | disabled, enabled, required |`disable` disables SSL, `enabled` enables SSL for client connections but still allows non-SSL connections and `required` requires SSL from all client connections. With the `required` option, client connections that do not use SSL will be rejected.
|
||||
ssl_cert | path to file |Path to server certificate
|
||||
ssl_key | path to file |Path to server private key
|
||||
ssl_ca_cert | path to file |Path to Certificate Authority file
|
||||
ssl_version|SSLV3,TLSV10,TLSV11,TLSV12,MAX| The SSL method level, defaults to highest available encryption level which is TLSv1.2
|
||||
ssl_cert_verify_depth|integer|Certificate authority certificate verification depth, default is 100.
|
@ -107,11 +107,11 @@ A number of bug fixes have been applied between the 1.0 beta release and this re
|
||||
</tr>
|
||||
<tr>
|
||||
<td>479</td>
|
||||
<td>Undefined filter reference in MaxScale.cnf causes a crash</td>
|
||||
<td>Undefined filter reference in maxscale.cnf causes a crash</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>410</td>
|
||||
<td>MaxScale.cnf server option is not parsed for spaces</td>
|
||||
<td>maxscale.cnf server option is not parsed for spaces</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>417</td>
|
||||
|
26
Documentation/Release-Notes/MaxScale-1.2.0-Release-Notes.md
Normal file
26
Documentation/Release-Notes/MaxScale-1.2.0-Release-Notes.md
Normal file
@ -0,0 +1,26 @@
|
||||
# MaxScale Release Notes
|
||||
|
||||
## 1.2 GA
|
||||
|
||||
This document details the changes in version 1.2 since the release of the 1.1.1 GA Release of the MaxScale product.
|
||||
|
||||
###***PLEASE NOTICE: MaxScale installation directories have changed in this version***
|
||||
The 1.2 version of MaxScale differs from previos versions in its installation layout. Please take great care when upgrading MaxScale from previous versions to version 1.2. An automatic upgrade will not work due to the severe changes in the installation layout.
|
||||
|
||||
## New Features
|
||||
|
||||
### Non-root MaxScale
|
||||
You can now run MaxScale as any user. The standard installation of a MaxScale package now creates the maxscale user and the maxscale group.
|
||||
|
||||
### FHS-compliant installation
|
||||
The 1.2 version of MaxScale now complies to the Filesystem Hierarchy Standard. This means that MAXSCALE_HOME is no longer necessary and directories can be moved to different locations.
|
||||
|
||||
A quick list of changes in installation directories and file names:
|
||||
|
||||
* Binaries go into `/usr/bin`
|
||||
* Configuration files to `/etc` and the configuration file is now lower case: `maxscale.cnf`
|
||||
* Logs to `/var/log/maxscale`
|
||||
* The module and library directory have been combined into a single directory in `/usr/lib64/maxscale`. If you have custom modules please make sure they are located there.
|
||||
* Data directory is `/var/lib/maxscale`. This is the default location for MaxScale-specific data.
|
||||
* PID file can be found at `/var/run/maxscale`
|
||||
|
@ -15,54 +15,33 @@ The purpose of this tutorial is to introduce the MaxScale Administrator to a few
|
||||
### Starting MaxScale
|
||||
|
||||
There are several ways to start MaxScale, the most convenient mechanism is probably using the Linux service interface. When a MaxScale package is installed the package manager will also installed a script in /etc/init.d which may be used to start and stop MaxScale either directly or via the service interface.
|
||||
|
||||
```
|
||||
$ service maxscale start
|
||||
|
||||
```
|
||||
or
|
||||
|
||||
```
|
||||
$ /etc/init.d/maxscale start
|
||||
|
||||
It is also possible to start MaxScale by executing the maxscale command itself, in this case you must ensure that the environment is correctly setup or command line options are passed. The major elements to consider are the correct setting of the MAXSCALE\_HOME directory and to ensure that LD\_LIBRARY\_PATH. The LD\_LIBRARY\_PATH should include the lib directory that was installed as part of the MaxScale installation, the MAXSCALE\_HOME should point to /usr/local/mariadb-maxscale if a default installation has been created or to the directory this was relocated to. Running the executable $MAXSCALE\_HOME/bin/maxscale will result in MaxScale running as a daemon process, unattached to the terminal in which it was started and using configuration files that it finds in the $MAXSCALE\_HOME directory.
|
||||
```
|
||||
It is also possible to start MaxScale by executing the maxscale command itself. Running the executable /usr/bin/maxscale will result in MaxScale running as a daemon process, unattached to the terminal in which it was started and using configuration files that it finds in the /etc directory.
|
||||
|
||||
Options may be passed to the MaxScale binary that alter this default behavior, this options are documented in the table below.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Switch</td>
|
||||
<td>Long Option</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>-d</td>
|
||||
<td>--nodaemon</td>
|
||||
<td>Run MaxScale attached to the terminal rather than as a daemon process. This is useful for debugging purposes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>-c</td>
|
||||
<td>--homedir=</td>
|
||||
<td>Ignore the environment variable MAXSCALE_HOME and use the supplied argument instead.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>-f</td>
|
||||
<td>--config=</td>
|
||||
<td>Use the filename passed as an argument instead of looking in $MAXSCALE_HOME/etc/MaxScale.cnf</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>-l<file>|<shm>|<stdout></td>
|
||||
<td>--log=</td>
|
||||
<td>Control where logs are written for the debug and trace level log messages. the default is to write these to a shared memory device, however using the -lfile or --log=file option will forced these to be written to regular files. Using -lstdout or --log=stdout will use the standard output for all enabled logs.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>-v</td>
|
||||
<td>--version</td>
|
||||
<td>Print version information for MaxScale</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>-?</td>
|
||||
<td>--help</td>
|
||||
<td>Print usage information for MaxScale</td>
|
||||
</tr>
|
||||
</table>
|
||||
Switch|Long Option|Description
|
||||
------|-----------|-----------
|
||||
`-d`|`--nodaemon`|enable running in terminal process (default:disabled)
|
||||
`-f FILE`|`--config=FILE`|relative or absolute pathname of MaxScale configuration file (default:/etc/maxscale.cnf)
|
||||
`-l[file shm]`|`--log=[file shm]`|log to file or shared memory (default: shm)
|
||||
`-L PATH`|`--logdir=PATH`|path to log file directory (default: /var/log/maxscale)
|
||||
`-D PATH`|`--datadir=PATH`|path to data directory, stored embedded mysql tables (default: /var/cache/maxscale)
|
||||
`-C PATH`|`--configdir=PATH`|path to configuration file directory (default: /etc/)
|
||||
`-B PATH`|`--libdir=PATH`|path to module directory (default: /usr/lib64/maxscale)
|
||||
`-A PATH`|`--cachedir=PATH`|path to cache directory (default: /var/cache/maxscale)
|
||||
`P PATH`|`--piddir=PATH`|PID file directory
|
||||
`-U USER`|`--user=USER`|run MaxScale as another user. The user ID and group ID of this user are used to run MaxScale.
|
||||
`-s [yes no]`|`--syslog=[yes no]`|log messages to syslog (default:yes)
|
||||
`-S [yes no]`|`--maxscalelog=[yes no]`|log messages to MaxScale log (default: yes)
|
||||
`-v`|`--version`|print version info and exit
|
||||
`-?`|`--help`|show this help
|
||||
|
||||
<a name="stopping"></a>
|
||||
### Stopping MaxScale
|
||||
@ -70,26 +49,27 @@ Options may be passed to the MaxScale binary that alter this default behavior, t
|
||||
There are numerous ways in which MaxScale can be stopped; using the service interface, killing the process or by use of the maxadmin utility.
|
||||
|
||||
Stopping MaxScale with the service interface is simply a case of using the service stop command or calling the init.d script with the stop argument.
|
||||
|
||||
```
|
||||
$ service maxscale stop
|
||||
|
||||
```
|
||||
or
|
||||
|
||||
```
|
||||
$ /etc/init.d/maxscale stop
|
||||
|
||||
MaxScale will also stop gracefully if it received a hangup signal, to find the process id of the MaxScale server use the ps command or read the contents of the maxscale.pid file located in the same directory as the logs.
|
||||
|
||||
$ kill -HUP `cat $MAXSCALE_HOME/log/maxscale.pid`
|
||||
|
||||
```
|
||||
MaxScale will also stop gracefully if it received a terminate signal, to find the process id of the MaxScale server use the ps command or read the contents of the maxscale.pid file located in the /var/run/maxscale directory.
|
||||
```
|
||||
$ kill `cat /var/run/maxscale/maxscale.pid`
|
||||
```
|
||||
In order to shutdown MaxScale using the maxadmin command you may either connect with maxadmin in interactive mode or pass the "shutdown maxscale" command you wish to execute as an argument to maxadmin.
|
||||
|
||||
```
|
||||
$ maxadmin -pmariadb shutdown maxscale
|
||||
|
||||
```
|
||||
<a name="checking"></a>
|
||||
### Checking The Status Of The MaxScale Services
|
||||
|
||||
It is possible to use the maxadmin command to obtain statistics regarding the services that are configured within your MaxScale configuration file. The maxadmin command "list services" will give very basic information regarding the services that are define. This command may be either run in interactive mode or passed on the maxadmin command line.
|
||||
|
||||
```
|
||||
$ maxadmin -pmariadb
|
||||
MaxScale> list services
|
||||
|
||||
@ -110,6 +90,7 @@ It is possible to use the maxadmin command to obtain statistics regarding the se
|
||||
--------------------------+----------------------+--------+---------------
|
||||
|
||||
MaxScale>
|
||||
```
|
||||
|
||||
It should be noted that network listeners count as a user of the service, therefore there will always be one user per network port in which the service listens. More detail can be obtained by use of the "show service" command which is passed a service name.
|
||||
|
||||
@ -117,7 +98,7 @@ It should be noted that network listeners count as a user of the service, theref
|
||||
### What Clients Are Connected To MaxScale
|
||||
|
||||
To determine what client are currently connected to MaxScale you can use the "list clients" command within maxadmin. This will give you IP address and the ID’s of the DCB and session for that connection. As with any maxadmin command this can be passed on the command line or typed interactively in maxadmin.
|
||||
|
||||
```
|
||||
$ maxadmin -pmariadb list clients
|
||||
|
||||
Client Connections
|
||||
@ -133,28 +114,27 @@ To determine what client are currently connected to MaxScale you can use the "li
|
||||
-----------------+------------------+----------------------+------------
|
||||
|
||||
$
|
||||
|
||||
```
|
||||
<a name="rotating"></a>
|
||||
### Rotating Log Files
|
||||
|
||||
MaxScale write log data into four log files with varying degrees of detail. With the exception of the error log, which can not be disabled, these log files may be enabled and disabled via the maxadmin interface or in the configuration file. The default behavior of MaxScale is to grow the log files indefinitely, the administrator must take action to prevent this.
|
||||
|
||||
It is possible to rotate either a single log file or all the log files with a single command. When the logfile is rotated, the current log file is closed and a new log file, with an increased sequence number in its name, is created. Log file rotation is achieved by use of the "flush log" or “flush logs” command in maxadmin.
|
||||
|
||||
```
|
||||
$ maxadmin -pmariadb flush logs
|
||||
|
||||
```
|
||||
Flushes all of the logs, whereas an individual log may be flushed with the "flush log" command.
|
||||
|
||||
```
|
||||
$ maxadmin -pmariadb
|
||||
MaxScale> flush log error
|
||||
MaxScale> flush log trace
|
||||
MaxScale>
|
||||
|
||||
```
|
||||
This may be integrated into the Linux logrotate mechanism by adding a configuration file to the /etc/logrotate.d directory. If we assume we want to rotate the log files once per month and wish to keep 5 log files worth of history, the configuration file would look like the following.
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>/usr/local/mariadb-maxscale/log/*.log {
|
||||
```
|
||||
/var/log/maxscale/*.log {
|
||||
monthly
|
||||
rotate 5
|
||||
missingok
|
||||
@ -163,30 +143,26 @@ sharedscripts
|
||||
postrotate
|
||||
\# run if maxscale is running
|
||||
if test -n "`ps acx|grep maxscale`"; then
|
||||
/usr/local/mariadb-maxscale/bin/maxadmin -pmariadb flush logs
|
||||
/usr/bin/maxadmin -pmariadb flush logs
|
||||
fi
|
||||
endscript
|
||||
}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
One disadvantage with this is that the password used for the maxadmin command has to be embedded in the log rotate configuration file. MaxScale will also rotate all of its log files if it receives the USR1 signal. Using this the logrotate configuration script can be rewritten as
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>/usr/local/mariadb-maxscale/log/*.log {
|
||||
```
|
||||
/var/log/maxscale/*.log {
|
||||
monthly
|
||||
rotate 5
|
||||
missingok
|
||||
nocompress
|
||||
sharedscripts
|
||||
postrotate
|
||||
kill -USR1 `cat /usr/local/mariadb-maxscale/log/maxscale.pid`
|
||||
kill -USR1 `cat /var/run/maxscale/maxscale.pid`
|
||||
endscript
|
||||
}</td>
|
||||
</tr>
|
||||
</table>
|
||||
}
|
||||
```
|
||||
|
||||
<a name="outofuse"></a>
|
||||
### Taking A Database Server Out Of Use
|
||||
@ -194,16 +170,16 @@ endscript
|
||||
MaxScale supports the concept of maintenance mode for servers within a cluster, this allows for planned, temporary removal of a database from the cluster within the need to change the MaxScale configuration.
|
||||
|
||||
To achieve the removal of a database server you can use the set server command in the maxadmin utility to set the maintenance mode flag for the server. This may be done interactively within maxadmin or by passing the command on the command line.
|
||||
|
||||
```
|
||||
MaxScale> set server dbserver3 maintenance
|
||||
MaxScale>
|
||||
|
||||
```
|
||||
This will cause MaxScale to stop routing any new requests to the server, however if there are currently requests executing on the server these will not be interrupted.
|
||||
|
||||
To bring the server back into service use the "clear server" command to clear the maintenance mode bit for that server.
|
||||
|
||||
```
|
||||
MaxScale> clear server dbserver3 maintenance
|
||||
MaxScale>
|
||||
|
||||
```
|
||||
Note that maintenance mode is not persistent, if MaxScale restarts when a node is in maintenance mode a new instance of MaxScale will not honour this mode. If multiple MaxScale instances are configured to use the node them maintenance mode must be set within each MaxScale instance. However if multiple services within one MaxScale instance are using the server then you only need set the maintenance mode once on the server for all services to take note of the mode change.
|
||||
|
||||
|
@ -60,7 +60,7 @@ If you wish to use two different usernames for the two different roles of monito
|
||||
|
||||
### Creating Your MaxScale Configuration
|
||||
|
||||
MaxScale configuration is held in an ini file that is located in the file MaxScale.cnf in the directory $MAXSCALE_HOME/etc, if you have installed in the default location then this file is available in /usr/local/mariadb-maxscale/etc/MaxScale.cnf. This is not created as part of the installation process and must be manually created. A template file does exist within this directory that may be use as a basis for your configuration.
|
||||
MaxScale configuration is held in an ini file that is located in the file maxscale.cnf in the directory /etc, if you have installed in the default location then this file is available in /etc/maxscale.cnf. This is not created as part of the installation process and must be manually created. A template file does exist within the /usr/share/maxscale directory that may be use as a basis for your configuration.
|
||||
|
||||
A global, maxscale, section is included within every MaxScale configuration file; this is used to set the values of various MaxScale wide parameters, perhaps the most important of these is the number of threads that MaxScale will use to execute the code that forwards requests and handles responses for clients.
|
||||
|
||||
@ -89,7 +89,7 @@ In order to instruct the router to which servers it should route we must add rou
|
||||
|
||||
The final step in the service section is to add the username and password that will be used to populate the user data from the database cluster. There are two options for representing the password, either plain text or encrypted passwords may be used. In order to use encrypted passwords a set of keys must be generated that will be used by the encryption and decryption process. To generate the keys use the maxkeys command and pass the name of the secrets file in which the keys are stored.
|
||||
|
||||
% maxkeys /usr/local/mariadb-maxscale/etc/.secrets
|
||||
% maxkeys /var/lib/maxscale/.secrets
|
||||
%
|
||||
|
||||
Once the keys have been created the maxpasswd command can be used to generate the encrypted password.
|
||||
@ -178,7 +178,7 @@ or
|
||||
|
||||
% service maxscale start
|
||||
|
||||
Check the error log in /usr/local/mariadb-maxscale/log to see if any errors are detected in the configuration file and to confirm MaxScale has been started. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
|
||||
Check the error log in /var/log/maxscale to see if any errors are detected in the configuration file and to confirm MaxScale has been started. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
|
||||
|
||||
% maxadmin -pmariadb list services
|
||||
|
||||
|
@ -62,7 +62,7 @@ If you wish to use two different usernames for the two different roles of monito
|
||||
|
||||
### Creating Your MaxScale Configuration
|
||||
|
||||
MaxScale configuration is held in an ini file that is located in the file MaxScale.cnf in the directory $MAXSCALE_HOME/etc, if you have installed in the default location then this file is available in /usr/local/mariadb-maxscale/etc/MaxScale.cnf. This is not created as part of the installation process and must be manually created. A template file does exist within this directory that may be use as a basis for your configuration.
|
||||
MaxScale configuration is held in an ini file that is located in the file maxscale.cnf in the directory /etc, if you have installed in the default location then this file is available in /etc/maxscale.cnf. This is not created as part of the installation process and must be manually created. A template file does exist within the /usr/share/maxscale directory that may be use as a basis for your configuration.
|
||||
|
||||
A global, maxscale, section is included within every MaxScale configuration file; this is used to set the values of various MaxScale wide parameters, perhaps the most important of these is the number of threads that MaxScale will use to execute the code that forwards requests and handles responses for clients.
|
||||
|
||||
@ -83,7 +83,7 @@ The router for we need to use for this configuration is the readwritesplit modul
|
||||
|
||||
The final step in the service sections is to add the username and password that will be used to populate the user data from the database cluster. There are two options for representing the password, either plain text or encrypted passwords may be used. In order to use encrypted passwords a set of keys must be generated that will be used by the encryption and decryption process. To generate the keys use the maxkeys command and pass the name of the secrets file in which the keys are stored.
|
||||
|
||||
% maxkeys /usr/local/mariadb-maxscale/etc/.secrets
|
||||
% maxkeys /var/lib/maxscale/.secrets
|
||||
%
|
||||
|
||||
Once the keys have been created the maxpasswd command can be used to generate the encrypted password.
|
||||
@ -183,7 +183,7 @@ or
|
||||
|
||||
% service maxscale start
|
||||
|
||||
Check the error log in /usr/local/mariadb-maxscale/log to see if any errors are detected in the configuration file and to confirm MaxScale has been started. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
|
||||
Check the error log in /var/log/maxscale to see if any errors are detected in the configuration file and to confirm MaxScale has been started. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
|
||||
|
||||
% maxadmin -pmariadb list services
|
||||
|
||||
|
@ -5,54 +5,65 @@ The plugin is capable of returning data in one of two ways, either as MySQL resu
|
||||
|
||||
# Configuration
|
||||
|
||||
The plugin is configured in the MaxScale.cnf plugin in much the same way as any other router service is configured, there needs to be a service section in the configuration file and also listeners defined for that service. The service does not however require any backend servers to be associated with it, or any monitors.
|
||||
The plugin is configured in the maxscale.cnf plugin in much the same way as any other router service is configured, there needs to be a service section in the configuration file and also listeners defined for that service. The service does not however require any backend servers to be associated with it, or any monitors.
|
||||
|
||||
The service entry needs to define the service name, the type as service and the router module to load.
|
||||
The specified user, with the password (plain or encrypted via maxpassword utility) is allowed to connect via MySQL protocol.
|
||||
Currently the user can connect to maxinfo from any remote IP and to localhost as well.
|
||||
|
||||
```
|
||||
[MaxInfo]
|
||||
type=service
|
||||
router=maxinfo
|
||||
user=monitor
|
||||
passwd=EBD2F49C3B375812A8CDEBA632ED8BBC
|
||||
```
|
||||
|
||||
The listener section defines the protocol, port and other information needed to create a listener for the service. To listen on a port using the MySQL protocol a section as shown below should be added to the configuration file.
|
||||
|
||||
```
|
||||
[MaxInfo Listener]
|
||||
type=listener
|
||||
service=MaxInfo
|
||||
protocol=MySQLClient
|
||||
port=9003
|
||||
```
|
||||
|
||||
To listen with the HTTP protocol and hence return JSON documents a section as should below is required.
|
||||
|
||||
```
|
||||
[MaxInfo JSON Listener]
|
||||
type=listener
|
||||
service=MaxInfo
|
||||
protocol=HTTPD
|
||||
port=8003
|
||||
|
||||
```
|
||||
|
||||
If both the MySQL and JSON responses are required then a single service can be configured with both types of listener.
|
||||
|
||||
As with any other listeners within MaxScale the listeners can be bound to a particular interface by use of the address= parameter. This allows the access to the maxinfo data to be limited to the localhost by adding an address=localhost parameter in the configuration file.
|
||||
|
||||
```
|
||||
[MaxInfo Listener]
|
||||
type=listener
|
||||
service=MaxInfo
|
||||
protocol=MySQLClient
|
||||
address=localhost
|
||||
port=9003
|
||||
```
|
||||
|
||||
# MySQL Interface to maxinfo
|
||||
|
||||
The maxinfo supports a small subset of SQL statements in addition to the MySQL status and ping requests. These may be used for simple monitoring of MaxScale.
|
||||
|
||||
```
|
||||
% mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz ping
|
||||
mysqld is alive
|
||||
% mysqladmin -hmaxscale.mariadb.com -P9003 -umonitor -pxyz status
|
||||
Uptime: 72 Threads: 1 Sessions: 11
|
||||
%
|
||||
```
|
||||
|
||||
The SQL command used to interact with maxinfo is the show command, a variety of show commands are available and will be described in the following sections.
|
||||
|
||||
@ -60,6 +71,7 @@ The SQL command used to interact with maxinfo is the show command, a variety of
|
||||
|
||||
The show variables command will display a set of name and value pairs for a number of MaxScale system variables.
|
||||
|
||||
```
|
||||
mysql> show variables;
|
||||
+--------------------+-------------------------+
|
||||
| Variable_name | Value |
|
||||
@ -77,9 +89,11 @@ The show variables command will display a set of name and value pairs for a numb
|
||||
9 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
The show variables command can also accept a limited like clause. This like clause must either be a literal string to match, a pattern starting with a %, a pattern ending with a % or a string with a % at both the start and the end.
|
||||
|
||||
```
|
||||
mysql> show variables like 'version';
|
||||
+---------------+----------------+
|
||||
| Variable_name | Value |
|
||||
@ -116,11 +130,13 @@ The show variables command can also accept a limited like clause. This like clau
|
||||
3 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
## Show status
|
||||
|
||||
The show status command displays a set of status counters, as with show variables the show status command can be passed a simplified like clause to limit the values returned.
|
||||
|
||||
```
|
||||
mysql> show status;
|
||||
+---------------------------+-------+
|
||||
| Variable_name | Value |
|
||||
@ -151,11 +167,13 @@ The show status command displays a set of status counters, as with show variable
|
||||
22 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
## Show services
|
||||
|
||||
The show services command will return a set of basic statistics regarding each of the configured services within MaxScale.
|
||||
|
||||
```
|
||||
mysql> show services;
|
||||
+----------------+----------------+--------------+----------------+
|
||||
| Service Name | Router Module | No. Sessions | Total Sessions |
|
||||
@ -172,6 +190,7 @@ The show services command will return a set of basic statistics regarding each o
|
||||
8 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
The show services command does not accept a like clause and will ignore any like clause that is given.
|
||||
|
||||
@ -179,6 +198,7 @@ The show services command does not accept a like clause and will ignore any like
|
||||
|
||||
The show listeners command will return a set of status information for every listener defined within the MaxScale configuration file.
|
||||
|
||||
```
|
||||
mysql> show listeners;
|
||||
+----------------+-----------------+-----------+------+---------+
|
||||
| Service Name | Protocol Module | Address | Port | State |
|
||||
@ -196,6 +216,7 @@ The show listeners command will return a set of status information for every lis
|
||||
9 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
The show listeners command will ignore any like clause passed to it.
|
||||
|
||||
@ -203,6 +224,7 @@ The show listeners command will ignore any like clause passed to it.
|
||||
|
||||
The show sessions command returns information on every active session within MaxScale. It will ignore any like clause passed to it.
|
||||
|
||||
```
|
||||
mysql> show sessions;
|
||||
+-----------+---------------+----------------+---------------------------+
|
||||
| Session | Client | Service | State |
|
||||
@ -222,11 +244,13 @@ The show sessions command returns information on every active session within Max
|
||||
11 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
## Show clients
|
||||
|
||||
The show clients command reports a row for every client application connected to MaxScale. Like clauses are not available of the show clients command.
|
||||
|
||||
```
|
||||
mysql> show clients;
|
||||
+-----------+---------------+---------+---------------------------+
|
||||
| Session | Client | Service | State |
|
||||
@ -237,11 +261,13 @@ The show clients command reports a row for every client application connected to
|
||||
2 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
## Show servers
|
||||
|
||||
The show servers command returns data for each backend server configured within the MaxScale configuration file. This data includes the current number of connections MaxScale has to that server and the state of that server as monitored by MaxScale.
|
||||
|
||||
```
|
||||
mysql> show servers;
|
||||
+---------+-----------+------+-------------+---------+
|
||||
| Server | Address | Port | Connections | Status |
|
||||
@ -254,11 +280,13 @@ The show servers command returns data for each backend server configured within
|
||||
4 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
## Show modules
|
||||
|
||||
The show modules command reports the information on the modules currently loaded into MaxScale. This includes the name type and version of each module. It also includes the API version the module has been written against and the current release status of the module.
|
||||
|
||||
```
|
||||
mysql> show modules;
|
||||
+----------------+-------------+---------+-------------+----------------+
|
||||
| Module Name | Module Type | Version | API Version | Status |
|
||||
@ -277,12 +305,13 @@ The show modules command reports the information on the modules currently loaded
|
||||
10 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
|
||||
```
|
||||
|
||||
## Show monitors
|
||||
|
||||
The show monitors command reports each monitor configured within the system and the state of that monitor.
|
||||
|
||||
```
|
||||
mysql> show monitors;
|
||||
+---------------+---------+
|
||||
| Monitor | Status |
|
||||
@ -292,12 +321,13 @@ The show monitors command reports each monitor configured within the system and
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
|
||||
```
|
||||
|
||||
## Show eventTimes
|
||||
|
||||
The show eventTimes command returns a table of statistics that reflect the performance of the event queuing and execution portion of the MaxScale core.
|
||||
|
||||
```
|
||||
mysql> show eventTimes;
|
||||
+---------------+-------------------+---------------------+
|
||||
| Duration | No. Events Queued | No. Events Executed |
|
||||
@ -336,6 +366,7 @@ The show eventTimes command returns a table of statistics that reflect the perfo
|
||||
30 rows in set (0.02 sec)
|
||||
|
||||
mysql>
|
||||
```
|
||||
|
||||
Each row represents a time interval, in 100ms increments, with the counts representing the number of events that were in the event queue for the length of time that row represents and the number of events that were executing of the time indicated by the row.
|
||||
|
||||
@ -347,6 +378,7 @@ The simplified JSON interface takes the URL of the request made to maxinfo and m
|
||||
|
||||
The /variables URL will return the MaxScale variables, these variables can not be filtered via this interface.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/variables
|
||||
[ { "Variable_name" : "version", "Value" : "1.0.6-unstable"},
|
||||
{ "Variable_name" : "version_comment", "Value" : "MariaDB MaxScale"},
|
||||
@ -358,11 +390,13 @@ The /variables URL will return the MaxScale variables, these variables can not b
|
||||
{ "Variable_name" : "MAXSCALE_UPTIME", "Value" : 3948},
|
||||
{ "Variable_name" : "MAXSCALE_SESSIONS", "Value" : 12}]
|
||||
$
|
||||
```
|
||||
|
||||
## Status
|
||||
|
||||
Use of the /status URI will return the status information that would normally be returned by the show status command. No filtering of the status information is available via this interface
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/status
|
||||
[ { "Variable_name" : "Uptime", "Value" : 3831},
|
||||
{ "Variable_name" : "Uptime_since_flush_status", "Value" : 3831},
|
||||
@ -387,11 +421,13 @@ Use of the /status URI will return the status information that would normally be
|
||||
{ "Variable_name" : "Max_event_queue_time", "Value" : 0},
|
||||
{ "Variable_name" : "Max_event_execution_time", "Value" : 1}]
|
||||
$
|
||||
```
|
||||
|
||||
## Services
|
||||
|
||||
The /services URI returns the data regarding the services defined within the configuration of MaxScale. Two counters are returned, the current number of sessions attached to this service and the total number connected since the service started.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/services
|
||||
[ { "Service Name" : "Test Service", "Router Module" : "readconnroute", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "Split Service", "Router Module" : "readwritesplit", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
@ -402,11 +438,13 @@ The /services URI returns the data regarding the services defined within the con
|
||||
{ "Service Name" : "CLI", "Router Module" : "cli", "No. Sessions" : 1, "Total Sessions" : 1},
|
||||
{ "Service Name" : "MaxInfo", "Router Module" : "maxinfo", "No. Sessions" : 5, "Total Sessions" : 20}]
|
||||
$
|
||||
```
|
||||
|
||||
## Listeners
|
||||
|
||||
The /listeners URI will return a JSON array with one entry per listener, each entry is a JSON object that describes the configuration and state of that listener.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/listeners
|
||||
[ { "Service Name" : "Test Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4006, "State" : "Running"},
|
||||
{ "Service Name" : "Split Service", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 4007, "State" : "Running"},
|
||||
@ -418,11 +456,13 @@ The /listeners URI will return a JSON array with one entry per listener, each en
|
||||
{ "Service Name" : "MaxInfo", "Protocol Module" : "MySQLClient", "Address" : "*", "Port" : 9003, "State" : "Running"},
|
||||
{ "Service Name" : "MaxInfo", "Protocol Module" : "HTTPD", "Address" : "*", "Port" : 8003, "State" : "Running"}]
|
||||
$
|
||||
```
|
||||
|
||||
## Modules
|
||||
|
||||
The /modules URI returns data for each plugin that has been loaded into MaxScale. The plugin name, type and version are returned as is the version of the plugin API that the plugin was built against and the release status of the plugin.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/modules
|
||||
[ { "Module Name" : "HTTPD", "Module Type" : "Protocol", "Version" : "V1.0.1", "API Version" : "1.0.0", "Status" : "In Development"},
|
||||
{ "Module Name" : "maxscaled", "Module Type" : "Protocol", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
@ -435,11 +475,13 @@ The /modules URI returns data for each plugin that has been loaded into MaxScale
|
||||
{ "Module Name" : "cli", "Module Type" : "Router", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "GA"},
|
||||
{ "Module Name" : "maxinfo", "Module Type" : "Router", "Version" : "V1.0.0", "API Version" : "1.0.0", "Status" : "Alpha"}]
|
||||
$
|
||||
```
|
||||
|
||||
## Sessions
|
||||
|
||||
The /sessions URI returns a JSON array with an object for each active session within MaxScale.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/sessions
|
||||
[ { "Session" : "0x1a8e9a0", "Client" : "80.176.79.245", "Service" : "MaxInfo", "State" : "Session ready for routing"},
|
||||
{ "Session" : "0x1a8e6d0", "Client" : "80.240.130.35", "Service" : "MaxInfo", "State" : "Session ready for routing"},
|
||||
@ -453,32 +495,38 @@ The /sessions URI returns a JSON array with an object for each active session wi
|
||||
{ "Session" : "0x1a5c530", "Client" : , "Service" : "Split Service", "State" : "Listener Session"},
|
||||
{ "Session" : "0x19ac1c0", "Client" : , "Service" : "Test Service", "State" : "Listener Session"}]
|
||||
$
|
||||
```
|
||||
|
||||
## Clients
|
||||
|
||||
The /clients URI is a limited version of the /sessions, in this case it only returns an entry for a session that represents a client connection.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/clients
|
||||
[ { "Session" : "0x1a90be0", "Client" : "80.176.79.245", "Service" : "MaxInfo", "State" : "Session ready for routing"},
|
||||
{ "Session" : "0x1a8e9a0", "Client" : "127.0.0.1", "Service" : "MaxInfo", "State" : "Session ready for routing"},
|
||||
{ "Session" : "0x1a8e6d0", "Client" : "80.240.130.35", "Service" : "MaxInfo", "State" : "Session ready for routing"}]
|
||||
$
|
||||
```
|
||||
|
||||
## Servers
|
||||
|
||||
The /servers URI is used to retrieve information for each of the servers defined within the MaxScale configuration. This information includes the connection count and the current status as monitored by MaxScale. The connection count is only those connections made by MaxScale to those servers.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/servers
|
||||
[ { "Server" : "server1", "Address" : "127.0.0.1", "Port" : 3306, "Connections" : 0, "Status" : "Running"},
|
||||
{ "Server" : "server2", "Address" : "127.0.0.1", "Port" : 3307, "Connections" : 0, "Status" : "Down"},
|
||||
{ "Server" : "server3", "Address" : "127.0.0.1", "Port" : 3308, "Connections" : 0, "Status" : "Down"},
|
||||
{ "Server" : "server4", "Address" : "127.0.0.1", "Port" : 3309, "Connections" : 0, "Status" : "Down"}]
|
||||
$
|
||||
```
|
||||
|
||||
## Event Times
|
||||
|
||||
The /event/times URI returns an array of statistics that reflect the performance of the event queuing and execution portion of the MaxScale core. Each element is an object that represents a time bucket, in 100ms increments, with the counts representing the number of events that were in the event queue for the length of time that row represents and the number of events that were executing of the time indicated by the object.
|
||||
|
||||
```
|
||||
$ curl http://maxscale.mariadb.com:8003/event/times
|
||||
[ { "Duration" : "< 100ms", "No. Events Queued" : 64, "No. Events Executed" : 63},
|
||||
{ "Duration" : " 100 - 200ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
@ -510,3 +558,4 @@ The /event/times URI returns an array of statistics that reflect the performance
|
||||
{ "Duration" : "2700 - 2800ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "2800 - 2900ms", "No. Events Queued" : 0, "No. Events Executed" : 0},
|
||||
{ "Duration" : "> 3000ms", "No. Events Queued" : 0, "No. Events Executed" : 0}]
|
||||
```
|
||||
|
@ -207,7 +207,7 @@ The SQL node is referenced here as [mysqld(API)], which reflects the fact that t
|
||||
|
||||
## Configuring MaxScale for connection load balancing of SQL nodes
|
||||
|
||||
Add these sections in MaxScale.cnf config file:
|
||||
Add these sections in maxscale.cnf config file:
|
||||
|
||||
[Cluster Service]
|
||||
type=service
|
||||
@ -249,7 +249,7 @@ Add these sections in MaxScale.cnf config file:
|
||||
|
||||
Assuming MaxScale is installed in server1, start it
|
||||
|
||||
[root@server1 ~]# cd /usr/local/mariadb-maxscale/bin
|
||||
[root@server1 ~]# cd /usr/bin
|
||||
|
||||
[root@server1 bin]# ./maxscale -c ../
|
||||
|
||||
|
@ -36,6 +36,7 @@ The first user required must be able to select data from the table mysql.user, t
|
||||
|
||||
2. Create the user, substituting the username, password and host on which maxscale runs within your environment
|
||||
|
||||
```
|
||||
MariaDB [(none)]> create user '*username*'@'*maxscalehost*' identified by '*password*';
|
||||
|
||||
**Query OK, 0 rows affected (0.00 sec)**
|
||||
@ -45,9 +46,11 @@ MariaDB [(none)]> create user '*username*'@'*maxscalehost*' identified by '*pass
|
||||
MariaDB [(none)]> grant SELECT on mysql.user to '*username*'@'*maxscalehost*';
|
||||
|
||||
**Query OK, 0 rows affected (0.03 sec)**
|
||||
```
|
||||
|
||||
Additionally, GRANT SELECT on the mysql.db table and SHOW DATABASES privileges are required in order to load databases name and grants suitable for database name authorization.
|
||||
|
||||
```
|
||||
MariaDB [(none)]> GRANT SELECT ON mysql.db TO 'username'@'maxscalehost';
|
||||
|
||||
**Query OK, 0 rows affected (0.00 sec)**
|
||||
@ -55,9 +58,11 @@ MariaDB [(none)]> GRANT SELECT ON mysql.db TO 'username'@'maxscalehost';
|
||||
MariaDB [(none)]> GRANT SHOW DATABASES ON *.* TO 'username'@'maxscalehost';
|
||||
|
||||
**Query OK, 0 rows affected (0.00 sec)**
|
||||
```
|
||||
|
||||
The second user is used to monitored the state of the cluster. This user, which may be the same username as the first, requires permissions to access the various sources of monitoring data. In order to monitor a replication cluster this user must be granted the roles REPLICATION SLAVE and REPLICATION CLIENT
|
||||
|
||||
```
|
||||
MariaDB [(none)]> grant REPLICATION SLAVE on *.* to '*username*'@'*maxscalehost*';
|
||||
|
||||
**Query OK, 0 rows affected (0.00 sec)**
|
||||
@ -65,220 +70,174 @@ MariaDB [(none)]> grant REPLICATION SLAVE on *.* to '*username*'@'*maxscalehost*
|
||||
MariaDB [(none)]> grant REPLICATION CLIENT on *.* to '*username*'@'*maxscalehost*';
|
||||
|
||||
**Query OK, 0 rows affected (0.00 sec)**
|
||||
```
|
||||
|
||||
If you wish to use two different usernames for the two different roles of monitoring and collecting user information then create a different username using the first two steps from above.
|
||||
|
||||
## Creating Your MaxScale Configuration
|
||||
|
||||
MaxScale configuration is held in an ini file that is located in the file MaxScale.cnf in the directory $MAXSCALE_HOME/etc, if you have installed in the default location then this file is available in /usr/local/mariadb/maxscle/etc/MaxScale.cnf. This is not created as part of the installation process and must be manually created. A template file does exist within this directory that may be use as a basis for your configuration.
|
||||
MaxScale configuration is held in an ini file that is located in the file maxscale.cnf in the directory /etc. This is not created as part of the installation process and must be manually created. A template file does exist in the `/usr/share/maxscale` folder that can be use as a basis for your configuration.
|
||||
|
||||
A global, maxscale, section is included within every MaxScale configuration file; this is used to set the values of various MaxScale wide parameters, perhaps the most important of these is the number of threads that MaxScale will use to execute the code that forwards requests and handles responses for clients.
|
||||
|
||||
```
|
||||
[maxscale]
|
||||
|
||||
threads=4
|
||||
```
|
||||
|
||||
Since we are using MySQL Replication and connection routing we want two different ports to which the client application can connect; one that will be directed to the current master within the replication cluster and another that will load balance between the slaves. To achieve this within MaxScale we need to define two services in the ini file; one for the read/write operations that should be executed on the master server and another for connections to one of the slaves. Create a section for each in your MaxScale.ini file and set the type to service, the section names are the names of the services themselves and should be meaningful to the administrator. Names may contain whitespace.
|
||||
|
||||
```
|
||||
[Write Service]
|
||||
|
||||
type=service
|
||||
|
||||
[Read Service]
|
||||
|
||||
type=service
|
||||
|
||||
```
|
||||
The router for these two sections is identical, the readconnroute module, also the services should be provided with the list of servers that will be part of the cluster. The server names given here are actually the names of server sections in the configuration file and not the physical hostnames or addresses of the servers.
|
||||
|
||||
```
|
||||
[Write Service]
|
||||
|
||||
type=service
|
||||
|
||||
router=readconnroute
|
||||
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
|
||||
[Read Service]
|
||||
|
||||
type=service
|
||||
|
||||
router=readconnroute
|
||||
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
```
|
||||
|
||||
In order to instruct the router to which servers it should route we must add router options to the service. The router options are compared to the status that the monitor collects from the servers and used to restrict the eligible set of servers to which that service may route. In our case we use the two options master and slave for our two services.
|
||||
|
||||
```
|
||||
[Write Service]
|
||||
|
||||
type=service
|
||||
|
||||
router=readconnroute
|
||||
|
||||
router_options=master
|
||||
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
|
||||
[Read Service]
|
||||
|
||||
type=service
|
||||
|
||||
router=readconnroute
|
||||
|
||||
router_options=slave
|
||||
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
```
|
||||
|
||||
The final step in the service sections is to add the username and password that will be used to populate the user data from the database cluster. There are two options for representing the password, either plain text or encrypted passwords may be used. In order to use encrypted passwords a set of keys must be generated that will be used by the encryption and decryption process. To generate the keys use the maxkeys command and pass the name of the secrets file in which the keys are stored.
|
||||
|
||||
% maxkeys /usr/local/mariadb-maxscale/etc/.secrets
|
||||
|
||||
%
|
||||
```
|
||||
maxkeys /var/lib/maxscale/.secrets
|
||||
```
|
||||
|
||||
Once the keys have been created the maxpasswd command can be used to generate the encrypted password.
|
||||
|
||||
% maxpasswd plainpassword
|
||||
|
||||
```
|
||||
maxpasswd plainpassword
|
||||
96F99AA1315BDC3604B006F427DD9484
|
||||
|
||||
%
|
||||
```
|
||||
|
||||
The username and password, either encrypted or plain text, are stored in the service section using the user and passwd parameters.
|
||||
|
||||
```
|
||||
[Write Service]
|
||||
|
||||
type=service
|
||||
|
||||
router=readconnroute
|
||||
|
||||
router_options=master
|
||||
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
|
||||
user=maxscale
|
||||
|
||||
passwd=96F99AA1315BDC3604B006F427DD9484
|
||||
|
||||
[Read Service]
|
||||
|
||||
type=service
|
||||
|
||||
router=readconnroute
|
||||
|
||||
router_options=slave
|
||||
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
|
||||
user=maxscale
|
||||
|
||||
passwd=96F99AA1315BDC3604B006F427DD9484
|
||||
```
|
||||
|
||||
This completes the definitions required by the services, however listening ports must be associated with the services in order to allow network connections. This is done by creating a series of listener sections. These sections again are named for the convenience of the administrator and should be of type listener with an entry labeled service which contains the name of the service to associate the listener with. Each service may have multiple listeners.
|
||||
|
||||
```
|
||||
[Write Listener]
|
||||
|
||||
type=listener
|
||||
|
||||
service=Write Service
|
||||
|
||||
[Read Listener]
|
||||
|
||||
type=listener
|
||||
|
||||
service=Read Service
|
||||
```
|
||||
|
||||
A listener must also define the protocol module it will use for the incoming network protocol, currently this should be the MySQLClient protocol for all database listeners. The listener may then supply a network port to listen on and/or a socket within the file system.
|
||||
|
||||
```
|
||||
[Write Listener]
|
||||
|
||||
type=listener
|
||||
|
||||
service=Write Service
|
||||
|
||||
protocol=MySQLClient
|
||||
|
||||
port=4306
|
||||
|
||||
socket=/tmp/ClusterMaster
|
||||
|
||||
[Read Listener]
|
||||
|
||||
type=listener
|
||||
|
||||
service=Read Service
|
||||
|
||||
protocol=MySQLClient
|
||||
|
||||
port=4307
|
||||
```
|
||||
|
||||
An address parameter may be given if the listener is required to bind to a particular network address when using hosts with multiple network addresses. The default behavior is to listen on all network interfaces.
|
||||
|
||||
The next stage is the configuration is to define the server information. This defines how to connect to each of the servers within the cluster, again a section is created for each server, with the type set to server, the network address and port to connect to and the protocol to use to connect to the server. Currently the protocol for all database connections in MySQLBackend.
|
||||
|
||||
```
|
||||
[dbserv1]
|
||||
|
||||
type=server
|
||||
|
||||
address=192.168.2.1
|
||||
|
||||
port=3306
|
||||
|
||||
protocol=MySQLBackend
|
||||
|
||||
[dbserv2]
|
||||
|
||||
type=server
|
||||
|
||||
address=192.168.2.2
|
||||
|
||||
port=3306
|
||||
|
||||
protocol=MySQLBackend
|
||||
|
||||
[dbserv3]
|
||||
|
||||
type=server
|
||||
|
||||
address=192.168.2.3
|
||||
|
||||
port=3306
|
||||
|
||||
protocol=MySQLBackend
|
||||
```
|
||||
|
||||
In order for MaxScale to monitor the servers using the correct monitoring mechanisms a section should be provided that defines the monitor to use and the servers to monitor. Once again a section is created with a symbolic name for the monitor, with the type set to monitor. Parameters are added for the module to use, the list of servers to monitor and the username and password to use when connecting to the the servers with the monitor.
|
||||
|
||||
```
|
||||
[Replication Monitor]
|
||||
|
||||
type=monitor
|
||||
|
||||
module=mysqlmon
|
||||
|
||||
servers=dbserv1, dbserv2, dbserv3
|
||||
|
||||
user=maxscale
|
||||
|
||||
passwd=96F99AA1315BDC3604B006F427DD9484
|
||||
```
|
||||
|
||||
As with the password definition in the server either plain text or encrypted passwords may be used.
|
||||
|
||||
The final stage in the configuration is to add the option service which is used by the maxadmin command to connect to MaxScale for monitoring and administration purposes. This creates a service section and a listener section.
|
||||
|
||||
```
|
||||
[CLI]
|
||||
|
||||
type=service
|
||||
|
||||
router=cli
|
||||
|
||||
[CLI Listener]
|
||||
|
||||
type=listener
|
||||
|
||||
service=CLI
|
||||
|
||||
protocol=maxscaled
|
||||
|
||||
address=localhost
|
||||
|
||||
port=6603
|
||||
```
|
||||
|
||||
In the case of the example above it should be noted that an address parameter has been given to the listener, this limits connections to maxadmin commands that are executed on the same machine that hosts MaxScale.
|
||||
|
||||
@ -286,14 +245,19 @@ In the case of the example above it should be noted that an address parameter ha
|
||||
|
||||
Upon completion of the configuration process MaxScale is ready to be started for the first time. This may either be done manually by running the maxscale command or via the service interface.
|
||||
|
||||
% maxscale
|
||||
```
|
||||
maxscale
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
% service maxscale start
|
||||
```
|
||||
service maxscale start
|
||||
```
|
||||
|
||||
Check the error log in /usr/local/mariadb-maxscale/log to see if any errors are detected in the configuration file and to confirm MaxScale has been started. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
|
||||
Check the error log in /var/log/lomaxscale/ to see if any errors are detected in the configuration file and to confirm MaxScale has been started. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
|
||||
|
||||
```
|
||||
% maxadmin -pmariadb list services
|
||||
|
||||
Services.
|
||||
@ -349,6 +313,7 @@ CLI | maxscaled | localhost | 6603 | Running
|
||||
---------------------+--------------------+-----------------+-------+--------
|
||||
|
||||
%
|
||||
```
|
||||
|
||||
MaxScale is now ready to start accepting client connections and routing them to the master or slaves within your cluster. Other configuration options are available that can alter the criteria used for routing, these include monitoring the replication lag within the cluster and routing only to slaves that are within a predetermined delay from the current master or using weights to obtain unequal balancing operations. These options may be found in the MaxScale Configuration Guide. More detail on the use of maxadmin can be found in the document "MaxAdmin - The MaxScale Administration & Monitoring Client Application".
|
||||
MaxScale is now ready to start accepting client connections and routing them to the master or slaves within your cluster. Other configuration options are available that can alter the criteria used for routing, these include monitoring the replication lag within the cluster and routing only to slaves that are within a predetermined delay from the current master or using weights to obtain unequal balancing operations. These options may be found in the MaxScale Configuration Guide. More detail on the use of maxadmin can be found in the document [MaxAdmin - The MaxScale Administration & Monitoring Client Application](Administration-Tutorial.md).
|
||||
|
||||
|
@ -70,7 +70,7 @@ If you wish to use two different usernames for the two different roles of monito
|
||||
|
||||
## Creating Your MaxScale Configuration
|
||||
|
||||
MaxScale configuration is held in an ini file that is located in the file MaxScale.cnf in the directory $MAXSCALE_HOME/etc, if you have installed in the default location then this file is available in /usr/local/mariadb-maxscale/etc/MaxScale.cnf. This is not created as part of the installation process and must be manually created. A template file does exist within this directory that may be use as a basis for your configuration.
|
||||
MaxScale configuration is held in an ini file that is located in the file maxscale.cnf in the directory /etc, if you have installed in the default location then this file is available in /etc/maxscale.cnf. This is not created as part of the installation process and must be manually created. A template file does exist within the /usr/share/maxscale directory that may be use as a basis for your configuration.
|
||||
|
||||
A global, maxscale, section is included within every MaxScale configuration file; this is used to set the values of various MaxScale wide parameters, perhaps the most important of these is the number of threads that MaxScale will use to execute the code that forwards requests and handles responses for clients.
|
||||
|
||||
@ -96,7 +96,7 @@ servers=dbserv1, dbserv2, dbserv3
|
||||
|
||||
The final step in the service sections is to add the username and password that will be used to populate the user data from the database cluster. There are two options for representing the password, either plain text or encrypted passwords may be used. In order to use encrypted passwords a set of keys must be generated that will be used by the encryption and decryption process. To generate the keys use the maxkeys command and pass the name of the secrets file in which the keys are stored.
|
||||
|
||||
% maxkeys /usr/local/mariadb-maxscale/etc/.secrets
|
||||
% maxkeys /var/lib/maxscale/.secrets
|
||||
|
||||
%
|
||||
|
||||
@ -226,7 +226,7 @@ or
|
||||
|
||||
% service maxscale start
|
||||
|
||||
Check the error log in /usr/local/mariadb-maxscale/log to see if any errors are detected in the configuration file and to confirm MaxScale has been started. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
|
||||
Check the error log in /var/log/maxscale to see if any errors are detected in the configuration file and to confirm MaxScale has been started. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
|
||||
|
||||
% maxadmin -pmariadb list services
|
||||
|
||||
|
@ -44,7 +44,7 @@ In order to use these scripts on your Nagios Server, you need to copy them from
|
||||
|
||||
MaxScale must be configured with 'maxscaled' protocol for the administration interface:
|
||||
|
||||
Example of MaxScale.cnf file:
|
||||
Example of maxscale.cnf file:
|
||||
|
||||
[AdminInterface]
|
||||
type=service
|
||||
@ -73,9 +73,9 @@ and add (just after localhost.cfg or commnads.cfg)
|
||||
- modify server IP address in server1.cfg, pointing to MaxScale server
|
||||
- maxadmin executable must be in the nagios server
|
||||
- default MaxScale AdminInterface port is 6603
|
||||
- default maxadmin executable path is /usr/local/mariadb-maxscale/bin/maxadmin
|
||||
- default maxadmin executable path is /usr/bin/maxadmin
|
||||
It can be changed by -m option
|
||||
- maxadmin executable could be copied from an existing maxscale installation (default location is /usr/local/mariadb-maxscale/bin/maxadmin)
|
||||
- maxadmin executable could be copied from an existing maxscale installation (default location is /usr/bin/maxadmin)
|
||||
|
||||
This example shows configuration that needs to be done on Nagios server in order to communicate to MaxScale server that is running on host server1.
|
||||
In this example we are using the check_maxscale_resource as the check command
|
||||
|
@ -193,7 +193,7 @@ This generates RPM or DEB packages based on your system. These packages can then
|
||||
|
||||
## Step 5 - Configure new applications
|
||||
|
||||
The new filter needs to be configured in MaxScale.cnf.
|
||||
The new filter needs to be configured in maxscale.cnf.
|
||||
|
||||
[Test Service]
|
||||
type=service
|
||||
|
@ -28,7 +28,7 @@ Using MaxScale as a replication proxy is much the same as using MaxScale as a pr
|
||||
|
||||
## Service Configuration
|
||||
|
||||
As with any MaxScale configuration a good starting point is with the service definition with the MaxScale.cnf file. The service requires a name which is the section name in the ini file, a type parameter with a value of service and the name of the router plugin that should be loaded. In the case of replication proxies this router name is binlogrouter.
|
||||
As with any MaxScale configuration a good starting point is with the service definition with the maxscale.cnf file. The service requires a name which is the section name in the ini file, a type parameter with a value of service and the name of the router plugin that should be loaded. In the case of replication proxies this router name is binlogrouter.
|
||||
|
||||
|
||||
[Replication]
|
||||
@ -84,7 +84,7 @@ This optional parameter allows for the administrator to define the number of the
|
||||
|
||||
### binlogdir
|
||||
|
||||
This parameter allows the location that MaxScale uses to store binlog files to be set. If this parameter is not set to a directory name then MaxScale will store the binlog files in the directory $MAXSCALE_HOME/<Service Name>.
|
||||
This parameter allows the location that MaxScale uses to store binlog files to be set. If this parameter is not set to a directory name then MaxScale will store the binlog files in the directory /var/cache/maxscale/<Service Name>.
|
||||
|
||||
### heartbeat
|
||||
|
||||
|
@ -32,7 +32,7 @@ Upon successful completion of the installation command you will have MaxScale in
|
||||
|
||||
### Creating Your MaxScale Configuration
|
||||
|
||||
The first step in the creation of your MaxScale.cnf file is to define the global maxscale section. This section configures the number of threads MaxScale uses. A good rule of thumb is to use at most as may threads as you have CPUs. MaxScale uses few threads for internal operations so one or two threads less than the maximum should be enough.
|
||||
The first step in the creation of your maxscale.cnf file is to define the global maxscale section. This section configures the number of threads MaxScale uses. A good rule of thumb is to use at most as may threads as you have CPUs. MaxScale uses few threads for internal operations so one or two threads less than the maximum should be enough.
|
||||
|
||||
```
|
||||
[maxscale]
|
||||
@ -92,7 +92,7 @@ After this we have a fully working configuration and we can move on to starting
|
||||
|
||||
Upon completion of the configuration process MaxScale is ready to be started . This may either be done manually by running the maxscale command or via the service interface. The service scripts are located in the `/etc/init.d/` folder and are accessible through both the `service` and `systemctl` commands.
|
||||
|
||||
After starting MaxScale check the error log in /usr/local/mariadb-maxscale/log to see if any errors are detected in the configuration file. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
|
||||
After starting MaxScale check the error log in /var/log/maxscale to see if any errors are detected in the configuration file. Also the maxadmin command may be used to confirm that MaxScale is running and the services, listeners etc have been correctly configured.
|
||||
|
||||
MaxScale is now ready to start accepting client connections and routing them. Queries are routed to the right servers based on the database they target and switching between the shards is seamless since MaxScale keeps the session state intact between servers.
|
||||
|
||||
|
@ -5,7 +5,7 @@ The database firewall filter is used to block queries that match a set of rules.
|
||||
|
||||
## Configuration
|
||||
|
||||
The database firewall filter only requires minimal configuration in the MaxScale.cnf file. The actual rules of the database firewall filter are located in a separate text file. The following is an example of a database firewall filter configuration in MaxScale.cnf.
|
||||
The database firewall filter only requires minimal configuration in the maxscale.cnf file. The actual rules of the database firewall filter are located in a separate text file. The following is an example of a database firewall filter configuration in maxscale.cnf.
|
||||
|
||||
```
|
||||
[DatabaseFirewall]
|
||||
|
@ -6,7 +6,7 @@ The Query Log All (QLA) filter is a filter module for MaxScale that is
|
||||
|
||||
## Configuration
|
||||
|
||||
The configuration block for the QLA filter requires the minimal filter options in it's section within the MaxScale.cnf file, stored in $MAXSCALE_HOME/etc/MaxScale.cnf.
|
||||
The configuration block for the QLA filter requires the minimal filter options in it's section within the maxscale.cnf file, stored in /etc/maxscale.cnf.
|
||||
```
|
||||
[MyLogFilter]
|
||||
type=filter
|
||||
|
@ -5,9 +5,9 @@ This filter is designed to extract queries and transform them into a canonical f
|
||||
|
||||
## Configuration
|
||||
|
||||
The configuration block for the **mqfilter** filter requires the minimal filter options in it’s section within the MaxScale.cnf file, stored in $MAXSCALE_HOME/etc/MaxScale.cnf. Although the filter will start, it will use the default values which only work with a freshly installed RabbitMQ server and use its default values. This setup is mostly intended for testing the filter.
|
||||
The configuration block for the **mqfilter** filter requires the minimal filter options in it’s section within the maxscale.cnf file, stored in /etc/maxscale.cnf. Although the filter will start, it will use the default values which only work with a freshly installed RabbitMQ server and use its default values. This setup is mostly intended for testing the filter.
|
||||
|
||||
The following is an example of a mqfilter configuration in the MaxScale.cnf file used for actual logging of queries to a RabbitMQ broker on a different host.
|
||||
The following is an example of a mqfilter configuration in the maxscale.cnf file used for actual logging of queries to a RabbitMQ broker on a different host.
|
||||
|
||||
```
|
||||
[RabbitMQ]
|
||||
|
@ -6,7 +6,7 @@ The regex filter is a filter module for MaxScale that is able to rewrite query c
|
||||
|
||||
# Configuration
|
||||
|
||||
The configuration block for the Regex filter requires the minimal filter options in it’s section within the MaxScale.cnf file, stored in $MAXSCALE_HOME/etc/MaxScale.cnf.
|
||||
The configuration block for the Regex filter requires the minimal filter options in it’s section within the maxscale.cnf file, stored in /etc/maxscale.cnf.
|
||||
|
||||
```
|
||||
[MyRegexFilter]
|
||||
|
@ -6,7 +6,7 @@ The tee filter is a filter module for MaxScale is a "plumbing" fitting in the Ma
|
||||
|
||||
# Configuration
|
||||
|
||||
The configuration block for the TEE filter requires the minimal filter parameters in it’s section within the MaxScale.cnf file, stored in $MAXSCALE_HOME/etc/MaxScale.cnf, that defines the filter to load and the service to send the duplicates to. Currently the tee filter does not support multi-statements.
|
||||
The configuration block for the TEE filter requires the minimal filter parameters in it’s section within the maxscale.cnf file, stored in /etc/maxscale.cnf, that defines the filter to load and the service to send the duplicates to. Currently the tee filter does not support multi-statements.
|
||||
|
||||
```
|
||||
[DataMartFilter]
|
||||
|
@ -6,7 +6,7 @@ The top filter is a filter module for MaxScale that monitors every SQL statement
|
||||
|
||||
# Configuration
|
||||
|
||||
The configuration block for the TOP filter requires the minimal filter options in it’s section within the MaxScale.cnf file, stored in $MAXSCALE_HOME/etc/MaxScale.cnf.
|
||||
The configuration block for the TOP filter requires the minimal filter options in it’s section within the maxscale.cnf file, stored in /etc/maxscale.cnf.
|
||||
|
||||
```
|
||||
[MyLogFilter]
|
||||
|
69
Documentation/maxscale.1
Normal file
69
Documentation/maxscale.1
Normal file
@ -0,0 +1,69 @@
|
||||
.TH maxscale 1
|
||||
.SH NAME
|
||||
maxscale - The intelligent proxy
|
||||
.SH SYNOPSIS
|
||||
.B maxscale
|
||||
[\fIOPTIONS...\fR]
|
||||
.SH DESCRIPTION
|
||||
The MariaDB Corporation MaxScale is an intelligent proxy that allows forwarding of
|
||||
database statements to one or more database servers using complex rules,
|
||||
a semantic understanding of the database statements and the roles of
|
||||
the various servers within the backend cluster of databases.
|
||||
|
||||
MaxScale is designed to provide load balancing and high availability
|
||||
functionality transparently to the applications. In addition it provides
|
||||
a highly scalable and flexible architecture, with plugin components to
|
||||
support different protocols and routing decisions.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BR "-d, --nodaemon"
|
||||
Run MaxScale in the terminal process
|
||||
.TP
|
||||
.BR -f " \fIFILE\fB, --config=\fIFILE\fR"
|
||||
Relative or absolute pathname of MaxScale configuration file to load.
|
||||
.TP
|
||||
.BR -l "[\fIfile|shm\fB], --log=[\fIfile|shm\fB]"
|
||||
Log trace and debug logs to file or shared memory. The debug and trace logs are disabled by default and if enabled, will log to shared memory.
|
||||
.TP
|
||||
.BR -L " \fIPATH\fB, --logdir=\fIPATH\fB"
|
||||
Path to log file directory.
|
||||
.TP
|
||||
.BR -D " \fIPATH\fB, --datadir=\fIPATH\fB"
|
||||
Path to data directory. This is where the embedded mysql tables are stored in addition to other MaxScale specific data.
|
||||
.TP
|
||||
.BR -C " \fIPATH\fB, --configdir=\fIPATH\fB"
|
||||
Path to configuration file directory. MaxScale will look for the \fImaxscale.cnf\fR file from this folder.
|
||||
.TP
|
||||
.BR -B " \fIPATH\fB, --libdir=\fIPATH\fB"
|
||||
Path to module directory. Modules are only searched from this folder.
|
||||
.TP
|
||||
.BR -A " \fIPATH\fB, --cachedir=\fIPATH\fB"
|
||||
Path to cache directory. This is where MaxScale stores cached authentication data.
|
||||
.TP
|
||||
.BR -P " \fIPATH\fB, --piddir=\fIPATH\fB"
|
||||
Location of MaxScale's PID file.
|
||||
.TP
|
||||
.BR -U " \fIUSER\fB, --user=\fIUSER\fB"
|
||||
Run MaxScale as another user. The user ID and group ID of this user are used to run MaxScale.
|
||||
.TP
|
||||
.BR -s " [\fIyes\fB|\fIno\fB], --syslog=[\fIyes\fB|\fIno\fB]"
|
||||
Log messages to syslog.
|
||||
.TP
|
||||
.BR -S " [\fIyes\fB|\fIno\fB], \fB--maxscalelog=[\fIyes\fB|\fIno\fB]"
|
||||
Log messages to MaxScale's own log files.
|
||||
.TP
|
||||
.BR "-v, --version"
|
||||
Print version information and exit.
|
||||
.TP
|
||||
.BR "-?, --help"
|
||||
Show the help information for MaxScale and exit.
|
||||
|
||||
.SH EXAMPLES
|
||||
Tutorials on GitHub:
|
||||
.UR https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Documentation-Contents.md#tutorials
|
||||
.UE
|
||||
.SH SEE ALSO
|
||||
The MaxScale documentation on GitHub:
|
||||
.UR https://github.com/mariadb-corporation/MaxScale/blob/master/Documentation/Documentation-Contents.md
|
||||
.UE
|
@ -108,7 +108,7 @@ master_down|A Master server has gone down
|
||||
master_up|A Master server has come up
|
||||
slave_down|A Slave server has gone down
|
||||
slave_up|A Slave server has come up
|
||||
server_down|A server with no assigned role has done down
|
||||
server_down|A server with no assigned role has gone down
|
||||
server_up|A server with no assigned role has come up
|
||||
synced_down|A synced Galera node has come up
|
||||
synced_up|A synced Galera node has gone down
|
||||
|
@ -99,7 +99,7 @@ master_down|A Master server has gone down
|
||||
master_up|A Master server has come up
|
||||
slave_down|A Slave server has gone down
|
||||
slave_up|A Slave server has come up
|
||||
server_down|A server with no assigned role has done down
|
||||
server_down|A server with no assigned role has gone down
|
||||
server_up|A server with no assigned role has come up
|
||||
lost_master|A server lost Master status
|
||||
lost_slave|A server lost Slave status
|
||||
|
@ -108,10 +108,40 @@ master_down|A Master server has gone down
|
||||
master_up|A Master server has come up
|
||||
slave_down|A Slave server has gone down
|
||||
slave_up|A Slave server has come up
|
||||
server_down|A server with no assigned role has done down
|
||||
server_down|A server with no assigned role has gone down
|
||||
server_up|A server with no assigned role has come up
|
||||
lost_master|A server lost Master status
|
||||
lost_slave|A server lost Slave status
|
||||
new_master|A new Master was detected
|
||||
new_slave|A new Slave was detected
|
||||
|
||||
|
||||
## Example 1 - Monitor script
|
||||
|
||||
Here is an example shell script which sends an email to an admin when a server goes down.
|
||||
|
||||
```
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#This script assumes that the local mail server is configured properly
|
||||
#The second argument is the event type
|
||||
event=${$2/.*=/}
|
||||
server=${$3/.*=/}
|
||||
message="A server has gone down at `date`."
|
||||
echo $message|mail -s "The event was $event for server $server." admin@my.org
|
||||
|
||||
```
|
||||
|
||||
Here is a monitor configuration that only triggers the script when a master or a slave server goes down.
|
||||
|
||||
```
|
||||
[Database Monitor]
|
||||
type=monitor
|
||||
module=mysqlmon
|
||||
servers=server1,server2
|
||||
script=mail_to_admin.sh
|
||||
events=master_down,slave_down
|
||||
```
|
||||
|
||||
When a master or a slave server goes down, the script is executed, a mail is sent and the administrator will be immediately notified of any possible problems.
|
||||
This is just a simple example showing what you can do with MaxScale and monitor scripts.
|
||||
|
@ -89,7 +89,7 @@ master_down|A Master server has gone down
|
||||
master_up|A Master server has come up
|
||||
slave_down|A Slave server has gone down
|
||||
slave_up|A Slave server has come up
|
||||
server_down|A server with no assigned role has done down
|
||||
server_down|A server with no assigned role has gone down
|
||||
server_up|A server with no assigned role has come up
|
||||
ndb_down|A MySQL Cluster node has gone down
|
||||
ndb_up|A MySQL Cluster node has come up
|
||||
|
@ -7,4 +7,4 @@ if(HIST)
|
||||
else()
|
||||
message(STATUS "Could not find editline library. MaxAdmin will be built without it.")
|
||||
endif()
|
||||
install(TARGETS maxadmin DESTINATION bin)
|
||||
install(TARGETS maxadmin DESTINATION ${MAXSCALE_BINDIR})
|
||||
|
12
cmake/install_layout.cmake
Normal file
12
cmake/install_layout.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
# Set the install layout
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(MAXSCALE_LIBDIR ${CMAKE_INSTALL_LIBDIR}/maxscale CACHE PATH "Library installation path")
|
||||
set(MAXSCALE_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Executable installation path")
|
||||
set(MAXSCALE_SHAREDIR ${CMAKE_INSTALL_DATADIR}/maxscale CACHE PATH "Share file installation path, includes licence and readme files")
|
||||
set(MAXSCALE_DOCDIR ${CMAKE_INSTALL_DOCDIR}/maxscale CACHE PATH "Documentation installation path, text versions only")
|
||||
set(MAXSCALE_CONFDIR ${CMAKE_INSTALL_SYSCONFDIR} CACHE PATH "Configuration file installation path, this is not usually needed")
|
||||
|
||||
# This is the only hard-coded absolute path
|
||||
set(MAXSCALE_VARDIR /var CACHE PATH "Data file path (usually /var/)")
|
||||
|
@ -132,29 +132,9 @@ macro(check_deps)
|
||||
endif()
|
||||
|
||||
|
||||
# set(MAXSCALE_DEPS aio ssl crypt crypto z m dl rt pthread)
|
||||
# foreach(lib ${MAXSCALE_DEPS})
|
||||
# find_library(lib${lib} ${lib})
|
||||
# if((DEFINED lib${lib}) AND (${lib${lib}} MATCHES "NOTFOUND"))
|
||||
# set(DEPS_ERROR TRUE)
|
||||
# set(FAILED_DEPS "${FAILED_DEPS} lib${lib}")
|
||||
# elseif(DEBUG_OUTPUT)
|
||||
# message(STATUS "Library was found at: ${lib${lib}}")
|
||||
# endif()
|
||||
# endforeach()
|
||||
|
||||
# if(DEPS_ERROR)
|
||||
# set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
# message(FATAL_ERROR "Cannot find dependencies: ${FAILED_DEPS}")
|
||||
# endif()
|
||||
|
||||
endmacro()
|
||||
|
||||
macro(check_dirs)
|
||||
|
||||
# This variable is used to prevent redundant checking of dependencies
|
||||
set(DEPS_OK TRUE CACHE BOOL "If all the dependencies were found.")
|
||||
|
||||
# Find the MySQL headers if they were not defined
|
||||
|
||||
if(DEFINED MYSQL_DIR)
|
||||
@ -168,7 +148,6 @@ macro(check_dirs)
|
||||
debugmsg("Search returned: ${MYSQL_DIR_LOC}")
|
||||
|
||||
if(${MYSQL_DIR_LOC} MATCHES "NOTFOUND")
|
||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
message(FATAL_ERROR "Fatal Error: MySQL headers were not found.")
|
||||
else()
|
||||
set(MYSQL_DIR ${MYSQL_DIR_LOC} CACHE PATH "Path to MySQL headers" FORCE)
|
||||
@ -193,7 +172,6 @@ debugmsg("Search returned: ${MYSQL_DIR_LOC}")
|
||||
else()
|
||||
find_file(ERRMSG_FILE errmsg.sys PATHS /usr/share /usr/share/mysql /usr/local/share/mysql PATH_SUFFIXES english mysql/english)
|
||||
if(${ERRMSG_FILE} MATCHES "NOTFOUND")
|
||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found, please define the path to it by using -DERRMSG=<path>")
|
||||
else()
|
||||
message(STATUS "Using errmsg.sys found at: ${ERRMSG_FILE}")
|
||||
@ -202,75 +180,12 @@ debugmsg("Search returned: ${MYSQL_DIR_LOC}")
|
||||
set(ERRMSG ${ERRMSG_FILE} CACHE FILEPATH "Path to the errmsg.sys file." FORCE)
|
||||
unset(ERRMSG_FILE)
|
||||
|
||||
# Find the embedded mysql library
|
||||
|
||||
# if (DEFINED EMBEDDED_LIB)
|
||||
# if( NOT (IS_DIRECTORY ${EMBEDDED_LIB}) )
|
||||
# debugmsg("EMBEDDED_LIB is not a directory: ${EMBEDDED_LIB}")
|
||||
# if(${CMAKE_VERSION} VERSION_LESS 2.8.12 )
|
||||
# set(COMP_VAR PATH)
|
||||
# else()
|
||||
# set(COMP_VAR DIRECTORY)
|
||||
# endif()
|
||||
# get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} ${COMP_VAR})
|
||||
# debugmsg("EMBEDDED_LIB directory component: ${EMBEDDED_LIB}")
|
||||
# endif()
|
||||
# debugmsg("Searching for the embedded library at: ${EMBEDDED_LIB}")
|
||||
# endif()
|
||||
|
||||
# if(STATIC_EMBEDDED)
|
||||
|
||||
# debugmsg("Using the static embedded library...")
|
||||
# set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
# set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
# if (DEFINED EMBEDDED_LIB)
|
||||
# debugmsg("Searching for libmysqld.a at: ${EMBEDDED_LIB}")
|
||||
# find_library(EMBEDDED_LIB_STATIC libmysqld.a PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
|
||||
# else()
|
||||
# find_library(EMBEDDED_LIB_STATIC libmysqld.a PATH_SUFFIXES mysql mariadb)
|
||||
# endif()
|
||||
# debugmsg("Search returned: ${EMBEDDED_LIB_STATIC}")
|
||||
|
||||
# set(EMBEDDED_LIB ${EMBEDDED_LIB_STATIC} CACHE FILEPATH "Path to libmysqld" FORCE)
|
||||
# set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
|
||||
|
||||
# else()
|
||||
# debugmsg("Using the dynamic embedded library...")
|
||||
# set(OLD_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
# set(CMAKE_FIND_LIBRARY_SUFFIXES ".so")
|
||||
# if (DEFINED EMBEDDED_LIB)
|
||||
# debugmsg("Searching for libmysqld.so at: ${EMBEDDED_LIB}")
|
||||
# find_library(EMBEDDED_LIB_DYNAMIC mysqld PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
|
||||
# else()
|
||||
# find_library(EMBEDDED_LIB_DYNAMIC mysqld PATH_SUFFIXES mysql mariadb)
|
||||
# endif()
|
||||
# debugmsg("Search returned: ${EMBEDDED_LIB_DYNAMIC}")
|
||||
# set(EMBEDDED_LIB ${EMBEDDED_LIB_DYNAMIC} CACHE FILEPATH "Path to libmysqld" FORCE)
|
||||
# set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
|
||||
|
||||
# endif()
|
||||
|
||||
# unset(EMBEDDED_LIB_DYNAMIC)
|
||||
# unset(EMBEDDED_LIB_STATIC)
|
||||
# unset(OLD_SUFFIXES)
|
||||
|
||||
# # Inform the user about the embedded library
|
||||
# if( (${EMBEDDED_LIB} MATCHES "NOTFOUND") OR (${EMBEDDED_LIB} MATCHES "NOTFOUND"))
|
||||
# set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
# message(FATAL_ERROR "Library not found: libmysqld. If your install of MySQL is in a non-default location, please provide the location with -DEMBEDDED_LIB=<path to library>")
|
||||
# else()
|
||||
# get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} REALPATH)
|
||||
# message(STATUS "Using embedded library: ${EMBEDDED_LIB}")
|
||||
# endif()
|
||||
|
||||
|
||||
# Check which init.d script to install
|
||||
if(WITH_SCRIPTS)
|
||||
find_file(RPM_FNC functions PATHS /etc/rc.d/init.d)
|
||||
if(${RPM_FNC} MATCHES "RPM_FNC-NOTFOUND")
|
||||
find_file(DEB_FNC init-functions PATHS /lib/lsb)
|
||||
if(${DEB_FNC} MATCHES "DEB_FNC-NOTFOUND")
|
||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||
message(FATAL_ERROR "Cannot find required init-functions in /lib/lsb/ or /etc/rc.d/init.d/, please confirm that your system files are OK.")
|
||||
else()
|
||||
set(DEB_BASED TRUE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.")
|
6
cmake/package_deb.cmake
Normal file
6
cmake/package_deb.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
# DEB specific CPack configuration parameters
|
||||
set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB")
|
||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/postinst;{CMAKE_BINARY_DIR}/postrm")
|
||||
execute_process(COMMAND dpgk --print-architecture OUTPUT_VARIABLE DEB_ARCHITECTURE)
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DEB_ARCHITECTURE})
|
||||
set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
23
cmake/package_rpm.cmake
Normal file
23
cmake/package_rpm.cmake
Normal file
@ -0,0 +1,23 @@
|
||||
# RPM specific CPack configuration parameters
|
||||
set(CPACK_GENERATOR "${CPACK_GENERATOR};RPM")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MaxScale")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${MAXSCALE_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${MAXSCALE_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${MAXSCALE_VERSION_PATCH}")
|
||||
set(CPACK_PACKAGE_CONTACT "MariaDB Corporation Ab")
|
||||
set(CPACK_PACKAGE_FILE_NAME "maxscale-${MAXSCALE_VERSION}")
|
||||
set(CPACK_PACKAGE_NAME "maxscale")
|
||||
set(CPACK_PACKAGE_VENDOR "MariaDB Corporation Ab")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_SOURCE_DIR}/etc/DESCRIPTION)
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
set(CPACK_RPM_PACKAGE_RELEASE ${MAXSCALE_BUILD_NUMBER})
|
||||
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_BINARY_DIR}/postinst)
|
||||
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_BINARY_DIR}/postrm)
|
||||
set(CPACK_RPM_PACKAGE_NAME "maxscale")
|
||||
set(CPACK_RPM_PACKAGE_VENDOR "MariaDB Corporation Ab")
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "GPLv2")
|
||||
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/etc /etc/ld.so.conf.d /etc/init.d /etc/rc.d/init.d")
|
||||
set(CPACK_RPM_SPEC_MORE_DEFINE "%define ignore \#")
|
||||
set(CPACK_RPM_USER_FILELIST "%ignore /etc/init.d")
|
||||
set(CPACK_RPM_USER_FILELIST "%ignore /etc/ld.so.conf.d")
|
||||
set(CPACK_RPM_USER_FILELIST "%ignore /etc")
|
@ -1,4 +1,5 @@
|
||||
execute_process(COMMAND /bin/sh -c "${CMAKE_BINARY_DIR}/bin/maxscale -c ${CMAKE_BINARY_DIR} &>/dev/null 2> /dev/null > /dev/null")
|
||||
execute_process(COMMAND /bin/sh -c "${CMAKE_BINARY_DIR}/bin/maxscale -f ${CMAKE_BINARY_DIR}/maxscale.cnf --logdir=${CMAKE_BINARY_DIR}/ --datadir=${CMAKE_BINARY_DIR}/ --cachedir=${CMAKE_BINARY_DIR}/ &> ${CMAKE_BINARY_DIR}/maxscale.output"
|
||||
OUTPUT_VARIABLE MAXSCALE_OUT)
|
||||
execute_process(COMMAND make test RESULT_VARIABLE RVAL)
|
||||
execute_process(COMMAND killall maxscale)
|
||||
if(NOT RVAL EQUAL 0)
|
||||
|
@ -18,12 +18,11 @@
|
||||
### END INIT INFO
|
||||
|
||||
#############################################
|
||||
# MaxScale HOME, PIDFILE, LIB
|
||||
# MaxScale PIDFILE and LIB
|
||||
#############################################
|
||||
|
||||
export MAXSCALE_HOME=@CMAKE_INSTALL_PREFIX@
|
||||
export MAXSCALE_PIDFILE=$MAXSCALE_HOME/log/maxscale.pid
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MAXSCALE_HOME/lib
|
||||
export MAXSCALE_PIDFILE=@MAXSCALE_VARDIR@/run/maxscale/maxscale.pid
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@/maxscale
|
||||
|
||||
###############################
|
||||
# LSB Exit codes (non-Status)
|
||||
@ -39,7 +38,7 @@ _RETVAL_STATUS_OK=0
|
||||
_RETVAL_STATUS_NOT_RUNNING=3
|
||||
|
||||
# Sanity checks.
|
||||
[ -x $MAXSCALE_HOME/bin/maxscale ] || exit $_RETVAL_NOT_INSTALLED
|
||||
[ -x @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale ] || exit $_RETVAL_NOT_INSTALLED
|
||||
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
@ -52,23 +51,23 @@ RETVAL=0
|
||||
|
||||
start() {
|
||||
echo -n $"Starting MaxScale: "
|
||||
my_check=`status -p $MAXSCALE_PIDFILE $MAXSCALE_HOME/bin/maxscale`
|
||||
my_check=`status -p $MAXSCALE_PIDFILE @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale`
|
||||
CHECK_RET=$?
|
||||
[ $CHECK_RET -eq 0 ] && echo -n " found $my_check" && success && CHECK_RET=0
|
||||
|
||||
daemon --pidfile $MAXSCALE_PIDFILE $MAXSCALE_HOME/bin/maxscale >& /dev/null
|
||||
daemon --pidfile $MAXSCALE_PIDFILE @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale --user=maxscale >& /dev/null
|
||||
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename
|
||||
|
||||
if [ $CHECK_RET -ne 0 ]; then
|
||||
sleep 2
|
||||
my_check=`status -p $MAXSCALE_PIDFILE $MAXSCALE_HOME/bin/maxscale`
|
||||
my_check=`status -p $MAXSCALE_PIDFILE @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale`
|
||||
CHECK_RET=$?
|
||||
[ $CHECK_RET -eq 0 ] && echo -n $my_check && success || failure
|
||||
fi
|
||||
|
||||
# Return rigth code
|
||||
# Return right code
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
failure
|
||||
RETVAL=$_RETVAL_NOT_RUNNING
|
||||
@ -100,7 +99,7 @@ stop() {
|
||||
reload() {
|
||||
echo -n $"Reloading MaxScale: "
|
||||
|
||||
killproc -p $MAXSCALE_PIDFILE $MAXSCALE_HOME/bin/maxscale -HUP
|
||||
killproc -p $MAXSCALE_PIDFILE @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale -HUP
|
||||
RETVAL=$?
|
||||
echo
|
||||
}
|
||||
|
30
etc/lsyncd_example.conf
Normal file
30
etc/lsyncd_example.conf
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
-- Lsyncd will log to these two files.
|
||||
settings{
|
||||
logfile = "/var/log/maxscale/maxscale-ha.log",
|
||||
statusFile = "/var/log/maxscale/maxscale-ha-status.log"
|
||||
}
|
||||
|
||||
-- Copy and paste the sync section and change the host value to add new remote targets.
|
||||
sync{
|
||||
default.rsyncssh,
|
||||
|
||||
-- This is where the maxscale.cnf file is copied from.
|
||||
source="/etc",
|
||||
|
||||
-- This is the user and host where the maxscale.cnf is copied to.
|
||||
host="user@127.0.0.1",
|
||||
|
||||
-- This is where the maxscale.cnf is copied to on the remote host.
|
||||
targetdir="/etc",
|
||||
|
||||
-- This is an optional section which defines a custom SSH port. Uncomment to enable.
|
||||
-- ssh={port=2222},
|
||||
|
||||
-- These are values passed to rsync. Only change these if you know what you are doing.
|
||||
rsync={
|
||||
compress=true,
|
||||
_extra = {[[--filter=+ *maxscale.cnf]],
|
||||
[[--filter=- **]]}
|
||||
}
|
||||
}
|
12
etc/maxscale.service.in
Normal file
12
etc/maxscale.service.in
Normal file
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=MariaDB MaxScale Database Proxy
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
Restart=on-failure
|
||||
PIDFile=@MAXSCALE_VARDIR@/run/maxscale/maxscale.pid
|
||||
ExecStart=@CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale --user=maxscale
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,5 +1,62 @@
|
||||
#!/bin/sh
|
||||
|
||||
cp @CMAKE_INSTALL_PREFIX@/maxscale /etc/init.d/
|
||||
cp @CMAKE_INSTALL_PREFIX@/maxscale.conf /etc/ld.so.conf.d/
|
||||
|
||||
# Create directories
|
||||
mkdir -p @CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@
|
||||
mkdir -p @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@
|
||||
mkdir -p @CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@
|
||||
mkdir -p @CMAKE_INSTALL_PREFIX@/@MAXSCALE_DOCDIR@
|
||||
|
||||
# MAXSCALE_VARDIR is an absolute path to /var by default
|
||||
mkdir -p @MAXSCALE_VARDIR@/log/maxscale
|
||||
mkdir -p @MAXSCALE_VARDIR@/lib/maxscale
|
||||
mkdir -p @MAXSCALE_VARDIR@/cache/maxscale
|
||||
mkdir -p @MAXSCALE_VARDIR@/run/maxscale
|
||||
|
||||
# Create MaxScale user
|
||||
if [ -f "/etc/passwd" -a "$(grep -c 'maxscale' /etc/passwd)" -eq 0 ]
|
||||
then
|
||||
useradd -r -s /bin/false maxscale
|
||||
groupadd maxscale
|
||||
fi
|
||||
|
||||
# Change the owner of the directories to maxscale:maxscale
|
||||
chown maxscale:maxscale @MAXSCALE_VARDIR@/log/maxscale
|
||||
chown maxscale:maxscale @MAXSCALE_VARDIR@/lib/maxscale
|
||||
chown maxscale:maxscale @MAXSCALE_VARDIR@/cache/maxscale
|
||||
chown maxscale:maxscale @MAXSCALE_VARDIR@/run/maxscale
|
||||
chmod 0755 @MAXSCALE_VARDIR@/log/maxscale
|
||||
chmod 0755 @MAXSCALE_VARDIR@/lib/maxscale
|
||||
chmod 0755 @MAXSCALE_VARDIR@/cache/maxscale
|
||||
chmod 0755 @MAXSCALE_VARDIR@/run/maxscale
|
||||
|
||||
# Copy init.d script and ldconfig file
|
||||
if [ -f "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/maxscale" ]
|
||||
then
|
||||
cp @CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/maxscale /etc/init.d/
|
||||
fi
|
||||
|
||||
if [ -f "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/maxscale.conf" ]
|
||||
then
|
||||
cp @CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/maxscale.conf /etc/init.d/
|
||||
fi
|
||||
|
||||
if [ -d "/usr/lib/systemd/system" -a -f @CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/maxscale.service ]
|
||||
then
|
||||
cp @CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/maxscale.service /usr/lib/systemd/system
|
||||
fi
|
||||
/sbin/ldconfig
|
||||
|
||||
cat <<EOF >& 2
|
||||
********** Notice: MaxScale 1.2 Changes **************
|
||||
|
||||
MaxScale 1.2 has changed the default installation locations
|
||||
and various files have changed locations. The configuration
|
||||
file is now read from /etc/maxscale.cnf (note the lower case name)
|
||||
and MaxScale data is in /var/lib/maxscale/.
|
||||
|
||||
The default location of binary log files and the authentication cache changed from
|
||||
/usr/local/mariadb-maxscale/<Service name> to /var/lib/maxscale/<Service name>.
|
||||
|
||||
******************************************************
|
||||
EOF
|
||||
|
@ -3,4 +3,9 @@ if [ "$1" -eq 0 ]
|
||||
then
|
||||
rm -f /etc/init.d/maxscale
|
||||
rm -f /etc/ld.so.conf.d/maxscale.conf
|
||||
else
|
||||
if [ -f "/usr/local/mariadb-maxscale/etc/MaxScale.cnf" ]
|
||||
then
|
||||
cp "/usr/local/mariadb-maxscale/etc/MaxScale.cnf" "/etc/maxscale.cnf"
|
||||
fi
|
||||
fi
|
||||
|
@ -21,9 +21,8 @@
|
||||
# MaxScale HOME, PIDFILE, LIB
|
||||
#############################################
|
||||
|
||||
export MAXSCALE_HOME=@CMAKE_INSTALL_PREFIX@
|
||||
export MAXSCALE_PIDFILE=$MAXSCALE_HOME/log/maxscale.pid
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MAXSCALE_HOME/lib
|
||||
export MAXSCALE_PIDFILE=@MAXSCALE_VARDIR@/run/maxscale/maxscale.pid
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@/maxscale
|
||||
|
||||
###############################
|
||||
# LSB Exit codes (non-Status)
|
||||
@ -39,14 +38,14 @@ _RETVAL_STATUS_OK=0
|
||||
_RETVAL_STATUS_NOT_RUNNING=3
|
||||
|
||||
# Sanity checks.
|
||||
[ -x $MAXSCALE_HOME/bin/maxscale ] || exit $_RETVAL_NOT_INSTALLED
|
||||
[ -x @CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale ] || exit $_RETVAL_NOT_INSTALLED
|
||||
|
||||
#################################
|
||||
# stop/start/status related vars
|
||||
#################################
|
||||
NAME=maxscale
|
||||
DAEMON=$MAXSCALE_HOME/bin/maxscale
|
||||
|
||||
DAEMON=@CMAKE_INSTALL_PREFIX@/@MAXSCALE_BINDIR@/maxscale
|
||||
DAEMON_OPTS= --user=maxscale
|
||||
# Source function library.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
@ -58,11 +57,11 @@ RETVAL=0
|
||||
|
||||
start() {
|
||||
log_daemon_msg "Starting MaxScale"
|
||||
start_daemon -p $MAXSCALE_PIDFILE $DAEMON 2> /dev/null > /dev/null
|
||||
start_daemon -p "$MAXSCALE_PIDFILE" "$DAEMON" "$DAEMON_OPTS" 2> /dev/null > /dev/null
|
||||
|
||||
sleep 2
|
||||
|
||||
status_of_proc -p $MAXSCALE_PIDFILE $DAEMON $NAME
|
||||
status_of_proc -p "$MAXSCALE_PIDFILE" "$DAEMON" $NAME
|
||||
|
||||
log_end_msg $?
|
||||
}
|
||||
@ -78,13 +77,13 @@ stop() {
|
||||
reload() {
|
||||
log_daemon_msg "Reloading MaxScale"
|
||||
|
||||
kill -HUP $(cat $MAXSCALE_PIDFILE)
|
||||
kill -HUP $(cat "$MAXSCALE_PIDFILE")
|
||||
|
||||
log_end_msg $?
|
||||
}
|
||||
|
||||
maxscale_wait_stop() {
|
||||
PIDTMP=$(pidofproc -p $MAXSCALE_PIDFILE $MAXSCALE_HOME/bin/maxscale)
|
||||
PIDTMP=$(pidofproc -p "$MAXSCALE_PIDFILE" "$DAEMON")
|
||||
kill -TERM "${PIDTMP:-}" 2> /dev/null;
|
||||
if [ -n "${PIDTMP:-}" ] && kill -0 "${PIDTMP:-}" 2> /dev/null; then
|
||||
local i=0
|
||||
@ -116,7 +115,7 @@ case "$1" in
|
||||
# return 3 on any error
|
||||
|
||||
log_daemon_msg "Checking MaxScale"
|
||||
status_of_proc -p $MAXSCALE_PIDFILE $DAEMON $NAME
|
||||
status_of_proc -p "$MAXSCALE_PIDFILE" "$DAEMON" $NAME
|
||||
RETVAL=$?
|
||||
|
||||
if [ $RETVAL -ne 0 ]; then
|
||||
|
@ -2,8 +2,8 @@ if(LOG_DEBUG)
|
||||
add_definitions(-DSS_LOG_DEBUG)
|
||||
endif()
|
||||
add_library(log_manager SHARED log_manager.cc)
|
||||
target_link_libraries(log_manager pthread aio stdc++ utils)
|
||||
install(TARGETS log_manager DESTINATION lib)
|
||||
target_link_libraries(log_manager pthread aio stdc++)
|
||||
install(TARGETS log_manager DESTINATION ${MAXSCALE_LIBDIR})
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
@ -1764,7 +1764,6 @@ static bool fnames_conf_init(
|
||||
|
||||
case 's':
|
||||
/** record list of log file ids for later use */
|
||||
if(do_syslog)
|
||||
shmem_id_str = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
@ -1796,12 +1795,14 @@ static bool fnames_conf_init(
|
||||
strdup(get_logpath_default()) : fn->fn_logpath;
|
||||
|
||||
/** Set identity string for syslog if it is not set in config.*/
|
||||
if(do_syslog)
|
||||
{
|
||||
syslog_ident_str =
|
||||
(syslog_ident_str == NULL ?
|
||||
(argv == NULL ? strdup(program_invocation_short_name) :
|
||||
strdup(*argv)) :
|
||||
syslog_ident_str);
|
||||
|
||||
}
|
||||
/* ss_dfprintf(stderr, "\n\n\tCommand line : ");
|
||||
for (i=0; i<argc; i++) {
|
||||
ss_dfprintf(stderr, "%s ", argv[i]);
|
||||
|
@ -1,5 +1,5 @@
|
||||
install(FILES nagios/check_maxscale_monitors.pl DESTINATION plugins/nagios)
|
||||
install(FILES nagios/check_maxscale_resources.pl DESTINATION plugins/nagios)
|
||||
install(FILES nagios/check_maxscale_threads.pl DESTINATION plugins/nagios)
|
||||
install(FILES nagios/maxscale_commands.cfg DESTINATION plugins/nagios)
|
||||
install(FILES nagios/server1.cfg DESTINATION plugins/nagios)
|
||||
install(FILES nagios/check_maxscale_monitors.pl DESTINATION ${MAXSCALE_SHAREDIR}/plugins/nagios)
|
||||
install(FILES nagios/check_maxscale_resources.pl DESTINATION ${MAXSCALE_SHAREDIR}/plugins/nagios)
|
||||
install(FILES nagios/check_maxscale_threads.pl DESTINATION ${MAXSCALE_SHAREDIR}/plugins/nagios)
|
||||
install(FILES nagios/maxscale_commands.cfg DESTINATION ${MAXSCALE_SHAREDIR}/plugins/nagios)
|
||||
install(FILES nagios/server1.cfg DESTINATION ${MAXSCALE_SHAREDIR}/plugins/nagios)
|
||||
|
@ -1,5 +1,5 @@
|
||||
add_library(query_classifier SHARED query_classifier.cc)
|
||||
install(TARGETS query_classifier DESTINATION lib)
|
||||
install(TARGETS query_classifier COMPONENT lib DESTINATION ${MAXSCALE_LIBDIR})
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
@ -1485,7 +1485,8 @@ void parsing_info_done(
|
||||
void* ptr)
|
||||
{
|
||||
parsing_info_t* pi;
|
||||
|
||||
THD* thd;
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
pi = (parsing_info_t *)ptr;
|
||||
@ -1496,6 +1497,8 @@ void parsing_info_done(
|
||||
|
||||
if (mysql->thd != NULL)
|
||||
{
|
||||
thd = (THD*)mysql->thd;
|
||||
thd->end_statement ();
|
||||
(*mysql->methods->free_embedded_thd)(mysql);
|
||||
mysql->thd = NULL;
|
||||
}
|
||||
|
@ -1,20 +1,18 @@
|
||||
add_library(atomic atomic.c)
|
||||
|
||||
if(BUILD_TESTS OR BUILD_TOOLS)
|
||||
add_library(fullcore STATIC adminusers.c config.c buffer.c dbusers.c dcb.c filter.c gwbitmask.c gw_utils.c hashtable.c hint.c housekeeper.c load_utils.c memlog.c modutil.c monitor.c poll.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c externcmd.c)
|
||||
add_library(fullcore STATIC adminusers.c atomic.c config.c buffer.c dbusers.c dcb.c filter.c gwbitmask.c gw_utils.c hashtable.c hint.c housekeeper.c load_utils.c memlog.c modutil.c monitor.c poll.c resultset.c secrets.c server.c service.c session.c spinlock.c thread.c users.c utils.c gwdirs.c externcmd.c)
|
||||
if(WITH_JEMALLOC)
|
||||
target_link_libraries(fullcore ${JEMALLOC_LIBRARIES})
|
||||
elseif(WITH_TCMALLOC)
|
||||
target_link_libraries(fullcore ${TCMALLOC_LIBRARIES})
|
||||
endif()
|
||||
target_link_libraries(fullcore ${CURL_LIBRARIES} utils log_manager pthread ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ssl aio rt crypt dl crypto inih z m stdc++ atomic)
|
||||
target_link_libraries(fullcore ${CURL_LIBRARIES} utils log_manager pthread ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ssl aio rt crypt dl crypto inih z m stdc++)
|
||||
endif()
|
||||
|
||||
add_executable(maxscale buffer.c spinlock.c gateway.c
|
||||
add_executable(maxscale atomic.c buffer.c spinlock.c gateway.c
|
||||
gw_utils.c utils.c dcb.c load_utils.c session.c service.c server.c
|
||||
poll.c config.c users.c hashtable.c dbusers.c thread.c gwbitmask.c
|
||||
monitor.c adminusers.c secrets.c filter.c modutil.c hint.c
|
||||
housekeeper.c memlog.c resultset.c externcmd.c)
|
||||
housekeeper.c memlog.c resultset.c gwdirs.c externcmd.c)
|
||||
|
||||
if(WITH_JEMALLOC)
|
||||
target_link_libraries(maxscale ${JEMALLOC_LIBRARIES})
|
||||
@ -22,16 +20,16 @@ elseif(WITH_TCMALLOC)
|
||||
target_link_libraries(maxscale ${TCMALLOC_LIBRARIES})
|
||||
endif()
|
||||
|
||||
target_link_libraries(maxscale ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ${CURL_LIBRARIES} log_manager utils ssl aio pthread crypt dl crypto inih z rt m stdc++ atomic)
|
||||
install(TARGETS maxscale DESTINATION bin)
|
||||
target_link_libraries(maxscale ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} ${CURL_LIBRARIES} log_manager utils ssl aio pthread crypt dl crypto inih z rt m stdc++)
|
||||
install(TARGETS maxscale DESTINATION ${MAXSCALE_BINDIR})
|
||||
|
||||
add_executable(maxkeys maxkeys.c secrets.c utils.c)
|
||||
add_executable(maxkeys maxkeys.c secrets.c utils.c gwdirs.c)
|
||||
target_link_libraries(maxkeys log_manager utils pthread crypt crypto)
|
||||
install(TARGETS maxkeys DESTINATION bin)
|
||||
install(TARGETS maxkeys DESTINATION ${MAXSCALE_BINDIR})
|
||||
|
||||
add_executable(maxpasswd maxpasswd.c secrets.c utils.c)
|
||||
add_executable(maxpasswd maxpasswd.c secrets.c utils.c gwdirs.c)
|
||||
target_link_libraries(maxpasswd log_manager utils pthread crypt crypto)
|
||||
install(TARGETS maxpasswd DESTINATION bin)
|
||||
install(TARGETS maxpasswd DESTINATION ${MAXSCALE_BINDIR})
|
||||
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <adminusers.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
#include <gwdirs.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -119,12 +120,7 @@ char fname[1024], *home;
|
||||
char uname[80], passwd[80];
|
||||
|
||||
initialise();
|
||||
if ((home = getenv("MAXSCALE_HOME")) != NULL && strlen(home) < 1024){
|
||||
sprintf(fname, "%s/etc/passwd", home);
|
||||
}
|
||||
else{
|
||||
sprintf(fname, "/usr/local/mariadb-maxscale/etc/passwd");
|
||||
}
|
||||
sprintf(fname, "%s/passwd", get_datadir());
|
||||
if ((fp = fopen(fname, "r")) == NULL)
|
||||
return NULL;
|
||||
if ((rval = users_alloc()) == NULL)
|
||||
@ -155,12 +151,7 @@ FILE *fp;
|
||||
char fname[1024], *home, *cpasswd;
|
||||
|
||||
initialise();
|
||||
if ((home = getenv("MAXSCALE_HOME")) != NULL && strlen(home) < 1024){
|
||||
sprintf(fname, "%s/etc/passwd", home);
|
||||
}
|
||||
else{
|
||||
sprintf(fname, "/usr/local/mariadb-maxscale/etc/passwd");
|
||||
}
|
||||
sprintf(fname, "%s/passwd", get_datadir());
|
||||
|
||||
if (users == NULL)
|
||||
{
|
||||
@ -253,15 +244,8 @@ char* admin_remove_user(
|
||||
/**
|
||||
* Open passwd file and remove user from the file.
|
||||
*/
|
||||
if ((home = getenv("MAXSCALE_HOME")) != NULL &&
|
||||
strnlen(home,PATH_MAX) < PATH_MAX &&
|
||||
strnlen(home,PATH_MAX) > 0) {
|
||||
sprintf(fname, "%s/etc/passwd", home);
|
||||
sprintf(fname_tmp, "%s/etc/passwd_tmp", home);
|
||||
} else {
|
||||
sprintf(fname, "/usr/local/mariadb-maxscale/etc/passwd");
|
||||
sprintf(fname_tmp, "/usr/local/mariadb-maxscale/etc/passwd_tmp");
|
||||
}
|
||||
sprintf(fname, "%s/passwd", get_datadir());
|
||||
sprintf(fname_tmp, "%s/passwd_tmp", get_datadir());
|
||||
/**
|
||||
* Rewrite passwd file from memory.
|
||||
*/
|
||||
|
@ -232,7 +232,7 @@ int rval;
|
||||
strcpy(version_string,tmp);
|
||||
}
|
||||
|
||||
ptr = strstr(tmp, "-embedded");
|
||||
ptr = strstr(version_string, "-embedded");
|
||||
if (ptr) {
|
||||
*ptr = '\0';
|
||||
}
|
||||
@ -346,6 +346,8 @@ hashtable_memory_fns(monitorhash,strdup,NULL,free,NULL);
|
||||
char *weightby;
|
||||
char *version_string;
|
||||
char *subservices;
|
||||
char *ssl,*ssl_cert,*ssl_key,*ssl_ca_cert,*ssl_version;
|
||||
char* ssl_cert_verify_depth;
|
||||
bool is_rwsplit = false;
|
||||
bool is_schemarouter = false;
|
||||
char *allow_localhost_match_wildcard_host;
|
||||
@ -354,6 +356,12 @@ hashtable_memory_fns(monitorhash,strdup,NULL,free,NULL);
|
||||
user = config_get_value(obj->parameters, "user");
|
||||
auth = config_get_value(obj->parameters, "passwd");
|
||||
subservices = config_get_value(obj->parameters, "subservices");
|
||||
ssl = config_get_value(obj->parameters, "ssl");
|
||||
ssl_cert = config_get_value(obj->parameters, "ssl_cert");
|
||||
ssl_key = config_get_value(obj->parameters, "ssl_key");
|
||||
ssl_ca_cert = config_get_value(obj->parameters, "ssl_ca_cert");
|
||||
ssl_version = config_get_value(obj->parameters, "ssl_version");
|
||||
ssl_cert_verify_depth = config_get_value(obj->parameters, "ssl_cert_verify_depth");
|
||||
enable_root_user = config_get_value(
|
||||
obj->parameters,
|
||||
"enable_root_user");
|
||||
@ -418,7 +426,21 @@ hashtable_memory_fns(monitorhash,strdup,NULL,free,NULL);
|
||||
}
|
||||
|
||||
if (version_string) {
|
||||
|
||||
/** Add the 5.5.5- string to the start of the version string if
|
||||
* the version string starts with "10.".
|
||||
* This mimics MariaDB 10.0 behavior which adds 5.5.5- for backwards compatibility. */
|
||||
if(strncmp(version_string,"10.",3) == 0)
|
||||
{
|
||||
((SERVICE *)(obj->element))->version_string = malloc((strlen(version_string) +
|
||||
strlen("5.5.5-") + 1) * sizeof(char));
|
||||
strcpy(((SERVICE *)(obj->element))->version_string,"5.5.5-");
|
||||
strcat(((SERVICE *)(obj->element))->version_string,version_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
((SERVICE *)(obj->element))->version_string = strdup(version_string);
|
||||
}
|
||||
} else {
|
||||
if (gateway.version_string)
|
||||
((SERVICE *)(obj->element))->version_string = strdup(gateway.version_string);
|
||||
@ -430,7 +452,84 @@ hashtable_memory_fns(monitorhash,strdup,NULL,free,NULL);
|
||||
max_slave_rlag_str =
|
||||
config_get_value(obj->parameters,
|
||||
"max_slave_replication_lag");
|
||||
|
||||
|
||||
if(ssl)
|
||||
{
|
||||
if(ssl_cert == NULL)
|
||||
{
|
||||
error_count++;
|
||||
skygw_log_write(LE,"Error: Server certificate missing for service '%s'."
|
||||
"Please provide the path to the server certificate by adding the ssl_cert=<path> parameter",
|
||||
obj->object);
|
||||
}
|
||||
if(ssl_ca_cert == NULL)
|
||||
{
|
||||
error_count++;
|
||||
skygw_log_write(LE,"Error: CA Certificate missing for service '%s'."
|
||||
"Please provide the path to the certificate authority certificate by adding the ssl_ca_cert=<path> parameter",
|
||||
obj->object);
|
||||
}
|
||||
if(ssl_key == NULL)
|
||||
{
|
||||
error_count++;
|
||||
skygw_log_write(LE,"Error: Server private key missing for service '%s'. "
|
||||
"Please provide the path to the server certificate key by adding the ssl_key=<path> parameter"
|
||||
,obj->object);
|
||||
}
|
||||
|
||||
if(access(ssl_ca_cert,F_OK) != 0)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Certificate authority file for service '%s' not found: %s",
|
||||
obj->object,
|
||||
ssl_ca_cert);
|
||||
error_count++;
|
||||
}
|
||||
if(access(ssl_cert,F_OK) != 0)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Server certificate file for service '%s' not found: %s",
|
||||
obj->object,
|
||||
ssl_cert);
|
||||
error_count++;
|
||||
}
|
||||
if(access(ssl_key,F_OK) != 0)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Server private key file for service '%s' not found: %s",
|
||||
obj->object,
|
||||
ssl_key);
|
||||
error_count++;
|
||||
}
|
||||
|
||||
if(error_count == 0)
|
||||
{
|
||||
if(serviceSetSSL(obj->element,ssl) != 0)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Unknown parameter for service '%s': %s",obj->object,ssl);
|
||||
error_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceSetCertificates(obj->element,ssl_cert,ssl_key,ssl_ca_cert);
|
||||
if(ssl_version)
|
||||
{
|
||||
if(serviceSetSSLVersion(obj->element,ssl_version) != 0)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Unknown parameter value for 'ssl_version' for service '%s': %s",obj->object,ssl_version);
|
||||
error_count++;
|
||||
}
|
||||
}
|
||||
if(ssl_cert_verify_depth)
|
||||
{
|
||||
if(serviceSetSSLVerifyDepth(obj->element,atoi(ssl_cert_verify_depth)) != 0)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Invalid parameter value for 'ssl_cert_verify_depth' for service '%s': %s",obj->object,ssl_cert_verify_depth);
|
||||
error_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (enable_root_user)
|
||||
serviceEnableRootUser(
|
||||
obj->element,
|
||||
@ -1352,7 +1451,7 @@ int i;
|
||||
}
|
||||
else if (strcmp(name, "ms_timestamp") == 0)
|
||||
{
|
||||
skygw_set_highp(config_truth_value(value));
|
||||
skygw_set_highp(config_truth_value((char*)value));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1360,7 +1459,7 @@ int i;
|
||||
{
|
||||
if (strcasecmp(name, lognames[i].logname) == 0)
|
||||
{
|
||||
if (config_truth_value(value))
|
||||
if (config_truth_value((char*)value))
|
||||
skygw_log_enable(lognames[i].logfile);
|
||||
else
|
||||
skygw_log_disable(lognames[i].logfile);
|
||||
@ -1938,6 +2037,12 @@ static char *service_params[] =
|
||||
"version_string",
|
||||
"filters",
|
||||
"weightby",
|
||||
"ssl_cert",
|
||||
"ssl_ca_cert",
|
||||
"ssl",
|
||||
"ssl_key",
|
||||
"ssl_version",
|
||||
"ssl_cert_verify_depth",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -974,19 +974,27 @@ getAllUsers(SERVICE *service, USERS *users)
|
||||
}
|
||||
}
|
||||
|
||||
if(service->optimize_wildcard && havedb && wildcard_db_grant(dbnm))
|
||||
if(havedb && wildcard_db_grant(dbnm))
|
||||
{
|
||||
rc = add_wildcard_users(users, row[0], row[1], password, row[4], dbnm, service->resources);
|
||||
skygw_log_write(LOGFILE_DEBUG|LOGFILE_TRACE,"%s: Converted '%s' to %d individual database grants.",service->name,dbnm,rc);
|
||||
if(service->optimize_wildcard)
|
||||
{
|
||||
rc = add_wildcard_users(users, row[0], row[1], password, row[4], dbnm, service->resources);
|
||||
skygw_log_write(LOGFILE_DEBUG|LOGFILE_TRACE,"%s: Converted '%s' to %d individual database grants.",service->name,dbnm,rc);
|
||||
}
|
||||
else
|
||||
{
|
||||
/** Use ANYDB for wildcard grants */
|
||||
rc = add_mysql_users_with_host_ipv4(users, row[0], row[1], password, "Y", NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = add_mysql_users_with_host_ipv4(users, row[0], row[1], password, row[4], havedb ? dbnm : NULL);
|
||||
}
|
||||
|
||||
skygw_log_write(LOGFILE_DEBUG,"%s: Adding user:%s host:%s anydb:%s db:%s.",
|
||||
LOGIF(LD,(skygw_log_write(LOGFILE_DEBUG,"%s: Adding user:%s host:%s anydb:%s db:%s.",
|
||||
service->name,row[0],row[1],row[4],
|
||||
havedb ? dbnm : NULL);
|
||||
havedb ? dbnm : NULL)));
|
||||
} else {
|
||||
/* we don't have dbgrants, simply set ANY DB for the user */
|
||||
rc = add_mysql_users_with_host_ipv4(users, row[0], row[1], password, "Y", NULL);
|
||||
@ -1483,10 +1491,18 @@ getUsers(SERVICE *service, USERS *users)
|
||||
}
|
||||
}
|
||||
|
||||
if(service->optimize_wildcard && havedb && wildcard_db_grant(row[5]))
|
||||
if(havedb && wildcard_db_grant(row[5]))
|
||||
{
|
||||
rc = add_wildcard_users(users, row[0], row[1], password, row[4], dbnm, service->resources);
|
||||
skygw_log_write(LOGFILE_DEBUG|LOGFILE_TRACE,"%s: Converted '%s' to %d individual database grants.",service->name,row[5],rc);
|
||||
if(service->optimize_wildcard)
|
||||
{
|
||||
rc = add_wildcard_users(users, row[0], row[1], password, row[4], dbnm, service->resources);
|
||||
skygw_log_write(LOGFILE_DEBUG|LOGFILE_TRACE,"%s: Converted '%s' to %d individual database grants.",service->name,row[5],rc);
|
||||
}
|
||||
else
|
||||
{
|
||||
/** Use ANYDB for wildcard grants */
|
||||
rc = add_mysql_users_with_host_ipv4(users, row[0], row[1], password, "Y", NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
29
server/core/gwdirs.c
Normal file
29
server/core/gwdirs.c
Normal file
@ -0,0 +1,29 @@
|
||||
#include <gwdirs.h>
|
||||
|
||||
/**
|
||||
* Get the directory with all the modules.
|
||||
* @return The module directory
|
||||
*/
|
||||
char* get_libdir()
|
||||
{
|
||||
return libdir?libdir:(char*)default_libdir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the service cache directory
|
||||
* @return The path to the cache directory
|
||||
*/
|
||||
char* get_cachedir()
|
||||
{
|
||||
return cachedir?cachedir:(char*)default_cachedir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the service cache directory
|
||||
* @return The path to the cache directory
|
||||
*/
|
||||
char* get_datadir()
|
||||
{
|
||||
return maxscaledatadir?maxscaledatadir:(char*)default_datadir;
|
||||
}
|
@ -48,6 +48,8 @@
|
||||
#include <curl/curl.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <gw.h>
|
||||
#include <gwdirs.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -104,21 +106,10 @@ WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
return realsize;
|
||||
}
|
||||
|
||||
char* get_maxscale_home(void)
|
||||
{
|
||||
char* home = getenv("MAXSCALE_HOME");
|
||||
if (home == NULL)
|
||||
{
|
||||
home = "/usr/local/mariadb-maxscale";
|
||||
}
|
||||
return home;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load the dynamic library related to a gateway module. The routine
|
||||
* will look for library files in the current directory,
|
||||
* $MAXSCALE_HOME/modules and /usr/local/mariadb-maxscale/modules.
|
||||
* the configured folder and /usr/lib64/maxscale.
|
||||
*
|
||||
* @param module Name of the module to load
|
||||
* @param type Type of module, used purely for registration
|
||||
@ -142,22 +133,17 @@ MODULE_INFO *mod_info = NULL;
|
||||
*
|
||||
* Search of the shared object.
|
||||
*/
|
||||
snprintf(fname,MAXPATHLEN+1, "./lib%s.so", module);
|
||||
|
||||
|
||||
snprintf(fname, MAXPATHLEN+1,"%s/lib%s.so", get_libdir(), module);
|
||||
|
||||
if (access(fname, F_OK) == -1)
|
||||
{
|
||||
home = get_maxscale_home ();
|
||||
snprintf(fname, MAXPATHLEN+1,"%s/modules/lib%s.so", home, module);
|
||||
|
||||
if (access(fname, F_OK) == -1)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to find library for "
|
||||
"module: %s.",
|
||||
module)));
|
||||
return NULL;
|
||||
}
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Unable to find library for "
|
||||
"module: %s. Module dir: %s",
|
||||
module, get_libdir())));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((dlhandle = dlopen(fname, RTLD_NOW|RTLD_LOCAL)) == NULL)
|
||||
|
@ -31,19 +31,25 @@
|
||||
#include <secrets.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
#include <gwdirs.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int arg_count = 6;
|
||||
int arg_count = 4;
|
||||
char *home;
|
||||
char *keyfile;
|
||||
char** arg_vector;
|
||||
int rval = 0;
|
||||
|
||||
if (argc != 2)
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
|
||||
return 1;
|
||||
keyfile = "/var/lib/maxscale/";
|
||||
fprintf(stderr, "Generating .secrets file in /var/lib/maxscale/ ...\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
keyfile = argv[1];
|
||||
}
|
||||
|
||||
arg_vector = malloc(sizeof(char*)*(arg_count + 1));
|
||||
|
||||
if(arg_vector == NULL)
|
||||
@ -54,26 +60,14 @@ int main(int argc, char **argv)
|
||||
|
||||
arg_vector[0] = "logmanager";
|
||||
arg_vector[1] = "-j";
|
||||
|
||||
if ((home = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
arg_vector[2] = (char*)malloc((strlen(home) + strlen("/log"))*sizeof(char));
|
||||
sprintf(arg_vector[2],"%s/log",home);
|
||||
}
|
||||
else
|
||||
{
|
||||
arg_vector[2] = strdup("/usr/local/mariadb-maxscale/log");
|
||||
}
|
||||
arg_vector[3] = "-o";
|
||||
arg_vector[4] = "-l";
|
||||
arg_vector[5] = "LOGFILE_ERROR";
|
||||
arg_vector[6] = NULL;
|
||||
arg_vector[2] = "/var/log/maxscale/maxkeys";
|
||||
arg_vector[3] = "-o";
|
||||
arg_vector[4] = NULL;
|
||||
skygw_logmanager_init(arg_count,arg_vector);
|
||||
free(arg_vector[2]);
|
||||
free(arg_vector);
|
||||
|
||||
|
||||
if (secrets_writeKeys(argv[1]))
|
||||
if (secrets_writeKeys(keyfile))
|
||||
{
|
||||
fprintf(stderr, "Failed to encode the password\n");
|
||||
rval = 1;
|
||||
|
@ -46,9 +46,9 @@ main(int argc, char **argv)
|
||||
char** arg_vector;
|
||||
int rval = 0;
|
||||
|
||||
if (argc != 2)
|
||||
if (argc != 3)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s <password>\n", argv[0]);
|
||||
fprintf(stderr, "Usage: %s <file> <password>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -60,18 +60,9 @@ main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
arg_vector[0] = "logmanager";
|
||||
arg_vector[1] = "-j";
|
||||
|
||||
if ((home = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
arg_vector[2] = (char*)malloc((strlen(home) + strlen("/log"))*sizeof(char));
|
||||
sprintf(arg_vector[2],"%s/log",home);
|
||||
}
|
||||
else
|
||||
{
|
||||
arg_vector[2] = strdup("/usr/local/mariadb-maxscale/log");
|
||||
}
|
||||
arg_vector[0] = strdup("logmanager");
|
||||
arg_vector[1] = strdup("-j");
|
||||
arg_vector[2] = strdup("/var/log/maxscale");
|
||||
|
||||
arg_vector[3] = "-o";
|
||||
arg_vector[4] = "-l";
|
||||
@ -88,9 +79,9 @@ main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
strncpy(pw,argv[1],80);
|
||||
strncpy(pw,argv[2],80);
|
||||
|
||||
if ((enc = encryptPassword(pw)) != NULL){
|
||||
if ((enc = encryptPassword(argv[1],pw)) != NULL){
|
||||
printf("%s\n", enc);
|
||||
}else{
|
||||
fprintf(stderr, "Failed to encode the password\n");
|
||||
|
@ -841,4 +841,4 @@ int modutil_count_statements(GWBUF* buffer)
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,8 @@ MONITOR *mon;
|
||||
mon->handle = NULL;
|
||||
mon->databases = NULL;
|
||||
mon->password = NULL;
|
||||
mon->user = NULL;
|
||||
mon->password = NULL;
|
||||
mon->read_timeout = DEFAULT_READ_TIMEOUT;
|
||||
mon->write_timeout = DEFAULT_WRITE_TIMEOUT;
|
||||
mon->connect_timeout = DEFAULT_CONNECT_TIMEOUT;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <log_manager.h>
|
||||
#include <ctype.h>
|
||||
#include <mysql_client_server_protocol.h>
|
||||
#include <gwdirs.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -52,31 +53,26 @@ int i;
|
||||
}
|
||||
|
||||
/**
|
||||
* secrets_readKeys
|
||||
*
|
||||
* This routine reads data from a binary file and extracts the AES encryption key
|
||||
* and the AES Init Vector
|
||||
*
|
||||
* This routine reads data from a binary file named ".secrets" and extracts the AES encryption key
|
||||
* and the AES Init Vector.
|
||||
* If the path parameter is not null the custom path is interpreted as a folder
|
||||
* containing the .secrets file. Otherwise the default location is used.
|
||||
* @return The keys structure or NULL on error
|
||||
*/
|
||||
static MAXKEYS *
|
||||
secrets_readKeys()
|
||||
secrets_readKeys(char* path)
|
||||
{
|
||||
char secret_file[255];
|
||||
char secret_file[PATH_MAX+1];
|
||||
char *home;
|
||||
MAXKEYS *keys;
|
||||
struct stat secret_stats;
|
||||
int fd;
|
||||
int len;
|
||||
static int reported = 0;
|
||||
|
||||
home = getenv("MAXSCALE_HOME");
|
||||
|
||||
if (home == NULL) {
|
||||
home = "/usr/local/mariadb-maxscale";
|
||||
}
|
||||
snprintf(secret_file, 255, "%s/etc/.secrets", home);
|
||||
|
||||
if(path != NULL)
|
||||
snprintf(secret_file, PATH_MAX, "%s/.secrets", path);
|
||||
else
|
||||
snprintf(secret_file, PATH_MAX, "%s/.secrets", get_datadir());
|
||||
/* Try to access secrets file */
|
||||
if (access(secret_file, R_OK) == -1)
|
||||
{
|
||||
@ -225,11 +221,14 @@ static int reported = 0;
|
||||
* @param secret_file The file with secret keys
|
||||
* @return 0 on success and 1 on failure
|
||||
*/
|
||||
int secrets_writeKeys(char *secret_file)
|
||||
int secrets_writeKeys(char *path)
|
||||
{
|
||||
int fd,randfd;
|
||||
unsigned int randval;
|
||||
MAXKEYS key;
|
||||
char secret_file[PATH_MAX + 10];
|
||||
|
||||
sprintf(secret_file,"%s/.secrets",path);
|
||||
|
||||
/* Open for writing | Create | Truncate the file for writing */
|
||||
if ((fd = open(secret_file, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR)) < 0)
|
||||
@ -332,7 +331,7 @@ char *ptr;
|
||||
unsigned char encrypted[80];
|
||||
int enlen;
|
||||
|
||||
keys = secrets_readKeys();
|
||||
keys = secrets_readKeys(NULL);
|
||||
if (!keys)
|
||||
return strdup(crypt);
|
||||
/*
|
||||
@ -369,12 +368,12 @@ int enlen;
|
||||
* Encrypt a password that can be stored in the MaxScale configuration file.
|
||||
*
|
||||
* Note the return is always a malloc'd string that the caller must free
|
||||
*
|
||||
* @param path Path the the .secrets file
|
||||
* @param password The password to encrypt
|
||||
* @return The encrypted password
|
||||
*/
|
||||
char *
|
||||
encryptPassword(char *password)
|
||||
encryptPassword(char* path, char *password)
|
||||
{
|
||||
MAXKEYS *keys;
|
||||
AES_KEY aeskey;
|
||||
@ -383,7 +382,7 @@ char *hex_output;
|
||||
unsigned char padded_passwd[80];
|
||||
unsigned char encrypted[80];
|
||||
|
||||
if ((keys = secrets_readKeys()) == NULL)
|
||||
if ((keys = secrets_readKeys(path)) == NULL)
|
||||
return NULL;
|
||||
|
||||
memset(padded_passwd, 0, 80);
|
||||
|
@ -32,6 +32,7 @@
|
||||
* 26/06/14 Mark Riddoch Addition of server parameters
|
||||
* 30/08/14 Massimiliano Pinto Addition of new service status description
|
||||
* 30/10/14 Massimiliano Pinto Addition of SERVER_MASTER_STICKINESS description
|
||||
* 01/06/15 Massimiliano Pinto Addition of server_update_address/port
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -844,3 +845,41 @@ int *data;
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the address value of a specific server
|
||||
*
|
||||
* @param server The server to update
|
||||
* @param address The new address
|
||||
*
|
||||
*/
|
||||
void
|
||||
server_update_address(SERVER *server, char *address)
|
||||
{
|
||||
spinlock_acquire(&server_spin);
|
||||
if (server && address) {
|
||||
if (server->name) {
|
||||
free(server->name);
|
||||
}
|
||||
server->name = strdup(address);
|
||||
}
|
||||
spinlock_release(&server_spin);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the port value of a specific server
|
||||
*
|
||||
* @param server The server to update
|
||||
* @param port The new port value
|
||||
*
|
||||
*/
|
||||
void
|
||||
server_update_port(SERVER *server, unsigned short port)
|
||||
{
|
||||
spinlock_acquire(&server_spin);
|
||||
if (server && port > 0) {
|
||||
server->port = port;
|
||||
}
|
||||
spinlock_release(&server_spin);
|
||||
}
|
||||
|
||||
|
@ -61,12 +61,17 @@
|
||||
#include <sys/types.h>
|
||||
#include <housekeeper.h>
|
||||
#include <resultset.h>
|
||||
#include <gw.h>
|
||||
#include <gwdirs.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
extern size_t log_ses_count[];
|
||||
extern __thread log_info_t tls_log_info;
|
||||
|
||||
static RSA *rsa_512 = NULL;
|
||||
static RSA *rsa_1024 = NULL;
|
||||
|
||||
/** To be used with configuration type checks */
|
||||
typedef struct typelib_st {
|
||||
int tl_nelems;
|
||||
@ -112,7 +117,7 @@ SERVICE *service;
|
||||
return NULL;
|
||||
if ((service->router = load_module(router, MODULE_ROUTER)) == NULL)
|
||||
{
|
||||
char* home = get_maxscale_home();
|
||||
char* home = get_libdir();
|
||||
char* ldpath = getenv("LD_LIBRARY_PATH");
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
@ -120,12 +125,13 @@ SERVICE *service;
|
||||
"Error : Unable to load %s module \"%s\".\n\t\t\t"
|
||||
" Ensure that lib%s.so exists in one of the "
|
||||
"following directories :\n\t\t\t "
|
||||
"- %s/modules\n\t\t\t - %s",
|
||||
"- %s/modules\n%s%s",
|
||||
MODULE_ROUTER,
|
||||
router,
|
||||
router,
|
||||
home,
|
||||
ldpath)));
|
||||
ldpath?"\t\t\t - ":"",
|
||||
ldpath?ldpath:"")));
|
||||
free(service);
|
||||
return NULL;
|
||||
}
|
||||
@ -133,7 +139,14 @@ SERVICE *service;
|
||||
service->routerModule = strdup(router);
|
||||
service->users_from_all = false;
|
||||
service->resources = NULL;
|
||||
|
||||
service->ssl_mode = SSL_DISABLED;
|
||||
service->ssl_init_done = false;
|
||||
service->ssl_ca_cert = NULL;
|
||||
service->ssl_cert = NULL;
|
||||
service->ssl_key = NULL;
|
||||
service->ssl_cert_verify_depth = DEFAULT_SSL_CERT_VERIFY_DEPTH;
|
||||
/** Support the highest possible SSL/TLS methods available as the default */
|
||||
service->ssl_method_type = SERVICE_SSL_TLS_MAX;
|
||||
if (service->name == NULL || service->routerModule == NULL)
|
||||
{
|
||||
if (service->name)
|
||||
@ -229,11 +242,7 @@ GWPROTOCOL *funcs;
|
||||
{
|
||||
/* Try loading authentication data from file cache */
|
||||
char *ptr, path[4097];
|
||||
strcpy(path, "/usr/local/mariadb-maxscale");
|
||||
if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
strncpy(path, ptr, 4096);
|
||||
}
|
||||
strcpy(path, get_cachedir());
|
||||
strncat(path, "/", 4096);
|
||||
strncat(path, service->name, 4096);
|
||||
strncat(path, "/.cache/dbusers", 4096);
|
||||
@ -257,15 +266,11 @@ GWPROTOCOL *funcs;
|
||||
else
|
||||
{
|
||||
/* Save authentication data to file cache */
|
||||
char *ptr, path[4097];
|
||||
char *ptr, path[PATH_MAX + 1];
|
||||
int mkdir_rval = 0;
|
||||
strcpy(path, "/usr/local/mariadb-maxscale");
|
||||
if ((ptr = getenv("MAXSCALE_HOME")) != NULL)
|
||||
{
|
||||
strncpy(path, ptr, 4096);
|
||||
}
|
||||
strcpy(path, get_cachedir());
|
||||
strncat(path, "/", 4096);
|
||||
strncat(path, service->name, 4096);
|
||||
strncat(path, service->name, PATH_MAX);
|
||||
if (access(path, R_OK) == -1)
|
||||
{
|
||||
mkdir_rval = mkdir(path, 0777);
|
||||
@ -280,7 +285,7 @@ GWPROTOCOL *funcs;
|
||||
mkdir_rval = 0;
|
||||
}
|
||||
|
||||
strncat(path, "/.cache", 4096);
|
||||
strncat(path, "/.cache", PATH_MAX);
|
||||
if (access(path, R_OK) == -1)
|
||||
{
|
||||
mkdir_rval = mkdir(path, 0777);
|
||||
@ -294,7 +299,7 @@ GWPROTOCOL *funcs;
|
||||
strerror(errno));
|
||||
mkdir_rval = 0;
|
||||
}
|
||||
strncat(path, "/dbusers", 4096);
|
||||
strncat(path, "/dbusers", PATH_MAX);
|
||||
dbusers_save(service->users, path);
|
||||
}
|
||||
if (loaded == 0)
|
||||
@ -417,6 +422,17 @@ serviceStart(SERVICE *service)
|
||||
SERV_PROTOCOL *port;
|
||||
int listeners = 0;
|
||||
|
||||
if(service->ssl_mode != SSL_DISABLED)
|
||||
{
|
||||
if(serviceInitSSL(service) != 0)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
|
||||
"%s: SSL initialization failed. Service not started.",
|
||||
service->name)));
|
||||
service->state = SERVICE_STATE_FAILED;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ((service->router_instance = service->router->createInstance(service,
|
||||
service->routerOptions)) == NULL)
|
||||
{
|
||||
@ -860,6 +876,97 @@ serviceOptimizeWildcard(SERVICE *service, int action)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the locations of the server's SSL certificate, server's private key and the CA
|
||||
* certificate which both the client and the server should trust.
|
||||
* @param service Service to configure
|
||||
* @param cert SSL certificate
|
||||
* @param key SSL private key
|
||||
* @param ca_cert SSL CA certificate
|
||||
*/
|
||||
void
|
||||
serviceSetCertificates(SERVICE *service, char* cert,char* key, char* ca_cert)
|
||||
{
|
||||
if(service->ssl_cert)
|
||||
free(service->ssl_cert);
|
||||
service->ssl_cert = strdup(cert);
|
||||
|
||||
if(service->ssl_key)
|
||||
free(service->ssl_key);
|
||||
service->ssl_key = strdup(key);
|
||||
|
||||
if(service->ssl_ca_cert)
|
||||
free(service->ssl_ca_cert);
|
||||
service->ssl_ca_cert = strdup(ca_cert);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum SSL/TLS version the service will support
|
||||
* @param service Service to configure
|
||||
* @param version SSL/TLS version string
|
||||
* @return 0 on success, -1 on invalid version string
|
||||
*/
|
||||
int
|
||||
serviceSetSSLVersion(SERVICE *service, char* version)
|
||||
{
|
||||
if(strcasecmp(version,"SSLV3") == 0)
|
||||
service->ssl_method_type = SERVICE_SSLV3;
|
||||
else if(strcasecmp(version,"TLSV10") == 0)
|
||||
service->ssl_method_type = SERVICE_TLS10;
|
||||
else if(strcasecmp(version,"TLSV11") == 0)
|
||||
service->ssl_method_type = SERVICE_TLS11;
|
||||
else if(strcasecmp(version,"TLSV12") == 0)
|
||||
service->ssl_method_type = SERVICE_TLS12;
|
||||
else if(strcasecmp(version,"MAX") == 0)
|
||||
service->ssl_method_type = SERVICE_SSL_TLS_MAX;
|
||||
else return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the service's SSL certificate verification depth. Depth of 0 means the peer
|
||||
* certificate, 1 is the CA and 2 is a higher CA and so on.
|
||||
* @param service Service to configure
|
||||
* @param depth Certificate verification depth
|
||||
* @return 0 on success, -1 on incorrect depth value
|
||||
*/
|
||||
int serviceSetSSLVerifyDepth(SERVICE* service, int depth)
|
||||
{
|
||||
if(depth < 0)
|
||||
return -1;
|
||||
|
||||
service->ssl_cert_verify_depth = depth;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable the service SSL capability of a service.
|
||||
* The SSL mode string passed as a parameter should be one of required, enabled
|
||||
* or disabled. Required requires all connections to use SSL encryption, enabled
|
||||
* allows both SSL and non-SSL connections and disabled does not use SSL encryption.
|
||||
* If the service SSL mode is set to enabled, then the client will decide whether
|
||||
* SSL encryption is used.
|
||||
* @param service Service to configure
|
||||
* @param action Mode string. One of required, enabled or disabled.
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
int
|
||||
serviceSetSSL(SERVICE *service, char* action)
|
||||
{
|
||||
int rval = 0;
|
||||
|
||||
if(strcasecmp(action,"required") == 0)
|
||||
service->ssl_mode = SSL_REQUIRED;
|
||||
else if(strcasecmp(action,"enabled") == 0)
|
||||
service->ssl_mode = SSL_ENABLED;
|
||||
else if(strcasecmp(action,"disabled") == 0)
|
||||
service->ssl_mode = SSL_DISABLED;
|
||||
else
|
||||
rval = -1;
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to strip escape characters from the name of the database the client
|
||||
* is connecting to.
|
||||
@ -1023,6 +1130,8 @@ int i;
|
||||
printf("\tUsers data: %p\n", (void *)service->users);
|
||||
printf("\tTotal connections: %d\n", service->stats.n_sessions);
|
||||
printf("\tCurrently connected: %d\n", service->stats.n_current);
|
||||
printf("\tSSL: %s\n", service->ssl_mode == SSL_DISABLED ? "Disabled":
|
||||
(service->ssl_mode == SSL_ENABLED ? "Enabled":"Required"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1132,6 +1241,8 @@ int i;
|
||||
service->stats.n_sessions);
|
||||
dcb_printf(dcb, "\tCurrently connected: %d\n",
|
||||
service->stats.n_current);
|
||||
dcb_printf(dcb,"\tSSL: %s\n", service->ssl_mode == SSL_DISABLED ? "Disabled":
|
||||
(service->ssl_mode == SSL_ENABLED ? "Enabled":"Required"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1260,7 +1371,14 @@ void *router_obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Refresh the database users for the service
|
||||
* This function replaces the MySQL users used by the service with the latest
|
||||
* version found on the backend servers. There is a limit on how often the users
|
||||
* can be reloaded and if this limit is exceeded, the reload will fail.
|
||||
* @param service Service to reload
|
||||
* @return 0 on success and 1 on error
|
||||
*/
|
||||
int service_refresh_users(SERVICE *service) {
|
||||
int ret = 1;
|
||||
/* check for another running getUsers request */
|
||||
@ -1780,3 +1898,139 @@ int *data;
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The RSA ket generation callback function for OpenSSL.
|
||||
* @param s SSL structure
|
||||
* @param is_export Not used
|
||||
* @param keylength Length of the key
|
||||
* @return Pointer to RSA structure
|
||||
*/
|
||||
RSA *tmp_rsa_callback(SSL *s, int is_export, int keylength)
|
||||
{
|
||||
RSA *rsa_tmp=NULL;
|
||||
|
||||
switch (keylength) {
|
||||
case 512:
|
||||
if (rsa_512)
|
||||
rsa_tmp = rsa_512;
|
||||
else { /* generate on the fly, should not happen in this example */
|
||||
rsa_tmp = RSA_generate_key(keylength,RSA_F4,NULL,NULL);
|
||||
rsa_512 = rsa_tmp; /* Remember for later reuse */
|
||||
}
|
||||
break;
|
||||
case 1024:
|
||||
if (rsa_1024)
|
||||
rsa_tmp=rsa_1024;
|
||||
break;
|
||||
default:
|
||||
/* Generating a key on the fly is very costly, so use what is there */
|
||||
if (rsa_1024)
|
||||
rsa_tmp=rsa_1024;
|
||||
else
|
||||
rsa_tmp=rsa_512; /* Use at least a shorter key */
|
||||
}
|
||||
return(rsa_tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the servce's SSL context. This sets up the generated RSA
|
||||
* encryption keys, chooses the server encryption level and configures the server
|
||||
* certificate, private key and certificate authority file.
|
||||
* @param service
|
||||
* @return
|
||||
*/
|
||||
int serviceInitSSL(SERVICE* service)
|
||||
{
|
||||
DH* dh;
|
||||
RSA* rsa;
|
||||
|
||||
if(!service->ssl_init_done)
|
||||
{
|
||||
switch(service->ssl_method_type)
|
||||
{
|
||||
case SERVICE_SSLV3:
|
||||
service->method = (SSL_METHOD*)SSLv3_server_method();
|
||||
break;
|
||||
case SERVICE_TLS10:
|
||||
service->method = (SSL_METHOD*)TLSv1_server_method();
|
||||
break;
|
||||
case SERVICE_TLS11:
|
||||
service->method = (SSL_METHOD*)TLSv1_1_server_method();
|
||||
break;
|
||||
case SERVICE_TLS12:
|
||||
service->method = (SSL_METHOD*)TLSv1_2_server_method();
|
||||
break;
|
||||
|
||||
/** Rest of these use the maximum available SSL/TLS methods */
|
||||
case SERVICE_SSL_MAX:
|
||||
service->method = (SSL_METHOD*)SSLv23_server_method();
|
||||
break;
|
||||
case SERVICE_TLS_MAX:
|
||||
service->method = (SSL_METHOD*)SSLv23_server_method();
|
||||
break;
|
||||
case SERVICE_SSL_TLS_MAX:
|
||||
service->method = (SSL_METHOD*)SSLv23_server_method();
|
||||
break;
|
||||
default:
|
||||
service->method = (SSL_METHOD*)SSLv23_server_method();
|
||||
break;
|
||||
}
|
||||
|
||||
service->ctx = SSL_CTX_new(service->method);
|
||||
|
||||
/** Enable all OpenSSL bug fixes */
|
||||
SSL_CTX_set_options(service->ctx,SSL_OP_ALL);
|
||||
|
||||
/** Generate the 512-bit and 1024-bit RSA keys */
|
||||
if(rsa_512 == NULL)
|
||||
{
|
||||
rsa_512 = RSA_generate_key(512,RSA_F4,NULL,NULL);
|
||||
if (rsa_512 == NULL)
|
||||
skygw_log_write(LE,"Error: 512-bit RSA key generation failed.");
|
||||
}
|
||||
if(rsa_1024 == NULL)
|
||||
{
|
||||
rsa_1024 = RSA_generate_key(1024,RSA_F4,NULL,NULL);
|
||||
if (rsa_1024 == NULL)
|
||||
skygw_log_write(LE,"Error: 1024-bit RSA key generation failed.");
|
||||
}
|
||||
|
||||
if(rsa_512 != NULL && rsa_1024 != NULL)
|
||||
SSL_CTX_set_tmp_rsa_callback(service->ctx,tmp_rsa_callback);
|
||||
|
||||
/** Load the server sertificate */
|
||||
if (SSL_CTX_use_certificate_file(service->ctx, service->ssl_cert, SSL_FILETYPE_PEM) <= 0) {
|
||||
skygw_log_write(LE,"Error: Failed to set server SSL certificate.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Load the private-key corresponding to the server certificate */
|
||||
if (SSL_CTX_use_PrivateKey_file(service->ctx, service->ssl_key, SSL_FILETYPE_PEM) <= 0) {
|
||||
skygw_log_write(LE,"Error: Failed to set server SSL key.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check if the server certificate and private-key matches */
|
||||
if (!SSL_CTX_check_private_key(service->ctx)) {
|
||||
skygw_log_write(LE,"Error: Server SSL certificate and key do not match.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* Load the RSA CA certificate into the SSL_CTX structure */
|
||||
if (!SSL_CTX_load_verify_locations(service->ctx, service->ssl_ca_cert, NULL)) {
|
||||
skygw_log_write(LE,"Error: Failed to set Certificate Authority file.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Set to require peer (client) certificate verification */
|
||||
SSL_CTX_set_verify(service->ctx,SSL_VERIFY_PEER,NULL);
|
||||
|
||||
/* Set the verification depth */
|
||||
SSL_CTX_set_verify_depth(service->ctx,service->ssl_cert_verify_depth);
|
||||
service->ssl_init_done = true;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -44,19 +44,4 @@ add_test(Internal-TestUsers test_users)
|
||||
add_test(Internal-TestAdminUsers test_adminusers)
|
||||
add_test(Internal-TestMemlog testmemlog)
|
||||
add_test(TestFeedback testfeedback)
|
||||
set_tests_properties(Internal-TestMySQLUsers
|
||||
Internal-TestHash
|
||||
Internal-TestHint
|
||||
Internal-TestSpinlock
|
||||
Internal-TestFilter
|
||||
Internal-TestBuffer
|
||||
Internal-TestDCB
|
||||
Internal-TestModutil
|
||||
Internal-TestPoll
|
||||
Internal-TestService
|
||||
Internal-TestServer
|
||||
Internal-TestUsers
|
||||
Internal-TestAdminUsers
|
||||
Internal-TestMemlog
|
||||
TestFeedback PROPERTIES ENVIRONMENT MAXSCALE_HOME=${CMAKE_BINARY_DIR}/)
|
||||
set_tests_properties(TestFeedback PROPERTIES TIMEOUT 30)
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gwdirs.h>
|
||||
#include <adminusers.h>
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
* Test that the username password admin/mariadb is accepted if no users
|
||||
* have been created and that no other users are accepted
|
||||
*
|
||||
* WARNING: $MAXSCALE_HOME/etc/passwd must be removed before this test is run
|
||||
* WARNING: The passwd file must be removed before this test is run
|
||||
*/
|
||||
static int
|
||||
test1()
|
||||
@ -269,9 +269,8 @@ int result = 0;
|
||||
char *home, buf[1024];
|
||||
|
||||
/* Unlink any existing password file before running this test */
|
||||
if ((home = getenv("MAXSCALE_HOME")) == NULL || strlen(home) >= 1024)
|
||||
home = "/usr/local/mariadb-maxscale";
|
||||
sprintf(buf, "%s/etc/passwd", home);
|
||||
|
||||
sprintf(buf, "%s/passwd", default_cachedir);
|
||||
if(!is_valid_posix_path(buf))
|
||||
exit(1);
|
||||
if (strcmp(buf, "/etc/passwd") != 0)
|
||||
|
@ -73,17 +73,8 @@ int main(int argc, char** argv)
|
||||
char* cnf;
|
||||
|
||||
hkinit();
|
||||
home = getenv("MAXSCALE_HOME");
|
||||
|
||||
if(home == NULL)
|
||||
{
|
||||
FAILTEST("MAXSCALE_HOME was not defined.");
|
||||
}
|
||||
printf("Home: %s\n",home);
|
||||
|
||||
cnf = malloc(strlen(home) + strlen("/etc/MaxScale.cnf") + 1);
|
||||
strcpy(cnf,home);
|
||||
strcat(cnf,"/etc/MaxScale.cnf");
|
||||
cnf = strdup("/etc/MaxScale.cnf");
|
||||
|
||||
printf("Config: %s\n",cnf);
|
||||
|
||||
@ -116,4 +107,4 @@ int main(int argc, char** argv)
|
||||
}
|
||||
mysql_library_end();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,9 @@
|
||||
#include <gwbitmask.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <netinet/in.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
#define ERRHANDLE
|
||||
|
||||
@ -132,7 +135,7 @@ typedef struct {
|
||||
#define DCBFD_CLOSED -1
|
||||
|
||||
/**
|
||||
* The statitics gathered on a descriptor control block
|
||||
* The statistics gathered on a descriptor control block
|
||||
*/
|
||||
typedef struct dcbstats {
|
||||
int n_reads; /*< Number of reads on this descriptor */
|
||||
@ -266,6 +269,7 @@ typedef struct dcb {
|
||||
unsigned int high_water; /**< High water mark */
|
||||
unsigned int low_water; /**< Low water mark */
|
||||
struct server *server; /**< The associated backend server */
|
||||
SSL* ssl; /*< SSL struct for connection */
|
||||
int dcb_port; /**< port of target server */
|
||||
skygw_chk_t dcb_chk_tail;
|
||||
} DCB;
|
||||
@ -311,6 +315,7 @@ void dcb_free(DCB *);
|
||||
DCB *dcb_connect(struct server *, struct session *, const char *);
|
||||
DCB *dcb_clone(DCB *);
|
||||
int dcb_read(DCB *, GWBUF **);
|
||||
int dcb_read_n(DCB*,GWBUF **,int);
|
||||
int dcb_drain_writeq(DCB *);
|
||||
void dcb_close(DCB *);
|
||||
DCB *dcb_process_zombies(int); /* Process Zombies except the one behind the pointer */
|
||||
@ -338,9 +343,14 @@ bool dcb_set_state(DCB* dcb, dcb_state_t new_state, dcb_state_t* old_state);
|
||||
void dcb_call_foreach (struct server* server, DCB_REASON reason);
|
||||
size_t dcb_get_session_id(DCB* dcb);
|
||||
bool dcb_get_ses_log_info(DCB* dcb, size_t* sesid, int* enabled_logs);
|
||||
|
||||
char *dcb_role_name(DCB *); /* Return the name of a role */
|
||||
|
||||
char *dcb_role_name(DCB *); /* Return the name of a role */
|
||||
int dcb_create_SSL(DCB* dcb);
|
||||
int dcb_accept_SSL(DCB* dcb);
|
||||
int dcb_connect_SSL(DCB* dcb);
|
||||
int gw_write_SSL(SSL* ssl, const void *buf, size_t nbytes);
|
||||
int dcb_write_SSL(DCB *dcb,GWBUF *queue);
|
||||
int dcb_read_SSL(DCB *dcb,GWBUF **head);
|
||||
int dcb_drain_writeq_SSL(DCB *dcb);
|
||||
|
||||
|
||||
/**
|
||||
@ -352,4 +362,4 @@ char *dcb_role_name(DCB *); /* Return the name of a
|
||||
|
||||
#define DCB_IS_CLONE(d) ((d)->flags & DCBF_CLONE)
|
||||
#define DCB_REPLIED(d) ((d)->flags & DCBF_REPLIED)
|
||||
#endif /* _DCB_H */
|
||||
#endif /* _DCB_H *
|
||||
|
@ -1,3 +1,25 @@
|
||||
#ifndef _GW_HG
|
||||
#define _GW_HG
|
||||
|
||||
/*
|
||||
* This file is distributed as part of the MariaDB Corporation MaxScale. It is free
|
||||
* software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation,
|
||||
* version 2.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright MariaDB Corporation Ab 2013-2014
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
@ -16,8 +38,8 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <gwdirs.h>
|
||||
|
||||
#define EXIT_FAILURE 1
|
||||
|
||||
@ -65,3 +87,5 @@ int gw_write(DCB *dcb, const void *buf, size_t nbytes);
|
||||
int gw_getsockerrno(int fd);
|
||||
int parse_bindconfig(char *, unsigned short, struct sockaddr_in *);
|
||||
int setipaddress(struct in_addr *, char *);
|
||||
char* get_libdir();
|
||||
#endif
|
||||
|
48
server/include/gwdirs.h.in
Normal file
48
server/include/gwdirs.h.in
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef _GW_DIRS_HG
|
||||
#define _GW_DIRS_HG
|
||||
|
||||
/*
|
||||
* This file is distributed as part of the MariaDB Corporation MaxScale. It is free
|
||||
* software: you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation,
|
||||
* version 2.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright MariaDB Corporation Ab 2015
|
||||
*/
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
/** Default file locations, configured by CMake */
|
||||
static const char* default_cnf_fname = "maxscale.cnf";
|
||||
static const char* default_configdir = "/etc/";
|
||||
static const char* default_piddir = "@MAXSCALE_VARDIR@/run/maxscale/"; /*< This should be changed to just /run eventually,
|
||||
* the /var/run folder is an old standard and the newe FSH 3.0
|
||||
* uses /run for PID files.*/
|
||||
static const char* default_logdir = "@MAXSCALE_VARDIR@/log/maxscale/";
|
||||
static const char* default_datadir = "@MAXSCALE_VARDIR@/lib/maxscale/";
|
||||
static const char* default_libdir = "@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@";
|
||||
static const char* default_cachedir = "@MAXSCALE_VARDIR@/cache/maxscale/";
|
||||
static const char* default_langdir = "@MAXSCALE_VARDIR@/lib/maxscale/";
|
||||
|
||||
static char* configdir = NULL;
|
||||
static char* logdir = NULL;
|
||||
static char* libdir = NULL;
|
||||
static char* cachedir = NULL;
|
||||
static char* maxscaledatadir = NULL;
|
||||
static char* langdir = NULL;
|
||||
static char* piddir = NULL;
|
||||
char* get_libdir();
|
||||
char* get_datadir();
|
||||
char* get_cachedir();
|
||||
#endif
|
@ -68,7 +68,6 @@ extern void unload_all_modules();
|
||||
extern void printModules();
|
||||
extern void dprintAllModules(DCB *);
|
||||
extern RESULTSET *moduleGetList();
|
||||
extern char *get_maxscale_home(void);
|
||||
extern void module_feedback_send(void*);
|
||||
extern void moduleShowFeedbackReport(DCB *dcb);
|
||||
|
||||
|
@ -53,5 +53,5 @@ typedef struct maxkeys {
|
||||
|
||||
extern int secrets_writeKeys(char *filename);
|
||||
extern char *decryptPassword(char *);
|
||||
extern char *encryptPassword(char *);
|
||||
extern char *encryptPassword(char*,char *);
|
||||
#endif
|
||||
|
@ -43,6 +43,7 @@
|
||||
* 30/08/14 Massimiliano Pinto Addition of SERVER_STALE_STATUS
|
||||
* 27/10/14 Massimiliano Pinto Addition of SERVER_MASTER_STICKINESS
|
||||
* 19/02/15 Mark Riddoch Addition of serverGetList
|
||||
* 01/06/15 Massimiliano Pinto Addition of server_update_address/port
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
@ -202,5 +203,7 @@ extern char *serverGetParameter(SERVER *, char *);
|
||||
extern void server_update(SERVER *, char *, char *, char *);
|
||||
extern void server_set_unique_name(SERVER *, char *);
|
||||
extern DCB *server_get_persistent(SERVER *, char *, const char *);
|
||||
extern void server_update_address(SERVER *, char *);
|
||||
extern void server_update_port(SERVER *, unsigned short);
|
||||
extern RESULTSET *serverGetList();
|
||||
#endif
|
||||
|
@ -26,7 +26,10 @@
|
||||
#include <hashtable.h>
|
||||
#include <resultset.h>
|
||||
#include <maxconfig.h>
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/dh.h>
|
||||
/**
|
||||
* @file service.h
|
||||
*
|
||||
@ -105,6 +108,24 @@ typedef struct server_ref_t{
|
||||
SERVER* server;
|
||||
}SERVER_REF;
|
||||
|
||||
typedef enum {
|
||||
SSL_DISABLED,
|
||||
SSL_ENABLED,
|
||||
SSL_REQUIRED
|
||||
} ssl_mode_t;
|
||||
|
||||
enum{
|
||||
SERVICE_SSLV3,
|
||||
SERVICE_TLS10,
|
||||
SERVICE_TLS11,
|
||||
SERVICE_TLS12,
|
||||
SERVICE_SSL_MAX,
|
||||
SERVICE_TLS_MAX,
|
||||
SERVICE_SSL_TLS_MAX
|
||||
};
|
||||
|
||||
#define DEFAULT_SSL_CERT_VERIFY_DEPTH 100 /*< The default certificate verification depth */
|
||||
|
||||
/**
|
||||
* Defines a service within the gateway.
|
||||
*
|
||||
@ -149,8 +170,19 @@ typedef struct service {
|
||||
FILTER_DEF **filters; /**< Ordered list of filters */
|
||||
int n_filters; /**< Number of filters */
|
||||
int conn_timeout; /*< Session timeout in seconds */
|
||||
ssl_mode_t ssl_mode; /*< one of DISABLED, ENABLED or REQUIRED */
|
||||
char *weightby;
|
||||
struct service *next; /**< The next service in the linked list */
|
||||
SSL_CTX *ctx;
|
||||
SSL_METHOD *method; /*< SSLv3 or TLS1.0/1.1/1.2 methods
|
||||
* see: https://www.openssl.org/docs/ssl/SSL_CTX_new.html */
|
||||
int ssl_cert_verify_depth; /*< SSL certificate verification depth */
|
||||
int ssl_method_type; /*< Which of the SSLv3 or TLS1.0/1.1/1.2 methods to use */
|
||||
char* ssl_cert; /*< SSL certificate */
|
||||
char* ssl_key; /*< SSL private key */
|
||||
char* ssl_ca_cert; /*< SSL CA certificate */
|
||||
bool ssl_init_done; /*< If SSL has already been initialized for this service */
|
||||
|
||||
} SERVICE;
|
||||
|
||||
typedef enum count_spec_t {COUNT_NONE=0, COUNT_ATLEAST, COUNT_EXACT, COUNT_ATMOST} count_spec_t;
|
||||
@ -178,6 +210,11 @@ extern int serviceRestart(SERVICE *);
|
||||
extern int serviceSetUser(SERVICE *, char *, char *);
|
||||
extern int serviceGetUser(SERVICE *, char **, char **);
|
||||
extern void serviceSetFilters(SERVICE *, char *);
|
||||
extern int serviceSetSSL(SERVICE *service, char* action);
|
||||
extern int serviceInitSSL(SERVICE* service);
|
||||
extern int serviceSetSSLVersion(SERVICE *service, char* version);
|
||||
extern int serviceSetSSLVerifyDepth(SERVICE* service, int depth);
|
||||
extern void serviceSetCertificates(SERVICE *service, char* cert,char* key, char* ca_cert);
|
||||
extern int serviceEnableRootUser(SERVICE *, int );
|
||||
extern int serviceSetTimeout(SERVICE *, int );
|
||||
extern void serviceWeightBy(SERVICE *, char *);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Example MaxScale.cnf for the Binlog Server.
|
||||
# Example maxscale.cnf for the Binlog Server.
|
||||
#
|
||||
#
|
||||
|
||||
@ -37,14 +37,13 @@ threads=6
|
||||
# The MaxScale Binlog Server Service.
|
||||
#
|
||||
# The name of this service will be used as the directory name
|
||||
# in $MAXSCALE_HOME where the binlogs will be saved.
|
||||
# in the cache directory where the binlogs will be saved.
|
||||
# If this name is changed, it must be changed in the listener
|
||||
# configuration below.
|
||||
[Binlog_Service]
|
||||
|
||||
# type must be service
|
||||
# router must be binlogrouter
|
||||
# (corresponding to the so file in $MAXSCALE_HOME/modules).
|
||||
type=service
|
||||
router=binlogrouter
|
||||
|
@ -3,48 +3,48 @@ if(BUILD_RABBITMQ)
|
||||
include_directories(${RABBITMQ_HEADERS})
|
||||
add_library(mqfilter SHARED mqfilter.c)
|
||||
target_link_libraries(mqfilter query_classifier log_manager utils ${RABBITMQ_LIBRARIES})
|
||||
install(TARGETS mqfilter DESTINATION modules)
|
||||
install(TARGETS mqfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
endif()
|
||||
|
||||
add_library(regexfilter SHARED regexfilter.c)
|
||||
target_link_libraries(regexfilter log_manager utils)
|
||||
install(TARGETS regexfilter DESTINATION modules)
|
||||
install(TARGETS regexfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(testfilter SHARED testfilter.c)
|
||||
target_link_libraries(testfilter log_manager utils)
|
||||
install(TARGETS testfilter DESTINATION modules)
|
||||
install(TARGETS testfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(qlafilter SHARED qlafilter.c)
|
||||
target_link_libraries(qlafilter log_manager utils)
|
||||
install(TARGETS qlafilter DESTINATION modules)
|
||||
install(TARGETS qlafilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(tee SHARED tee.c)
|
||||
target_link_libraries(tee log_manager utils)
|
||||
install(TARGETS tee DESTINATION modules)
|
||||
install(TARGETS tee DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(topfilter SHARED topfilter.c)
|
||||
target_link_libraries(topfilter log_manager utils)
|
||||
install(TARGETS topfilter DESTINATION modules)
|
||||
install(TARGETS topfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(dbfwfilter SHARED dbfwfilter.c)
|
||||
target_link_libraries(dbfwfilter log_manager utils query_classifier)
|
||||
install(TARGETS dbfwfilter DESTINATION modules)
|
||||
install(TARGETS dbfwfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(namedserverfilter SHARED namedserverfilter.c)
|
||||
target_link_libraries(namedserverfilter log_manager utils)
|
||||
install(TARGETS namedserverfilter DESTINATION modules)
|
||||
install(TARGETS namedserverfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
if(BUILD_SLAVELAG)
|
||||
add_library(slavelag SHARED slavelag.c)
|
||||
target_link_libraries(slavelag log_manager utils query_classifier)
|
||||
install(TARGETS slavelag DESTINATION modules)
|
||||
install(TARGETS slavelag DESTINATION ${MAXSCALE_LIBDIR})
|
||||
endif()
|
||||
|
||||
if(BUILD_TOOLS)
|
||||
add_executable(ruleparser dbfwfilter.c)
|
||||
target_compile_definitions(ruleparser PUBLIC "BUILD_RULE_PARSER")
|
||||
target_link_libraries(ruleparser ${EMBEDDED_LIB} log_manager utils query_classifier fullcore)
|
||||
install(TARGETS ruleparser DESTINATION tools)
|
||||
install(TARGETS ruleparser DESTINATION ${MAXSCALE_BINDIR})
|
||||
endif()
|
||||
|
||||
add_subdirectory(hint)
|
||||
|
@ -2214,15 +2214,13 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if((home = getenv("MAXSCALE_HOME")) == NULL)
|
||||
home = malloc(sizeof(char)*(PATH_MAX+1));
|
||||
if(getcwd(home,PATH_MAX) == NULL)
|
||||
{
|
||||
home = malloc(sizeof(char)*(PATH_MAX+1));
|
||||
if(getcwd(home,PATH_MAX) == NULL)
|
||||
{
|
||||
free(home);
|
||||
home = NULL;
|
||||
}
|
||||
free(home);
|
||||
home = NULL;
|
||||
}
|
||||
|
||||
printf("Log files written to: %s\n",home?home:"/tpm");
|
||||
|
||||
int argc_ = 2;
|
||||
|
@ -1,4 +1,4 @@
|
||||
add_library(hintfilter SHARED hintfilter.c hintparser.c)
|
||||
set_target_properties(hintfilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${CMAKE_INSTALL_PREFIX}/lib)
|
||||
set_target_properties(hintfilter PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_LIBDIR})
|
||||
target_link_libraries(hintfilter ssl log_manager utils)
|
||||
install(TARGETS hintfilter DESTINATION modules)
|
||||
install(TARGETS hintfilter DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
@ -305,7 +305,9 @@ char *remote, *userName;
|
||||
sprintf(my_session->filename, "%s.%d",
|
||||
my_instance->filebase,
|
||||
my_instance->sessions);
|
||||
atomic_add(&my_instance->sessions,1);
|
||||
|
||||
// Multiple sessions can try to update my_instance->sessions simultaneously
|
||||
atomic_add(&(my_instance->sessions), 1);
|
||||
|
||||
if (my_session->active)
|
||||
{
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_executable(harness_ui harness_ui.c harness_common.c)
|
||||
add_executable(harness harness_util.c harness_common.c)
|
||||
@ -25,7 +24,3 @@ add_test(TestTeeRecursion ${CMAKE_CURRENT_SOURCE_DIR}/tee_recursion.sh
|
||||
${TEST_PASSWORD}
|
||||
${TEST_HOST}
|
||||
${TEST_PORT})
|
||||
|
||||
set_tests_properties(TestHintfilter TestRegexfilter TestFwfilter1 TestFwfilter2 TestTeeRecursion
|
||||
PROPERTIES
|
||||
ENVIRONMENT MAXSCALE_HOME=${CMAKE_BINARY_DIR}/)
|
||||
|
@ -17,8 +17,8 @@ function execute_test()
|
||||
return 1
|
||||
fi
|
||||
|
||||
LAST_LOG=$(ls $BINDIR/log -1|grep err|sort|uniq|tail -n 1)
|
||||
TEST_RESULT=$(cat $BINDIR/log/$LAST_LOG | grep -i recursive)
|
||||
LAST_LOG=$(ls $BINDIR/ -1|grep error|sort|uniq|tail -n 1)
|
||||
TEST_RESULT=$(cat $BINDIR/$LAST_LOG | grep -i recursive)
|
||||
if [[ "$TEST_RESULT" != "" ]]
|
||||
then
|
||||
return 0
|
||||
@ -49,8 +49,8 @@ USER=$3
|
||||
PWD=$4
|
||||
HOST=$5
|
||||
PORT=$6
|
||||
CONF=$BINDIR/etc/MaxScale.cnf
|
||||
OLDCONF=$BINDIR/etc/MaxScale.cnf.old
|
||||
CONF=$BINDIR/etc/maxscale.cnf
|
||||
OLDCONF=$BINDIR/etc/maxscale.cnf.old
|
||||
MAXPID=$BINDIR/log/$(ls -1 $BINDIR/log|grep maxscale)
|
||||
TEST1=$SRCDIR/server/modules/filter/test/tee_recursion1.cnf
|
||||
TEST2=$SRCDIR/server/modules/filter/test/tee_recursion2.cnf
|
||||
|
@ -54,7 +54,9 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
#include <service.h>
|
||||
#include <router.h>
|
||||
#include <poll.h>
|
||||
@ -89,6 +91,10 @@
|
||||
#define COM_QUIT_PACKET_SIZE (4+1)
|
||||
struct dcb;
|
||||
|
||||
#define MYSQL_FAILED_AUTH 1
|
||||
#define MYSQL_FAILED_AUTH_DB 2
|
||||
#define MYSQL_FAILED_AUTH_SSL 3
|
||||
|
||||
typedef enum {
|
||||
MYSQL_ALLOC,
|
||||
MYSQL_PENDING_CONNECT,
|
||||
@ -97,6 +103,11 @@ typedef enum {
|
||||
MYSQL_AUTH_RECV,
|
||||
MYSQL_AUTH_FAILED,
|
||||
MYSQL_HANDSHAKE_FAILED,
|
||||
MYSQL_AUTH_SSL_REQ, /*< client requested SSL but SSL_accept hasn't beed called */
|
||||
MYSQL_AUTH_SSL_HANDSHAKE_DONE, /*< SSL handshake has been fully completed */
|
||||
MYSQL_AUTH_SSL_HANDSHAKE_FAILED, /*< SSL handshake failed for any reason */
|
||||
MYSQL_AUTH_SSL_HANDSHAKE_ONGOING, /*< SSL_accept has been called but the
|
||||
* SSL handshake hasn't been completed */
|
||||
MYSQL_IDLE
|
||||
} mysql_auth_state_t;
|
||||
|
||||
@ -290,6 +301,7 @@ typedef struct {
|
||||
unsigned long tid; /*< MySQL Thread ID, in
|
||||
* handshake */
|
||||
unsigned int charset; /*< MySQL character set at connect time */
|
||||
bool use_ssl;
|
||||
#if defined(SS_DEBUG)
|
||||
skygw_chk_t protocol_chk_tail;
|
||||
#endif
|
||||
@ -309,7 +321,7 @@ typedef struct {
|
||||
#define MYSQL_IS_CHANGE_USER(payload) (MYSQL_GET_COMMAND(payload)==0x11)
|
||||
#define MYSQL_GET_NATTR(payload) ((int)payload[4])
|
||||
|
||||
#endif /** _MYSQL_PROTOCOL_H */
|
||||
|
||||
|
||||
MySQLProtocol* mysql_protocol_init(DCB* dcb, int fd);
|
||||
void mysql_protocol_done (DCB* dcb);
|
||||
@ -405,4 +417,4 @@ void init_response_status (
|
||||
int* npackets,
|
||||
ssize_t* nbytes);
|
||||
|
||||
|
||||
#endif /** _MYSQL_PROTOCOL_H */
|
@ -1,16 +1,16 @@
|
||||
add_library(mysqlmon SHARED mysql_mon.c monitor_common.c)
|
||||
target_link_libraries(mysqlmon log_manager utils)
|
||||
install(TARGETS mysqlmon DESTINATION modules)
|
||||
install(TARGETS mysqlmon DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(galeramon SHARED galeramon.c monitor_common.c)
|
||||
target_link_libraries(galeramon log_manager utils)
|
||||
install(TARGETS galeramon DESTINATION modules)
|
||||
install(TARGETS galeramon DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(ndbclustermon SHARED ndbclustermon.c monitor_common.c)
|
||||
target_link_libraries(ndbclustermon log_manager utils)
|
||||
install(TARGETS ndbclustermon DESTINATION modules)
|
||||
install(TARGETS ndbclustermon DESTINATION ${MAXSCALE_LIBDIR})
|
||||
if(BUILD_MMMON)
|
||||
add_library(mmmon SHARED mmmon.c monitor_common.c)
|
||||
target_link_libraries(mmmon log_manager utils)
|
||||
install(TARGETS mmmon DESTINATION modules)
|
||||
install(TARGETS mmmon DESTINATION ${MAXSCALE_LIBDIR})
|
||||
endif()
|
||||
|
@ -123,7 +123,7 @@ startMonitor(void *arg,void* opt)
|
||||
MONITOR* mon = arg;
|
||||
GALERA_MONITOR *handle = mon->handle;
|
||||
CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
||||
bool have_events = false;
|
||||
bool have_events = false,script_error = false;
|
||||
if (handle != NULL)
|
||||
{
|
||||
handle->shutdown = 0;
|
||||
@ -163,6 +163,7 @@ startMonitor(void *arg,void* opt)
|
||||
}
|
||||
else
|
||||
{
|
||||
script_error = true;
|
||||
if(access(params->value,F_OK) == 0)
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
@ -175,17 +176,24 @@ startMonitor(void *arg,void* opt)
|
||||
"Error: The file cannot be found: %s",
|
||||
params->value);
|
||||
}
|
||||
handle->script = NULL;
|
||||
}
|
||||
}
|
||||
else if(!strcmp(params->name,"events"))
|
||||
{
|
||||
mon_parse_event_string((bool*)&handle->events,sizeof(handle->events),params->value);
|
||||
have_events = true;
|
||||
if(mon_parse_event_string((bool*)&handle->events,sizeof(handle->events),params->value) != 0)
|
||||
script_error = true;
|
||||
else
|
||||
have_events = true;
|
||||
}
|
||||
params = params->next;
|
||||
}
|
||||
|
||||
if(script_error)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Errors were found in the script configuration parameters "
|
||||
"for the monitor '%s'. The script will not be used.",mon->name);
|
||||
free(handle->script);
|
||||
handle->script = NULL;
|
||||
}
|
||||
/** If no specific events are given, enable them all */
|
||||
if(!have_events)
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ startMonitor(void *arg,void* opt)
|
||||
MONITOR* mon = (MONITOR*)arg;
|
||||
MM_MONITOR *handle = mon->handle;
|
||||
CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
||||
bool have_events = false;
|
||||
bool have_events = false,script_error = false;
|
||||
|
||||
if (handle)
|
||||
{
|
||||
@ -148,6 +148,7 @@ startMonitor(void *arg,void* opt)
|
||||
}
|
||||
else
|
||||
{
|
||||
script_error = true;
|
||||
if(access(params->value,F_OK) == 0)
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
@ -165,11 +166,20 @@ startMonitor(void *arg,void* opt)
|
||||
}
|
||||
else if(!strcmp(params->name,"events"))
|
||||
{
|
||||
mon_parse_event_string((bool*)&handle->events,sizeof(handle->events),params->value);
|
||||
have_events = true;
|
||||
if(mon_parse_event_string((bool*)&handle->events,sizeof(handle->events),params->value) != 0)
|
||||
script_error = true;
|
||||
else
|
||||
have_events = true;
|
||||
}
|
||||
params = params->next;
|
||||
}
|
||||
if(script_error)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Errors were found in the script configuration parameters "
|
||||
"for the monitor '%s'. The script will not be used.",mon->name);
|
||||
free(handle->script);
|
||||
handle->script = NULL;
|
||||
}
|
||||
/** If no specific events are given, enable them all */
|
||||
if(!have_events)
|
||||
{
|
||||
|
@ -230,7 +230,7 @@ void mon_append_node_names(MONITOR_SERVERS* start,char* str, int len)
|
||||
MONITOR_SERVERS* ptr = start;
|
||||
bool first = true;
|
||||
int slen = strlen(str);
|
||||
|
||||
char arr[256];
|
||||
while(ptr && slen < len)
|
||||
{
|
||||
if(!first)
|
||||
@ -238,7 +238,8 @@ void mon_append_node_names(MONITOR_SERVERS* start,char* str, int len)
|
||||
strncat(str,",",len);
|
||||
}
|
||||
first = false;
|
||||
strncat(str,ptr->server->unique_name,len);
|
||||
sprintf(arr,"%s:%d",ptr->server->name,ptr->server->port);
|
||||
strcat(str,arr);
|
||||
ptr = ptr->next;
|
||||
slen = strlen(str);
|
||||
}
|
||||
@ -299,10 +300,11 @@ void monitor_launch_script(MONITOR* mon,MONITOR_SERVERS* ptr, char* script)
|
||||
EXTERNCMD* cmd;
|
||||
|
||||
snprintf(argstr,PATH_MAX + MON_ARG_MAX,
|
||||
"%s --event=%s --initiator=%s --nodelist=",
|
||||
"%s --event=%s --initiator=%s:%d --nodelist=",
|
||||
script,
|
||||
mon_get_event_name(ptr),
|
||||
ptr->server->unique_name);
|
||||
ptr->server->name,
|
||||
ptr->server->port);
|
||||
|
||||
mon_append_node_names(mon->databases,argstr,PATH_MAX + MON_ARG_MAX + 1);
|
||||
if((cmd = externcmd_allocate(argstr)) == NULL)
|
||||
@ -343,7 +345,10 @@ int mon_parse_event_string(bool* events, size_t count,char* string)
|
||||
{
|
||||
event = mon_name_to_event(tok);
|
||||
if(event == UNDEFINED_MONITOR_EVENT)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Invalid event name %s",tok);
|
||||
return -1;
|
||||
}
|
||||
events[event] = true;
|
||||
tok = strtok_r(NULL,",| ",&saved);
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ startMonitor(void *arg, void* opt)
|
||||
MONITOR* monitor = (MONITOR*)arg;
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR*)monitor->handle;
|
||||
CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
||||
bool have_events = false;
|
||||
bool have_events = false,script_error = false;
|
||||
|
||||
if (handle)
|
||||
{
|
||||
@ -176,6 +176,7 @@ startMonitor(void *arg, void* opt)
|
||||
}
|
||||
else
|
||||
{
|
||||
script_error = true;
|
||||
if(access(params->value,F_OK) == 0)
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
@ -193,11 +194,20 @@ startMonitor(void *arg, void* opt)
|
||||
}
|
||||
else if(!strcmp(params->name,"events"))
|
||||
{
|
||||
mon_parse_event_string(handle->events,sizeof(handle->events),params->value);
|
||||
have_events = true;
|
||||
if(mon_parse_event_string((bool*)&handle->events,sizeof(handle->events),params->value) != 0)
|
||||
script_error = true;
|
||||
else
|
||||
have_events = true;
|
||||
}
|
||||
params = params->next;
|
||||
}
|
||||
if(script_error)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Errors were found in the script configuration parameters "
|
||||
"for the monitor '%s'. The script will not be used.",monitor->name);
|
||||
free(handle->script);
|
||||
handle->script = NULL;
|
||||
}
|
||||
/** If no specific events are given, enable them all */
|
||||
if(!have_events)
|
||||
{
|
||||
@ -313,6 +323,8 @@ char *server_string;
|
||||
int read_timeout = mon->read_timeout;
|
||||
int write_timeout = mon->write_timeout;
|
||||
|
||||
if(database->con)
|
||||
mysql_close(database->con);
|
||||
database->con = mysql_init(NULL);
|
||||
|
||||
mysql_options(database->con, MYSQL_OPT_CONNECT_TIMEOUT, (void *)&connect_timeout);
|
||||
|
@ -111,7 +111,7 @@ startMonitor(void *arg,void* opt)
|
||||
MONITOR* mon = (MONITOR*)arg;
|
||||
MYSQL_MONITOR *handle = mon->handle;
|
||||
CONFIG_PARAMETER* params = (CONFIG_PARAMETER*)opt;
|
||||
bool have_events = false;
|
||||
bool have_events = false,script_error = false;
|
||||
|
||||
if (handle != NULL)
|
||||
{
|
||||
@ -140,6 +140,7 @@ startMonitor(void *arg,void* opt)
|
||||
}
|
||||
else
|
||||
{
|
||||
script_error = true;
|
||||
if(access(params->value,F_OK) == 0)
|
||||
{
|
||||
skygw_log_write(LE,
|
||||
@ -157,10 +158,19 @@ startMonitor(void *arg,void* opt)
|
||||
}
|
||||
else if(!strcmp(params->name,"events"))
|
||||
{
|
||||
mon_parse_event_string(&handle->events,sizeof(handle->events),params->value);
|
||||
have_events = true;
|
||||
if(mon_parse_event_string((bool*)&handle->events,sizeof(handle->events),params->value) != 0)
|
||||
script_error = true;
|
||||
else
|
||||
have_events = true;
|
||||
}
|
||||
params = params->next;
|
||||
}
|
||||
if(script_error)
|
||||
{
|
||||
skygw_log_write(LE,"Error: Errors were found in the script configuration parameters "
|
||||
"for the monitor '%s'. The script will not be used.",mon->name);
|
||||
free(handle->script);
|
||||
handle->script = NULL;
|
||||
}
|
||||
/** If no specific events are given, enable them all */
|
||||
if(!have_events)
|
||||
|
@ -1,27 +1,28 @@
|
||||
add_library(MySQLClient SHARED mysql_client.c mysql_common.c)
|
||||
target_link_libraries(MySQLClient log_manager utils)
|
||||
install(TARGETS MySQLClient DESTINATION modules)
|
||||
install(TARGETS MySQLClient DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(MySQLBackend SHARED mysql_backend.c mysql_common.c)
|
||||
target_link_libraries(MySQLBackend log_manager utils)
|
||||
install(TARGETS MySQLBackend DESTINATION modules)
|
||||
install(TARGETS MySQLBackend DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(telnetd SHARED telnetd.c)
|
||||
target_link_libraries(telnetd log_manager utils)
|
||||
install(TARGETS telnetd DESTINATION modules)
|
||||
install(TARGETS telnetd DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
add_library(HTTPD SHARED httpd.c)
|
||||
target_link_libraries(HTTPD log_manager utils)
|
||||
install(TARGETS HTTPD DESTINATION modules)
|
||||
install(TARGETS HTTPD DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
if(BUILD_TESTS)
|
||||
add_library(testprotocol SHARED testprotocol.c)
|
||||
install(TARGETS testprotocol DESTINATION modules)
|
||||
install(TARGETS testprotocol DESTINATION ${MAXSCALE_LIBDIR})
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
add_library(maxscaled SHARED maxscaled.c)
|
||||
target_link_libraries(maxscaled log_manager utils)
|
||||
install(TARGETS maxscaled DESTINATION modules)
|
||||
install(TARGETS maxscaled DESTINATION ${MAXSCALE_LIBDIR})
|
||||
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
* 09/09/2014 Massimiliano Pinto Added: 777 permission for socket path
|
||||
* 13/10/2014 Massimiliano Pinto Added: dbname authentication check
|
||||
* 10/11/2014 Massimiliano Pinto Added: client charset added to protocol struct
|
||||
*
|
||||
* 29/05/2015 Markus Makela Added SSL support
|
||||
*/
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
@ -46,6 +46,7 @@
|
||||
#include <modinfo.h>
|
||||
#include <sys/stat.h>
|
||||
#include <modutil.h>
|
||||
#include <netinet/tcp.h>
|
||||
|
||||
MODULE_INFO info = {
|
||||
MODULE_API_PROTOCOL,
|
||||
@ -69,14 +70,18 @@ static int gw_MySQLWrite_client(DCB *dcb, GWBUF *queue);
|
||||
static int gw_error_client_event(DCB *dcb);
|
||||
static int gw_client_close(DCB *dcb);
|
||||
static int gw_client_hangup_event(DCB *dcb);
|
||||
|
||||
int gw_read_client_event_SSL(DCB* dcb);
|
||||
int gw_MySQLWrite_client_SSL(DCB *dcb, GWBUF *queue);
|
||||
int gw_write_client_event_SSL(DCB *dcb);
|
||||
int mysql_send_ok(DCB *dcb, int packet_number, int in_affected_rows, const char* mysql_message);
|
||||
int MySQLSendHandshake(DCB* dcb);
|
||||
static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue);
|
||||
static int gw_mysql_do_authentication(DCB *dcb, GWBUF **queue);
|
||||
static int route_by_statement(SESSION *, GWBUF **);
|
||||
extern char* get_username_from_auth(char* ptr, uint8_t* data);
|
||||
extern int check_db_name_after_auth(DCB *, char *, int);
|
||||
extern char* create_auth_fail_str(char *username, char *hostaddr, char *sha1, char *db);
|
||||
extern char* create_auth_fail_str(char *username, char *hostaddr, char *sha1, char *db,int);
|
||||
|
||||
int do_ssl_accept(MySQLProtocol* protocol);
|
||||
|
||||
/*
|
||||
* The "module object" for the mysqld client protocol module.
|
||||
@ -242,7 +247,7 @@ MySQLSendHandshake(DCB* dcb)
|
||||
char server_scramble[GW_MYSQL_SCRAMBLE_SIZE + 1]="";
|
||||
char *version_string;
|
||||
int len_version_string=0;
|
||||
|
||||
|
||||
MySQLProtocol *protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
|
||||
GWBUF *buf;
|
||||
|
||||
@ -319,7 +324,16 @@ MySQLSendHandshake(DCB* dcb)
|
||||
|
||||
|
||||
mysql_server_capabilities_one[0] &= ~GW_MYSQL_CAPABILITIES_COMPRESS;
|
||||
mysql_server_capabilities_one[0] &= ~GW_MYSQL_CAPABILITIES_SSL;
|
||||
|
||||
if(dcb->service->ssl_mode != SSL_DISABLED)
|
||||
{
|
||||
mysql_server_capabilities_one[1] |= GW_MYSQL_CAPABILITIES_SSL >> 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_server_capabilities_one[0] &= ~GW_MYSQL_CAPABILITIES_SSL;
|
||||
}
|
||||
|
||||
|
||||
memcpy(mysql_handshake_payload, mysql_server_capabilities_one, sizeof(mysql_server_capabilities_one));
|
||||
mysql_handshake_payload = mysql_handshake_payload + sizeof(mysql_server_capabilities_one);
|
||||
@ -375,21 +389,24 @@ MySQLSendHandshake(DCB* dcb)
|
||||
/**
|
||||
* gw_mysql_do_authentication
|
||||
*
|
||||
* Performs the MySQL protocol 4.1 authentication, using data in GWBUF *queue
|
||||
* Performs the MySQL protocol 4.1 authentication, using data in GWBUF **queue.
|
||||
*
|
||||
* (MYSQL_session*)client_data including: user, db, client_sha1 are copied into
|
||||
* the dcb->data and later to dcb->session->data.
|
||||
*
|
||||
* client_capabilitiesa are copied into the dcb->protocol
|
||||
* the dcb->data and later to dcb->session->data. client_capabilities are copied
|
||||
* into the dcb->protocol.
|
||||
*
|
||||
* If SSL is enabled for the service, the SSL handshake will be done before the
|
||||
* MySQL authentication.
|
||||
*
|
||||
* @param dcb Descriptor Control Block of the client
|
||||
* @param queue The GWBUF with data from client
|
||||
* @param queue Pointer to the location of the GWBUF with data from client
|
||||
* @return 0 If succeed, otherwise non-zero value
|
||||
*
|
||||
* @note in case of failure, dcb->data is freed before returning. If succeed,
|
||||
* dcb->data is freed in session.c:session_free.
|
||||
*/
|
||||
static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
|
||||
static int gw_mysql_do_authentication(DCB *dcb, GWBUF **buf) {
|
||||
GWBUF* queue = *buf;
|
||||
MySQLProtocol *protocol = NULL;
|
||||
/* int compress = -1; */
|
||||
int connect_with_db = -1;
|
||||
@ -402,7 +419,7 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
|
||||
uint8_t *stage1_hash = NULL;
|
||||
int auth_ret = -1;
|
||||
MYSQL_session *client_data = NULL;
|
||||
|
||||
int ssl = 0;
|
||||
CHK_DCB(dcb);
|
||||
|
||||
protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
|
||||
@ -437,7 +454,7 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
|
||||
/* Detect now if there are enough bytes to continue */
|
||||
if (client_auth_packet_size < (4 + 4 + 4 + 1 + 23))
|
||||
{
|
||||
return 1;
|
||||
return MYSQL_FAILED_AUTH;
|
||||
}
|
||||
|
||||
memcpy(&protocol->client_capabilities, client_auth_packet + 4, 4);
|
||||
@ -451,11 +468,66 @@ static int gw_mysql_do_authentication(DCB *dcb, GWBUF *queue) {
|
||||
&protocol->client_capabilities);
|
||||
*/
|
||||
|
||||
/** Skip this if the SSL handshake is already done.
|
||||
* If not, start the SSL handshake. */
|
||||
if(protocol->protocol_auth_state != MYSQL_AUTH_SSL_HANDSHAKE_DONE)
|
||||
{
|
||||
|
||||
ssl = protocol->client_capabilities & GW_MYSQL_CAPABILITIES_SSL;
|
||||
|
||||
/** Client didn't requested SSL when SSL mode was required*/
|
||||
if(!ssl && protocol->owner_dcb->service->ssl_mode == SSL_REQUIRED)
|
||||
{
|
||||
LOGIF(LT,(skygw_log_write(LT,"User %s@%s connected to service '%s' without SSL when SSL was required.",
|
||||
protocol->owner_dcb->user,
|
||||
protocol->owner_dcb->remote,
|
||||
protocol->owner_dcb->service->name)));
|
||||
return MYSQL_FAILED_AUTH_SSL;
|
||||
}
|
||||
|
||||
if(LOG_IS_ENABLED(LT) && ssl)
|
||||
{
|
||||
skygw_log_write(LT,"User %s@%s connected to service '%s' with SSL.",
|
||||
protocol->owner_dcb->user,
|
||||
protocol->owner_dcb->remote,
|
||||
protocol->owner_dcb->service->name);
|
||||
}
|
||||
|
||||
/** Do the SSL Handshake */
|
||||
if(ssl && protocol->owner_dcb->service->ssl_mode != SSL_DISABLED)
|
||||
{
|
||||
protocol->protocol_auth_state = MYSQL_AUTH_SSL_REQ;
|
||||
|
||||
if(do_ssl_accept(protocol) < 0)
|
||||
{
|
||||
return MYSQL_FAILED_AUTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if(dcb->service->ssl_mode == SSL_ENABLED)
|
||||
{
|
||||
/** This is a non-SSL connection to a SSL enabled service.
|
||||
* We have only read enough of the packet to know that the client
|
||||
* is not requesting SSL and the rest of the auth packet is still
|
||||
* waiting in the socket. We need to read the data from the socket
|
||||
* to find out the username of the connecting client. */
|
||||
int bytes = dcb_read(dcb,&queue);
|
||||
queue = gwbuf_make_contiguous(queue);
|
||||
client_auth_packet = GWBUF_DATA(queue);
|
||||
client_auth_packet_size = gwbuf_length(queue);
|
||||
*buf = queue;
|
||||
LOGIF(LD,(skygw_log_write(LD,"%lu Read %d bytes from fd %d",pthread_self(),bytes,dcb->fd)));
|
||||
}
|
||||
}
|
||||
|
||||
username = get_username_from_auth(username, client_auth_packet);
|
||||
|
||||
if (username == NULL)
|
||||
{
|
||||
return 1;
|
||||
return MYSQL_FAILED_AUTH;
|
||||
}
|
||||
|
||||
/* get charset */
|
||||
@ -557,6 +629,24 @@ gw_MySQLWrite_client(DCB *dcb, GWBUF *queue)
|
||||
return dcb_write(dcb, queue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write function for client DCB: writes data from MaxScale to Client using SSL
|
||||
* encryption. The SSH handshake must have already been done.
|
||||
*
|
||||
* @param dcb The DCB of the client
|
||||
* @param queue Queue of buffers to write
|
||||
*/
|
||||
int
|
||||
gw_MySQLWrite_client_SSL(DCB *dcb, GWBUF *queue)
|
||||
{
|
||||
MySQLProtocol *protocol = NULL;
|
||||
CHK_DCB(dcb);
|
||||
protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
|
||||
CHK_PROTOCOL(protocol);
|
||||
return dcb_write_SSL(dcb, queue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Client read event triggered by EPOLLIN
|
||||
*
|
||||
@ -580,9 +670,66 @@ int gw_read_client_event(
|
||||
CHK_DCB(dcb);
|
||||
protocol = DCB_PROTOCOL(dcb, MySQLProtocol);
|
||||
CHK_PROTOCOL(protocol);
|
||||
rc = dcb_read(dcb, &read_buffer);
|
||||
|
||||
|
||||
|
||||
#ifdef SS_DEBUG
|
||||
skygw_log_write(LD,"[gw_read_client_event] Protocol state: %s",
|
||||
gw_mysql_protocol_state2string(protocol->protocol_auth_state));
|
||||
|
||||
#endif
|
||||
|
||||
/** SSL authentication is still going on, we need to call do_ssl_accept
|
||||
* until it return 1 for success or -1 for error */
|
||||
if(protocol->protocol_auth_state == MYSQL_AUTH_SSL_HANDSHAKE_ONGOING ||
|
||||
protocol->protocol_auth_state == MYSQL_AUTH_SSL_REQ)
|
||||
{
|
||||
|
||||
switch(do_ssl_accept(protocol))
|
||||
{
|
||||
case 0:
|
||||
return 0;
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
int b = 0;
|
||||
ioctl(dcb->fd,FIONREAD,&b);
|
||||
if(b == 0)
|
||||
{
|
||||
skygw_log_write(LD,
|
||||
"[gw_read_client_event] No data in socket after SSL auth");
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case -1:
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(protocol->use_ssl)
|
||||
{
|
||||
/** SSL handshake is done, communication is now encrypted with SSL */
|
||||
rc = dcb_read_SSL(dcb, &read_buffer);
|
||||
}
|
||||
else if(dcb->service->ssl_mode != SSL_DISABLED &&
|
||||
protocol->protocol_auth_state == MYSQL_AUTH_SENT)
|
||||
{
|
||||
/** The service allows both SSL and non-SSL connections.
|
||||
* read only enough of the auth packet to know if the client is
|
||||
* requesting SSL. If the client is not requesting SSL the rest of
|
||||
the auth packet will be read later. */
|
||||
rc = dcb_read_n(dcb, &read_buffer,(4 + 4 + 4 + 1 + 23));
|
||||
}
|
||||
else
|
||||
{
|
||||
/** Normal non-SSL connection */
|
||||
rc = dcb_read(dcb, &read_buffer);
|
||||
}
|
||||
|
||||
if (rc < 0)
|
||||
{
|
||||
dcb_close(dcb);
|
||||
@ -690,8 +837,8 @@ int gw_read_client_event(
|
||||
dcb->dcb_readqueue = gwbuf_append(dcb->dcb_readqueue, read_buffer);
|
||||
nbytes_read = gwbuf_length(dcb->dcb_readqueue);
|
||||
data = (uint8_t *)GWBUF_DATA(dcb->dcb_readqueue);
|
||||
|
||||
if (nbytes_read < 3 || nbytes_read < MYSQL_GET_PACKET_LEN(data))
|
||||
int plen = MYSQL_GET_PACKET_LEN(data);
|
||||
if (nbytes_read < 3 || nbytes_read < MYSQL_GET_PACKET_LEN(data) + 4)
|
||||
{
|
||||
rc = 0;
|
||||
goto return_rc;
|
||||
@ -719,7 +866,7 @@ int gw_read_client_event(
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Now there should be at least one complete mysql packet in read_buffer.
|
||||
*/
|
||||
@ -729,8 +876,19 @@ int gw_read_client_event(
|
||||
{
|
||||
int auth_val;
|
||||
|
||||
auth_val = gw_mysql_do_authentication(dcb, read_buffer);
|
||||
|
||||
auth_val = gw_mysql_do_authentication(dcb, &read_buffer);
|
||||
|
||||
if(protocol->protocol_auth_state == MYSQL_AUTH_SSL_REQ ||
|
||||
protocol->protocol_auth_state == MYSQL_AUTH_SSL_HANDSHAKE_ONGOING ||
|
||||
protocol->protocol_auth_state == MYSQL_AUTH_SSL_HANDSHAKE_DONE ||
|
||||
protocol->protocol_auth_state == MYSQL_AUTH_SSL_HANDSHAKE_FAILED)
|
||||
{
|
||||
/** SSL was requested and the handshake is either done or
|
||||
* still ongoing. After the handshake is done, the client
|
||||
* will send another auth packet. */
|
||||
break;
|
||||
}
|
||||
|
||||
if (auth_val == 0)
|
||||
{
|
||||
SESSION *session;
|
||||
@ -796,7 +954,7 @@ int gw_read_client_event(
|
||||
fail_str = create_auth_fail_str((char *)((MYSQL_session *)dcb->data)->user,
|
||||
dcb->remote,
|
||||
(char*)((MYSQL_session *)dcb->data)->client_sha1,
|
||||
(char*)((MYSQL_session *)dcb->data)->db);
|
||||
(char*)((MYSQL_session *)dcb->data)->db,auth_val);
|
||||
modutil_send_mysql_err_packet(dcb, 2, 0, 1045, "28000", fail_str);
|
||||
}
|
||||
if (fail_str)
|
||||
@ -824,6 +982,113 @@ int gw_read_client_event(
|
||||
}
|
||||
break;
|
||||
|
||||
case MYSQL_AUTH_SSL_HANDSHAKE_DONE:
|
||||
{
|
||||
int auth_val;
|
||||
|
||||
auth_val = gw_mysql_do_authentication(dcb, &read_buffer);
|
||||
|
||||
|
||||
if (auth_val == 0)
|
||||
{
|
||||
SESSION *session;
|
||||
|
||||
protocol->protocol_auth_state = MYSQL_AUTH_RECV;
|
||||
/**
|
||||
* Create session, and a router session for it.
|
||||
* If successful, there will be backend connection(s)
|
||||
* after this point.
|
||||
*/
|
||||
session = session_alloc(dcb->service, dcb);
|
||||
|
||||
if (session != NULL)
|
||||
{
|
||||
CHK_SESSION(session);
|
||||
ss_dassert(session->state != SESSION_STATE_ALLOC);
|
||||
|
||||
protocol->protocol_auth_state = MYSQL_IDLE;
|
||||
/**
|
||||
* Send an AUTH_OK packet to the client,
|
||||
* packet sequence is # 2
|
||||
*/
|
||||
mysql_send_ok(dcb, 3, 0, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
protocol->protocol_auth_state = MYSQL_AUTH_FAILED;
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_read_client_event] session "
|
||||
"creation failed. fd %d, "
|
||||
"state = MYSQL_AUTH_FAILED.",
|
||||
pthread_self(),
|
||||
protocol->owner_dcb->fd)));
|
||||
|
||||
/** Send ERR 1045 to client */
|
||||
mysql_send_auth_error(
|
||||
dcb,
|
||||
3,
|
||||
0,
|
||||
"failed to create new session");
|
||||
|
||||
dcb_close(dcb);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char* fail_str = NULL;
|
||||
|
||||
protocol->protocol_auth_state = MYSQL_AUTH_FAILED;
|
||||
|
||||
if (auth_val == 2) {
|
||||
/** Send error 1049 to client */
|
||||
int message_len = 25 + MYSQL_DATABASE_MAXLEN;
|
||||
|
||||
fail_str = calloc(1, message_len+1);
|
||||
snprintf(fail_str, message_len, "Unknown database '%s'",
|
||||
(char*)((MYSQL_session *)dcb->data)->db);
|
||||
|
||||
modutil_send_mysql_err_packet(dcb, 3, 0, 1049, "42000", fail_str);
|
||||
}else if(auth_val == 3){
|
||||
/** Send error 1045 to client */
|
||||
fail_str = create_auth_fail_str((char *)((MYSQL_session *)dcb->data)->user,
|
||||
dcb->remote,
|
||||
(char*)((MYSQL_session *)dcb->data)->client_sha1,
|
||||
(char*)((MYSQL_session *)dcb->data)->db,auth_val);
|
||||
modutil_send_mysql_err_packet(dcb, 3, 0, 1045, "28000", fail_str);
|
||||
}else {
|
||||
/** Send error 1045 to client */
|
||||
fail_str = create_auth_fail_str((char *)((MYSQL_session *)dcb->data)->user,
|
||||
dcb->remote,
|
||||
(char*)((MYSQL_session *)dcb->data)->client_sha1,
|
||||
(char*)((MYSQL_session *)dcb->data)->db,auth_val);
|
||||
modutil_send_mysql_err_packet(dcb, 3, 0, 1045, "28000", fail_str);
|
||||
}
|
||||
if (fail_str)
|
||||
free(fail_str);
|
||||
|
||||
LOGIF(LD, (skygw_log_write(
|
||||
LOGFILE_DEBUG,
|
||||
"%lu [gw_read_client_event] after "
|
||||
"gw_mysql_do_authentication, fd %d, "
|
||||
"state = MYSQL_AUTH_FAILED.",
|
||||
protocol->owner_dcb->fd,
|
||||
pthread_self())));
|
||||
/**
|
||||
* Release MYSQL_session since it is not used anymore.
|
||||
*/
|
||||
if (!DCB_IS_CLONE(dcb))
|
||||
{
|
||||
free(dcb->data);
|
||||
}
|
||||
dcb->data = NULL;
|
||||
|
||||
dcb_close(dcb);
|
||||
}
|
||||
read_buffer = gwbuf_consume(read_buffer, nbytes_read);
|
||||
}
|
||||
break;
|
||||
|
||||
case MYSQL_IDLE:
|
||||
{
|
||||
uint8_t* payload = NULL;
|
||||
@ -943,12 +1208,13 @@ return_rc:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// client write event to Client triggered by EPOLLOUT
|
||||
//////////////////////////////////////////////
|
||||
/**
|
||||
/**
|
||||
* @node Client's fd became writable, and EPOLLOUT event
|
||||
* arrived. As a consequence, client input buffer (writeq) is flushed.
|
||||
* arrived. As a consequence, client input buffer (writeq) is flushed.
|
||||
*
|
||||
* Parameters:
|
||||
* @param dcb - in, use
|
||||
@ -956,7 +1222,7 @@ return_rc:
|
||||
*
|
||||
* @return constantly 1
|
||||
*
|
||||
*
|
||||
*
|
||||
* @details (write detailed description here)
|
||||
*
|
||||
*/
|
||||
@ -966,6 +1232,53 @@ int gw_write_client_event(DCB *dcb)
|
||||
|
||||
CHK_DCB(dcb);
|
||||
|
||||
ss_dassert(dcb->state != DCB_STATE_DISCONNECTED);
|
||||
|
||||
if (dcb == NULL) {
|
||||
goto return_1;
|
||||
}
|
||||
|
||||
if (dcb->state == DCB_STATE_DISCONNECTED) {
|
||||
goto return_1;
|
||||
}
|
||||
|
||||
if (dcb->protocol == NULL) {
|
||||
goto return_1;
|
||||
}
|
||||
protocol = (MySQLProtocol *)dcb->protocol;
|
||||
CHK_PROTOCOL(protocol);
|
||||
|
||||
if (protocol->protocol_auth_state == MYSQL_IDLE)
|
||||
{
|
||||
dcb_drain_writeq(dcb);
|
||||
goto return_1;
|
||||
}
|
||||
|
||||
return_1:
|
||||
#if defined(SS_DEBUG)
|
||||
if (dcb->state == DCB_STATE_POLLING ||
|
||||
dcb->state == DCB_STATE_NOPOLLING ||
|
||||
dcb->state == DCB_STATE_ZOMBIE)
|
||||
{
|
||||
CHK_PROTOCOL(protocol);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* EPOLLOUT event arrived and as a consequence, client input buffer (writeq) is
|
||||
* flushed. The data is encrypted and SSL is used. The SSL handshake must have
|
||||
* been successfully completed prior to this function being called.
|
||||
* @param client dcb
|
||||
* @return constantly 1
|
||||
*/
|
||||
int gw_write_client_event_SSL(DCB *dcb)
|
||||
{
|
||||
MySQLProtocol *protocol = NULL;
|
||||
|
||||
CHK_DCB(dcb);
|
||||
|
||||
ss_dassert(dcb->state != DCB_STATE_DISCONNECTED);
|
||||
|
||||
if (dcb == NULL) {
|
||||
@ -984,7 +1297,7 @@ int gw_write_client_event(DCB *dcb)
|
||||
|
||||
if (protocol->protocol_auth_state == MYSQL_IDLE)
|
||||
{
|
||||
dcb_drain_writeq(dcb);
|
||||
dcb_drain_writeq_SSL(dcb);
|
||||
goto return_1;
|
||||
}
|
||||
|
||||
@ -1064,6 +1377,9 @@ int gw_MySQLListener(
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno))));
|
||||
}
|
||||
|
||||
if((syseno = setsockopt(l_so, IPPROTO_TCP, TCP_NODELAY, (char *)&one, sizeof(one))) != 0){
|
||||
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,"Error: Failed to set socket options. Error %d: %s",errno,strerror(errno))));
|
||||
}
|
||||
|
||||
// set NONBLOCKING mode
|
||||
setnonblocking(l_so);
|
||||
@ -1605,61 +1921,79 @@ return_rc:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a character array including the query string.
|
||||
* GWBUF given as input includes either one complete or partial query.
|
||||
* Length of buffer is at most the query length+4 (length of packet header).
|
||||
* Do the SSL authentication handshake.
|
||||
* This creates the DCB SSL structure if one has not been created and starts the
|
||||
* SSL handshake handling.
|
||||
* @param protocol Protocol to connect with SSL
|
||||
* @return 1 on success, 0 when the handshake is ongoing or -1 on error
|
||||
*/
|
||||
#if defined(NOT_USED)
|
||||
static char* gw_get_or_create_querystr (
|
||||
void* data,
|
||||
bool* new_allocation)
|
||||
int do_ssl_accept(MySQLProtocol* protocol)
|
||||
{
|
||||
GWBUF* buf = (GWBUF *)data;
|
||||
size_t buflen; /*< first gw buffer data length */
|
||||
size_t packetlen; /*< length of mysql packet */
|
||||
size_t querylen; /*< total buffer length-<length of type indicator> */
|
||||
size_t nbytes_copied;
|
||||
char* startpos; /*< first byte of query in gw buffer */
|
||||
char* str; /*< resulting query string */
|
||||
|
||||
CHK_GWBUF(buf);
|
||||
packetlen = MYSQL_GET_PACKET_LEN((uint8_t *)GWBUF_DATA(buf));
|
||||
str = (char *)malloc(packetlen); /*< leave space for terminating null */
|
||||
|
||||
if (str == NULL)
|
||||
{
|
||||
goto return_str;
|
||||
}
|
||||
*new_allocation = true;
|
||||
/**
|
||||
* First buffer includes 4 bytes header and a type indicator byte.
|
||||
*/
|
||||
buflen = GWBUF_LENGTH(buf);
|
||||
querylen = packetlen-1;
|
||||
ss_dassert(buflen<=querylen+5); /*< 5 == header+type indicator */
|
||||
startpos = (char *)GWBUF_DATA(buf)+5;
|
||||
nbytes_copied = MIN(querylen, buflen-5);
|
||||
memcpy(str, startpos, nbytes_copied);
|
||||
memset(&str[querylen-1], 0, 1);
|
||||
buf = gwbuf_consume(buf, querylen-1);
|
||||
|
||||
/**
|
||||
* In case of multi-packet statement whole buffer consists of query
|
||||
* string.
|
||||
*/
|
||||
while (buf != NULL)
|
||||
{
|
||||
buflen = GWBUF_LENGTH(buf);
|
||||
memcpy(str+nbytes_copied, GWBUF_DATA(buf), buflen);
|
||||
nbytes_copied += buflen;
|
||||
buf = gwbuf_consume(buf, buflen);
|
||||
}
|
||||
ss_dassert(str[querylen-1] == 0);
|
||||
|
||||
return_str:
|
||||
return str;
|
||||
}
|
||||
int rval,errnum;
|
||||
char errbuf[2014];
|
||||
DCB* dcb = protocol->owner_dcb;
|
||||
if(dcb->ssl == NULL)
|
||||
{
|
||||
if(dcb_create_SSL(dcb) != 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
rval = dcb_accept_SSL(dcb);
|
||||
|
||||
switch(rval)
|
||||
{
|
||||
case 0:
|
||||
/** Not all of the data has been read. Go back to the poll
|
||||
queue and wait for more.*/
|
||||
|
||||
rval = 0;
|
||||
skygw_log_write_flush(LT,"SSL_accept ongoing for %s@%s",
|
||||
protocol->owner_dcb->user,
|
||||
protocol->owner_dcb->remote);
|
||||
return 0;
|
||||
break;
|
||||
case 1:
|
||||
spinlock_acquire(&protocol->protocol_lock);
|
||||
protocol->protocol_auth_state = MYSQL_AUTH_SSL_HANDSHAKE_DONE;
|
||||
protocol->use_ssl = true;
|
||||
spinlock_release(&protocol->protocol_lock);
|
||||
|
||||
spinlock_acquire(&dcb->authlock);
|
||||
dcb->func.write = gw_MySQLWrite_client_SSL;
|
||||
dcb->func.write_ready = gw_write_client_event_SSL;
|
||||
spinlock_release(&dcb->authlock);
|
||||
|
||||
rval = 1;
|
||||
|
||||
skygw_log_write_flush(LT,"SSL_accept done for %s@%s",
|
||||
protocol->owner_dcb->user,
|
||||
protocol->owner_dcb->remote);
|
||||
break;
|
||||
|
||||
case -1:
|
||||
|
||||
spinlock_acquire(&protocol->protocol_lock);
|
||||
protocol->protocol_auth_state = MYSQL_AUTH_SSL_HANDSHAKE_FAILED;
|
||||
spinlock_release(&protocol->protocol_lock);
|
||||
rval = -1;
|
||||
skygw_log_write_flush(LE,
|
||||
"Error: Fatal error in SSL_accept for %s",
|
||||
protocol->owner_dcb->remote);
|
||||
break;
|
||||
|
||||
default:
|
||||
skygw_log_write_flush(LE,
|
||||
"Error: Fatal error in SSL_accept, returned value was %d.",
|
||||
rval);
|
||||
break;
|
||||
}
|
||||
#ifdef SS_DEBUG
|
||||
skygw_log_write(LD,"[do_ssl_accept] Protocol state: %s",
|
||||
gw_mysql_protocol_state2string(protocol->protocol_auth_state));
|
||||
#endif
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <skygw_types.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
#include <netinet/tcp.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -137,7 +138,7 @@ void mysql_protocol_done (
|
||||
goto retblock;
|
||||
}
|
||||
scmd = p->protocol_cmd_history;
|
||||
|
||||
|
||||
while (scmd != NULL)
|
||||
{
|
||||
scmd2 = scmd->scom_next;
|
||||
@ -812,6 +813,23 @@ int gw_do_connect_to_backend(
|
||||
goto close_so;
|
||||
}
|
||||
|
||||
int one = 1;
|
||||
if(setsockopt(so, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) != 0)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error: Failed to set socket options "
|
||||
"%s:%d failed.\n\t\t Socket configuration failed "
|
||||
"due %d, %s.",
|
||||
host,
|
||||
port,
|
||||
errno,
|
||||
strerror(errno))));
|
||||
rv = -1;
|
||||
/** Close socket */
|
||||
goto close_so;
|
||||
}
|
||||
|
||||
/* set socket to as non-blocking here */
|
||||
setnonblocking(so);
|
||||
rv = connect(so, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
|
||||
@ -890,7 +908,11 @@ gw_mysql_protocol_state2string (int state) {
|
||||
case MYSQL_AUTH_FAILED:
|
||||
return "MySQL Authentication failed";
|
||||
case MYSQL_IDLE:
|
||||
return "MySQL authentication is succesfully done.";
|
||||
return "MySQL authentication is succesfully done.";
|
||||
case MYSQL_AUTH_SSL_REQ: return "MYSQL_AUTH_SSL_REQ";
|
||||
case MYSQL_AUTH_SSL_HANDSHAKE_DONE: return "MYSQL_AUTH_SSL_HANDSHAKE_DONE";
|
||||
case MYSQL_AUTH_SSL_HANDSHAKE_FAILED: return "MYSQL_AUTH_SSL_HANDSHAKE_FAILED";
|
||||
case MYSQL_AUTH_SSL_HANDSHAKE_ONGOING: return "MYSQL_AUTH_SSL_HANDSHAKE_ONGOING";
|
||||
default:
|
||||
return "MySQL (unknown protocol state)";
|
||||
}
|
||||
@ -2199,7 +2221,8 @@ char *create_auth_fail_str(
|
||||
char *username,
|
||||
char *hostaddr,
|
||||
char *sha1,
|
||||
char *db)
|
||||
char *db,
|
||||
int errcode)
|
||||
{
|
||||
char* errstr;
|
||||
const char* ferrstr;
|
||||
@ -2214,6 +2237,10 @@ char *create_auth_fail_str(
|
||||
{
|
||||
ferrstr = "Access denied for user '%s'@'%s' (using password: %s) to database '%s'";
|
||||
}
|
||||
else if(errcode == MYSQL_FAILED_AUTH_SSL)
|
||||
{
|
||||
ferrstr = "Access without SSL denied";
|
||||
}
|
||||
else
|
||||
{
|
||||
ferrstr = "Access denied for user '%s'@'%s' (using password: %s)";
|
||||
@ -2233,6 +2260,10 @@ char *create_auth_fail_str(
|
||||
{
|
||||
sprintf(errstr, ferrstr, username, hostaddr, (*sha1 == '\0' ? "NO" : "YES"), db);
|
||||
}
|
||||
else if(errcode == MYSQL_FAILED_AUTH_SSL)
|
||||
{
|
||||
sprintf(errstr, ferrstr);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(errstr, ferrstr, username, hostaddr, (*sha1 == '\0' ? "NO" : "YES"));
|
||||
|
11
server/modules/protocol/test/CMakeLists.txt
Normal file
11
server/modules/protocol/test/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
configure_file(test_ssl.sh ${CMAKE_CURRENT_BINARY_DIR}/test_ssl.sh @ONLY)
|
||||
configure_file(no_ca.cnf ${CMAKE_CURRENT_BINARY_DIR}/no_ca.cnf @ONLY)
|
||||
configure_file(no_server_cert.cnf ${CMAKE_CURRENT_BINARY_DIR}/no_server_cert.cnf @ONLY)
|
||||
configure_file(no_server_key.cnf ${CMAKE_CURRENT_BINARY_DIR}/no_server_key.cnf @ONLY)
|
||||
configure_file(bad_ca.cnf ${CMAKE_CURRENT_BINARY_DIR}/bad_ca.cnf @ONLY)
|
||||
configure_file(bad_cert.cnf ${CMAKE_CURRENT_BINARY_DIR}/bad_cert.cnf @ONLY)
|
||||
configure_file(bad_key.cnf ${CMAKE_CURRENT_BINARY_DIR}/bad_key.cnf @ONLY)
|
||||
configure_file(bad_ssl.cnf ${CMAKE_CURRENT_BINARY_DIR}/bad_ssl.cnf @ONLY)
|
||||
configure_file(bad_ssl_version.cnf ${CMAKE_CURRENT_BINARY_DIR}/bad_ssl_version.cnf @ONLY)
|
||||
configure_file(ok.cnf ${CMAKE_CURRENT_BINARY_DIR}/ok.cnf @ONLY)
|
||||
add_test(NAME SSLTest COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test_ssl.sh)
|
28
server/modules/protocol/test/bad_ca.cnf
Normal file
28
server/modules/protocol/test/bad_ca.cnf
Normal file
@ -0,0 +1,28 @@
|
||||
[maxscale]
|
||||
threads=1
|
||||
logdir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
datadir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
piddir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
cachedir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
|
||||
[Testservice]
|
||||
type=service
|
||||
router=readconnroute
|
||||
servers=server1
|
||||
user=user
|
||||
passwd=pwd
|
||||
ssl=enabled
|
||||
ssl_ca_cert=This is not a value
|
||||
ssl_cert=@CMAKE_CURRENT_BINARY_DIR@/server-cert
|
||||
ssl_key=@CMAKE_CURRENT_BINARY_DIR@/server-key
|
||||
|
||||
[Testlistener]
|
||||
type=listener
|
||||
service=Testservice
|
||||
protocol=MySQLBackend
|
||||
port=12345
|
||||
|
||||
[server1]
|
||||
type=server
|
||||
address=127.0.0.1
|
||||
port=4321
|
28
server/modules/protocol/test/bad_cert.cnf
Normal file
28
server/modules/protocol/test/bad_cert.cnf
Normal file
@ -0,0 +1,28 @@
|
||||
[maxscale]
|
||||
threads=1
|
||||
logdir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
datadir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
piddir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
cachedir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
|
||||
[Testservice]
|
||||
type=service
|
||||
router=readconnroute
|
||||
servers=server1
|
||||
user=user
|
||||
passwd=pwd
|
||||
ssl=enabled
|
||||
ssl_ca_cert=@CMAKE_CURRENT_BINARY_DIR@/ca
|
||||
ssl_cert=This is not a value
|
||||
ssl_key=@CMAKE_CURRENT_BINARY_DIR@/server-key
|
||||
|
||||
[Testlistener]
|
||||
type=listener
|
||||
service=Testservice
|
||||
protocol=MySQLBackend
|
||||
port=12345
|
||||
|
||||
[server1]
|
||||
type=server
|
||||
address=127.0.0.1
|
||||
port=4321
|
28
server/modules/protocol/test/bad_key.cnf
Normal file
28
server/modules/protocol/test/bad_key.cnf
Normal file
@ -0,0 +1,28 @@
|
||||
[maxscale]
|
||||
threads=1
|
||||
logdir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
datadir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
piddir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
cachedir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
|
||||
[Testservice]
|
||||
type=service
|
||||
router=readconnroute
|
||||
servers=server1
|
||||
user=user
|
||||
passwd=pwd
|
||||
ssl=enabled
|
||||
ssl_ca_cert=@CMAKE_CURRENT_BINARY_DIR@/ca
|
||||
ssl_cert=@CMAKE_CURRENT_BINARY_DIR@/server-cert
|
||||
ssl_key=This is not a value
|
||||
|
||||
[Testlistener]
|
||||
type=listener
|
||||
service=Testservice
|
||||
protocol=MySQLBackend
|
||||
port=12345
|
||||
|
||||
[server1]
|
||||
type=server
|
||||
address=127.0.0.1
|
||||
port=4321
|
28
server/modules/protocol/test/bad_ssl.cnf
Normal file
28
server/modules/protocol/test/bad_ssl.cnf
Normal file
@ -0,0 +1,28 @@
|
||||
[maxscale]
|
||||
threads=1
|
||||
logdir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
datadir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
piddir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
cachedir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
|
||||
[Testservice]
|
||||
type=service
|
||||
router=readconnroute
|
||||
servers=server1
|
||||
user=user
|
||||
passwd=pwd
|
||||
ssl=testing
|
||||
ssl_ca_cert=@CMAKE_CURRENT_BINARY_DIR@/ca
|
||||
ssl_cert=@CMAKE_CURRENT_BINARY_DIR@/server-cert
|
||||
ssl_key=@CMAKE_CURRENT_BINARY_DIR@/server-key
|
||||
|
||||
[Testlistener]
|
||||
type=listener
|
||||
service=Testservice
|
||||
protocol=MySQLBackend
|
||||
port=12345
|
||||
|
||||
[server1]
|
||||
type=server
|
||||
address=127.0.0.1
|
||||
port=4321
|
29
server/modules/protocol/test/bad_ssl_version.cnf
Normal file
29
server/modules/protocol/test/bad_ssl_version.cnf
Normal file
@ -0,0 +1,29 @@
|
||||
[maxscale]
|
||||
threads=1
|
||||
logdir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
datadir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
piddir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
cachedir=@CMAKE_CURRENT_BINARY_DIR@
|
||||
|
||||
[Testservice]
|
||||
type=service
|
||||
router=readconnroute
|
||||
servers=server1
|
||||
user=user
|
||||
passwd=pwd
|
||||
ssl=enabled
|
||||
ssl_ca_cert=@CMAKE_CURRENT_BINARY_DIR@/ca
|
||||
ssl_cert=@CMAKE_CURRENT_BINARY_DIR@/server-cert
|
||||
ssl_key=@CMAKE_CURRENT_BINARY_DIR@/server-key
|
||||
ssl_version=Don't use SSL, it's not needed!
|
||||
|
||||
[Testlistener]
|
||||
type=listener
|
||||
service=Testservice
|
||||
protocol=MySQLBackend
|
||||
port=12345
|
||||
|
||||
[server1]
|
||||
type=server
|
||||
address=127.0.0.1
|
||||
port=4321
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user