•  
  • Linux (33)

ActiveMQ installation on Centos

Categories: Linux
Tags: No Tags
Comments: No Comments
Published on: November 2, 2011

ActiveMQ Installation:

I will be installing ActiveMQ on Centos 5.4.

First you need to install JDK.

You can download RPM Installer and run it.  Doesn’t get any easier. Look at java installation on centos.

Then you need to add your java installation to your path.

Download ActiveMQ.

Once you are done downloading.

Untar it then go in to bin directory.

You can start activemq as follows:

# ./activemq console

Memcached

Categories: Linux, Programming, Scalability
Tags: No Tags
Comments: 1 Comment
Published on: October 24, 2011

Memcached is Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, page rendering or simply anything you like to store temporarily.

Memcached is simply a Key/Value store. You can see it as a standalone distributed hash table or dictionary. Memcached doesn’t know what your date is like, all it does is to store key value pairs with expiration and using LRU (Least recently used) algorithm to maintain the cached items.

What makes Memcached cool is that it provides scalability. How does it do this? By hashing algorithms that its clients implements. There are two phase of hashing, one of which happens at the client and the other happens at the server. Therefore, eventually all the memcached clients implement some hashing algorithm in order to benefit from the memcached’s distributed nature. I will mention this in a bit.

Having said that memcached is a distributed hash table (key value store), servers are disconnected from each other, and usually they are unaware of each there. There is no communication between memcached servers, any synchronization or broadcasting. This increases the flexibility to be able to scale out the memcached servers. If you are running low on resources on a memcached server, you can add another memcached server, and you can keep adding more cache servers as you need. You should pay attention that, if you don’t add cache servers, your cached item will start to be dropped out of memcached as the cache becomes full and as I mentioned Least recently used algorithm is used to drop the oldest cached items. This is also called Eviction.

In computer science world, one of the most important notations is Algorithmic complexity. Example: searching for an item, sorting a collection etc. Memcached considers this and implements a O(1), constant time, key value store. This means that storing an item to cache and extracting an item from the cache is constant time operation, which is very fast. This is achieved by implementing a good hash code method that doesn’t cause collisions.

On another note, Memcached storage of cached items is not traversable/iterable. You cannot traverse the whole cache.

Memcached is awesome! But not for every architecture.

  • You have objects larger than 1MB.
    • Memcached is not for large media and streaming huge blobs.
  • You have keys larger than 250 chars.
    • Memcached doesn’t support more than 250 chars.
  • If you want persistence or a database. You might consider MemcacheDB which provides persistence for Memcached.
  • You’re running in an insecure environment. Memcached doesn’t have any authentication or authorization system.

As I mentioned Memcached has two-stage hashing. It behaves as a giant hash table, looking up key = value pairs. Give it a key, and set or get some arbitrary data. That is it really. That is all it does.

When doing a memcached lookup, first the client hashes the key against the whole list of servers that you need to introduce to your clients. Once it has chosen a server after the first hashing procedure, the client then sends its request, and the server that was chosen does an internal hash key lookup for the actual item data. This enables the client to know which cache server to query again, when the item that was sent to cache is requested.

You need to understand that memcached is not redundant. There is no notion of replication or communication between cache servers; they are unaware of each other. Their only purpose is to store an item and give back an item. If one of your cache servers fails, you will lose all your data within that cache server. You will have to remove the cache server that failed from the list of the cache servers of your clients, ie: configuration.

Moreover, when one of your cache fail and you want to add another one, or you remove your cache from your clients, that will cause a big problem which is all your data, cached items will be invalid. This is due to double hashing mechanism, which clients, uses to hash the items based on the servers. So all your cache will be invalid, and you will have a spike. In order to avoid this, you will have to start a new node and assign the IP address of the dead node to the newly created node; this will prevent all your data to be invalid. Yet another way to solve this problem would be to use Consistent Hashing , in order to avoid computation of hash values of all the data.

Memcached operations aim to be atomic. All individual commands sent to memcached are atomic.

Memcached mimics organization of data via namespaces and it only stores objects. On the other hand, Microsoft App Fabric Cache provides notion of regions or sections. This allows you to keep the same Type of items in independent caches. Moreover, you can store strong Type instead of objects with AppFabric Cache, which I think these features are great.

Memcached is fast. It utilizes highly efficient, non-blocking networking libraries to ensure that memcached is always fast even under heavy load. In other words, in circumstances where your database might be falling over, memcached won’t be. Which is precisely what memcache was designed to do: to take the load off of your database, which for the majority of popular web applications is the biggest performance bottleneck and risk to scalability.

Memcached is simple and easy to deploy. It does not require a lot of technical knowledge to use or use effectively – it just does what it is supposed to.

Compressing large values is a great way to get more out of your memory and network communication/bandwidth. Compression can save a lot of memory for some values, and also potentially reduce latency as smaller values are quicker to fetch over the network.

Most clients support enabling or disabling compression by threshold of item size, and some on a per-item basis. Smaller items won’t necessarily benefit as much from having their data reduced, and would simply waste CPU.

Main Operations to work with Memcached is as follows:

Storing an item to database, you can pass values for datetime or timespan for expiration of the object being set.

Remove an item from the cache.

Increment and decrement given a keys value.

TryGet or Get is used to get an object from the cache.

Some of the clients allows retrieving multiple elements from the cache.

 

On another note, you can read about Microsoft AppFabric Cache.

Centos Install C/C++

Categories: Linux
Tags: No Tags
Comments: No Comments
Published on: October 1, 2011

Here is how you can install C/C++ on CentOS.

#yum install gcc-c++

You might also want to install it with some more useful packages. Then your command will be:

#yum install gcc-c++ compat-gcc-32 compat-gcc-32-c++

Process Switching (Context Switching)

Categories: Linux, Programming
Tags:
Comments: No Comments
Published on: December 6, 2010

Process is essential for any multi programming operating system. A process is an executing instance of a program. Time sharing operating systems can start the same program which will run with different processes. For example, a dozen of user can use pico editor at once, and then there will be 16 processes for pico running on the same CPU. All the processes have a life cycle; a process begins, executes, might create child processes, sleeps, and dies. Each process have a single parent. When a process is created it s very identical to its parent.

Threads are light weight processes. Threads can run in parallel and share the same address space and other resources with the parent process. Threads belong to a process.

CPU switching between processes or threads to another is called process switching. Context Switching is an important feature of multitasking operating systems. The target is to share the CPU so that multiple processes, tasks will run on the same CPU. Context switching is done by storing and restoring the states of the processes.

Check root kit

Categories: Linux
Tags:
Comments: No Comments
Published on: December 6, 2010

Here is a program that checks for root kits on your linux box.

http://www.chkrootkit.org/

Set up Java in Linux

Categories: Linux
Tags:
Comments: No Comments
Published on: December 6, 2010

Linux Java Setup.

export JAVA_HOME=/usr/java/jdk1.5.0_12

export PATH=$PATH:$JAVA_HOME/bin

to .bash profile

Essential Tasks of System Administration

Categories: Linux
Tags: ,
Comments: No Comments
Published on: April 14, 2010

Below are some essential tasks of system administration :

Adding and Removing Users :
The system administrator adds accounts for new users and removes the accounts of users that are no longer active. These process of adding and removing users can be automated.

Adding and Removing Hardware :
When there is a change in hardware configuration, System administrator should handle the new device drivers, configuration of the device.

Performing Backups :
Performing backups is one the most important role of  a System Administrator, To avoid chaos and data loss , System administrator should take back ups. Taking back ups can be automated.

Installing Software :
When a new software is installed, it should be tested many times before informing users.Local software should be installed in seperate folders than system programs to avoid problems during , upgrade of the system or kernel, in case local software wont be overwritten by System Software.

Monitoring the System:
Unix systems require supervision. Daily activities include making sure that , email, web services , network services are working correctly.Writing shell script and watching log files for signs of trouble and keeping an eye on system resources.

TroubleShooting :
Unix System administration has been like chaos. Finding the problem is sometimes harder than solving it. Trouble shooting  is a key role of system administrator and it comes with experience.

Maintaining Local Documentation :
Updating and orginizing man pages is yet another role of the SysAdmin.

Auditing Security :
Security is a very big issue. As the systems get bigger, security becomes more important. SysAdmin must implement security audits, run sniffers and script to ensure that network, system and file system is secure.

Linux File system summary

Categories: Linux
Tags:
Comments: No Comments
Published on: April 14, 2010

/bin :Contains executables for everyuser.
/boot :Contains the kernel image, system mpa, bootstrap…
/dev :Contains special files that represents hardware
/etc :Containts configuration files
profile : defualt settings for the system (path, alias commands)
fstab :File system table, default mounts.
X11 : X window configuration files
rc.d :start up scripts
init.d :startup scripts
inetd.conf :inetd listener configuration
skel :D irecotry comntaining default user confguration files.
passwd : user information and passwords
shadow : User password
sysconfig :may files with control system configuration

/home : Contains user’s home directories
/lib : Contains libraries
/mnt : Contains mount points for other file systems.
/proc : Virtual system (in memory) contains kernel and process info
cpuinfo :CPU information
dasd/devices : dasd addresses that the system recognized
devices :devices supported
meminfo :memory utilization
proc/swaps :swap file or devices enabled
proc/uptime : time since last boot

/root :home directory for root user
/sbin :Contains system admin executables
/tmp :Temporary storage space
/usr :Unix system resources
/var : contains logs & spool files
/lost& found :location for lost and found files are stored after a crash recovery by fs2ck

WGET linux utility

Categories: Linux
Tags:
Comments: No Comments
Published on: April 14, 2010

Wget is a really handy little command line utility. That assists downloading and retrieving of remote files. Luckily most systems ship with Wget.

Installing:

Installation is very simple because this is an rpm. As root just type

[root@kewllinuxbox root]# rpm -ivh wget-1.5.3-6.i386.rpm
wget                     ##################################################
[root@kewllinuxbox root]#

Each hash mark (#) represents 2% of the install completed.

Using:

This program is very simple to use, check out the following example.

$ wget http://www.linuxinstruct.com/tutorials/wget/wget-1.5.3-6.i386.rpm

The first thing you will notice is that it displays a lot of information on the download. You might want to use this on its own terminal so you can continue working.

That will download the file from the following location. Many other handy arguments can be used but the most popular is the -c arugment. That is the continue arg. It allows you to cancel the download and pick up where you left off. Another handy arg is -q. That changes it output from verbose to quiet.

Creating Tar and Gzip files

Categories: Linux
Tags:
Comments: No Comments
Published on: April 14, 2010

To create a tarball use this syntax:

#  tar -cf [name of tarball].tar [list of files or directories]

That will create the tarball. A tarball is just a bunch of files inside one. Now we want to compress it using gzip.
To compress it with maximum compression use this syntax:

#  gzip -9 [file].tar

This will create a file called [file].tar.gz
The -9 is for maximum compression. It can be anything from 1-9

page 1 of 4»

Welcome , today is Tuesday, February 7, 2012

Bad Behavior has blocked 250 access attempts in the last 7 days.