Redis backup script

August 7, 2015 3 comments
#!/bin/bash 
## Fri, 07 Aug 2015 14:04:57 +0300 
## redis backup every 15 minutes 
## */15 * * * * redis.backup.maintenance.sh >> /var/log/redis.backup.log 2>&1 
## at /etc/rc.local : 
## test -d /var/run/redis.backup.lock.dir && rm -rf /var/run/redis.backup.lock.dir 
## watch the job: 
## tail -f /var/log/redis.backup.log 

#redis-cli LASTSAVE | awk '{print $1}' | { read gmt ; date "+%Y-%m-%d %H:%M:%S" -d "@$gmt" ; } 
# 2015-08-07 01:25:54 

lockf="/var/run/redis.backup.lock.dir"

# check for running script start 
if [ -d "${lockf}" ]
then
 echo "$(date +%Y-%m-%d.%H.%M.%S) : ${lockf} exists, exiting"
 exit 0
else
 mkdir "${lockf}" && echo "$(date +%Y-%m-%d.%H.%M.%S) : created lock at ${lockf}"
fi


echo "$(date +%Y-%m-%d.%H.%M.%S) : redis backup start"
echo "$(date +%Y-%m-%d.%H.%M.%S) : cleanup the /redis_backups and leave the last 6 backups"
find /redis_backups -maxdepth 1 -type f -name "dump.rdb.*" | sort -r | sed '7,$!d' | while read to_be_deleted; do rm -f ${to_be_deleted} && echo "$(date +%Y-%m-%d.%H.%M.%S) : deleted ${to_be_deleted}";done

last_save=$(redis-cli LASTSAVE | awk '{print $1}')
echo -n "$(date +%Y-%m-%d.%H.%M.%S) : executing redis-cli BGSAVE : "
redis-cli BGSAVE
while true
do
 if [ $(redis-cli LASTSAVE | awk '{print $1}') -eq ${last_save} ]
 then
 echo -n ". "
 sleep 2
 else
 echo ""
 echo "$(date +%Y-%m-%d.%H.%M.%S) : start ionice -c2 -n0 cp -vv /opt/redis/dump.rdb to /redis_backups/"
 ionice -c2 -n0 cp -vv /opt/redis/dump.rdb /redis_backups/dump.rdb.$(date +%Y-%m-%d.%H.%M.%S) && echo "$(date +%Y-%m-%d.%H.%M.%S) : backup comleted"
 break
 fi
done


if [ -d "${lockf}" ]
then
 echo "$(date +%Y-%m-%d.%H.%M.%S) : removing the lock"
 rm -rf "${lockf}"
fi
Categories: AWS, bash, NoSQL Tags: , ,

MariaDB MySQL Percona list all indexes without using INFORMATION_SCHEMA.STATISTICS

July 8, 2015 1 comment

There is nothing more to be said:

SELECT
gen.TABLE_SCHEMA
, gen.TABLE_NAME
, (select
count(TABLE_NAME) from information_schema.columns idx
where
idx.TABLE_SCHEMA = gen.TABLE_SCHEMA
and idx.TABLE_NAME=gen.TABLE_NAME
) as COLUMN_NUM
, (select
count(TABLE_NAME) from information_schema.columns idx
where
idx.TABLE_SCHEMA = gen.TABLE_SCHEMA
and idx.TABLE_NAME=gen.TABLE_NAME
and COLUMN_KEY != ""
) as INDEX_NUM_ALL
, (select
count(TABLE_NAME) from information_schema.columns idx
where
idx.TABLE_SCHEMA = gen.TABLE_SCHEMA
and idx.TABLE_NAME=gen.TABLE_NAME
and COLUMN_KEY = "PRI"
) as INDEX_NUM_PRI
, (select
count(TABLE_NAME) from information_schema.columns idx
where
idx.TABLE_SCHEMA = gen.TABLE_SCHEMA
and idx.TABLE_NAME=gen.TABLE_NAME
and COLUMN_KEY = "UNI"
) as INDEX_NUM_UNI
, (select
count(TABLE_NAME) from information_schema.columns idx
where
idx.TABLE_SCHEMA = gen.TABLE_SCHEMA
and idx.TABLE_NAME=gen.TABLE_NAME
and COLUMN_KEY = "MUL"
) as INDEX_NUM_MUL

from information_schema.tables gen
where true
and gen.TABLE_SCHEMA !='mysql'
and gen.TABLE_SCHEMA!='performance_schema'
and gen.TABLE_SCHEMA!='information_schema'
;
+-----------------+-----------------------+------------+---------------+---------------+---------------+---------------+
| TABLE_SCHEMA | TABLE_NAME | COLUMN_NUM | INDEX_NUM_ALL | INDEX_NUM_PRI | INDEX_NUM_UNI | INDEX_NUM_MUL |
+-----------------+-----------------------+------------+---------------+---------------+---------------+---------------+
Categories: MariaDB, MySQL Tags: , , ,

MySQL, Percona, MariaDB long running processes clean up one liner

April 30, 2015 Leave a comment

There are tools like pt-kill from the percona tool kit that may print/kill the long running transactions at MariaDB, MySQL or at Percona data instances, but a lot of backup scripts are just some simple bash lines.
So checking for long running transactions before the backup to be executed seems to be a step that is missed a lot.

Here is one line that might be just added in every bash script before the backup to be executed
Variant 1. Just log all the processlist entries and calculate which ones were running longer than TIMELIMIT:

$ export TIMELIMIT=70 && echo "$(date) : check for long runnig queries start:" >> /tmp/processlist.list.to.kill && mysql -BN -e 'show processlist;' | tee -a /tmp/processlist.list.to.kill | awk -vlongtime=${TIMELIMIT} '($6>longtime){print "kill "$1";"}' | tee -a /tmp/processlist.list.to.kill

Variant 2: Log all the processlist, calculate the calculate which processes are running longer than TIMELIMIT, and kill them before to execute the backup:

$ export TIMELIMIT=70 && echo "$(date) : check for long runnig queries start:" >> /tmp/processlist.list.to.kill && mysql -BN -e 'show processlist;' | tee -a /tmp/processlist.list.to.kill | awk -vlongtime=${TIMELIMIT} '($6>longtime){print "kill "$1";"}' | tee -a /tmp/processlist.list.to.kill | mysql >> /tmp/processlist.list.to.kill 2>&1

Update bash at Slackware 11 with the latest patch against shellshock bugs CVE-2014-6271 CVE-2014-7169 CVE-2014-7186 CVE-2014-7187

October 1, 2014 1 comment

I still have Slackware 11 machines … so I had to recompile the bash

I took a moment to read this nice blog related to shellshock: http://chester.me/archives/2014/09/building-bash-from-source-shellshock-mitigation/
So in short what I did at my Slackware 11 machines:

root@DL-380:[Wed Oct 01 23:05:47]:[~]$ cat /etc/slackware-version 
Slackware 11.0.0
root@DL-380:[Wed Oct 01 23:05:47]:[/opt/installs]$ bash --version
GNU bash, version 3.1.17(2)-release (i486-slackware-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.

root@DL-380:[Wed Oct 01 23:06:02]:[/opt/installs]$ wget  http://ftp.gnu.org/gnu/bash/bash-3.1.tar.gz
root@DL-380:[Wed Oct 01 23:06:35]:[/opt/installs]$ lftp http://ftp.gnu.org/gnu/bash
cd: received redirection to `http://ftp.gnu.org/gnu/bash/'
cd ok, cwd=/gnu/bash                               
lftp ftp.gnu.org:/gnu/bash> mirror bash-3.1-patches 
Total: 1 directory, 44 files, 0 symlinks                  
New: 44 files, 0 symlinks
60375 bytes transferred in 5 seconds (11.3K/s)
lftp ftp.gnu.org:/gnu/bash> exit
root@DL-380:[Wed Oct 01 23:07:39]:[/opt/installs]$ rm bash-3.1-patches/*sig
root@DL-380:[Wed Oct 01 23:07:53]:[/opt/installs]$ tar xvf bash-3.1.tar.gz 
root@DL-380:[Wed Oct 01 23:08:54]:[/opt/installs]$ cd bash-3.1
root@DL-380:[Wed Oct 01 23:08:59]:[/opt/installs/bash-3.1]$ 
root@DL-380:[Wed Oct 01 23:08:59]:[/opt/installs/bash-3.1]$ for patch_file in `find /opt/installs/bash-3.1-patches/ -type f `;  do echo $patch_file && patch -p0 < $patch_file ; done
root@DL-380:[Wed Oct 01 23:09:23]:[/opt/installs/bash-3.1]$ tail patchlevel.h
#if !defined (_PATCHLEVEL_H_)
#define _PATCHLEVEL_H_

/* It's important that there be no other strings in this file that match the
   regexp `^#define[     ]*PATCHLEVEL', since that's what support/mkversion.sh
   looks for to find the patch level (for the sccs version string). */

#define PATCHLEVEL 21

#endif /* _PATCHLEVEL_H_ */
root@DL-380:[Wed Oct 01 23:09:44]:[/opt/installs/bash-3.1]$ ./configure 
root@DL-380:[Wed Oct 01 23:10:49]:[/opt/installs/bash-3.1]$ make --j3 
ls -l bash
-rwxr-xr-x 1 root root 1556950 2014-10-01 23:11 bash
size bash
   text       data        bss        dec        hex    filename
 634120      22840      19432     676392      a5228    bash
root@DL-380:[Wed Oct 01 23:11:19]:[/opt/installs/bash-3.1]$ 
root@DL-380:[Wed Oct 01 23:11:19]:[/opt/installs/bash-3.1]$ env x='() { :;}; echo vulnerable' bash -c "echo this is a test" 
vulnerable
this is a test
root@DL-380:[Wed Oct 01 23:12:36]:[/opt/installs/bash-3.1]$ env x='() { :;}; echo vulnerable' ./bash -c "echo this is a test" 
this is a test
root@DL-380:[Wed Oct 01 23:12:41]:[/opt/installs/bash-3.1]$ ./bash --version
GNU bash, version 3.1.21(2)-release (i686-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
root@DL-380:[Wed Oct 01 23:12:46]:[/opt/installs/bash-3.1]$ which bash
/usr/bin/bash
root@DL-380:[Wed Oct 01 23:13:11]:[/opt/installs/bash-3.1]$ file /usr/bin/bash
/usr/bin/bash: symbolic link to `/bin/bash'
root@DL-380:[Wed Oct 01 23:13:15]:[/opt/installs/bash-3.1]$ file /bin/bash
/bin/bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped
root@DL-380:[Wed Oct 01 23:13:18]:[/opt/installs/bash-3.1]$ cp -fp bash /bin/bash
root@DL-380:[Wed Oct 01 23:13:28]:[/opt/installs/bash-3.1]$ env x='() { :;}; echo vulnerable' bash -c "echo this is a test" 
this is a test
root@DL-380:[Wed Oct 01 23:13:43]:[/opt/installs/bash-3.1]$ (for x in {1..200} ; do echo "for x$x in ; do :"; done; for x in {1..200} ; do echo done ; done) | bash || echo "CVE-2014-7187 vulnerable, word_lineno" 
root@DL-380:[Wed Oct 01 23:13:53]:[/opt/installs/bash-3.1]$ bash -c 'true <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF' || echo "CVE-2014-7186 vulnerable, redir_stack" 
root@DL-380:[Wed Oct 01 23:14:02]:[/opt/installs/bash-3.1]$ 

Done

Slackware4LIfe 🙂

How to relabel two identical TOSHIBA 1Tb USB 3.0 disks in a view to be auto mounted properly at XBMC

September 19, 2014 Leave a comment

I have two identical 1TB Toshiba USB 3.0 disks, and when I attach them to my RaspberryPI running XBMC, they appear as identical TOSHIBA EXT mounts at the GUI

After searching at the udev rules, I decided just to rename the partitions …

root@raspbmc:[Fri Sep 19 19:31:40][~]$ umount /media/TOSHIBA\ EXT 
root@raspbmc:[Fri Sep 19 19:31:56][~]$ ntfslabel /dev/sdb1 TOSHIBA_GABI
root@raspbmc:[Fri Sep 19 19:32:16][~]$ udevadm info -q all -n /dev/sdb1
P: /devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2:1.0/host1/target1:0:0/1:0:0:0/block/sdb/sdb1
N: sdb1
S: disk/by-id/usb-TOSHIBA_External_USB_3.0_23183A059E8A-0:0-part1
S: disk/by-label/TOSHIBA_GABI
S: disk/by-path/platform-bcm2708_usb-usb-0:1.2:1.0-scsi-0:0:0:0-part1
S: disk/by-uuid/BC2CF6852CF639CA
E: DEVLINKS=/dev/disk/by-id/usb-TOSHIBA_External_USB_3.0_23183A059E8A-0:0-part1 /dev/disk/by-label/TOSHIBA_GABI /dev/disk/by-path/platform-bcm2708_usb-usb-0:1.2:1.0-scsi-0:0:0:0-part1 /dev/disk/by-uuid/BC2CF6852CF639CA
E: DEVNAME=/dev/sdb1
E: DEVPATH=/devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2:1.0/host1/target1:0:0/1:0:0:0/block/sdb/sdb1
E: DEVTYPE=partition
E: ID_BUS=usb
E: ID_FS_LABEL=TOSHIBA_GABI
E: ID_FS_LABEL_ENC=TOSHIBA_GABI
E: ID_FS_TYPE=ntfs
E: ID_FS_USAGE=filesystem
E: ID_FS_UUID=BC2CF6852CF639CA
E: ID_FS_UUID_ENC=BC2CF6852CF639CA
E: ID_INSTANCE=0:0
E: ID_MODEL=External_USB_3.0
E: ID_MODEL_ENC=External\x20USB\x203.0
E: ID_MODEL_ID=a00d
E: ID_PART_ENTRY_DISK=8:16
E: ID_PART_ENTRY_NUMBER=1
E: ID_PART_ENTRY_OFFSET=2048
E: ID_PART_ENTRY_SCHEME=dos
E: ID_PART_ENTRY_SIZE=1953519616
E: ID_PART_ENTRY_TYPE=0x7
E: ID_PART_TABLE_TYPE=dos
E: ID_PATH=platform-bcm2708_usb-usb-0:1.2:1.0-scsi-0:0:0:0
E: ID_PATH_TAG=platform-bcm2708_usb-usb-0_1_2_1_0-scsi-0_0_0_0
E: ID_REVISION=5438
E: ID_SERIAL=TOSHIBA_External_USB_3.0_23183A059E8A-0:0
E: ID_SERIAL_SHORT=23183A059E8A
E: ID_TYPE=disk
E: ID_USB_DRIVER=usb-storage
E: ID_USB_INTERFACES=:080650:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=TOSHIBA
E: ID_VENDOR_ENC=TOSHIBA\x20
E: ID_VENDOR_ID=0480
E: MAJOR=8
E: MINOR=17
E: SUBSYSTEM=block
E: UDEV_LOG=3
E: UDISKS_DISABLE_POLLING=1
E: UDISKS_PARTITION=1
E: UDISKS_PARTITION_ALIGNMENT_OFFSET=0
E: UDISKS_PARTITION_NUMBER=1
E: UDISKS_PARTITION_OFFSET=1048576
E: UDISKS_PARTITION_SCHEME=mbr
E: UDISKS_PARTITION_SIZE=1000202043392
E: UDISKS_PARTITION_SLAVE=/sys/devices/platform/bcm2708_usb/usb1/1-1/1-1.2/1-1.2:1.0/host1/target1:0:0/1:0:0:0/block/sdb
E: UDISKS_PARTITION_TYPE=0x07
E: UDISKS_PRESENTATION_NOPOLICY=0
E: USEC_INITIALIZED=691627146808

root@raspbmc:[Fri Sep 19 19:32:52][~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p2  7.3G  2.1G  4.9G  30% /
/dev/mmcblk0p1   69M   50M   19M  73% /boot
/dev/sda1       932G  778G  155G  84% /media/TOSHIBA_ALL
/dev/sdb1       932G  775G  157G  84% /media/TOSHIBA_GABI
root@raspbmc:[Fri Sep 19 19:33:27][~]$ cat /scripts/upd_hist/build_info
raspbmc-rls-1.0-hardfp-b20140527-u20140527
root@raspbmc:[Fri Sep 19 19:35:33][~]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p2  7.3G  2.1G  4.9G  30% /
/dev/mmcblk0p1   69M   50M   19M  73% /boot
/dev/sda1       932G  778G  155G  84% /media/TOSHIBA_ALL
/dev/sdb1       932G  775G  157G  84% /media/TOSHIBA_GABI

slackware4life 🙂

Fedora release 20 (Heisenbug) enable client OpenVPN service on boot

August 21, 2014 Leave a comment

In short, I had to deal with the Fedora EVIL EVIL EVIL !!! Systemd
I found my openvpn startup script useless ..
Managed to set the VPN at the Network Manager just loading the openvpn config file, but I wanted to be started on boot … because out of the blue my Fedora 20 Gnome boot hanged on the blue logo !!! This is another story to be told.

Anyway, back to the OpenVPN issue, the steps to do make it start on boot, following the instructions at http://fedoraproject.org/wiki/Openvpn

1. Set the keys and the config file at /etc/openvpn

root@outoutdragkh.f20:[Thu Aug 21 01:30:06][~]$ cd /etc/openvpn/
root@outdragkh.f20:[Thu Aug 21 01:30:10][/etc/openvpn]$ ls
keys  outdragkh.client.conf

2. Fix selinux context of the config files :

root@outdragkh.f20:[Thu Aug 21 01:30:10][/etc/openvpn]$  restorecon -Rv /etc/openvp

3. Check the general openvpn service file:

root@outdragkh.f20:[Thu Aug 21 01:30:32][/etc/openvpn]$ ls /lib/systemd/system/openvpn\@.service
/lib/systemd/system/openvpn@.service
root@outdragkh.f20:[Thu Aug 21 01:30:51][/etc/openvpn]$ cat /lib/systemd/system/openvpn\@.service
[Unit]
Description=OpenVPN Robust And Highly Flexible Tunneling Application On %I
After=syslog.target network.target

[Service]
PrivateTmp=true
Type=forking
PIDFile=/var/run/openvpn/%i.pid
ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/%i.pid --cd /etc/openvpn/ --config %i.conf

[Install]
WantedBy=multi-user.target

4. Set the systemd start scripts for the outoutdragkh.client.conf

root@outdragkh.f20:[Thu Aug 21 01:30:55][/etc/openvpn]$ ln -s /lib/systemd/system/openvpn\@.service /etc/systemd/system/multi-user.target.wants/openvpn\@outdragkh.client.service
root@outdragkh.f20:[Thu Aug 21 01:32:04][/etc/openvpn]$ ls /etc/systemd/system/multi-user.target.wants/openvpn@outdragkh.client.service 
/etc/systemd/system/multi-user.target.wants/openvpn@outdragkh.client.service

5. Enable the dragkh OpenVPN service

root@outdragkh.f20:[Thu Aug 21 01:32:12][/etc/openvpn]$ systemctl -f enable openvpn@outdragkh.client.service
rm '/etc/systemd/system/multi-user.target.wants/openvpn@outdragkh.client.service'
ln -s '/usr/lib/systemd/system/openvpn@.service' '/etc/systemd/system/multi-user.target.wants/openvpn@outdragkh.client.service'

6. Start the dragkh OpenVPN service

root@outdragkh.f20:[Thu Aug 21 01:32:30][/etc/openvpn]$ systemctl start openvpn@outdragkh.client.service 
root@outdragkh.f20:[Thu Aug 21 01:32:49][/etc/openvpn]$ systemctl status openvpn@outdragkh.client.service 
openvpn@outdragkh.client.service - OpenVPN Robust And Highly Flexible Tunneling Application On outdragkh.client
   Loaded: loaded (/usr/lib/systemd/system/openvpn@.service; enabled)
   Active: active (running) since Thu 2014-08-21 01:32:49 CEST; 5s ago
  Process: 3194 ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/%i.pid --cd /etc/openvpn/ --config %i.conf (code=exited, status=0/SUCCESS)
 Main PID: 3195 (openvpn)
   CGroup: /system.slice/system-openvpn.slice/openvpn@outdragkh.client.service
           └─3195 /usr/sbin/openvpn --daemon --writepid /var/run/openvpn/outdragkh.client.pid --cd /etc/openvpn/ --config outdragkh.client.conf

Aug 21 01:32:49 dragkh.wordpress.com systemd[1]: Started OpenVPN Robust And Highly Flexible Tunneling Application On outdragkh.client.
root@outdragkh.f20:[Thu Aug 21 01:32:55][/etc/openvpn]$ systemctl status openvpn@outdragkh.client.service 

done …

Slackware2Life 🙂

MySQL backup and cleanup bash scripts with mydumper

June 28, 2014 1 comment

1. Backup script

#!/bin/sh
# Fri Jun 27 10:44:49 2014
# done by dragkh
# usage: 
# cat /etc/cron.d/backupmysql 
# 0  3  *  *  *       root    /root/bin/clean.backup.hyperion.mysql.mydumper.daily.sh >>  /var/log/clean.backup.${HOSTNAME}.mysql.mydumper.daily.log 2>&1
# 35  3  *  *  *       root    /root/bin/backup.hyperion.mysql.mydumper.daily.sh >> /var/log/backup.${HOSTNAME}.mysql.mydumper.daily.log 2>&1

ROOT_BACKUP_DIR="/home/mydumper"

seik_date () {
if [ -z $1 ]
then
# cdate=`date +%Y-%m-%d\ %H:%M:%S\ %Z`; export cdate; echo $cdate
cdate=`date -R`; export cdate; echo $cdate
else

if [ -z ${2} ]
then
cdate=`date +%Y-%m-%d.%H.%M.%S`; export cdate; echo $cdate
else
cdate=`date "+%Y-%m-%d %H:%M:%S"`; export cdate; echo $cdate
fi

fi
}


function check_dir {
 test ! -d "${1}" && mkdir -p "${1}"
}


function set_cpu_threads {
    # set the threads one less than the existing 
    threads=$(cat /proc/cpuinfo  |  grep processor | tail -1 | awk '{print $3}')
    test $threads -lt 1 && threads=1
}

function dump_schema {
    mysqldump -d --dump-date --all-databases > ${DATA_DIR}/${HOSTNAME}.only.sql
}


function dump_data {
    echo "$(seik_date f) : executing : mydumper -o $DATA_DIR --long-query-guard 120 -r 100000 -c -e -m -L ${DATA_DIR}/mysql-backup.log -t ${threads} -v 3"
    mydumper -o $DATA_DIR --long-query-guard 120 -r 100000 -c -e -m -L ${DATA_DIR}/mysql-backup.log -t ${threads} -v 3
}

DATA_DIR="${ROOT_BACKUP_DIR}/$(seik_date d)"
check_dir "${DATA_DIR}" && echo "$(seik_date f) : ${DATA_DIR} is missing, creating it now .."
set_cpu_threads
echo "$(seik_date f) : star dumping the schema at ${DATA_DIR}.."
dump_schema && echo "$(seik_date f) : end dumping the schema at ${DATA_DIR} .."
echo "$(seik_date f) : start dumping the data at ${DATA_DIR} via ${threads} parallel threads .."
dump_data && echo "$(seik_date f) : end dumping the data at ${DATA_DIR} via ${threads} parallel threads .."

2. Clean up script keeping always backup directories intact

#!/bin/bash
# Sat Jun 28 03:16:38 EEST 2014
# done by dragkh
# usage: 
# cat /etc/cron.d/backupmysql
# 0       3       *       *       *       root    /root/bin/clean.backup.hyperion.mysql.mydumper.daily.sh >> /var/log/clean.backup.${HOSTNAME}.mysql.mydumper.daily.log 2>&1
# 35      3      *       *       *       root    /root/bin/backup.hyperion.mysql.mydumper.daily.sh >> /var/log/backup.${HOSTNAME}.mysql.mydumper.daily.log 2>&1

ROOT_BACKUP_DIR="/home/mydumper"

seik_date () {
if [ -z $1 ]
then
cdate=`date -R`; export cdate; echo $cdate
else

if [ -z ${2} ]
then
cdate=`date +%Y-%m-%d.%H.%M.%S`; export cdate; echo $cdate
else
cdate=`date "+%Y-%m-%d %H:%M:%S"`; export cdate; echo $cdate
fi

fi
}

day_limit=7;  
ls -t ${ROOT_BACKUP_DIR} | \
while read dir
do 
    ((dir_num++))
    test $dir_num -gt $day_limit && test -d "${ROOT_BACKUP_DIR}/${dir}" &&  rm -rf "${dir}" && echo "$(seik_date d) : removed [${dir_num}]::[${dir}]" && continue 
    test -d "${ROOT_BACKUP_DIR}/${dir}" && echo "$(seik_date d) : skipping [${dir_num}]::[${dir}]"
done

Fix 32 inch LCD LG TV model 32LG5600 problem menu on screen keeps popping up and disappearing

May 11, 2014 4 comments

Recently I had issues with my 32 inch LCD LG TV /32LG5600/. I was about to order new TV … 🙂
I read some posts like from the Google search Google Search LG TV popping up menu on screen and disappearing and I decided to disable the TV set side buttons.
All the procedure took 10 minutes, including the clean up.
All the photos about you may check here https://plus.google.com/photos/115378324869440910839/albums/6012302457181181569

At https://picasaweb.google.com/115378324869440910839/FixLGTV32LG5600?noredirect=1#6012302457178078274 you may see the buttons at the top of the photo.

At https://picasaweb.google.com/115378324869440910839/FixLGTV32LG5600?noredirect=1#6012302457002999506 you will see the side buttons before to disconnect them.

At https://picasaweb.google.com/115378324869440910839/FixLGTV32LG5600?noredirect=1#6012302454434989874 you see the disconnected side buttons, which fixed the issue permanently.

No more popping up menus on the screen.

Slackware4Life 🙂

Compile at CentOS 6.5 the new MySQL webscalesql-5.6.17 branch by Facebook, Google, LinkedIn, and Twitter

March 31, 2014 Leave a comment

http://webscalesql.org/

yeah , big buzz around that one 🙂

So I decided to check the install process:

1. Clone the repo from

root@webscalesql-5.6.clean:[Mon Mar 31 11:37:11][~]$ cd /opt/
root@webscalesql-5.6.clean:[Mon Mar 31 11:37:15][/opt]$ mkdir installs
root@webscalesql-5.6.clean:[Mon Mar 31 11:37:17][/opt]$ cd installs/
root@webscalesql-5.6.clean:[Mon Mar 31 11:37:19][/opt/installs]$ git clone https://github.com/webscalesql/webscalesql-5.6.git
Initialized empty Git repository in /opt/installs/webscalesql-5.6/.git/
remote: Counting objects: 30397, done.
remote: Compressing objects: 100% (12678/12678), done.
remote: Total 30397 (delta 18716), reused 27620 (delta 16936)
Receiving objects: 100% (30397/30397), 47.99 MiB | 460 KiB/s, done.
Resolving deltas: 100% (18716/18716), done.

2. Update the CentOs install just in case before to play with it:

root@webscalesql-5.6.clean:[Mon Mar 31 11:40:35][/opt/installs]$ yum update -y 

3. Compile it :
Note : The final part of the prompt here “[webscalesql-5.6.17]” id the actual git branch version.

root@webscalesql-5.6.clean:[Mon Mar 31 12:23:22][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ cmake . -DBUILD_CONFIG=mysql_release -DENABLE_DOWNLOADS=1
-bash: cmake: command not found

3.1 No Cmake ? The CentOS install was done without cmake etc dev tools as at production they are not needed.
Now, we need it: Install cmake

root@webscalesql-5.6.clean:[Mon Mar 31 12:23:34][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ yum install cmake -y 
....
Installed:
  cmake.x86_64 0:2.6.4-5.el6  
root@webscalesql-5.6.clean:[Mon Mar 31 12:24:10][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ cmake --version
cmake version 2.6-patch 4                                                                                                                                                               

3.2 Try to compile it again?

root@webscalesql-5.6.clean:[Mon Mar 31 12:24:20][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ cmake . -DBUILD_CONFIG=mysql_release -DENABLE_DOWNLOADS=1
-- Running cmake version 2.6.4
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error: your C compiler: "CMAKE_C_COMPILER-NOTFOUND" was not found.   Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.

No luck, the development tools are missing
3.3 Install ‘Development Tools’ group

root@webscalesql-5.6.clean:[Mon Mar 31 12:24:54][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ yum groupinstall 'Development Tools'
Installed:
  autoconf.noarch 0:2.63-5.1.el6      automake.noarch 0:1.11.1-4.el6      bison.x86_64 0:2.4.1-5.el6                       byacc.x86_64 0:1.9.20070509-7.el6   cscope.x86_64 0:15.6-6.el6           
  ctags.x86_64 0:5.8-2.el6            diffstat.x86_64 0:1.51-2.el6        doxygen.x86_64 1:1.6.1-6.el6                     flex.x86_64 0:2.5.35-8.el6          gcc.x86_64 0:4.4.7-4.el6             
  gcc-c++.x86_64 0:4.4.7-4.el6        gcc-gfortran.x86_64 0:4.4.7-4.el6   indent.x86_64 0:2.2.10-7.el6                     intltool.noarch 0:0.41.0-1.1.el6    libtool.x86_64 0:2.2.6-15.5.el6      
  patchutils.x86_64 0:0.3.1-3.1.el6   rcs.x86_64 0:5.7-37.el6             redhat-rpm-config.noarch 0:9.0.3-42.el6.centos   rpm-build.x86_64 0:4.8.0-37.el6     subversion.x86_64 0:1.6.11-10.el6_5  
  swig.x86_64 0:1.3.40-6.el6          systemtap.x86_64 0:2.3-4.el6_5     

Dependency Installed:
  apr.x86_64 0:1.3.9-5.el6_2              apr-util.x86_64 0:1.3.9-3.el6_0.1            cloog-ppl.x86_64 0:0.15.7-1.2.el6      cpp.x86_64 0:4.4.7-4.el6       gettext-devel.x86_64 0:0.17-16.el6      
  gettext-libs.x86_64 0:0.17-16.el6       kernel-devel.x86_64 0:2.6.32-431.11.2.el6    libart_lgpl.x86_64 0:2.3.20-5.1.el6    libgcj.x86_64 0:4.4.7-4.el6    libstdc++-devel.x86_64 0:4.4.7-4.el6    
  mpfr.x86_64 0:2.4.1-6.el6               neon.x86_64 0:0.29.3-3.el6_4                 pakchois.x86_64 0:0.4-3.2.el6          ppl.x86_64 0:0.10.2-11.el6     systemtap-client.x86_64 0:2.3-4.el6_5   
  systemtap-devel.x86_64 0:2.3-4.el6_5   

3.4 Try to compile … one more time 🙂

root@webscalesql-5.6.clean:[Mon Mar 31 12:30:37][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ cmake . -DBUILD_CONFIG=mysql_release -DENABLE_DOWNLOADS=1
-- Running cmake version 2.6.4
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at cmake/build_configurations/mysql_release.cmake:43 (MESSAGE):
        aio is required on Linux, you need to install the required library:

            Debian/Ubuntu:              apt-get install libaio-dev
            RedHat/Fedora/Oracle Linux: yum install libaio-devel
            SuSE:                       zypper install libaio-devel

          If you really do not want it, pass -DIGNORE_AIO_CHECK to cmake.
          
Call Stack (most recent call first):
  CMakeLists.txt:94 (INCLUDE)
-- Configuring incomplete, errors occurred!

So install libaio libs ..

root@webscalesql-5.6.clean:[Mon Mar 31 12:32:43][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ yum install libaio-devel

Installed:
  libaio-devel.x86_64 0:0.3.107-10.el6                                                                                                                                                               

3.5 Try to compile … again
Now the CMakeCache.txt file has to be removed in a view to start form scratch:

root@webscalesql-5.6.clean:[Mon Mar 31 12:33:23][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ rm CMakeCache.txt 
rm: remove regular file `CMakeCache.txt'? y
root@webscalesql-5.6.clean:[Mon Mar 31 12:33:57][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ cmake . -DBUILD_CONFIG=mysql_release -DENABLE_DOWNLOADS=1
--
---
-- Could NOT find Curses  (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
  Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
  cmake/readline.cmake:125 (FIND_CURSES)
  cmake/readline.cmake:194 (FIND_SYSTEM_LIBEDIT)
  CMakeLists.txt:397 (MYSQL_CHECK_READLINE)
-- Configuring incomplete, errors occurred!

So follow up the hint and installed the libs:

root@webscalesql-5.6.clean:[Mon Mar 31 12:34:25][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ yum install ncurses-devel

Installed:
  ncurses-devel.x86_64 0:5.7-3.20090208.el6                                                                                                                                                          

3.6 Try to compile … 🙂

root@webscalesql-5.6.clean:[Mon Mar 31 12:35:44][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ rm CMakeCache.txt 
rm: remove regular file `CMakeCache.txt'? y
root@webscalesql-5.6.clean:[Mon Mar 31 12:35:51][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ cmake . -DBUILD_CONFIG=mysql_release -DENABLE_DOWNLOADS=1
...
....
.....
-- Found Curses: /usr/lib64/libcurses.so
-- Looking for tputs in /usr/lib64/libcurses.so
-- Looking for tputs in /usr/lib64/libcurses.so - found
-- Looking for include files HAVE_READLINE_HISTORY_H
-- Looking for include files HAVE_READLINE_HISTORY_H - not found.
CMake Error at cmake/readline.cmake:186 (MESSAGE):
  Cannot find libreadline!
Call Stack (most recent call first):
  cmake/readline.cmake:194 (FIND_SYSTEM_LIBEDIT)
  CMakeLists.txt:397 (MYSQL_CHECK_READLINE)
-- Configuring incomplete, errors occurred!

readline-devel was needed indeed even we installed ncurses libs

root@webscalesql-5.6.clean:[Mon Mar 31 12:37:20][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ yum install readline-devel

Installed:
  readline-devel.x86_64 0:6.0-4.el6                                                                                                                                                                  

3.7 Try to compile … 🙂

root@webscalesql-5.6.clean:[Mon Mar 31 12:37:38][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ rm CMakeCache.txt 
rm: remove regular file `CMakeCache.txt'? y
root@webscalesql-5.6.clean:[Mon Mar 31 12:37:47][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ cmake . -DBUILD_CONFIG=mysql_release -DENABLE_DOWNLOADS=1
-- Successfully downloaded http://googlemock.googlecode.com/files/gmock-1.6.0.zip to /opt/installs/webscalesql-5.6/source_downloads
CMake Error: Problem with tar_extract_all(): Invalid argument
CMake Error: Problem extracting tar: /opt/installs/webscalesql-5.6/source_downloads/gmock-1.6.0.zip
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/installs/webscalesql-5.6

3.8 Fix CMake Error: Problem with tar_extract_all(): Invalid argument at extracting the gmock-1.6.0.zip archive.

root@webscalesql-5.6.clean:[Mon Mar 31 12:46:05][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ cd source_downloads/
root@webscalesql-5.6.clean:[Mon Mar 31 12:46:08][/opt/installs/webscalesql-5.6/source_downloads] [webscalesql-5.6.17]$ ls
gmock-1.6.0.zip
root@webscalesql-5.6.clean:[Mon Mar 31 12:46:08][/opt/installs/webscalesql-5.6/source_downloads] [webscalesql-5.6.17]$ unzip -a gmock-1.6.0.zip 

3.9 Try to compile it …. 🙂

root@webscalesql-5.6.clean:[Mon Mar 31 12:47:10][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ rm CMakeCache.txt 
rm: remove regular file `CMakeCache.txt'? y
root@webscalesql-5.6.clean:[Mon Mar 31 12:47:12][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ cmake . -DBUILD_CONFIG=mysql_release -DENABLE_DOWNLOADS=1
 -- GMOCK_SOURCE_DIR:/opt/installs/webscalesql-5.6/source_downloads/gmock-1.6.0
-- Performing Test HAVE_NO_NULL
-- Performing Test HAVE_NO_NULL - Failed
-- Performing Test HAVE_NO_UNUSED_TYPEDEFS
-- Performing Test HAVE_NO_UNUSED_TYPEDEFS - Failed
-- GTEST_LIBRARIES:gmock;gtest
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/installs/webscalesql-5.6
root@webscalesql-5.6.clean:[Mon Mar 31 12:47:20][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ make
.
..
...
Linking C static library libmysys.a
[ 15%] Built target mysys
Scanning dependencies of target dbug
[ 15%] Building C object dbug/CMakeFiles/dbug.dir/dbug.c.o
Linking C static library libdbug.a
[ 15%] Built target dbug
Scanning dependencies of target mysys_ssl
[ 15%] Building CXX object mysys_ssl/CMakeFiles/mysys_ssl.dir/crypt_genhash_impl.cc.o
cc1plus: error: unrecognized command line option "-std=c++11"
make[2]: *** [mysys_ssl/CMakeFiles/mysys_ssl.dir/crypt_genhash_impl.cc.o] Error 1
make[1]: *** [mysys_ssl/CMakeFiles/mysys_ssl.dir/all] Error 2
make: *** [all] Error 2

4 Fix -std=c++11 error.
This error is ude to old gcc c++. That is fixable by installing the CentOS devtools:

root@webscalesql-5.6.clean:[Mon Mar 31 12:47:25]:[/opt/installs/webscalesql-5.6]$ yum info  gcc-c++
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: sunsite.rediris.es
 * extras: sunsite.rediris.es
 * updates: sunsite.rediris.es
base                                                                                                                                                                          | 3.7 kB     00:00     
extras                                                                                                                                                                        | 3.4 kB     00:00     
testing-1.1-devtools-6                                                                                                                                                        |  951 B     00:00     
updates                                                                                                                                                                       | 3.4 kB     00:00     
Installed Packages
Name        : gcc-c++
Arch        : x86_64
Version     : 4.4.7
Release     : 4.el6
Size        : 11 M
Repo        : installed
From repo   : base
Summary     : C++ support for GCC
root@webscalesql-5.6.clean:[Mon Mar 31 12:48:39][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ g++ --version
g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@webscalesql-5.6.clean:[Mon Mar 31 12:50:11][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ cd /etc/yum.repos.d/
root@webscalesql-5.6.clean:[Mon Mar 31 12:50:30][/etc/yum.repos.d]$ wget  http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo
--2014-03-31 12:50:38--  http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo
Resolving people.centos.org... 204.15.73.242
Connecting to people.centos.org|204.15.73.242|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 174 [text/plain]
Saving to: “devtools-1.1.repo”

100%[===========================================================================================================================================================>] 174         --.-K/s   in 0s      

2014-03-31 12:50:39 (19.9 MB/s) - “devtools-1.1.repo” saved [174/174]

root@webscalesql-5.6.clean:[Mon Mar 31 12:50:39][/etc/yum.repos.d]$ yum repolist
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: sunsite.rediris.es
 * extras: sunsite.rediris.es
 * updates: sunsite.rediris.es
testing-1.1-devtools-6                                                                                                                                                        |  951 B     00:00     
testing-1.1-devtools-6/primary                                                                                                                                                |  13 kB     00:00     
testing-1.1-devtools-6                                                                                                                                                                         42/42
repo id                                                                                   repo name                                                                                            status
base                                                                                      CentOS-6 - Base                                                                                      6,367
extras                                                                                    CentOS-6 - Extras                                                                                       14
testing-1.1-devtools-6                                                                    testing 1.1 devtools for CentOS 6                                                                       42
updates                                                                                   CentOS-6 - Updates                                                                                     713
repolist: 7,136

root@webscalesql-5.6.clean:[Mon Mar 31 12:51:08][/etc/yum.repos.d]$ yum install devtoolset-1.1

Install      19 Package(s)

Total download size: 85 M
Installed size: 303 M
Installed:
  devtoolset-1.1.noarch 0:1-13.el6                                                                                                                                                                   

Dependency Installed:
  devtoolset-1.1-binutils.x86_64 0:2.23.51.0.3-3.el6                 devtoolset-1.1-dwz.x86_64 0:0.7-1.el6                            devtoolset-1.1-elfutils.x86_64 0:0.154-6.el6                   
  devtoolset-1.1-elfutils-libelf.x86_64 0:0.154-6.el6                devtoolset-1.1-elfutils-libs.x86_64 0:0.154-6.el6                devtoolset-1.1-gcc.x86_64 0:4.7.2-5.el6                        
  devtoolset-1.1-gcc-c++.x86_64 0:4.7.2-5.el6                        devtoolset-1.1-gcc-gfortran.x86_64 0:4.7.2-5.el6                 devtoolset-1.1-gdb.x86_64 0:7.5.0.20120926-26.el6              
  devtoolset-1.1-libquadmath-devel.x86_64 0:4.7.2-5.el6              devtoolset-1.1-libstdc++-devel.x86_64 0:4.7.2-5.el6              devtoolset-1.1-oprofile.x86_64 0:0.9.7-6.el6                   
  devtoolset-1.1-runtime.noarch 0:1-13.el6                           devtoolset-1.1-systemtap.x86_64 0:1.8-8.el6                      devtoolset-1.1-systemtap-client.x86_64 0:1.8-8.el6             
  devtoolset-1.1-systemtap-devel.x86_64 0:1.8-8.el6                  devtoolset-1.1-systemtap-runtime.x86_64 0:1.8-8.el6              devtoolset-1.1-valgrind.x86_64 1:3.8.1-3.2.el6                 

Complete!
root@webscalesql-5.6.clean:[Mon Mar 31 13:01:29][/etc/yum.repos.d]$ cd /opt/installs/webscalesql-5.6/
root@webscalesql-5.6.clean:[Mon Mar 31 13:01:48][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ rm CMakeCache.txt 
rm: remove regular file `CMakeCache.txt'? y   
root@webscalesql-5.6.clean:[Mon Mar 31 13:01:56][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ cmake . -DBUILD_CONFIG=mysql_release -DENABLE_DOWNLOADS=1
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/installs/webscalesql-5.6
root@webscalesql-5.6.clean:[Mon Mar 31 13:02:33][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ make 
..
Linking C static library libdbug.a
[ 15%] Built target dbug
[ 15%] Building CXX object mysys_ssl/CMakeFiles/mysys_ssl.dir/crypt_genhash_impl.cc.o
cc1plus: error: unrecognized command line option "-std=c++11"
make[2]: *** [mysys_ssl/CMakeFiles/mysys_ssl.dir/crypt_genhash_impl.cc.o] Error 1
make[1]: *** [mysys_ssl/CMakeFiles/mysys_ssl.dir/all] Error 2
make: *** [all] Error 2

After the install of devtoos you have to enable the devtoolset-1.1 bash:

root@webscalesql-5.6.clean:[Mon Mar 31 13:04:41][/opt/installs/webscalesql-5.6] [webscalesql-5.6.17]$ scl enable devtoolset-1.1 bash
[root@webscalesql-5 webscalesql-5.6]# export PS1="\u@\H:[\d \t]:[\w]$ "
root@webscalesql-5.6.clean:[Mon Mar 31 13:05:50]:[/opt/installs/webscalesql-5.6]$ rm CMakeCache.txt 
rm: remove regular file `CMakeCache.txt'? y
root@webscalesql-5.6.clean:[Mon Mar 31 13:06:04]:[/opt/installs/webscalesql-5.6]$ cmake . -DBUILD_CONFIG=mysql_release -DENABLE_DOWNLOADS=1
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/installs/webscalesql-5.6
root@webscalesql-5.6.clean:[Mon Mar 31 13:07:46]:[/opt/installs/webscalesql-5.6]$ make

Linking CXX executable my_safe_process
[100%] Built target my_safe_process
root@webscalesql-5.6.clean:[Mon Mar 31 13:36:58]:[/opt/installs/webscalesql-5.6]$ make install

The compile and the installation is done ! Finally .. 🙂
Done

5. Now, the post install:

root@webscalesql-5.6.clean:[Mon Mar 31 13:41:56]:[/opt/installs/webscalesql-5.6]$ cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql.server
root@webscalesql-5.6.clean:[Mon Mar 31 13:42:17]:[/opt/installs/webscalesql-5.6]$ mysql
bash: mysql: command not found

root@webscalesql-5.6.clean:[Mon Mar 31 13:42:36]:[/opt/installs/webscalesql-5.6]$ export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/scripts
root@webscalesql-5.6.clean:[Mon Mar 31 13:43:06]:[/opt/installs/webscalesql-5.6]$ mysql --version
mysql  Ver 14.14 Distrib 5.6.17, for Linux (x86_64) using readline 6.0
root@webscalesql-5.6.clean:[Mon Mar 31 13:43:10]:[/opt/installs/webscalesql-5.6]$ cd /var/lib/mysql/
root@webscalesql-5.6.clean:[Mon Mar 31 13:43:25]:[/var/lib/mysql]$ ls
root@webscalesql-5.6.clean:[Mon Mar 31 13:43:26]:[/var/lib/mysql]$ chown -R mysql .
chown: invalid user: `mysql'
root@webscalesql-5.6.clean:[Mon Mar 31 13:43:33]:[/var/lib/mysql]$ groupadd mysql
root@webscalesql-5.6.clean:[Mon Mar 31 13:43:40]:[/var/lib/mysql]$ useradd -r -g mysql mysql
root@webscalesql-5.6.clean:[Mon Mar 31 13:43:44]:[/var/lib/mysql]$ chown -R mysql .
root@webscalesql-5.6.clean:[Mon Mar 31 13:43:48]:[/var/lib/mysql]$ mysql_install_db --basedir=/usr/local/mysql --user=mysql --datadir=/var/lib/mysql
Installing MySQL system tables...2014-03-31 13:43:58 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-03-31 13:43:58 25002 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-03-31 13:43:58 25002 [Note] InnoDB: The InnoDB memory heap is disabled
2014-03-31 13:43:58 25002 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-03-31 13:43:58 25002 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-03-31 13:43:58 25002 [Note] InnoDB: Using Linux native AIO
2014-03-31 13:43:58 25002 [Note] InnoDB: Not using CPU crc32 instructions
2014-03-31 13:43:58 25002 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-03-31 13:43:58 25002 [Note] InnoDB: Completed initialization of buffer pool
2014-03-31 13:43:58 25002 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-03-31 13:43:58 25002 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-03-31 13:43:58 25002 [Note] InnoDB: Database physically writes the file full: wait...
2014-03-31 13:43:59 25002 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-03-31 13:44:04 25002 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-03-31 13:44:09 25002 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-03-31 13:44:09 25002 [Warning] InnoDB: New log files created, LSN=45781
2014-03-31 13:44:09 25002 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-03-31 13:44:09 25002 [Note] InnoDB: Doublewrite buffer created
2014-03-31 13:44:09 25002 [Note] InnoDB: 128 rollback segment(s) are active.
2014-03-31 13:44:09 25002 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-03-31 13:44:09 25002 [Note] InnoDB: Foreign key constraint system tables created
2014-03-31 13:44:09 25002 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-03-31 13:44:10 25002 [Note] InnoDB: Tablespace and datafile system tables created.
2014-03-31 13:44:10 25002 [Note] InnoDB: Waiting for purge to start
2014-03-31 13:44:10 25002 [Note] InnoDB: 5.6.17 started; log sequence number 0
2014-03-31 13:44:14 25002 [Note] Binlog end
2014-03-31 13:44:14 25002 [Note] unregister_replicator OK
2014-03-31 13:44:14 25002 [Note] InnoDB: FTS optimize thread exiting.
2014-03-31 13:44:14 25002 [Note] InnoDB: Starting shutdown...
2014-03-31 13:44:15 25002 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2014-03-31 13:44:15 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-03-31 13:44:15 25024 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-03-31 13:44:15 25024 [Note] InnoDB: The InnoDB memory heap is disabled
2014-03-31 13:44:15 25024 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-03-31 13:44:15 25024 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-03-31 13:44:15 25024 [Note] InnoDB: Using Linux native AIO
2014-03-31 13:44:15 25024 [Note] InnoDB: Not using CPU crc32 instructions
2014-03-31 13:44:15 25024 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-03-31 13:44:15 25024 [Note] InnoDB: Completed initialization of buffer pool
2014-03-31 13:44:15 25024 [Note] InnoDB: Highest supported file format is Barracuda.
2014-03-31 13:44:15 25024 [Note] InnoDB: 128 rollback segment(s) are active.
2014-03-31 13:44:15 25024 [Note] InnoDB: Waiting for purge to start
2014-03-31 13:44:15 25024 [Note] InnoDB: 5.6.17 started; log sequence number 1625977
2014-03-31 13:44:15 25024 [Note] Binlog end
2014-03-31 13:44:15 25024 [Note] unregister_replicator OK
2014-03-31 13:44:15 25024 [Note] InnoDB: FTS optimize thread exiting.
2014-03-31 13:44:15 25024 [Note] InnoDB: Starting shutdown...
2014-03-31 13:44:17 25024 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/local/mysql/bin/mysqladmin -u root password 'new-password'
  /usr/local/mysql/bin/mysqladmin -u root -h webscalesql-5.6.clean password 'new-password'

Alternatively you can run:

  /usr/local/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd . ; /usr/local/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

  cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/local/mysql/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server


root@webscalesql-5.6.clean:[Mon Mar 31 13:44:17]:[/var/lib/mysql]$ chkconfig --list mysql.server
service mysql.server supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add mysql.server')

root@webscalesql-5.6.clean:[Mon Mar 31 13:45:31]:[/var/lib/mysql]$ chkconfig --add  mysql.server
root@webscalesql-5.6.clean:[Mon Mar 31 13:45:36]:[/var/lib/mysql]$ chkconfig --list mysql.server
mysql.server   	0:off	1:off	2:on	3:on	4:on	5:on	6:off

root@webscalesql-5.6.clean:[Mon Mar 31 13:47:53]:[/usr/local/mysql/support-files]$ service mysql.server status
MySQL is not running                                       [FAILED]
root@webscalesql-5.6.clean:[Mon Mar 31 13:48:04]:[/usr/local/mysql/support-files]$ 

root@webscalesql-5.6.clean:[Mon Mar 31 13:48:04]:[/usr/local/mysql/support-files]$ service mysql.server start
Starting MySQL.                                            [  OK  ]
root@webscalesql-5.6.clean:[Mon Mar 31 13:48:13]:[/usr/local/mysql/support-files]$ service mysql.server status
MySQL running (25273)                                      [  OK  ]

root@webscalesql-5.6.clean:[Mon Mar 31 13:48:17]:[/usr/local/mysql/support-files]$ mysql 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

root@webscalesql-5.6.clean:[Mon Mar 31 13:48:26]:[/usr/local/mysql/support-files]$ mysql -h 127.0.0.1
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.17 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql root@127.0.0.1:[Mon Mar 31 13:49:21 2014][mysql]> select user,password,host from user;
+------+----------+-----------------------+
| user | password | host                  |
+------+----------+-----------------------+
| root |          | localhost             |
| root |          | webscalesql-5.6.clean |
| root |          | 127.0.0.1             |
| root |          | ::1                   |
|      |          | localhost             |
|      |          | webscalesql-5.6.clean |
+------+----------+-----------------------+
6 rows in set (0.00 sec)

mysql> set password=password('webscalesql');
Query OK, 0 rows affected (0.00 sec)

mysql> Bye
root@webscalesql-5.6.clean:[Mon Mar 31 13:51:17]:[/usr/local/mysql/support-files]$ nano /root/.my.cnf
root@webscalesql-5.6.clean:[Mon Mar 31 13:51:52]:[/usr/local/mysql/support-files]$ cat /root/.my.cnf 
[mysql]
user=root
password=webscalesql
prompt=mysql\_\u@\h:[\D][\d]>\_
host=127.0.0.1
root@webscalesql-5.6.clean:[Mon Mar 31 13:52:21]:[/usr/local/mysql/support-files]$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.17 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql root@127.0.0.1:[Mon Mar 31 13:52:26 2014][(none)]> 

All that was done inspired by the SkySQL::Global Leaders in MariaDB & MySQL blog of Mr. Kolbe Kegel at WebScaleSQL! Will it build?

Slackware4Life!

Connect MySQL to sqlite3 database or to flat txt file via CONNECT engine of MariaDB 10.0.7 on Fedora/CentOS

January 31, 2014 Leave a comment

You might don’t know that, but the MariaDB engines are amazing ..
More info you can find here:
https://mariadb.com/kb/en/mariadb-storage-engines/

I was teased by CONNECT engine : https://mariadb.com/kb/en/connect/

What is good for ? Well, I leave that to your imagination, as you could have MariaDB as a spider connected and managing InnoDB tables, flat files, MS ACCESS databases, MS Excel files … all that in same time.
So how to use it?
By the documentation :
1. https://mariadb.com/kb/en/loading-the-connect-handler/
check if there is CONNECT already installed, if not, install it:

mysql root@mariadb-10.0.7:[Wed Jan 29 09:36:14 2014][(none)]> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MRG_MyISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| FEDERATED          | YES     | FederatedX pluggable storage engine                            | YES          | NO   | YES        |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| Aria               | YES     | Crash-safe tables with MyISAM heritage                         | NO           | NO   | NO         |
| CASSANDRA          | YES     | Cassandra storage engine                                       | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
11 rows in set (0.00 sec)

Its not installed by default for MariaDB 10.0.7
So lets install it:

mysql root@mariadb-10.0.7:[Wed Jan 29 09:36:19 2014][(none)]> INSTALL PLUGIN CONNECT SONAME 'ha_connect';
ERROR 1126 (HY000): Can't open shared library '/usr/lib64/mysql/plugin/ha_connect.so' (errno: 2, cannot open shared object file: No such file or directory)

My first install failed and I had to install MariaDB-connect-engine package from MariaDB

$ yum info MariaDB-connect-engine
Name        : MariaDB-connect-engine
Arch        : x86_64
Version     : 10.0.7
Release     : 1
Size        : 4.3 M
Repo        : installed
From repo   : mariadb
Summary     : MariaDB: a very fast and robust SQL database server
URL         : http://mariadb.org
License     : GPL
Description : MariaDB: a very fast and robust SQL database server
            : 
            : It is GPL v2 licensed, which means you can use the it free of charge under the
            : conditions of the GNU General Public License Version 2 (http://www.gnu.org/licenses/).
            : 
            : MariaDB documentation can be found at http://kb.askmonty.org/
            : MariaDB bug reports should be submitted through https://mariadb.atlassian.net/


$ cat /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.0 CentOS repository list - created 2013-12-18 18:07 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos6-amd64
#baseurl = ftp://ftp.ulak.net.tr/pub/MariaDB/yum/10.0/centos6-amd64
#baseurl = ftp://ftp.ulak.net.tr/pub/MariaDB/mariadb-10.0.6/yum/centos6-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1


then again

mysql root@mariadb-10.0.7:[Wed Jan 29 09:40:45 2014][(none)]> INSTALL PLUGIN CONNECT SONAME 'ha_connect';
Query OK, 0 rows affected (0.00 sec)
mysql root@mariadb-10.0.7:[Wed Jan 29 09:44:56 2014][(none)]> pager grep CONNECT
PAGER set to 'grep CONNECT'
mysql root@mariadb-10.0.7:[Wed Jan 29 09:45:24 2014][(none)]> show engines;
+--------------------+---------+--------------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                            | Transactions | XA   | Savepoints |
+--------------------+---------+--------------------------------------------------------------------+--------------+------+------------+
| CSV                | YES     | CSV storage engine                                                 | NO           | NO   | NO         |
| MRG_MyISAM         | YES     | Collection of identical MyISAM tables                              | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                              | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears)     | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables          | NO           | NO   | NO         |
| CONNECT            | YES     | Management of External Data (SQL/MED), including many file formats | NO           | NO   | NO         |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys         | YES          | YES  | YES        |
| ARCHIVE            | YES     | Archive storage engine                                             | NO           | NO   | NO         |
| FEDERATED          | YES     | FederatedX pluggable storage engine                                | YES          | NO   | YES        |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                                 | NO           | NO   | NO         |
| Aria               | YES     | Crash-safe tables with MyISAM heritage                             | NO           | NO   | NO         |
| CASSANDRA          | YES     | Cassandra storage engine                                           | NO           | NO   | NO         |
+--------------------+---------+--------------------------------------------------------------------+--------------+------+------------+
12 rows in set (0.00 sec)

Now, sqlite3
UnixODBC was installed along with the MariaDB-connect-engine package, but I was not a able to find SQLite UnixODBC driver installed. Neither I was able to get if from the Fedora repos.
Checking for the http://www.unixodbc.org/drivers.html I ended up with compiling the SQLite ODBC Driver from http://www.ch-werner.de/sqliteodbc/

The instructions are good enough for me:
1. get the source from

$ wget http://www.ch-werner.de/sqliteodbc/sqliteodbc-0.996.tar.gz

2. Untar it :

$ tar xvf sqliteodbc-0.996.tar.gz

3. go to the source directory:

$ cd sqliteodbc-0.996

4. compile it

$ ./configure
..
...
configure: WARNING: SQLite4 header file and source not found
configure: error: No usable SQLite header/library on this system

4.1 In case you get the No usable SQLite header/library error, installs the sqlite-devel package

$ yum install sqlite-devel
sqlite-devel.x86_64 0:3.6.20-1.el6 will be installed

4.2 run configure again

$ ./configure
..
...
checking for ODBC headers and libraries... no
configure: error: ODBC header files and/or libraries not found

4.3 In case you get error: ODBC header files and/or libraries not found, install the unixODBC-devel package:

$ yum install unixODBC-devel
Package unixODBC-devel.x86_64 0:2.2.14-12.el6_3 will be installed

4.4 run configure again:

$ ./configure
make 
make install

5. Check the installed ODBC drivers:

$ odbcinst -q -d
[PostgreSQL]
[MySQL]
$ cat /etc/odbcinst.ini
# Example driver definitions

# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[PostgreSQL]
Description     = ODBC for PostgreSQL
Driver          = /usr/lib/psqlodbc.so
Setup           = /usr/lib/libodbcpsqlS.so
Driver64        = /usr/lib64/psqlodbc.so
Setup64         = /usr/lib64/libodbcpsqlS.so
FileUsage       = 1


# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[MySQL]
Description     = ODBC for MySQL
Driver          = /usr/lib/libmyodbc5.so
Setup           = /usr/lib/libodbcmyS.so
Driver64        = /usr/lib64/libmyodbc5.so
Setup64         = /usr/lib64/libodbcmyS.so
FileUsage       = 1

6. Install the sqlite3 odbc driver:

$ nano /etc/odbcinst.ini
# Example driver definitions

# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[PostgreSQL]
Description     = ODBC for PostgreSQL
Driver          = /usr/lib/psqlodbc.so
Setup           = /usr/lib/libodbcpsqlS.so
Driver64        = /usr/lib64/psqlodbc.so
Setup64         = /usr/lib64/libodbcpsqlS.so
FileUsage       = 1


# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[MySQL]
Description     = ODBC for MySQL
Driver          = /usr/lib/libmyodbc5.so
Setup           = /usr/lib/libodbcmyS.so
Driver64        = /usr/lib64/libmyodbc5.so
Setup64         = /usr/lib64/libodbcmyS.so
FileUsage       = 1

[SQLite]
Description=SQLite ODBC Driver
Driver=/usr/local/lib/libsqliteodbc.so
Setup=/usr/local/lib/libsqliteodbc.so
Threading=2
 
$ odbcinst -q -d
[PostgreSQL]
[MySQL]
[SQLite]

So the SQLite ODBC driver was installed.

In a view to trace the CONNECT engine , its good to create connect.ini file in the mysql directory

$ cat /var/lib/mysql/connect.ini 
[CONNECT]
Trace=2

The CONNECT engine errors will be in the mysql error.log, in my case mariadb-10.0.7.err

How to create a MySQL table using sqlite3 database?
create the sqlite3 table :

root@mariadb-10.0.7:[Wed Jan 29 10:57:39][/usr/lib64/mysql]$ sqlite3 maria-sqlite3.db
SQLite version 3.6.20
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE DEPARTMENT(
   ...>     ID INT PRIMARY KEY      NOT NULL,
   ...>     DEPT           CHAR(50) NOT NULL,
   ...>     EMP_ID         INT      NOT NULL
   ...>  );
sqlite> .tables
DEPARTMENT
sqlite> insert into DEPARTMENT (ID,DEPT,EMP_ID) values(1,'sales',1);
sqlite> insert into DEPARTMENT (ID,DEPT,EMP_ID) values(2,'sales',2);
sqlite> insert into DEPARTMENT (ID,DEPT,EMP_ID) values(3,'sales',3);
sqlite> insert into DEPARTMENT (ID,DEPT,EMP_ID) values(4,'marketing',4);
sqlite> insert into DEPARTMENT (ID,DEPT,EMP_ID) values(5,'marketing',5);

note,  its in /usr/lib64/mysql
its good to place the database in a place where the mysql user can read/write it.
root@mariadb-10.0.7:[Wed Jan 29 11:04:14][/usr/lib64/mysql]$ mv maria-sqlite3.db /tmp/
root@mariadb-10.0.7:[Wed Jan 29 11:04:20][/usr/lib64/mysql]$ chmod 0777 /tmp/maria-sqlite3.db
root@mariadb-10.0.7:[Wed Jan 29 11:07:26][/usr/lib64/mysql]$ mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.0.7-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql root@mariadb-10.0.7:[Wed Jan 29 11:07:27 2014][(none)]> create database sqlite3;
Query OK, 1 row affected (0.00 sec)

mysql root@mariadb-10.0.7:[Wed Jan 29 11:07:39 2014][(none)]> use sqlite3                                                                                                                            Database changed
mysql root@mariadb-10.0.7:[Wed Jan 29 11:07:57 2014][sqlite3]> create table my_dept engine=CONNECT table_type=ODBC tabname='DEPARTMENT' Connection='Driver=SQLite;Database=/tmp/maria-sqlite3.db;version=3;';
Query OK, 0 rows affected (0.13 sec)

mysql root@mariadb-10.0.7:[Wed Jan 29 11:08:03 2014][sqlite3]> select * from my_dept;
+----+-----------+--------+
| ID | DEPT      | EMP_ID |
+----+-----------+--------+
|  1 | sales     |      1 |
|  2 | sales     |      2 |
|  3 | sales     |      3 |
|  4 | marketing |      4 |
|  5 | marketing |      5 |
+----+-----------+--------+
5 rows in set (0.00 sec)

mysql root@mariadb-10.0.7:[Wed Jan 29 11:08:41 2014][sqlite3]> show create table my_dept \G
*************************** 1. row ***************************
       Table: my_dept
Create Table: CREATE TABLE `my_dept` (
  `ID` int(9) NOT NULL,
  `DEPT` varchar(50) NOT NULL,
  `EMP_ID` int(9) NOT NULL
) ENGINE=CONNECT DEFAULT CHARSET=latin1 CONNECTION='Driver=SQLite;Database=/tmp/maria-sqlite3.db;version=3;' `TABLE_TYPE`='ODBC' `TABNAME`='DEPARTMENT'
1 row in set (0.00 sec)

In case you have the CONNECT engine trace set to 2, you will see in the mysql error log something like:

 DBMS: SQLite, Version: 3.6.20, rc=0
ODBCColumns: max=4096 len=0,0,0
Getting col results ncol=12
Columns: NBCOL=12 NBLIN=3
s_init: CREATE TABLE whatever (`ID` INT(9) NOT NULL,`DEPT` VARCHAR(50) NOT NULL,`EMP_ID` INT(9) NOT NULL) TABLE_TYPE='ODBC' TABNAME='DEPARTMENT' CONNECTION='Driver=SQLite;Database=/tmp/maria-sqlite3.db;version=3;'
ColDB: am=100 colname=ID tabname=my_dept num=0
cdp(1).Name=ID cp=(nil)
 making new ODBCCOL C1 ID at 0x7f1259400420
colp=0x7f1259400420
ColDB: am=100 colname=DEPT tabname=my_dept num=0
cdp(2).Name=DEPT cp=(nil)
 making new ODBCCOL C2 DEPT at 0x7f12594004b8
colp=0x7f12594004b8
ColDB: am=100 colname=EMP_ID tabname=my_dept num=0
cdp(3).Name=EMP_ID cp=(nil)
 making new ODBCCOL C3 EMP_ID at 0x7f1259400550
colp=0x7f1259400550
....
DBMS: SQLite, Version: 3.6.20, rc=0
Prepare hstmt=0x7f12ebc59f00 INSERT INTO DEPARTMENT (ID, DEPT, EMP_ID) VALUES (?,?,?)
 setting INTEGER to: 1
 setting INTEGER to: 1
S1000: [unixODBC][SQLite]attempt to write a readonly database (8), Native=8
ODBC CloseDB: closing my_dept

In case you get read only table :

mysql root@mariadb-10.0.7:[Wed Jan 29 11:09:51 2014][sqlite3]> insert into my_dept (ID,DEPT,EMP_ID) values(6,'IT-DBA',6);
ERROR 1296 (HY000): Got error 122 '[unixODBC][SQLite]attempt to write a readonly database (8)' from CONNECT

It seems you have your SQLite db in a folder where your database user /mysql/ must have write permissions,but does not.
Most probably you have selinux activated.
How to fix that without disabling the selinux? The best way is move the SQLite db file to the mysql data directory : /var/lib/mysql/, or to create a separated directory where mysql shell user has write permissions.

mysql root@mariadb-10.0.6:[Fri Jan 31 12:06:54 2014][sqlite3]> insert into my_dept (ID,DEPT,EMP_ID) values (6,'mysql',6);
ERROR 1296 (HY000): Got error 122 '[unixODBC][SQLite]attempt to write a readonly database (8)' from CONNECT
mysql root@mariadb-10.0.6:[Fri Jan 31 12:07:27 2014][sqlite3]> drop table my_dept;
Query OK, 0 rows affected (0.00 sec)

Move the db file to MySQL data directory :

root@mariadb-10.0.6:[Fri Jan 31 12:09:15][/var/lib/mysql]$ cp -rp /tmp/maria-sqlite3.db  ./
mysql root@mariadb-10.0.6:[Fri Jan 31 12:08:17 2014][sqlite3]> create table my_dept_new  engine=CONNECT table_type=ODBC tabname='DEPARTMENT'  Connection='Driver=SQLite;Database=/var/lib/mysql/maria-sqlite3.db;version=3;';
Query OK, 0 rows affected (0.11 sec)

mysql root@mariadb-10.0.6:[Fri Jan 31 12:09:57 2014][sqlite3]> select * from my_dept_new;
+----+------------+--------+
| ID | DEPT       | EMP_ID |
+----+------------+--------+
|  1 | sales      |      1 |
|  2 | sales      |      2 |
|  3 | sales      |      3 |
|  4 | marketing  |      4 |
|  5 | marketing  |      5 |
|  7 | IT-SUPPORT |      7 |
+----+------------+--------+
6 rows in set (0.01 sec)

mysql root@mariadb-10.0.6:[Fri Jan 31 12:10:02 2014][sqlite3]> insert into my_dept_new (ID,DEPT,EMP_ID) values (6,'mysql',6);                                                                        Query OK, 1 row affected (0.08 sec)

mysql root@mariadb-10.0.6:[Fri Jan 31 12:10:07 2014][sqlite3]> select * from my_dept_new;
+----+------------+--------+
| ID | DEPT       | EMP_ID |
+----+------------+--------+
|  1 | sales      |      1 |
|  2 | sales      |      2 |
|  3 | sales      |      3 |
|  4 | marketing  |      4 |
|  5 | marketing  |      5 |
|  7 | IT-SUPPORT |      7 |
|  6 | mysql      |      6 |
+----+------------+--------+
7 rows in set (0.01 sec)

So now we have R/W sqlite3 table managed by MariaDB 10.0.7