Working with memcache and mysql using memcache_functions_mysql UDFs - mysql

I have installed the following packages --
libevent-2.0.21
memcached-1.4.17
libmemcached-0.34
memcached_functions_mysql_1.1
All of the above have been installed successfully.
The output of the ldconfig -v command (the part where it shows that libmemcached libraries have been included) is as follows:
$ldconfig -v
/usr/local/libmemcached/lib:
libmemcached.so.3 -> libmemcached.so.3.0.0
libmemcachedprotocol.so.0 -> libmemcachedprotocol.so.0.0.0
libmemcachedutil.so.0 -> libmemcachedutil.so.0.0.0
But when I try to load UDF's into mysql using the install_functions.sql that is shipped with memcache_functions it throws the following error:
ERROR 1126 (HY000) at line 38: Can't open shared library 'libmemcached_functions_mysql.so' (errno: 0 libmemcached.so.3: cannot open shared object file: No such file or directory)
And the contents of the plugin directory are:
-rw-r--r-- 1 root root 6.1K Jan 21 13:49 adt_null.so
-rw-r--r-- 1 root root 11K Jan 21 13:49 auth.so
-rw-r--r-- 1 root root 6.0K Jan 21 13:49 auth_socket.so
-rw-r--r-- 1 root root 6.2K Jan 21 13:49 auth_test_plugin.so
-rw-r--r-- 1 root root 35K Jan 21 13:49 ha_example.so
-rw-r--r-- 1 root root 10K Jan 21 13:49 libdaemon_example.so
-rw-r--r-- 1 root root 361K Feb 13 02:47 libmemcached_functions_mysql.a
-rwxr-xr-x 1 root root 1.1K Feb 13 02:47 libmemcached_functions_mysql.la
-rwxr-xr-x 1 root root 167K Feb 13 02:47 libmemcached_functions_mysql.so
-rwxr-xr-x 1 root root 167K Feb 13 02:47 libmemcached_functions_mysql.so.0
-rwxr-xr-x 1 root root 167K Feb 13 02:47 libmemcached_functions_mysql.so.0.0.0
-rw-r--r-- 1 root root 11K Jan 21 13:49 mypluglib.so
-rw-r--r-- 1 root root 5.9K Jan 21 13:49 qa_auth_client.so
-rw-r--r-- 1 root root 11K Jan 21 13:49 qa_auth_interface.so
-rw-r--r-- 1 root root 6.0K Jan 21 13:49 qa_auth_server.so
-rw-r--r-- 1 root root 39K Jan 21 13:49 semisync_master.so
-rw-r--r-- 1 root root 15K Jan 21 13:49 semisync_slave.so

Installing memcached on Ubuntu 12.04.1 LTS (64 bit)
Python - 2.6.8
MySQL – 5.5.28
Zope – 2.12.19
1. Install memcached
apt-get install memcached
2. Install libmemcached -0 .34 (Version is very important. May or may not work with other versions).
Download it from https://launchpad.net/libmemcached/
tar xvf libmemcached-0.34.tar.gz
sudo ./configure --prefix=/usr/lib/libmemcached --with-memcached=/usr/bin/memcached
sudo make
sudo make install.
3. Install memcached_functions_mysql (Version 1.1 used at the time of the installation. (To create UDF’s that are invoked by triggers to manipulate the cache).
Downloading from https://launchpad.net/memcached-udfs
sudo ./configure --prefix=/usr/local/memcached_mysql --libdir=/usr/lib/mysql/plugin --with-mysql=/usr/bin/mysql_config --with-libmemcached=/usr/lib/libmemcached
sudo make
sudo make install
Navigate to the “sql” folder inside the memcached_mysql_functions directory.
mysql –u <username> -p < install_functions.sql
4. For Zope users
Install python-memcached-1.53
Download it from https://pypi.python.org/pypi/python-memcached/
Navigate to the extracted python-memcached directory.
/home/zope/zope/bin/python setup.py install
5. Edit the script containing which imports the modules.
allow_module('memcache')
from memcache import Client
allow_class(Client)
allow_module('memcache.Client.get')
allow_module('memcache.Client.set')
This is done so that memcache can be imported and used in your Restricted Python scripts.
If an external method is used to handle the above case, then the file does need to be updated with the above content.

Related

how to start mariaDB on boot after external drive is mounted

I am using a raspberry pi 3 with OSMC as the operating system along with Debian Stretch and nginx, and installed manually mariaDB 10.2 following some instructions I found somewhere a while back.
I have changed the datadir for mariadb to /media/USBHDD2/shared/mysql
When I boot, or reboot, the pi, mariaDB fails to start. Before, when I had the default datadir = /var/lib/mysql it was all fine. If I change it back it is fine.
However, if I login to the console I can successfully start it by using
service mysql start
Note that I am using 'service' rather than 'systemctl' - the latter does not work. The files mariadb.service and mysql.service do not exist anywhere.
In /etc/init.d I find two files: mysql and myswql which seem to be identical. If I remove the myswql from the directory mariadb won't start at all. I have tried editing these by putting, for example, a sleep 15 at the beginning, but to no avail. I have read all sorts of solutions about trying to test if the USBHDD2 is mounted, eg using
while ! test -f /media/USBHDD2/shared/test.txt
do
sleep 1
done
which I tried in the /etc/init.d/mysql and myswql files, and also in rc.local before calling for the start of mysql.
But that doesn't work either.
I also renamed the links in rc?.d to S99mysql so is starts after everything else, still no joy.
I have spent two full days on this to no avail. What do I need to do to get this working so that mysql starts on boot?
Files system is ntfs
output from ls -la //media/USBHDD2/shared/mysql is as follows:
total 176481
drwxrwxrwx 1 root root 4096 Mar 27 11:41 .
drwxrwxrwx 1 root root 4096 Mar 27 13:06 ..
-rwxrwxrwx 1 root root 16384 Mar 27 11:41 aria_log.00000001
-rwxrwxrwx 1 root root 52 Mar 27 11:41 aria_log_control
-rwxrwxrwx 1 root root 0 Nov 3 2016 debian-10.1.flag
-rwxrwxrwx 1 root root 12697 Mar 27 11:41 ib_buffer_pool
-rwxrwxrwx 1 root root 50331648 Mar 27 11:41 ib_logfile0
-rwxrwxrwx 1 root root 50331648 Mar 26 22:02 ib_logfile1
-rwxrwxrwx 1 root root 79691776 Mar 27 11:41 ibdata1
drwxrwxrwx 1 root root 32768 Mar 25 18:37 montegov_admin
-rwxrwxrwx 1 root root 0 Nov 3 2016 multi-master.info
drwxrwxrwx 1 root root 20480 Sep 3 2019 mysql
drwxrwxrwx 1 root root 0 Sep 3 2019 performance_schema
drwxrwxrwx 1 root root 86016 Mar 25 20:06 rentmaxpro_wp187
drwxrwxrwx 1 root root 0 Sep 3 2019 test
drwxrwxrwx 1 root root 32768 Nov 3 2016 trustedhomerenta_admin
drwxrwxrwx 1 root root 32768 Nov 3 2016 trustedhomerenta_demo
drwxrwxrwx 1 root root 40960 Mar 25 21:05 trustedhomerenta_meta
drwxrwxrwx 1 root root 36864 Mar 25 21:25 trustedhomerenta_montego
drwxrwxrwx 1 root root 36864 Mar 26 20:37 trustedhomerenta_testmontego
The problem is that the external drive is configured as ntfs.
Mysql requires the files and directory to be owned by mysql:mysql but since the ntfs does not have the same system of owners and groups as linux, the linux mount process asigns its own owner and group to the filestructure when mounting the drive. By defualt this ends up being root:root so mysql cannot use them.
ntfs does not allow CHOWN to work, so there is no way to change the ownership away from root.
One solution is to backup all the files, repartition as EXT4, and then restore all the files.
The solution I finally used was to specify mysql as the owner and group at the time that the drive is being mounted. Thus my /etc/fstab file was changed to:
ID=C2CA68D9CA68CB6D /media/USBHDD2 ntfs users,exec,uid=mysql,gid=mysql 0 2
and now mysql starts properly at boot.
phew ;-)
Thanks #danblack for getting me thinking in the right direction

How to rebuild the set of installed packages when you have a broken install on Ubuntu?

On Ubuntu 19.10, I have a broken install/removal of MariaDB. I attempted every solution to this sort of problem. Yet I still can't replace MariaDB with mysql-server and am seemingly unable to remove MariaDB.
What is left on the system in /var/lib/dpkg/info/mariadb* that I want to go away is:
-rw-r--r-- 1 root root 118 Oct 27 14:02 mariadb-client-10.3.list
-rwxr-xr-x 1 root root 174 Aug 2 10:53 mariadb-client-10.3.postrm
-rw-r--r-- 1 root root 28 Oct 27 14:02 mariadb-common.list
-rwxr-xr-x 1 root root 361 Aug 2 10:53 mariadb-common.postrm
-rw-r--r-- 1 root root 509 Oct 27 14:02 mariadb-server-10.3.list
-rwxr-xr-x 1 root root 3449 Aug 2 10:53 mariadb-server-10.3.postrm
Yet when I try anything like:
sudo mv /var/lib/dpkg/info/mariadb* /tmp/
sudo dpkg --remove --force-remove-reinstreq mariadb (or variations)
gives only:
dpkg: warning: ignoring request to remove mariadb-server which isn't installed
SO how do I rebuild the database of installed packages??? and create a health system again??

google-chrome --headless --screenshot is crashing with message "Could not get download directory" on Centos 7

I'm attempting to get a screenshot via command line using the new features of Google Chrome 59 (Google Chrome 59.0.3071.86) in a Centos 7 box and I'm getting an error saying it could not get the download directory. I attempted to create the directory in my home folder but no success! Any suggestions?
[root#vm_1 ~]# google-chrome-stable --headless --disable-gpu --enable-logging -v=5 --screenshot=out.png http://www.google.com
[0613/154943.103775:VERBOSE1:zygote_main_linux.cc(626)] ZygoteMain: initializing 0 fork delegates
[0613/154943.104006:INFO:cpu_info.cc(50)] Available number of cores: 1
[0613/154943.108816:VERBOSE1:audio_manager_pulse.cc(273)] Failed to connect to the context. Error: Connection refused
[0613/154943.108868:WARNING:audio_manager.cc(293)] Multiple instances of AudioManager detected
[0613/154943.108875:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected
[0613/154943.109345:VERBOSE1:webrtc_internals.cc(106)] Could not get the download directory.
Trace/breakpoint trap
[root#vm_1 ~]# google-chrome-stable --version
[root#vm_1 ~]# Google Chrome 59.0.3071.86
Here is my folder structure:
[root#vm_1 ~]# ls -la
total 56
dr-xr-x---. 12 root root 4096 Jun 13 15:23 .
dr-xr-xr-x. 17 root root 4096 Jun 13 13:42 ..
-rw-------. 1 root root 1116 Dec 24 2015 anaconda-ks.cfg
drwx------. 3 root root 16 Jan 22 10:10 .ansible
-rw-------. 1 root root 18800 Jun 13 14:59 .bash_history
-rw-r--r--. 1 root root 18 Dec 28 2013 .bash_logout
-rw-r--r--. 1 root root 176 Dec 28 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 28 2013 .bashrc
drwx------. 3 root root 16 Oct 24 2016 .cache
drwx------. 3 root root 26 Jun 13 2017 .config
-rw-r--r--. 1 root root 100 Dec 28 2013 .cshrc
drwxr-xr-x. 2 root root 6 Jun 13 2017 download
drwxr-xr-x. 2 root root 6 Jun 13 2017 Download
drwxr-xr-x. 2 root root 6 Jun 13 2017 downloads
drwxr-xr-x. 2 root root 6 Jun 13 2017 Downloads
drwxr-xr-x. 3 root root 18 Jun 13 2017 .local
drwxr-----. 3 root root 18 Dec 24 2015 .pki
drwx------. 2 root root 28 Jan 22 10:09 .ssh
-rw-r--r--. 1 root root 129 Dec 28 2013 .tcshrc
-rw-r--r-- 1 root root 228 Jun 13 15:23 test.py
[root#vm_1 ~]#
I found an answer to this here:
https://bugs.chromium.org/p/chromium/issues/detail?id=695212
The fix is to install the google font package:
$ sudo yum install gnu-free-sans-fonts
Then this should work:
$ google-chrome --headless --disable-gpu --enable-logging -v=10 --screenshot=out.png http://www.chromestatus.com

Perl can not connect to MySQL (with DBD::mysql) on RHEL 6.7

I have Perl installed on Linux RHEL:
perl -v
This is perl 5, version 12, subversion 2 (v5.12.2) built for x86_64-linux-thread-multi
When I run command to see Perl modules installed:
find `perl -e 'print "#INC"'` -name '*.pm' -print
I can see for DBI:
/mu/sdk/perl/5.12.2-gcc443-rhel5-64/lib/DBI/DBD/Metadata.pm
/mu/sdk/perl/5.12.2-gcc443-rhel5-64/lib/DBI/DBD/SqlEngine.pm
/mu/sdk/perl/5.12.2-gcc443-rhel5-64/lib/DBD/mysql/GetInfo.pm
/mu/sdk/perl/5.12.2-gcc443-rhel5-64/lib/DBD/mysql.pm
/mu/sdk/perl/5.12.2-gcc443-rhel5-64/lib/Bundle/DBD/mysql.pm
And MySQL installed and running:
Server version: 5.6.26 MySQL Community Server (GPL)
I have 2 lines of code in a Perl Script:
use DBI;
my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost","root", "pass");
Error that I see is:
$ perl mysql.pl
install_driver(mysql) failed: Can't load '/mu/sdk/perl/5.12.2-gcc443-rhel5-64/lib/auto/DBD/mysql/mysql.so' for module DBD::mysql: libmysqlclient.so.15: cannot open shared object file: No such file or directory at /mu/apps/perl/5.12.2-gcc443-rhel5-64/lib/DynaLoader.pm line 200.
at (eval 3) line 3
Compilation failed in require at (eval 3) line 3.
Perhaps a required shared library or dll isn't installed where expected
at mysql.pl line 2
$
I verified with YUM:
$ sudo yum install perl-DBD-MySQL
Setting up Install Process
Package perl-DBD-MySQL-4.013-3.el6.x86_64 already installed and latest version
Nothing to do
$
This is the list of /usr/lib64/mysql :
$ pwd
/usr/lib64/mysql
$ ls -lrth
/usr/lib64/mysql
total 14M
-rwxr-xr-x 1 root root 8.6M Jul 14 17:47 libmysqlclient.so.18.1.0*
-rwxr-xr-x 1 root root 2.7M Jul 14 17:49 libmysqlclient.so.16.0.0*
-rwxr-xr-x 1 root root 2.7M Jul 14 17:49 libmysqlclient_r.so.16.0.0*
lrwxrwxrwx 1 root root 24 Jul 27 18:23 libmysqlclient.so.18 -> libmysqlclient.so.18.1.0*
lrwxrwxrwx 1 root root 24 Jul 27 18:23 libmysqlclient_r.so.18.1.0 -> libmysqlclient.so.18.1.0*
lrwxrwxrwx 1 root root 20 Jul 27 18:23 libmysqlclient_r.so.18 -> libmysqlclient.so.18*
lrwxrwxrwx 1 root root 24 Jul 27 18:23 libmysqlclient.so.16 -> libmysqlclient.so.16.0.0*
lrwxrwxrwx 1 root root 26 Jul 27 18:23 libmysqlclient_r.so.16 -> libmysqlclient_r.so.16.0.0*
drwxr-xr-x 3 root root 4.0K Jul 27 18:23 plugin/
$
What should I do next?
How to configure this problematic (libmysqlclient.so.15) or there is some other problem?

Docker: correct way of persisting container data to host

I'm using OSX and running docker over a Boot2docker VM.
I've been trying to figure out how to persist a container's data (MySQL official docker image) to the host but without much success.
I keep receiving an error stating that the /var/lib/mysql directory that the MySQL service is trying to write to is not accessible.
docker run -e MYSQL_ROOT_PASSWORD=12345 -v "$(pwd)/.docker-volumes/mysql:/var/lib/mysql" mysql:5.6
Looking at the permissions of the mounted library in the container, this is what I see:
root#mysql:/# ls -la /var/lib/
total 44
drwxr-xr-x 16 root root 4096 Jan 27 18:35 .
drwxr-xr-x 18 root root 4096 Jan 27 18:35 ..
drwxr-xr-x 7 root root 4096 Jan 27 18:35 apt
drwxr-xr-x 14 root root 4096 Jan 27 18:35 dpkg
drwxr-xr-x 2 root root 4096 Jul 14 2013 initscripts
drwxr-xr-x 2 root root 4096 Jul 14 2013 insserv
drwxrwsr-x 2 libuuid libuuid 4096 Dec 11 2012 libuuid
drwxr-xr-x 2 root root 4096 Dec 24 13:41 misc
drwxr-xr-x 1 1000 staff 102 Feb 4 15:10 mysql
drwxr-xr-x 2 root root 4096 Jan 27 16:48 pam
drwxr-xr-x 2 root root 4096 Nov 23 2012 update-rc.d
drwxr-xr-x 2 root root 4096 Jul 14 2013 urandom
As you can see, the mysql directory is owned by 1000 and belongs to the group 'staff'.
My assumption is that the service process running MySQL is probably set to another user (mysql) and therefore I get this error.
I've read that this specific issue can be solved using volume data containers, but since they persist the data only until the last container actually uses their volume, It's not a good solution for me.
Am I approaching this in the wrong way?
Thanks.
You're definitely better off using a data-volume container, I do the same thing with local psql and couchdb databases. The data actually persists, it's just not accessible unless you link the volume to a container. To actually force the volume to be removed you have to specify docker rm -v, that will remove the data volume if no other container is linked to it.