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)

Tuesday, 14 August 2012

OpDemand. One another cloud managment system.

OpDemand
Of course I never use it, but I like they homepage design. :)




Tuesday, 31 July 2012

"IfIsEvil" - Nice article describing why you have not use IF at you nginx configuration

IfIsEvil:
Directive if has problems when used in location context, in some cases it doesn't do what you expect but something completely different instead. In some cases it even segfaults. It's generally a good idea to avoid it if possible...

Friday, 22 June 2012

Amazon AWS Elastic load balancer and Apache slowloris

I have just  investigated what Amazon AWS Elastic load balancer helps to protect Apache from "slowloris" DDoS attacks...

How it was tested:
I've use this tool for test.
The first test direct to ec2 instance and the second one to elb with one ec2 instance registered on it...

Saturday, 9 June 2012

Finally Amazon implemented my idea: using Spot Instances for Auto Scaling!

"This release of Amazon Elastic Compute Cloud (Amazon EC2) introduces several new Spot Instance features that make it easier to get started and handle the potential of interruption. The new features include integration with Auto Scaling and AWS CloudFormation.
 ..."

Release Notes: http://aws.amazon.com/releasenotes/0814290369059292?ref_=pe_12300_24358190
Docs: http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/spot-launching-autoscaling.html


Wednesday, 4 April 2012

[SOLVED] native fileinfo (version 1.0.2-dev) fails at php 5.3.X

Zend exception:

finfo_open() [function.finfo-open]: Warning: description `8-bit ISDN mu-law compressed (CCITT G.721 ADPCM voice data enco' truncated
/mnt/www/zend/Zend/Validate/File/MimeType.php on line 199
#0 [internal function]: exceptionErrorHandler(8, 'finfo_open() [<...', '/mnt/www/zend/Z...', 199, Array)

I thought it was Zend bug, but bug it native fileinfo extension...

test php script:

php
$finfo = finfo_open(FILEINFO_MIME, "/usr/share/file/magic"); // return mime type ala mimetype extension

if (!$finfo) {
    echo "Opening fileinfo database failed";
    exit();
}
?>

SOLUTION:
Just install fileinfo from pecl:


# cd /tmp# wget http://pecl.php.net/get/Fileinfo-1.0.4.tgz# tar -xzvf Fileinfo-1.0.4.tgz# phpize && ./configure && make# sudo make install 



-- vladget

Thursday, 15 March 2012

Friday, 17 February 2012

Automatic incremental MySQL backup with xtrabackup.

#!/bin/bash

now=`date +%Y-%m-%d_%H-%M-%S`
backup_directory="/media/data/backup"
current_backup=$backup_directory/$now"_full"

logfile="/var/log/db-backup/"$now"_full"

mysql_user="root"
mysql_pass=""


echo "========================================="
echo "        MySQL Data Backup (Full)"
echo "========================================="

#perform full backup
innobackupex --ibbackup=xtrabackup_55 --parallel=4 --user=$mysql_user --password=$mysql_pass --no-timestamp $current_backup 2> $logfile

# see if the backup completed sucsessfully
if ! tail $logfile -n 1 | grep completed.OK
then
        rm -R $current_backup
        echo "\nERROR: backup failed! (log: "$logfile")"
  exit 1
fi

echo $current_backup > $backup_directory/last_backup

echo "Backup Completed OK!"

Monday, 13 February 2012

MySQL: increasing query cache hit rate.
Part 1: Expecting SQL queries.


The most common mistakes:


1. Using different cases

Incoming queries are compared to those in the query cache before parsing, so the following two queries are regarded as different by the query cache:
    SELECT * FROM tbl_name
    Select * from tbl_name

Advice: use database abstraction layer or stick to single coding style.


2. Call to date/time functions at database side

A query cannot be cached if it contains any of the functions shown in the following list:
CONVERT_TZ() 
CURDATE() 
CURRENT_DATE() 
CURRENT_TIME() 
CURRENT_TIMESTAMP() 
CURTIME() 
NOW() 
SYSDATE() 
UNIX_TIMESTAMP() with no parameters 

Advice(UPDATED): Move date/time function to your application and cut off the seconds or/and  minutes  or/and hour part.
(If your database server and your application on the same, or both configured to same timezone, and using ntp servers).

3. Call to RAND(), FOUND_ROWS() functions at database side

Same for previos case: Queries which contain these function cannot be cached.

Advice: You could found "RAND()" analog at any programming language. Use SQL_CALC_FOUND_ROWS() function instead FOUND_ROWS()


4. Merging huge request with tables with high changing rate

If a table changes, all cached queries that use the table become invalid and are removed from the cache. This includes queries that use MERGE tables that map to the changed table. A table can be changed by many types of statements, such as INSERT, UPDATE, DELETE, TRUNCATE TABLE, ALTER TABLE, DROP TABLE, or DROP DATABASE.

Advice: Spit it to 2+ requests. 
Two queries(the first one which contains "huge part", but cached, and the second one for table with high change rate) will work faster then one merged.


-- Vladimir Getmanshchuk aka vladget

Friday, 27 January 2012

mycld: spotscale - autoscaling solution for Amazon EC2 based on Spot Instances.


I've commited new debuged version today.
Please review: http://code.google.com/p/mycld/source/browse/



My Clouding exp.: mycld: spotscale - autoscaling solution for Amazon...

My Clouding exp.: mycld: spotscale - autoscaling solution for Amazon...: mycld: spotscale - autoscaling solution for Amazon EC2 based on Spot Instances. I've commited new debuged version today. Please review:...

Monday, 23 January 2012

New version of mycld released!


New features:
- OOP
- Logger (see the log dir: tail -f /root/mycld/logs/*.log)
- implemented: all adjustment types, works with more then one elb, something else, i dont remember all :)
- fixed: a lot of bugs

How to disable IPv6 at FreeBSD 9.x


add to /etc/rc.conf:

# IPv6 Networking
ipv6_network_interfaces="none"          # Default is auto
ipv6_activate_all_interfaces="NO"       # this is the default
ip6addrctl_enable="NO"                  # New way to disable IPv6 support
ip6addrctl_policy="ipv4_prefer"         # Use IPv4 instead of IPv6


more info here

-- vladget (Vladimir Getmanshchuk)

Friday, 20 January 2012

NoSQL from AWS called "Dynamo". LOL.



Amazon DynamoDB - Internet-Scale Data Storage the NoSQL Way
Posted: 18 Jan 2012 09:32 AM PST
We want to make it very easy for you to be able to store any amount of semistructured data and to be able to read, write, and modify it quickly, efficiently, and with predictable performance. We don't want you to have to worry about servers, disks, replication, failover, monitoring, software installation, configuration, or updating, hardware upgrades, network bandwidth, free space, sharding, rearchitecting, or a host of other things that will jump up and bite you at the worst possible time.

We want you to think big, to dream big dreams, and to envision (and then build) data-intensive applications that can scale from zero users up to tens or hundreds of millions of users before you know it. We want you to succeed, and we don't want your database to get in the way. Focus on your app and on building a user base, and leave the driving to us.

Sound good?



from aws blog

Monday, 16 January 2012

NEW VERSION 0.0.6 RELEASED!
POST UPDATED!
AWS auto-scaling for EC2 spot-instances!
How to implement.


Requirements:
You must to have setup AWS auto-scaling or you have to setup it using this guide.
(btw. You need AWS Autoscaling CLI tools for setup your autoscaling.)

Make sure what your autoscalig configuration works correct on on-demand ec2 instances.
So your autoscaling configuration must have:
- lauch-config at least with options: --image-id value --instance-type value --group value[,value...] --key value, other options are optinal.
[--block-device-mapping "key1=value1,key2=value2..." ] 
- still did not implemented
!

- auto-scaling-group at least with options: --availability-zones value[,value...] --launch-configuration value --max-size value --min-size value --load-balancers value[, value]], other options are optinal.
[--desired-capacity value] [--grace-period value] [--health-check-type value][--placement-group value] [--vpc-zone-identifier value] -still did not implemented

- policies mandatory options: --auto-scaling-group --adjustment= --type --cooldown

- alarms: all except one: value of option: --dimension, can't be autoscaling metric like 
--dimensions "AutoScalingGroupName=MyAutoScalingGroup", because cloudwatch has no data for current scaling process.
I recommend You use loadbalancer metric, or use my common design for autoscaling: one on-demand instance at master role + scaleout  with spot-instance in slave role.

Also you need *nix like OS (FreeBSD, Linux, Mac OS X, etc) with:
 - PHP 5.3.x +
 - MySQL 5.x
 - AWSSDKforPHP (and all its dependents)
 - PEAR PHP Log

Installation:

1. Install dependencies

1.1 Make sure what PEAR has been installed and path included in include_path directive at your php.ini.
To adding directive to php.ini (where /usr/share/pear - path to you pear):

    # echo "include_path=\".:/usr/share/pear\"" >> /etc/php.ini

1.2 Discover pear channel and install AWSSDKforPHP(aka cloudfusion):

    # pear channel-discover pear.amazonwebservices.com
   
# pear install aws/sdk

1.3 Config SDK:

    # cp -Rp /usr/share/pear/AWSSDKforPHP/config-sample.inc.php ~/.aws/sdk/config.inc.php
   
# vim ~/.aws/sdk/config.inc.php (add your AWS security credentials to config)
   
# chmod 600 ~/.aws/sdk/config.inc.php

1.4. Install Log package from PEAR:

    # pear install Log

 

2. Install mycld

2.1 Get the mycld from code.google.com

    # svn checkout http://mycld.googlecode.com/svn/trunk ~/mycld

2.2 Create MySQL database

   # mysql -u root -p < ~/mycld/db.sql

2.3 Config mycld for accessing your MySQL

    # cd ~/mycld/conf/
   
# cp -Rp db.ini.sample db.ini
   
# vim db.ini (change your mysql user and/or password)

Running:

1. Suspend you AWS autoscaling activities first:

    # as-suspend-processes MyAutoScalingGroup

2. Add cron job:

    # echo "*/5 * * * * root /root/mycld/mycld.cli.runner.php \
-s spotscale -a check -d >> /root/mycld/logs/spotscale-error.log \
2>&1" >> /etc/crontab 


Debugging:



1. Check what you are running mycld.cli.runner.php with "-d"'.

    # grep "mycld" /etc/crontab | grep "-d"


2. Watch logs:
 
    # tail -f ~/mycld/logs/*.log


How to implement AWS auto-scaling for spot-instances

-- vladget

Wednesday, 11 January 2012