Labels

freebsd (12) AWS (9) linux (8) mysql (8) EC2 (7) auto-scaling (7) php (7) unix (7) howto (5) amazon (4) example (4) php5.3 (4) /usr/ports (3) backup (3) bash (3) cloud (3) cloudwatch (3) ffmpeg (3) loadbalancer (3) mycld (3) patch (3) php53 (3) scaling (3) scalr (3) security (3) spot instances (3) sql (3) tutorial (3) AWSSDKforPHP (2) CentOS (2) WSDL (2) ZEND framework (2) alarms (2) bug (2) cache (2) cloudfusion (2) console (2) exploit (2) fileinfo (2) fix (2) lauchconfig (2) mysqldump (2) mysqlse (2) php-fpm (2) policies (2) ports (2) portupgrade (2) redhat (2) sed (2) shell (2) sphinx (2) sphinxse (2) video (2) x264 (2) /etc/motd (1) 9.x (1) ELB (1) MP4Box (1) MySQL status codes HY000 sqlstate sql states (1) OS (1) RFC (1) SIP (1) URI (1) alias (1) apache (1) banner (1) big databases (1) blog (1) bsd (1) bugtraq (1) checklist (1) chkconfig (1) clean (1) cleaning (1) clear (1) code (1) conf (1) configs (1) configuration (1) content type (1) converting (1) core (1) cron (1) cve (1) database (1) debian (1) deinterlasing (1) dependency (1) disable (1) dump (1) editor (1) editors (1) email (1) encoding char utf8 latin1 script linux bash (1) error (1) escaping (1) exim (1) expat (1) exploits (1) extensions (1) faac (1) fastcgi (1) feed (1) figlet (1) fps (1) freebsd-update (1) freeswitch (1) fresh installation (1) gcc (1) geo (1) gop (1) gpac (1) grep (1) h.264 (1) h264 (1) hitrate (1) hostname (1) incremental (1) init (1) init.d (1) innobackupex (1) ivp6 (1) keyint_min (1) libx264 (1) libxml2 (1) list (1) mail (1) make (1) map (1) maxmind (1) mencoder (1) mime (1) mindmeister (1) mindmeister.com (1) mp4 (1) mplayer (1) mta queue (1) mysql charset (1) mysql charset encoding char utf8 latin1 script linux bash (1) networking (1) nginx (1) nmap (1) optimization (1) paranoia (1) paranoiac (1) percona (1) performance (1) portdowngrade (1) portsnap (1) postgre (1) postgres (1) postgresql (1) presets (1) putty (1) query cache (1) rc (1) rc.conf (1) rc.d (1) remote (1) restore (1) rhel (1) rhel5 (1) script (1) scrubing (1) seclist (1) seclist.org (1) seek (1) seeking (1) segfault (1) slow loris (1) slowloris (1) smtp (1) software (1) sphinxsearch (1) stty (1) terminal (1) time (1) timezone (1) tmp (1) transcoding (1) tty (1) update (1) video transcoding (1) vulnerabilities (1) wal-e (1) web (1) web servers (1) wordpress (1) x86_64 (1) xtrabackup (1) yum (1) zend (1)

Monday, 20 December 2010

php.ini & uploads

memory_limit > post_max_size > upload_max_filesize

-- vladget

Thursday, 16 December 2010

FREEBSD AT AWS EC2 LIVES !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

YEAH!!!!
Today's Topics:
...
 27. FreeBSD/EC2 lives! (Colin Percival)
 28. Re: FreeBSD/EC2 lives! (Aleksey Ovcharenko)
 29. Re: FreeBSD/EC2 lives! (Colin Percival)
... 
 31. Re: FreeBSD/EC2 lives! (Luke Marsden)
...
 33. Re: FreeBSD/EC2 lives! (Colin Percival)
 34. Re: FreeBSD/EC2 lives! (G?t Andr?s)
 ...
I've checked EC2 AMIs and found it there:
ami-c01aeca9 - 118940168514/FreeBSD/EC2 9.0-CURRENT 2010-12-12


-- vladget

Saturday, 11 December 2010

Amazon bring DNS service to cloud! route53

Next day after I've done with setup of BIND server at one of my EC2 instance, amazon run route53..
No comments!

There are web-based GUI managment tool for aws route53 - http://www.dns30.com/ - really reactive market trend following.... ))

-- vladget

Monday, 4 October 2010

Removing video noize on video seek (progressive download)

There are two rules:

1. IF FPS = 29,97 -> FPS = 30, GOP = 10*FPS, keyint_min = FPS
2. refs=1 (you can change it at x264 preset)

Restoring a single table from mysqldump

So... Let's run!

# gzip -cd mysqldatabase.sql.gz > mysqldatabase.sql
# sed -n "/^-- Table structure for table \`your_mysql_table\`/,/^-- Table structure for table/p" mysqldatabase.sql > your_mysql_table.sql

Based on this great article


-- vladget

Saturday, 10 July 2010

updating MySQL 5.0.x with SphinxSE as storage engine on RHEL 5. How-To. Tutorial

0. !!! Dump all databases: 
mkdir -p /root/backups/mysql && \
mysqldump --single-transaction --all-databases > /root/backups/mysql/all-databases`date +%Y%m%d%H%M`.sql
1. Installing dependencies:
yum -y install bison patch automake libtool wget
2 .Getting sources:
cd ~ && mkdir src && cd src
wget http://downloads.mysql.com/archives/mysql-5.0/mysql-5.0.91.tar.gz
wget http://www.sphinxsearch.com/downloads/sphinx-0.9.9-rc2.tar.gz
tar xzf mysql-5.0.91.tar.gz
tar xzf sphinx-0.9.9-rc2.tar.gz

3. Compiling MySQL with SphinxSE:
cp ./sphinx-0.9.9/mysqlse/sphinx.5.0.37.diff ./mysql-5.0.91/
cd ./mysql-5.0.91 && patch -p1 < sphinx.5.0.37.diff
sh BUILD/autorun.sh
cp -R ~/src/sphinx-0.9.9/mysqlse ~/src/mysql-5.0.91/sql/sphinx
./configure \
--build=x86_64-redhat-linux-gnu \
--host=x86_64-redhat-linux-gnu \
--target=x86_64-redhat-linux-gnu \
--program-prefix= \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
--datadir=/usr/share \
--includedir=/usr/include \
--libdir=/usr/lib64 \
--libexecdir=/usr/libexec \
--localstatedir=/var \
--sharedstatedir=/usr/com \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--with-readline \
--with-openssl \
--without-debug \
--enable-shared \
--with-bench \
--localstatedir=/var/lib/mysql \
--with-unix-socket-path=/var/lib/mysql/mysql.sock \
--with-mysqld-user=mysql \
--with-innodb \
--with-berkeley-db \
--with-sphinx-storage-engine \
--enable-local-infile \
--enable-largefile \
--enable-thread-safe-client \
--disable-dependency-tracking \
--with-named-curses-libs=/usr/lib64/libncurses.so.5 && make

4. Stoping & remove current MySQL:
service mysqld stop
yum list | grep mysql
yum erase mysql-server.x86_64

5. Install MySQL with SphinxSE:
sudo make install
6. Start MySQL:
mkdir -p /var/run/mysqld/
chown -R mysql:mysql /var/run/mysqld/
vi  /etc/rc.d/init.d/mysqld
#!/bin/bash
#
# mysqld        This shell script takes care of starting and stopping
#               the MySQL subsystem (mysqld).
#
# chkconfig: - 64 36
# description:  MySQL database server.
# processname: mysqld
# config: /etc/my.cnf
# pidfile: /var/run/mysqld/mysqld.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network


prog="MySQL"

# extract value of a MySQL option from config files
# Usage: get_mysql_option SECTION VARNAME DEFAULT
# result is returned in $result
# We use my_print_defaults which prints all options from multiple files,
# with the more specific ones later; hence take the last match.
get_mysql_option(){
        result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1`
        if [ -z "$result" ]; then
            # not found, use default
            result="$3"
        fi
}

get_mysql_option mysqld datadir "/var/lib/mysql"
datadir="$result"
get_mysql_option mysqld socket "$datadir/mysql.sock"
socketfile="$result"
get_mysql_option mysqld_safe log-error "/var/log/mysqld.log"
errlogfile="$result"
get_mysql_option mysqld_safe pid-file "/var/run/mysqld/mysqld.pid"
mypidfile="$result"

start(){
        touch "$errlogfile"
        chown mysql:mysql "$errlogfile"
        chmod 0640 "$errlogfile"
        [ -x /sbin/restorecon ] && /sbin/restorecon "$errlogfile"
        if [ ! -d "$datadir/mysql" ] ; then
            action $"Initializing MySQL database: " /usr/bin/mysql_install_db --datadir="$datadir" --user=mysql
            ret=$?
            chown -R mysql:mysql "$datadir"
            if [ $ret -ne 0 ] ; then
                return $ret
            fi
        fi
        chown mysql:mysql "$datadir"
        chmod 0755 "$datadir"
        # Pass all the options determined above, to ensure consistent behavior.
        # In many cases mysqld_safe would arrive at the same conclusions anyway
        # but we need to be sure.
        /usr/bin/mysqld_safe   --datadir="$datadir" --socket="$socketfile" \
                --log-error="$errlogfile" --pid-file="$mypidfile" \
                --user=mysql >/dev/null 2>&1 &
        ret=$?
        # Spin for a maximum of N seconds waiting for the server to come up.
        # Rather than assuming we know a valid username, accept an "access
        # denied" response as meaning the server is functioning.
        if [ $ret -eq 0 ]; then
            STARTTIMEOUT=30
            while [ $STARTTIMEOUT -gt 0 ]; do
                RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` && break
                echo "$RESPONSE" | grep -q "Access denied for user" && break
                sleep 1
                let STARTTIMEOUT=${STARTTIMEOUT}-1
            done
            if [ $STARTTIMEOUT -eq 0 ]; then
                    echo "Timeout error occurred trying to start MySQL Daemon."
                    action $"Starting $prog: " /bin/false
                    ret=1
            else
                    action $"Starting $prog: " /bin/true
            fi
        else
            action $"Starting $prog: " /bin/false
        fi
        [ $ret -eq 0 ] && touch /var/lock/subsys/mysqld
        return $ret
}

stop(){
        MYSQLPID=`cat "$mypidfile"  2>/dev/null `
        if [ -n "$MYSQLPID" ]; then
            /bin/kill "$MYSQLPID" >/dev/null 2>&1
            ret=$?
            if [ $ret -eq 0 ]; then
                STOPTIMEOUT=60
                while [ $STOPTIMEOUT -gt 0 ]; do
                    /bin/kill -0 "$MYSQLPID" >/dev/null 2>&1 || break
                    sleep 1
                    let STOPTIMEOUT=${STOPTIMEOUT}-1
                done
                if [ $STOPTIMEOUT -eq 0 ]; then
                    echo "Timeout error occurred trying to stop MySQL Daemon."
                    ret=1
                    action $"Stopping $prog: " /bin/false
                else
                    rm -f /var/lock/subsys/mysqld
                    rm -f "$socketfile"
                    action $"Stopping $prog: " /bin/true
                fi
            else
                action $"Stopping $prog: " /bin/false
            fi
        else
            ret=1
            action $"Stopping $prog: " /bin/false
        fi
        return $ret
}

restart(){
    stop
    start
}

condrestart(){
    [ -e /var/lock/subsys/mysqld ] && restart || :
}

# See how we were called.
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    status mysqld
    ;;
  restart)
    restart
    ;;
  condrestart)
    condrestart
    ;;
  *)
    echo $"Usage: $0 {start|stop|status|condrestart|restart}"
    exit 1
esac

exit $?

chmod 755 /etc/rc.d/init.d/mysqld
chkconfig mysqld on
service mysqld start
7. Checking:

echo "show engines" | mysql | grep Sphinx
SPHINX YES Sphinx storage engine 0.9.9

Other info:
http://www.sphinxsearch.com/docs/current.html#sphinxse


-- vladget

Wednesday, 23 June 2010

Correct FreeBSD rc script for php-fpm

# cat /usr/local/etc/rc.d/php-fpm
#!/bin/sh

# PROVIDE: php-fpm
# REQUIRE: NETWORKING SERVERS
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable php-fpm:
# php_fpm_enable (bool):      Set to "NO" by default.
#                             Set it to "YES" to enable php-fpm
# php_fpm_config (str):       Set to "" by default.
#                             Define your php-fpm configuration file here.

. /etc/rc.subr

name="php_fpm"
rcvar=`set_rcvar`

load_rc_config $name

: ${php_fpm_enable="NO"}
: ${php_fpm_pidfile="/var/run/php-fpm.pid"}
: ${php_fpm_config="/usr/local/etc/php-fpm.conf"}
: ${php_fpm_flags="--fpm"}

command="/usr/local/bin/php-fpm"
pidfile=${php_fpm_pidfile}
reload_precmd="php_fpm_prereload"
quit_cmd="php_fpm_quit"

[ -n "$php_fpm_config" ] && php_fpm_flags="$php_fpm_flags --fpm-config $php_fpm_config"

php_fpm_prereload()
{
        sig_reload=USR2
}

php_fpm_quit()
{
        sig_stop=QUIT
        run_rc_command stop
}

extra_commands="reload quit"
run_rc_command "$1"

-- vladget

Thursday, 17 June 2010

Compiling MySQL 5.0.x with SphinxSE (as Engine) on FreeBSD/Linux - tutorial / copy-paste how to

FreeBSD: 
# Install dependencies (bison, patch, automake, libtool), etc:
portsnap fetch update
cd /usr/ports/devel/bison && make install clean distclean
cd /usr/ports/devel/patch && make install clean distclean
cd /usr/ports/devel/automake110 && make install clean distclean
cd /usr/ports/devel/libtool22 && make install clean distclean
cd /usr/ports/ftp/wget && make install clean distclean


# Get sources:
mkdir -p /mysql_new/src && cd /mysql_new/src
wget "http://sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz"
wget "http://downloads.mysql.com/archives/mysql-5.0/mysql-5.0.91.tar.gz"


# Extract sorces:
tar zxpf sphinx-0.9.9.tar.gz
tar zxpf mysql-5.0.91.tar.gz


# Patching MySQL sources:
cd mysql-5.0.91 && patch -p1 < ../sphinx-0.9.9/mysqlse/sphinx.5.0.37.diff
/bin/sh BUILD/autorun.sh

# Copy Sphinx sources to MySQL sources:
mkdir sql/sphinx && cp ../sphinx-0.9.9/mysqlse/* sql/sphinx

# Configure and make MySQL:
# Add this variables to make.conf
# and DONT FORGET REMOVE its from make.conf!

cat /etc/make.conf
CC='cc'
CFLAGS=' -DDBUG_OFF -O2 -pipe  -fno-strict-aliasing  '
CXX='c++'
CXXFLAGS=' -DDBUG_OFF -O2 -pipe -fno-strict-aliasing -O2 -pipe  -fno-strict-aliasing -felide-constructors -fno-rtti -fno-exceptions -fno-implicit-templates -fno-exceptions -fno-rtti -DMYSQLD_NET_RETRY_COUNT=1000000'
LDFLAGS=''
ASFLAGS=''

./configure \
--localstatedir=/var/db/mysql \
--without-debug \
--without-readline \
--without-libedit \
--without-bench \
--without-extra-tools \
--with-libwrap \
--with-low-memory \
--with-sphinx-storage-engine \
--with-comment=FreeBSD && make
 

# Install MySQL:
make install

# Check it:
mysql> show engines\G
...
*************************** 9. row ***************************
 Engine: SPHINX
Support: YES
Comment: Sphinx storage engine 0.9.9
...


# Recommend Readings:
Installing SphinxSE



Linux:
MySQL: How do you enable sphinxse (Sphinx Storage Engine) in your mysql installation?


-- FreeBSDer

Tuesday, 13 April 2010

ffmpeg: transcoding video for mp4 seek

ffmpeg -i INPUT.MOV \
-acodec libfaac -ab 96k -ar 44100 \
-vcodec libx264 -deinterlace -pix_fmt yuv420p \
-b 1500k -s 920Ñ…518 -aspect 16:9 \
-r 30 -vpre hq-vladget -crf 22 \
OUTPUT.mp4 \

mp4box -inter 5000 OUTPUT*.mp4

~/.ffmpeg/libx264-hq-vladget.ffpreset:
coder=1
flags=+loop
cmp=+chroma
partitions=+parti8x8+parti4x4+partp8x8+partb8x8
me_method=umh
subq=8
me_range=16
g=250
keyint_min=25
sc_threshold=40
i_qfactor=0.71
b_strategy=2
qcomp=0.6
qmin=10
qmax=51
qdiff=4
bf=4
refs=4
directpred=3
trellis=1
flags2=+bpyramid+wpred+mixed_refs+dct8x8+fastpskip

php5-ffmpeg

Have to fix pathes to *.h @:

/usr/local/include/ffmpeg/avcodec.h:30
/usr/local/include/ffmpeg/avformat.h:47
/usr/local/include/ffmpeg/avio.h:33
/usr/local/include/ffmpeg/swscale.h:30

Tuesday, 30 March 2010

GeoIP module for Nginx

Installing GeoIP lib:
# cd /usr/ports/net/GeoIP && make install clean

Checking nginx for geoip module:
# nginx -V | grep "--with-http_geoip_module"

Downloading MaxMind Geo database:
# cd /usr/local/etc/nginx
# wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
# gzip -cd GeoIP.dat.gz > GeoIP.dat

Enabling GeoIP module at nginx.conf:
http {
geoip_country /usr/local/etc/nginx/GeoIP.dat;
...

Adding fastcgi_params for provide GEOIP variable to fast-cgi server:
fastcgi_param GEOIP_COUNTRY_CODE $geoip_city_country_code;

# /usr/local/etc/rc.d/nginx reload

MANs:
http://sysoev.ru/nginx/docs/http/ngx_http_geoip_module.html
http://www.maxmind.com/app/c
http://www.maxmind.com/app/geolitecountry

--
FreeBSDer

Monday, 29 March 2010

PHP (php) segfault fix (wrong libxml2 version)

Bug & solution:
http://forums.freebsd.org/archive/index.php/t-8965.html

HOW-TO:
# portdowngrade -s:pserver:anoncvs@anoncvs.fr.FreeBSD.org:/home/ncvs textproc/libxml2 -o [password is anoncvs]
# portsdb -Uu
# portupgrade -f libxml2

--
FreeBSDer

Wednesday, 17 February 2010

Checklist for Resetting a Messed Up Terminal

This is just quick headnotes from Chapter 42 of great book Unix Power Tools which I've tested on FreeBSD:

Cleaning:
# clear or [Ctrl-l]

General trick:
(this trick helps you fix majority of the most common problems like backspace doesn't work, ^M, stairs from new lines, etc...)
# [CTRL-j] reset [CTRL-j]


P.S. # man stty
--
FreeBSDer

Monday, 15 February 2010

Deinterlasing @ mencoder

The available deinterlacers are:
-vf lavcdeint
-vf kerndeint
-vf filmdint
-vf pp=lb
-vf pp=li
-vf pp=ci
-vf pp=md
-vf pp=fd

Wednesday, 3 February 2010

Cool Tool from ports

# portsnap fetch update
# cd /usr/ports/misc/figlet && make install clean
# figlet Cool Tool

____            _   _____           _
 / ___|___   ___ | | |_   _|__   ___ | |
| |   / _ \ / _ \| |   | |/ _ \ / _ \| |
| |__| (_) | (_) | |   | | (_) | (_) | |
 \____\___/ \___/|_|   |_|\___/ \___/|_|

# echo Creating cool banner for your host
# mv /etc/motd /etc/motd.`date "+%Y%m%d"` && figlet -c `hostname -s` > /etc/motd

--
FreeBSDer

Monday, 1 February 2010

Remove All messages From the Exim Mail Queue

Queue list:
exim -bp

To remove a message:
exim -Mrm {message-id}

To remove all messages:
exim -bp | exiqgrep -i | xargs exim -Mrm


--
FreeBSDer

Wednesday, 6 January 2010

Removing comments/annotations from configuration files

Tested examples:
grep -v "^;" /usr/local/etc/php.ini | sed -e '/^$/d'
grep -v "^#" /usr/local/etc/exim/configure | grep -v "^ #" | sed -e '/^$/d'

--
FreeBSDer