Thursday, March 18, 2010

ext4 disable journal

At one high loaded web project I needed a very fast file system. I decided to use Ext4 with disabled journal (As a google:))).

# Create ext4 fs on /dev/sda10 disk
mkfs.ext4 /dev/sda10

# Enable writeback mode. This mode will typically provide the best ext4 performance.
tune2fs -o journal_data_writeback /dev/sda10

# Delete has_journal option
tune2fs -O ^has_journal /dev/sda10

# Required fsck
e2fsck -f /dev/sda10

# Check fs options
dumpe2fs /dev/sda10 |more

For more performance add fstab opions: data=writeback,noatime,nodiratime
i.e:
/dev/sda10 /opt ext4 defaults,data=writeback,noatime,nodiratime 0 0

Tested at non-boot partition ;)

Friday, March 5, 2010

Key-Value Storages

memcached - distributed memory object caching system ( http://memcached.org/ )
memcachedb - distributed key-value storage ( http://memcachedb.org/ )
redis - A persistent key-value database with built-in net interface written in ANSI-C for Posix systems ( http://code.google.com/p/redis/ )
MongoDB - scalable, high-performance, open source, schema-free, document-oriented database. Written in C++ ( http://www.mongodb.org )
CouchDB - doc. oriented, written in Erlang ( http://couchdb.apache.org/ )
Riak - NoSQL, decentralized ( http://riak.basho.com/ )
RINGO - distributed key-value storage for immutable data, written in Erlang ( http://github.com/tuulos/ringo )
Dynamo - Amazon’s Highly Available Key-value Store ( http://www.allthingsdistributed.com/2007/10/amazons_dynamo.html )
Cassandra - highly scalable, eventually consistent, distributed, structured key-value store. "Dynamo 2.0" ( http://incubator.apache.org/cassandra/ )
Scalaris - scalable, transactional, distributed key-value store ( http://code.google.com/p/scalaris/ )


Thursday, September 10, 2009

CentOS 5.2 - Missing Dependency: kernel-headers

If you have troubles with kernel-headers in CentOS 5.2 like:
Error: Missing Dependency: kernel-headers is needed by package glibc-headers
Error: Missing Dependency: kernel-headers >= 2.2.1 is needed by package glibc-headers

install kernel headers:
#uname -a
Linux myserver 2.6.18-92.1.18.el5 #1 SMP Wed Nov 12 09:19:49 EST 2008 x86_64

for x86_64
#wget http://vault.centos.org/5.2/os/x86_64/CentOS/kernel-headers-2.6.18-92.el5.x86_64.rpm
#rpm -i kernel-headers-2.6.18-92.el5.x86_64.rpm

for i386
#wget http://vault.centos.org/5.2/os/i386/CentOS/kernel-headers-2.6.18-92.el5.i386.rpm
#rpm -i kernel-headers-2.6.18-92.el5.i386.rpm

Wednesday, September 2, 2009

Enable mysql replication on production server

How to add slave mysql server without stopping master?

Bin-logging must be enabled on master. Then just dump all data from master:
mysqldump  --defaults-file=/etc/mysql/debian.cnf -BA --master-data | gzip > /pathtogzipfile/filename
This command dump all data from master and store master "binlog filename" and log position.

Copy gzipped dump to slave. Ungzip and apply (mysql < yourfile.sql). Execute "slave start;" (slave must be configured for replication before this step :)

Saturday, August 1, 2009

keep in mind

#echo "1 2 3 4 5 6 7" |awk '{print $3, $NF}'
3 7

Friday, July 31, 2009

apache fail

Don't use apache2-mpm-worker for perl projects. Never!

never

NEVER! :)

Wednesday, July 22, 2009

nginx basic auth (htpasswd)

Nginx supports basic auth (ngx_http_auth_basic_module)

directives:
auth_basic [|off]
auth_basic_user_file path/to/file

htpasswd file format:
# comment
login:password

Command htpasswd should be used with option -d , because nginx supports crypt() algorithm only.

Example:
htpasswd -c -d /etc/nginx/htpasswd asalnikov

nginx.conf part:
location /
{
auth_basic "closed site";
auth_basic_user_file /etc/nginx/htpasswd;
...
}

Sunday, July 12, 2009

Kubuntu Jaunty Wi-Fi Speed with WPA2 encryption

After upgrading my Kubuntu to Jaunty, I had problems with Internet access via Wi-Fi. Speed was many times less than before the upgrade (only then I use WPA2 encryption). This way solve the problem:

$ sudo aptitude install linux-image-2.6.28-11-generic

and reboot, choosing this kernel

P.S. in KDE4, NetworkManager replaced by plasma-widget-network-manager. If you can't connect to your wi-fi network with WPA2 encryption just install "linux-backports-modules-jaunty-generic" package.

Thursday, July 9, 2009

ssh tunnels

In many cases, development projects are on the same data center, and the server product is on the other. And often it is necessary to provide the link between the test and product servers.

Simply ssh tunnel:

ssh -p40088 -2 -N -C -f -L 172.11.5.58:3307:10.20.1.103:3306 tunnel@x.x.x.x

-p40088 - gateway to production DC ssh port
172.11.5.58:3307 - host:port on local server
10.20.1.103:3306 - host:port on remote server
tunnel@x.x.x.x - username@host of gateway to production DC


And now when I connect to port 3307 on local server I get connect with 10.20.1.103:3306 on production server.

Monday, July 6, 2009

How to copy directories structure

cd olddir
find . -type d > /tmp/dirlist
cd newdir
for i in `cat /tmp/dirlist` ; do mkdir -p $i ; done

very simply :)