Configruing HandlerSocket plugin for MySQL

21 Dec

This post assumes you are installing HandlerSocket plugin on MySQL cluster. But the steps should be applicable for the non-cluster MySQL installation as well.

Download and Extract MySQL Cluster Source Code

  • IMPORTANT: If you are installing HandlerSocket plugin on MySQL Cluster, download the source code to the instance that contains the SQL/Mgmt Server node.

Download, Extract and Build HandlerSocket Source Code

  • cd /opt/mysqlcluster/src
  • wget –no-check-certificate https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL/tarball/master
  • tar xvf master
  • ln -s ahiguti-HandlerSocket-Plugin-for-MySQL-0986a75 handler_src
  • cd handler_src
  • ./autogen.sh
  • ./configure –with-mysql-source=/opt/mysqlcluster/src/mysqlc_src –with-mysql-bindir=/opt/mysqlcluster/home/mysqlc/bin –with-mysql-plugindir=/opt/mysqlcluster/home/mysqlc/lib/plugin
    • IF YOU GET THE FOLLOWING ERROR:
      ...
      checking mysql source... yes: Using /opt/mysqlcluster/src/mysqlc_src, version 5.5.15
      checking mysql binary... yes: Using /opt/mysqlcluster/home/mysqlc/bin/mysql_config, version 5.5.15-ndb-7.2.1
      configure: error: MySQL source version does not match MySQL binary version
      ...
      • According to the install docs https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL/blob/master/docs-en/installation.en.txt: –with-mysql-source refers to the top of MySQL source directory (which
        contains the VERSION file or the configure.in file)
      • The VERSION file contains:
        MYSQL_VERSION_MAJOR=5
        MYSQL_VERSION_MINOR=5
        MYSQL_VERSION_PATCH=15
        MYSQL_VERSION_EXTRA=-ndb-7.2.1
      • But looking at the generated configure script, only the first 3 entries are checked with the output of mysql_config –version which returns the EXTRA information in addition to the 3 entries. This causes the match to fail
    • AS A WORKAROUND we do the following:
  • cd /opt/mysqlcluster/src/mysqlc_src
  • cp VERSION VERSION.bkup
  • gedit VERSION and append the EXTRA value to the PATCH value as follows:
    MYSQL_VERSION_MAJOR=5
    MYSQL_VERSION_MINOR=5
    MYSQL_VERSION_PATCH=15-ndb-7.2.1
    MYSQL_VERSION_EXTRA=-ndb-7.2.1
    • Re-run the configure command above
  • Compile and install HandlerSocket:
    • make && make install

Configure mysqld to use the HandlerSocket plugin

  • Shutdown any running mysqld process
    • mysqladmin -u myuser -h 127.0.0.1 -p shutdown
      • Note if you don’t have the myuser user setup in your environment then use:
        • mysqladmin -u root -h 127.0.0.1 shutdown
  • Edit the my.cnf file to add the setting for HandlerSocket.
    • cd /opt/mysqlcluster/deploy/conf
    • gedit my.cnf and should look like this:
      [mysqld]
      ndbcluster
      datadir=/opt/mysqlcluster/deploy/mysqld_data
      basedir=/opt/mysqlcluster/home/mysqlc
      port=3306
      loose_handlersocket_port = 9998
          # the port number to bind to (for read requests)
      loose_handlersocket_port_wr = 9999
          # the port number to bind to (for write requests)
      loose_handlersocket_threads = 16
          # the number of worker threads (for read requests)
      loose_handlersocket_threads_wr = 1
          # the number of worker threads (for write requests)
      open_files_limit = 65535
          # to allow handlersocket accept many concurrent
          # connections, make open_files_limit as large as
          # possible.
  • Restart mysqld
    • mysqld –defaults-file=/opt/mysqlcluster/deploy/conf/my.cnf –user=root &
  • Install the plugin
    • mysql -h 127.0.0.1 -u myuser -p OR mysql -h 127.0.0.1 -u root depending on your environment
    • mysql> install plugin handlersocket soname ‘handlersocket.so’;
      • You should see a bunch of messages and then a confirmation that the plugin was installed.
    • mysql> show processlist ;
      • This should list the handlersocket process
  • If handlersocket.so is successfully installed, it starts accepting connections on port 9998 (Reads) and 9999 (Writes).
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: