Wednesday, July 25, 2012

Change the computer name on a Linux system

# check the existing computer name
sudo hostname vps5.iweb.cortica.com

# change the name to the "new-name"
sudo hostname new-name

Sunday, July 15, 2012

Configuring Tomcat 7 to work with Netbeans 7 on Windows 7

For a Java web app project Netbeans 7.x on Windows requires to know the location of Tomcat and the user name and password for server administrative access. The point is that while installing Tomcat within Netbeans installations on Windows I was not asked for any user name or password for Tomcat access.

Empirical finidng:
to make Tomcat work go to your Tomcat 'conf' folder (with my default installation path for Tomcat 7.0.27 it is located at C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.27\conf) and open XML file "tomcat-users.xml".

Next, uncomment the lines



to get user 'tomcat' with password 'tomcat' - good enough security for your local developers installation. Next, enter this user /pwd into Netbeans dialog.

Thursday, July 12, 2012

Clustering RabbitMQ on CentOS 6

#Assuming you got to instances of RabbitMQ installed on two separate computers in the same LAN segment, run the following command on both nodes (A and B):

rabbitmqctl status

# verify that both RabbitMQ nodes run EXACTLY the same Erlang version
# if they do not - upgrade Erlang on one of them to match the second Erlang version
# at the beginning of its layout the command displays RabbitMQ node name, e.g. rabbit@my-server-A - note this node name for the later use

# Check that both machines A and B can talk to each other (no firewall issues etc)

telnet localhost 4369


# Let's work on server A configuring RabbitMQ there to be clustered with server B.
# all the work is done on server A only, nothing should be done on server B

# stop rabbitmq service on server A

service rabbitmq-server stop



# add alias for B an A:
vi /etc/hosts

# add to /etc/hosts the alias of server B like it is displayed in the "rabbitmqctl status" output after "@" symbol, e.g. "10.10.10.10   my-server-B"
# use internal IP for server B alias if you got such, so the connection between serves A and B will go over internal switch

# copy Erlang cookie from the server B to the server  A:
scp root@my-server-B:/var/lib/rabbitmq/.erlang.cookie /var/lib/rabbitmq/.erlang.cookie

# give the cookie file the correct ownership (comes with 'root' after copying)
chown rabbitmq:rabbitmq /var/lib/rabbitmq/.erlang.cookie

# start rabbitmq service
service rabbitmq-server start

#stop and reset the app
rabbitmqctl stop_app

rabbitmqctl reset

# cluster the current node (on server A) to the node on server B as a disk node
#(if you prefer to cluster node A to B as RAM node run       rabbitmqctl cluster rabbit@my-server-B)

rabbitmqctl cluster rabbit@my-server-B rabbit@my-server-A

# you should see the success message here

# start the app and enjoy
rabbitmqctl start_app

#verify that two nodes are indeed clustered: use management plugin
# go to server A, HTTP on port 55672
# you should see "node" column in the Queues view, filled in with 'my-server-B' node name










Thursday, July 05, 2012

Show running queries if MySQl is stuck

Sometimes we want to know which query causes the DB to be so slow. Here is the magic MySQL queries which can do it:
 
show processlist;
 
Look into "info" column listed in the output table to see what queries are working now.

Tuesday, July 03, 2012

Installing Erlang from the sources on CentOS 6


# enable EPEL
su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm'

# go to http://www.erlang.org/download.html and select the latest source code archive
wget http://www.erlang.org/download/otp_src_R15B01.tar.gz

#uncompress
tar -xvf otp_src_R15B01.tar.gz

#install everything we need to compile the sources
sudo yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-devel

#go to that folder
cd otp_src_R15B01

#configure, make and install
./configure --with-ssl
sudo make install

#create a symbolic link
sudo ln -s /usr/local/bin/erl /bin/erl