bash

Parallel load a mysqldump

< class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-teaser">

pload.sh

#!/usr/bin/env bash

[[ $# -ne 6 ]] && echo "$(basename $0) <dumpfile> <# of splits/chunks. max 20> <# of mysql clients> <db user> <db password> <db schema>" && exit 1
user=$4
password=$5
schema=$6

#add multiple hosts if available
declare -a hosts=('127.0.0.1' '127.0.0.1')
MYSQL_CMD=mysql

dumpfile=$1
splits=$2
clients=$3

declare -a splitfiles=('xaa'  'xab'  'xac'  'xad'  'xae'  'xaf'  'xag'  'xah'  'xai'  'xaj'  'xak'  'xal' 'xam'  'xan'  'xao'  'xap'  'xaq'  'xar'  'xas'  'xat')

# split file

Tags: 

Add MongoDB repo for apt and/or yum (bash)

< class="field field-name-body field-type-text-with-summary field-label-hidden view-mode-teaser">
#!/bin/bash

[ `whoami` != "root" ] && echo "Do: sudo $(basename $0)" && exit 1

install=$1

dist="Unknown"
regex_lsb="Description:[[:space:]]*([^ ]*)"
regex_etc="/etc/(.*)[-_]"

do_lsb () {
lsb=`lsb_release -d`
[[ $lsb =~ $regex_lsb ]] && dist=${BASH_REMATCH[1]} ; return 0
return 1
}

do_release_file () {
etc_files=`ls /etc/*[-_]{release,version} 2>/dev/null`
for file in $etc_files
do
  [[ $file =~ $regex_etc ]] && dist=${BASH_REMATCH[1]} ; break
done
}

if [ `command -v lsb_release` ]
then
  do_lsb
  [ $? -ne 0 ] && do_release_file
else

Tags: 

Subscribe to bash