How to set up master-slave replication in MySQL

by Tweak on September 22, 2010
in Mysql

Before we go into how to set up master-slave replication in MySQL, let us talk about some of the reasons I have set up master-slave replication using MySQL.

1) Offload some of the queries from one server to another and spread the load: One of the biggest advantages to have master-slave set up in MySQL is to be able to use master for all of the inserts and send some, if not all, select queries to slave. This will most probably speed up your application without having to diving into optimizing all the queries or buying more hardware.

2) Do backups from slave: One of the advantages people overlook is that you can use MySQL slave to do backups from. That way site is not affected at all when doing backups. This becomes a big deal when your database has grown to multiple gigs and every time you do backups using mysqldump, site lags when table locks happen. For some sites, this could mean that site goes down for few secs to minutes. If you have slave, you just take slave out of rotation (should be built into code) and run backups off the slave. You can even stop slave MySQL instance and copy the var folder instead of doing mysqldump.
Read more…

Installing Nginx on CentOS 5

by Tweak on September 18, 2010
in Servers

Nginx, pronounced “Engine X”, is a high-performance Web server and reverse proxy. It was created by Igor Sysoev for rambler.ru, Russia’s second-largest Web site. Rambler has used Nginx since summer 2004, and it’s currently serving about 500 million requests per day. Like Apache, Nginx is used by some of the largest Web sites in the US, including WordPress , Hulu and MochiMedia. As of May 2010, Nginx is the third most popular Web server across all domains.
Read more…

Config Nginx as a Reverse Proxy

by Tweak on September 18, 2010
in Servers

Using Nginx as a reverse proxy is great for a few reasons. Firstly it handles static content very well. It is able to handle the requests and serve static content much faster and this has cut our page load time in about half (using YSlow with a clear cache). The memory footprint of Nginx is very small so this extra speed increase is worth every megabyte. Secondly, it allows for quick and easy migration of your Apache services to another server. Through the config files you are able to specify an IP of your server and a port. If your apache server is taking a pounding it wouldn’t be difficult to move it to another server and just change the proxy IP to your now remote server.

If you haven’t installed Nginx, please read here
Read more…

How to install memcached

by Tweak on September 17, 2010
in Linux, Servers

Memcached is a very popular open source object caching server. It was developed to speed up livejournal.com by Danga Interactive. We use memcached for a lot of our sites. We use it for different purposes but one main purpose is to cache query results so we don’t have to keep hitting database. As most of the people who work with databases know it is costly to keep hitting database for same information over and over.

When you run the Memcached daemon, it runs and listens on a specific port. One of the things Memcached does lack is security. Memcached will let anybody who can make a connection to its port have full access to all objects. So you would have to run a firewall to block unauthorized access. It is usually wise to do put firewall on it even if you trust everybody on the same network since accidents do happen. That said, let’s get memcached installed!
Read more…

Benchmarking Your Site with ‘http_load’

by Tweak on May 8, 2010
in Apache, Linux, Servers

http_load is a stunningly useful HTTP benchmarking utility that gives you a rough idea of how many hits per second a server is capable of serving. You simply tell it what pages to grab, and how many “clients” it should run in parallel; it gives you back useful information about the average fetches per second and the average, minimum, and maximum response times. It’s no substitute for a solid profiler to dig into the hows and whys of your application’s performance, but it’s great at telling you when you’re “good enough” to launch.

Installing http_load on OS X

  1. Download from http://www.acme.com/software/http_load/
  2. Open terminal, cd to the directory where the archive is and unzip
    $ tar xvzf http_load-12mar2006.tar.gz
  3. Move to that directory
    $ cd http_load-12mar2006
  4. Run
    $ make
  5. Run
    $ sudo make install

Read more…

How to check an MD5 hash on a file

by Tweak on May 5, 2010
in Linux

MD5 is a one-way hash algorithm as defined by RFC1321 and can be used to help determine the integrity of a file by providing a 128 bit digital signature. This digital signature is like a fingerprint for a file, changing just one single byte in a file will result in a different MD5 hash.

MD5 hashes can be used to catalog files on a filesystem and then determine at a later date that the files have not been altered in any way, for example if someone broke into a system and modified system files.

They can also be used to ensure a file downloaded from a website is the same as expected. This can be especially important when downloading a file from a mirror site to ensure you are not installing a modified program which contains a trojan horse or some other nasty. By simply comparing the MD5 hash of the file you have downloaded from the mirror with that from the original website you can determine whether or not the file is exactly the same.
Read more…

Check / List Running Services

by Tweak on May 4, 2010
in Linux, Servers

Q. How do I list all currently running services in CentOS / RHEL / Fedora Linux server ?

A. There are various ways and tools to find and list all running services under CentOS / RHEL / Fedora Linux systems.

service command – list running services

service --status-all
service --status-all | grep ntpd
service --status-all | less

Read more…

APF installation error on VPS : unable to load iptables module (ip_tables), aborting.

by Tweak on April 21, 2010
in Linux, Security

While installing APF on your VPS you get the following error :

apf -s
apf(13665): {glob} status log not found, created
apf(13665): {glob} activating firewall
apf(13744): {glob} unable to load iptables module (ip_tables), aborting.
apf(13665): {glob} firewall initalized
apf(13665): {glob} !!DEVELOPMENT MODE ENABLED!! – firewall will flush every 5 minutes.

You need to configure the APF for your VPS.

nano /etc/apf/conf.apf

modify
SET_MONOKERN=”0?

to
SET_MONOKERN=”1?
Read more…

How to Change the Timezone in Linux

by Tweak on November 10, 2009
in Linux, Servers

  1. Logged in as root, check which timezone your machine is currently using by executing `date`. You’ll see something like Mon Nov 9 13:49:01 EST 2009, PST in this case is the current timezone.
  2. Change to the directory /usr/share/zoneinfo here you will find a list of time zone regions. Choose the most appropriate region, if you live in Hong_Kong or the Singapore this directory is the “Asia” directory.
  3. Read more…

Install bandwidth monitor vnstat

by Tweak on September 5, 2009
in Linux, Servers

vnStat is a network traffic monitor for Linux that keeps a log of daily network traffic for the selected interface(s). vnStat isn’t a packet sniffer. The traffic information is analyzed from the /proc -filesystem, so vnStat can be used without root permissions. However at least a 2.2.x kernel is required.

  1. Install vnStat
    wget http://humdi.net/vnstat/vnstat-1.7.tar.gz
    tar zxvf vnstat-1.7.tar.gz
    cd vnstat-1.7
    make
    make install
  2. Read more…

« Previous PageNext Page »