How to , and other stuff about linux, photo, php … A linux, photography blog. To remember some linux situation, and fix them quickly.

December 28, 2011

Automatic script for backup up redis on a amazon ebs

Filed under: Linux — admin @ 2:08 pm

Hello

Bellow is a script for backup up a redis on a unmounted ebs volume . First of all you have to create this file on that ebs

/mnt/backup/mounted

Why  I use this  ? Well I use it because I want to run on multiple servers.

 

 

 

#!/bin/bash
instance=i-xxxxx
volume=vol-xxxx
iplocalhost=10.00.00.111
mkdir /mnt/backup
atached=0
if [ ! -f /tmp/redis1 ]; then
touch /tmp/redis1
else
exit 0
fi
export EC2_HOME=/path/ec2-1.4.4.2
export JAVA_HOME=/usr/lib/jvm/jre
export CLASSPATH=${EC2_HOME}/lib
export EC2_PRIVATE_KEY=/root/path/pk.pem
export EC2_CERT=/root/path/cert.pem
while [ $atached -lt 1 ];do
/path/ec2-1.4.4.2/bin/ec2-attach-volume -K /root/path/pk.pem -C /root/path/cert.pem $volume -i $instance -d /dev/sdh
sleep 10
mount /dev/sdh /mnt/backup
sleep 5
if [ -f /mnt/backup/mounted ]; then
rsync -vrplogDtH /var/lib/redis/6379 /mnt/backup/cassandra1
atached=1
fi
done
cd /
umount -lf /mnt/backup
sleep 3
/path/ec2-1.4.4.2/bin/ec2-detach-volume -K /root/path/pk.pem -C /root/path/cert.pem $volume -i $instance -d /dev/sdh
rm -rf /tmp/redis1

December 23, 2011

Using Domain Names With Elastic Load Balancing route53

Filed under: Linux — admin @ 12:33 pm

Well a few day’s ago I have to setup a domain to use loadbalancer from Amazon.  Well there are 2 posibilities

1. You may associate a subdomain  with CNAME to loadbalancer, however this is not a good solution because you may not use ex: matrafox.info you may use only www.matrafox.info

2.  Move the domain to amazon also use route53 and you may add alias to domain also. How you may do this.

elb-associate-route53-hosted-zone myLoadBalancer –rr-name example.com –hosted-zone-id Z123000000 –weight 100
elb-associate-route53-hosted-zone myLoadBalancer –rr-name www.example.com –hosted-zone-id Z123000000 –weight 100

And if you want to remvoe just use
elb-disassociate-route53-hosted-zone myLB –rr-name example.com –hosted-zone-id Z123000000 –weight 100

myLoadBalancer – is the name of your load balancer
example.com – name of your domain
Z123000000 – this you will get from route53 page. Each domain has a unique zone id
weight – is something from route53 that you need it.

However wehen I try this solution I have this error:
elb-associate-route53-hosted-zone: program error

It appear that this error was because the domain was not fully propagated.

However to use this second solution you have to know your credential, and have installed their api.

One other simple solution is to add directly into route53, how you do this ?
1. go to ec2/load balancer and copy dns name of your load balancer ex: MyLoadBalancer-0000000000.us-east-1.elb.amazonaws.com , and his name ( myloadbalancer )
2. go to route 53 and edit your domain.
3. Chose what you want to be on load balancer .
and the parameter are
A – IPV4 address
Alias : yes
alias target: ( name of your load balancer ) myloadbalancer ( this will be all with low letter )
Weighted Set: yes
Weight : 100
Set id: MyLoadBalancer-0000000000.us-east-1.elb.amazonaws.com. ( do not forget the dot from the end )
And save this is preaty easy because you don’t have to use a lot of commands.

ngnix php apc memcached – connection stay active

Filed under: Linux — admin @ 10:58 am

Well, one client complain because the server start going to be verry slow. After a short look, I see that where over 20k ESTABLISHED connection from php-fpm to memcached server.

The main problem was that the server didn’t verify if have a connection active and every time was adding a new one.

After a short search we nottice that we have the stable version of memcached ( php module ) , and the new one have something like isPristine function, you won’t find anything on official documentation on pecl site.

So, the fix was to upgrade to memcached-2.0.0b2 .

How to upgrade memcached:

pecl uninstall memcached

pecl install memcached-2.0.0b2

After this you may use into php code  isPristine

 

 

December 22, 2011

how to set keyword azerty on centos

Filed under: Linux — admin @ 11:18 am

Well today I face another problem. I use Oracle VM VirtualBox Manager, and because of time consume to install a linux from dvd, I search and download a image from internet.

Well everything was good until I boot up and try to write something on that virtual machine. The keyword was mess up.

I search a little on internet and a lot of people sugested to use  system-config-keyboard however I don’t have any GUI installed, and I wanted to make it work from command line.

Well finally I found that you may fix this by using

loadkeys us

After using this you will see tha path to configuration file, on my server are located  “/lib/kbd/keymaps/i386/” . There you may find what you need and after that just run loadkeys and the name of the file without map.gz

 

December 19, 2011

DataStax OpsCenter “not recognize”

Filed under: Linux — admin @ 2:55 pm

Well , today I was trying to install DataStax OpsCenter on a Centos 5.4 ( 5.x ) . After download and configured when to start I see a error. Well this was because on that version the python on that server is 2.4  more exaclty python-2.4.3-44.el5_7.1 .

How to upgrade centos 5.x with python 2.6 ? Well the solution is to yum install python26.

Will install another package and the DataStax OpsCenter will start working.

 

 

Older Posts »

Powered by WordPress