Archive

Archive for the ‘cloud’ Category

Change of database: Percona Mysql to Postrgres for django

October 15th, 2011 alex No comments

Colleague of mine came with strange bug: 1. * i am opening python shell, and sending request User.objects.all() It returns valid information * then i’m adding user via web site * then i send request User.objects.all() again and new user is missing. If i will reopen shell then everything will be ok

  1. when i’m running “python manage.py test name_of_application” creating and deleting database takes too long Percona Server version: 5.5.15-55 Percona Server (GPL), Release 21.0 We decided that Postgres will be better and switched to it
Tags: , , ,
Categories: cloud Tags: , , ,

Monitoring rabbitmq server 2.5.1. with monit

July 15th, 2011 alex 2 comments

Simple task like setting up monitoring with monit for rabbit mq include two parts: 1) As discussed here Modify /etc/init.d/rabbitmq-server

  1. The following are added to the start function:
  2.   pid=`/usr/sbin/rabbitmqctl status | perl -n -e'/{pid,(\d+)/ && print
  3. $1'`
  4.   echo $pid > /var/run/rabbitmq.pid
  5. Right before:
  6.   echo SUCCESS
  7. The pid file is deleted within the stop function:
  8.          rm /var/run/rabbitmq.pid
  9. right after,
  10.          if [ $RETVAL = 0 ] ; then

2) Add this to monit configuration file:

  1. ### rabbitmq-server
  2. check process rabbitmq-server with pidfile /var/run/rabbitmq.pid
  3.      group rabbitmq
  4.      start program "/etc/init.d/rabbitmq-server start"
  5.      stop program "/etc/init.d/rabbitmq-server stop"
  6.      if failed port 5672 type tcp then restart
  7.      if 3 restarts within 3 cycles then timeout
Tags: , , ,

Django optimisation in production

July 10th, 2011 alex No comments

Few days ago I realised that my django installation in production started producing too many memory errors – thanks to monit memory alerts were filling my mailbox without any serious service interruption. But hundreds email messages daily annoyed me enough to look deeper into trouble.

Read more…

No tags for this post.
Categories: cloud, python, web Tags:

Secure Riak installation using n2n VPN

July 8th, 2011 alex No comments

Recently, I decided to have a closer look at Riak non-sql database, but found out that unlike CouchDB riak doesn’t have a HTTP basic auth implemented, or any other way of defining secure access to database.

I have three servers to build a cluster, but I feel very uneasy leaving open ports and full access to database to everyone in the world. The best practice guide here lists all ports necessary to secure riak installation, but messing with iptables didn’t feel like compelling idea.

So I decided to set up a VPN and only make riak nodes available on internal network inside VPN. Again, system administration is my hobby rather than the main job, so VPN installation should be straightforward and simple.

That’s how I found absolutely amazing product – n2n – Peer-to-Peer VPN network. I used svn version, but it is in standard ubuntu repos. I suggest install n2n network first, then configure cluster later(obviously I did it other way around,but you don’t have to repeat my mistakes). I successfully installed n2n on 3 Ubuntu Lucid 10.04.2 and Mac OS X Leopard and Snow Leopard.

1) Step 1. Prepare supernode (Linux):

sudo aptitude install uml-utilities #user mode utils
sudo tunctl -t tun0 # create tun0 interface
sudo aptitude install quilt libssl-dev #necessary libraries
svn co https://svn.ntop.org/svn/ntop/trunk/n2n #checkout trunk
cd n2n/n2n_v1/
make

So far everything straightforward.

Step2. Start supernode:

./supernode -l 1222 -v
“-v” indicate verbose output, supernode is a daemon, so no need to nhop etc.

Step3. On any other machine (not supernode), for linux follow step 1, create tun0 interface, then

  1. sudo ./edge -d tun0 -a new_node_internal_ip -c myVNPnetwork -k secretkey -l supernode_ip:1222 -v

For linux client “-d” is compulsory and should pass already created tun0 interface after that. new_node_internal_ip – new internal IP, my for example in range 10.0...

“-k secretkey” – you network encryption key. Should be common between nodes.

Then most important part – wait. Looking at verbose output of supernode and edge, edge should have:

"Registering with supernode"
Received REGISTER_ACK from remote peer [ip=*:1222]
for successful registration. Every time when you shutdown/restart edge or supernode it takes some time to re-register. Depending on the network it can take from few seconds to a few minutes. If you shutdown supernode, all clients should re-register, which can take up to 5 minutes.

Next repeat step 1 and 3 for other linux client for example. Do not try to install edge client on supernode until you have at least two other nodes and you can ping each other on internal ip. Replace “-v” with “-f” once configuration is fully functional.

If you want to add Mac OS X client, install tun/tap driver for mac os first from here, then

sudo ./edge  -a new_node_internal_ip -c myVNPnetwork -k secretkey -l supernode_ip:1222 -v

no need to pass parameter “-d”.

Now, assuming you have successfully installed at least two clients and have pinged each other over internal network, adding supernode computer as a node edge:

  1. sudo ./edge -d tun0 -a new_node_internal_ip -c myVNPnetwork -k secretkey -l supernode_ip:1222 -v -r

“-r Enable packet forwarding through n2n community” is important parameter here and that was the only way how I manage to add edge on supernode computer. This is enforces all packets to go via supernode ( Usually supernode acts only as an information exchange for other nodes, and encrypted connection formed between two edges directly ( remember it’s p2p network), but routing becomes messy if you connect edge node on same computer which runs supernode – other edge clients can’t see edge installed on supernode directly).

Supernode also acts as a router for a nodes behind NAT firewall.

All nodes should be fine and talking, we can go to Basic Cluster setup. For linux:

  1. wget http://downloads.basho.com/riak/CURRENT/riak_0.14.2-1_amd64.deb
  2. dpkg -i riak_0.14.2-1_amd64.deb
  3. sudo dpkg -i riak_0.14.2-1_amd64.deb

Then edit “/etc/riak/app.config” and “/etc/riak/vm.args”, put new (internal) IP addresses in appropriate places. If you already had riak installation,

  1. sudo riak-admin reip riak@old_ip riak@new_ip
  2. sudo riak-admin remove riak@127.0.0.1

and on other new riak nodes:

  1. ./bin/riak-admin join riak@10.0.*.2

Now you should have a secure riak cluster and in my case it is also spread across two datacenters and home. But you still may want to for a trial of Enterprise Riak if you are serious about deploying riak in production.

Tags: , , , , , , , , , , ,

Selecting mac ports python on mac (Leopard)

June 25th, 2011 alex No comments

Selecting python installed from mac ports on leopard works now like this:

  1. sudo port selectset python python26

Took some time to figure it out as most of the hints on the web don’t work

Tags: , , ,
Categories: cloud Tags: , , ,

Useful JavaScript one-liner for couchdb

June 1st, 2011 alex 1 comment

I found myself using more and more of this one-liner for working with couchdb database:

  1. var getNewDatabusUUID = JSON.parse($.ajax({ type: "GET", url: "/_uuids/",
  2.                 async: false }).responseText);
  3.  $.log("New uuid generated " + getNewDatabusUUID.uuids);

this example retrieves new uuids from couchdb, but I was using it to retrieve _rev of the document before deletion and similar one-off problems.

Tags: , , , , , ,
Categories: cloud, web Tags: , , , , , ,

Checkbox and select elements in couch db

April 4th, 2011 alex No comments

If you wanted to make a select or checkbox element using mustache in couch db and trying to find example, here it is:

Read more…

No tags for this post.
Categories: cloud Tags:

Technical questions which are not valid in the absence of context

March 5th, 2011 alex No comments

Recently I was asked the number of technical questions which I nearly failed to answer, not because I don’t now the answer, but because I believe such questions require more information about the context. There is a common assumption about the default mind frame with ms windows and C/C+. The assumption doesn’t work for me hence I came out as a non-technical person (I think people who know me a bit will consider it as a joke, since most of the conversations I came out as a mix of geek and scientist).

  • Network: what is the difference between port and socket.(I wonder what is the difference between port and file in *unix).
  • between process and thread ( not much if you are reading programming erlang. I wonder what answer will be for QNX or other RTOS)
  • how many ways to copy file from Linux to windows (I know at least +1 to most common: use netcat)

  • Posted using BlogPress from my iPad

No tags for this post.
Categories: cloud Tags:

Chef cookbook for xtreemfs deployment

December 10th, 2010 alex No comments

I just pushed xtreemfs cookbook to my git repo This cookbook automates xtreemfs quick start for ubuntu 10.04. I am using it with vagrant:

  1.    config.vm.define : xtreemfs do |xtreemfs_config|
  2.     xtreemfs_config.vm.box="base"
  3.     xtreemfs_config.vm.provisioner=:chef_solo
  4.     xtreemfs_config.vm.forward_port("ssh", 22, 2227,:auto => true)  
  5.     xtreemfs_config.vm.forward_port("web", 30638, 8080)
  6.     xtreemfs_config.vm.network("192.168.100.16")
  7.     xtreemfs_config.chef.node_name="xtreemfs"
  8.     xtreemfs_config.chef.log_level = :debug
  9.     xtreemfs_config.chef.cookbooks_path = ["cookbooks","other_cookbooks"]
  10.     xtreemfs_config.chef.run_list.clear
  11.     xtreemfs_config.chef.add_recipe("apt")
  12.     # xtreemfs_config.chef.add_recipe("tomcat")
  13.     xtreemfs_config.chef.add_recipe("xtreemfs::server")
  14.     xtreemfs_config.chef.add_recipe("xtreemfs::client")
  15.  end
Tags: , , ,
Categories: cloud Tags: , , ,

Good way to ad apt repository using chef – from hadoop cookbook

December 9th, 2010 alex 2 comments

I found an interesting way of adding apt repository in hadoop cookbook:

  1. execute "apt-get update" do
  2.   action :nothing
  3. end
  4.  
  5. template "/etc/apt/sources.list.d/cloudera.list" do
  6.   owner "root"
  7.   mode "0644"
  8.   source "cloudera.list.erb"
  9.   notifies :run, resources("execute[apt-get update]"), :immediately
  10. end
  11.  
  12. execute "curl -s http://archive.cloudera.com/debian/archive.key | apt-key add -" do
  13.   not_if "apt-key export 'Cloudera Apt Repository'"
  14. end
Tags: , ,
Categories: cloud Tags: , ,