fstab file insights

There's a file called /etc/fstab in your Linux system. Learn what its contents mean and how it's used in conjunction with the mount command. When you learn to understand the fstab file, you'll be able to edit its contents yourself, too.
In this tuXfile I assume you already know how to mount file systems and partitions with the mount command. If you don't, I suggest reading theMounting tuXfile before reading this one.

What is fstab and why it's useful

fstab is a configuration file that contains information of all the partitions and storage devices in your computer. The file is located under /etc, so the full path to this file is /etc/fstab.
/etc/fstab contains information of where your partitions and storage devices should be mounted and how. If you can't access your Windows partition from Linux, aren't able to mount your CD or write to your floppy as a normal user, or have problems with your CD-RW, you probably have a misconfigured /etc/fstab file. So, you can usually fix your mounting problems by editing your fstab file.
/etc/fstab is just a plain text file, so you can open and edit it with any text editor you're familiar with. However, note that you must have the root privileges before editing fstab. So, in order to edit the file, you must either log in as root or use the su command to become root.

Overview of the file

Of course everybody has a bit different /etc/fstab file because the partitions, devices and their properties are different on different systems. But the basic structure of fstab is always the same. Here's an example of the contents of /etc/fstab:
/dev/hda2   /              ext2 defaults             1 1
/dev/hdb1   /home          ext2 defaults             1 2
/dev/cdrom  /media/cdrom   auto ro,noauto,user,exec  0 0
/dev/fd0    /media/floppy  auto rw,noauto,user,sync  0 0
proc        /proc          proc defaults             0 0
/dev/hda1   swap           swap pri=42               0 0
What does all this gibberish mean? As you see, every line (or row) contains the information of one device or partition. The first column contains the device name, the second one its mount point, third its file system type, fourth the mount options, fifth (a number) dump options, and sixth (another number) file system check options. Let's take a closer look at this stuff.

1st and 2nd columns: Device and default mount point

The first and second columns should be pretty straightforward. They tell themount command exactly the same things that you tell mount when you mount stuff manually: what is the device or partition, and what is the mount point. The mount point specified for a device in /etc/fstab is its default mount point. That is the directory where the device will be mounted if you don't specify any other mount point when mounting the device.
Like you already learned from the Mounting tuXfile, most Linux distros create special directories for mount points. Most distros create them under/mnt, but some (at least SuSE) under /media. As you probably noticed when looking at the example fstab, I use SuSE's mount points as an example.
What does all this mean? If I type the following command:
$ mount /dev/fd0
my floppy will be mounted in /media/floppy, because that's the default mount point specified in /etc/fstab. If there is no entry for /dev/fd0 in my fstab when I issue the command above, mount gets very confused because it doesn't know where to mount the floppy.
You can freely change the default mount points listed in /etc/fstab if you're not satisfied with the defaults your distro has given you. Just make sure the mount point is a directory that already exists on your system. If it doesn't, simply create it.
Some partitions and devices are also automatically mounted when your Linux system boots up. For example, have a look at the example fstababove. There are lines that look like this:
/dev/hda2 / ext2 defaults 1 1
/dev/hdb1 /home ext2 defaults 1 2
As you've learned, these lines mean that /dev/hda2 will be mounted to / and /dev/hdb1 to /home. This is done automatically when your Linux system boots up... if it wouldn't, you'd have a hard time using your cool Linux system because all the programs you use are in / and you wouldn't be able to run them if / wasn't mounted! But how does the system know where you want to mount /dev/hda2 and /dev/hdb1? By looking at the/etc/fstab file of course.

3rd column: Filesystem type

The third column in /etc/fstab specifies the file system type of the device or partition. Many different file systems are supported but we'll take a look at the most common ones only.
ext2 and ext3 Very likely your Linux partitions are Ext3. Ext2 used to be the standard file system for Linux, but these days, Ext3 and ReiserFS are usually the default file systems for almost every new Linux distro. Ext3 is a newer file system type that differs from Ext2 in that it's journaled, meaning that if you turn the computer off without properly shutting down, you shouldn't lose any data and your system shouldn't spend ages doing file system checks the next time you boot up.
reiserfs Your Linux partitions may very well be formatted as ReiserFS. Like Ext3, ReiserFS is a journaled file system, but it's much more advanced than Ext3. Many Linux distros (including SuSE) have started using ReiserFS as their default file system for Linux partitions.
swap The file system name is self-explanatory. The file system type "swap" is used in your swap partitions.
vfat and ntfs Your Windows partitions are probably either Vfat or NTFS. The 9x series (95, 98, ME) all use Vfat (more widely known as FAT32), and the NT series (NT, 2000, XP) use NTFS. In 2000 and XP you can choose the file system type, so 2000 and XP partitions may be formatted as Vfat, too. If you want to be able to write to your Windows partitions from Linux, I suggest formatting them as Vfat, because Linux's support for writing to NTFS partitions is a bit shabby at this moment.
auto No, this isn't a file system type :-) The option "auto" simply means that the file system type is detected automatically. If you take a look at the example fstab above, you'll see that the floppy and CD-ROM both have "auto" as their file system type. Why? Their file system type may vary. One floppy might be formatted for Windows and the other for Linux's Ext2. That's why it's wise to let the system automatically detect the file system type of media such as floppies and cdroms.

4th column: Mount options

The fourth column in fstab lists all the mount options for the device or partition. This is also the most confusing column in the fstab file, but knowing what some of the most common options mean, saves you from a big headache. Yes, there are many options available, but I'll take a look at the most widely used ones only. For more information, check out the man page of mount.
auto and noauto With the auto option, the device will be mounted automatically (at bootup, just like I told you a bit earlier, or when you issue the mount -a command). auto is the default option. If you don't want the device to be mounted automatically, use the noauto option in /etc/fstab. With noauto, the device can be mounted only explicitly.
user and nouser These are very useful options. The user option allows normal users to mount the device, whereas nouser lets only the root to mount the device. nouser is the default, which is a major cause of headache for new Linux users. If you're not able to mount your cdrom, floppy, Windows partition, or something else as a normal user, add the useroption into /etc/fstab.
exec and noexec exec lets you execute binaries that are on that partition, whereas noexec doesn't let you do that. noexec might be useful for a partition that contains binaries you don't want to execute on your system, or that can't even be executed on your system. This might be the case of a Windows partition.
exec is the default option, which is a good thing. Imagine what would happen if you accidentally used the noexec option with your Linux root partition...
ro Mount the file system read-only.
rw Mount the file system read-write. Again, using this option might cure the headache of many new Linux users who are tearing their hair off because they can't write to their floppies, Windows partitions, or something else.
sync and async How the input and output to the file system should be done. sync means it's done synchronously. If you look at the examplefstab, you'll notice that this is the option used with the floppy. In plain English, this means that when you, for example, copy a file to the floppy, the changes are physically written to the floppy at the same time you issue the copy command.
However, if you have the async option in /etc/fstab, input and output is done asynchronously. Now when you copy a file to the floppy, the changes may be physically written to it long time after issuing the command. This isn't bad, and may sometimes be favorable, but can cause some nasty accidents: if you just remove the floppy without unmounting it first, the copied file may not physically exist on the floppy yet!
async is the default. However, it may be wise to use sync with the floppy, especially if you're used to the way it's done in Windows and have a tendency to remove floppies before unmounting them first.
defaults Uses the default options that are rw, suid, dev, exec, auto, nouser, and async.

5th and 6th columns: Dump and fsck options

Dump and, uh, what options? Well, dump is a backup utility and fsck is a file system check utility. I won't discuss them in great length here (they would both need their own tuXfile), but I'll mention them, because otherwise you'd spend the rest of the day wondering what on God's green Earth do these things mean.
The 5th column in /etc/fstab is the dump option. Dump checks it and uses the number to decide if a file system should be backed up. If it's zero, dump will ignore that file system. If you take a look at the example fstab, you'll notice that the 5th column is zero in most cases.
The 6th column is a fsck option. fsck looks at the number in the 6th column to determine in which order the file systems should be checked. If it's zero, fsck won't check the file system.

Example /etc/fstab entries

As an example, we'll take a look at a couple of fstab entries that have been a source of endless frustration for new Linux users: floppy and CD-ROM (although these days floppies aren't that important anymore).
/dev/fd0 /media/floppy auto rw,noauto,user,sync 0 0
This line means that the floppy is mounted to /media/floppy by default and that its file system type is detected automatically. This is useful because the type of the floppy may wary. Note especially the rw and user options: they must be there if you want to be able to mount and write to the floppy as a normal user. If you have trouble with this, check your fstabfile to see if these options are there. Also note the sync option. It can be async just as well, but it's sync because of reasons discussed a bit earlier.
/dev/cdrom /media/cdrom auto ro,noauto,user,exec 0 0
Note, again, the user option that enables you to mount the CD as a normal user. The CD-ROM has the ro option because it's no use mounting a CD-ROM read-write because you wouldn't be able to write to it anyway. Also note the exec option. It's especially useful if you'd like to be able to execute something from your CD.
Also note that the noauto option is used with the floppy and CD-ROM. This means that they won't be automatically mounted when your Linux system boots up. This is useful for removable media, because sometimes there won't be any floppy or CD-ROM when you boot up your system, so there isn't any reason to try to mount something that doesn't even exist.

glusterfs 3.5


A Distributed File System is a file system that allows multiple clients to concurrently access data across multiple servers or bricks in a trusted storage pool

GlusterFS uses a native FUSE-based client to export the file system, but it can also be configured to use NFS and CIFS to export the storage system to client hosts that cannot use the native client (FUSE).
GlusterFS is a powerful network/cluster filesystem running in user space that uses FUSE to connect 

with the VFS layer in the OS. GlusterFS is a File System itself that uses already tried and tested 

disk file systems like ext3, ext4, xfs, etc. to store the data. It can easily scale up to petabytes 

of storage which is available to user under a single mount point .

FUSE is a loadable kernel module for UNIX-like operating systems. It enables non-privileged users to create their own file systems without editing kernel code. This is achieved by running file system code in user space, while the actual FUSE module provides a bridge to kernel. 

Terms.

brick  - A locally attached filesystem (e.g. xfs on top of LVM) that is part of a volume.For example, if a server named storage1.example.com had a local storage mounted under /mnt/disk1, a brick would be referred to as storage1.example.com:/mnt/disk1.
client - The machine which mounts the volume.
server - The machine which hosts the filesystem in which data will be stored.
volume - A Network available filesystem which can be mounted using native GlusterFS, NFS, CIFS, it is a logical collection of bricks. Most management operations in GlusterFS happen on the volume level.

etc.


apt-get install xfsprogs
apt-get install software-properties-common
sudo add-apt-repository ppa:gluster/glusterfs-3.5
apt-get update
sudo apt-get install glusterfs-server


<if vmware used and additional harddisk is used , to detect new disk added without restart run 
below command>
#ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done


fdisk /dev/sdb
...make new partition as lvm

pvcreate /dev/sdb1

vgcreate vg10 /dev/sdb1

lvcreate -L 1G vg10 -n lvmhome
OR
lvcreate -l 100%FREE -n lvmhome testvg
mkfs.xfs -i size=512 /dev/mapper/vg10-lvmhome 

#Mount the new lvm to /public directory on both servers
mkdir -p /public/sdb1
mount -t xfs  /dev/mapper/vg10-lvmhome /public/sdb1
echo "/dev/mapper/vg10-lvmhome /public/sdb1 xfs defaults 0 0" >> /etc/fstab 

#gluster peer status
Number of Peers: 0

Creating a trusted storage pool.
A trusted storage pool consists of the storage servers that will comprise the volume, in other 
words it is a trusted network of storage servers. When you start the first server, the storage pool 
consists of that server alone. To add additional storage servers to the storage pool, you can use 
the probe command from a storage server that is already trusted. The GlusterFS service must be 
running on all storage servers that you want to add to the storage pool.

Example 
( To create a trusted storage pool of four servers, add three servers to the storage pool from 

server gnode1 )

1. Probe the servers you want to add to the storage pool  on only one primary server eg here gluster1

root@gluster1:~# gluster peer probe gluster2
peer probe: success. 

Note: Do not self-probe local host - gluster1.

@gluster1 server
root@gluster1:~# gluster peer status
Number of Peers: 1

Hostname: gluster2
Uuid: 925b360f-a85d-44b8-87d1-94a0c4270e17
State: Peer in Cluster (Connected)

@gluster2 server
root@gluster2:~# gluster peer status
Number of Peers: 1

Hostname: 192.168.163.139
Uuid: 4f5f5a70-be91-4754-889b-ca0e708c0be3
State: Peer in Cluster (Connected)

Now that we have a trusted storage pool consisting of 4 servers lets create the Volumes that we can 
actually use to store files later on.
 Run below command in only one primary server

@gluster1#gluster volume create gvola replica 2 gluster1:/public/sdb1/brick/ gluster2:/public/sdb1/brick/

another example 
cat /etc/fstab   "on all nodes"
 /dev/sdb1  /export/disk1  xfs defaults 0 0
run `mkdir  /export/disk1/brick` on all nodes

# gluster volume create GWEB replica 3 mx1:/export/disk1/brick/  mx2:/export/disk1/brick/  mx3:/export/disk1/brick/

@gluster1# gluster volume start gvola
volume start: gvola: success
To confirm , make sure you see volume started.
#gluster volume info
 Volume Name: gvola
Type: Replicate
Volume ID: c29b0f57-c018-4d4e-9bdc-2dda6f122dfc
Status: Started
OR run #gluster volume status


Note: If the volume is not started, clues as to what went wrong will be in log files under /var/log/glusterfs on one or both of the servers - usually in etc-glusterfs-glusterd.vol.log

Allowing client to mount

#gluster volume set gvola auth.allow 192.168.163.141

At client side
modprobe fuse
to make sure fuse is loaded into kernel
dmesg | grep fuse

apt-get install glusterfs-client   <make sure version of client and server match>

Finally mounting the filesystem:-

mount -t glusterfs gluster1:gvola /mnt


Expanding Volume by adding Bricks  

 

 

Removing Brick

gluster volume rebalance GWEB stop   #stop rebalance if runing

gluster volume remove-brick GWEB replica 3 mx1:/export/disk2/brick mx2:/export/disk2/brick mx3:/export/disk2/brick start    #use "force" instead of "start"
























Detect new hard disk added in vm-ware workstation v 10.0 without reboot



ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done
fdisk -l

git intro

 git clone https://github.com/miguelgrinberg/flasky.git

#creating branch called "test" and switch to it
git checkout -b test
 
git branch  #to know which branch
* test    <=this is current branch
  master
 
git status
git checkout README.md  #to discard changes

Or you can delete the whole branch:
$ git checkout master   #switch to master
$ git branch -D test


git  add .  #adds all to staging

git commit -a -m "message to forkers or self reference" #commit all
git commit file1 file2  #commit particular files
 
How do you know which commits have not yet been pushed upstream, but are still sitting in branches?  
git status won't tell you, so use this command: 

git log --branches --not --remotes
 
Add existing file to git hub
############################3


git init 

git add . 

git commit -m "Initial commit" 

git remote add origin <project url> 

git push -f origin master







 
 
 

file descriptor

Any program that runs on a Linux machine has access to something called a File Descriptor Table.This table acts as a map providing the process access to "files, directories, unnamed pipes, named pipes, sockets and kernel-level data structures" . This table exists for each process. Inside the bash shell you have access to the three standard file descriptors: standard input, standard output and standard error.
Standard Input, Standard Output, and Standard Error are all character devices. Character devices provide a mechanism to send a stream of characters or bytes. A stream provides sequential access – that is, it provides output in the order in which it was received, this is also known as a FIFO pipe, which stands for First-In First-Out

In simple words, when you open a file, the operating system creates an entry to represent that file and store the information about that opened file. So if there are 100 files opened in your OS then there will be 100 entries in OS (somewhere in kernel). These entries are represented by integers like (...100, 101, 102....). This entry number is the file descriptor. So it is just an integer number that uniquely represents an opened file in operating system. If your process opens 10 files then your Process table will have 10 entries for file descriptors.
Similarly when you open a network socket, it is also represented by an integer and it is called Socket Descriptor.

Why is number of open files limited in Linux?

The reason is that the operating system needs memory to manage each open file, and memory is a limited resource - especially on embedded systems.
The reason is that the operating system needs memory to manage each open file, and memory is a limited resource - especially on embedded systems.

As root user you can change the maximum of the open files count per process (via ulimit -n) and per system (e.g   echo 800000 > /proc/sys/fs/file-max).
note that lsof | wc -l sums up a lot of duplicated entries (forked processes can share file handles etc). That number could be much higher than the limit set in /proc/sys/fs/file-max.

To get the current number of open files from the Linux kernel point of view, do this: cat /proc/sys/file/file-nr

Example: This server has 40096 out of max 65536 open files, although lsof reports a much larger number:

# cat /proc/sys/fs/file-max
65536
# cat /proc/sys/fs/file-nr 
40096   0       65536
# lsof | wc -l
521504

Standard Input

Standard Input is a file descriptor that a program is given for input sent to it. On Linux machines the file descriptor can be accessed under the path /proc/PID/fd/0, where PID is the process id of the program. When the output of one command is piped into the input of another command, the input is taken from Standard Input. It is often referred to by the token STDIN or the file descriptor 0.

Standard Output

Standard Output is a file descriptor that a program is given to send output data to. When a command is run and output goes to a terminal, the output is usually being sent to Standard Output. It is worth nothing that there are exceptions where the output is being sent directly to the terminal. This is the case with anything that uses the curses library for rendering, such as irssi or top. On Linux machines the file descriptor can be accessed under the path /proc/PID/fd/1 where PID is the process id of the command. When the output of a command is piped to another command it is sending the contents of Standard Output. This is often referred to as STDOUT or the file descriptor 1.

Standard Error

Standard Error is a file descriptor that a program is given to send error output data to. When a command reports an error to the terminal it is most often sent through Standard Error. On Linux machines the file descriptor can be accessed under the path /proc/PID/fd/2 where PID is the process id of the command. When displayed in a terminal and not using any forms of redirection there appears to be no difference to the user between Standard Error and Standard Output. It is often referred to by STDERR and the file descriptor 2.

apache 2.4 tuning and Keepalive

https://servercheck.in/blog/3-small-tweaks-make-apache-fly

Note: There is a good discussion on Reddit about situations when KeepAlive may be helpful and may, in fact, help Apache (or your server in general) perform better, like if you have an AJAX-heavy site, or if you are serving many requests to mobile or international users. Additionally, if you use a reverse proxy like squid, Varnish, or Nginx in front of Apache, KeepAlive doesn't have the same cost in terms of memory and process usage.
KeepAlive does one simple thing: destroy Apache's ability to handle many concurrent requests. Well, that and speed up existing connections by allowing them to download all assets before closing a TCP connection between a browser and your server (see note above).
This feature was designed to help ensure a browser could load the HTML, some images, stylesheets, etc. from your server all within one connection. Before people started using CDNs like CloudFlare or Amazon S3 for static content, and when most people had internet connections with hundreds of milliseconds of latency, this setting was much more valuable. (It still could be, in some circumstances, for mobile clients on 3G or LTE networks, or if you have an AJAX-heavy site.)
However, for many websites today, either setting the KeepAliveTimeout to a lower value like 1-5 seconds or switching KeepAlive off altogether will be a much better option.
Real-world example: When I launched Server Check.in with this thread on Hacker News, the post made the HN front page, meaning I was getting upwards of 10-20 requests per second for an hour or so. I noticed quickly that the server's load was under 1.00, and nothing seemed awry, but trying to access https://servercheck.in/ was taking 30 seconds or longer!
Turning off KeepAlive allowed the server to serve more users more quickly, since I didn't have a bunch of httpd threads sitting connected to browsers that had already received all the content they needed. If I want to turn it back on at some point, I'll make sure to set it lower than the default of 30 seconds!
Caveat: Now, in my case, I have the MaxClients directive set to 45, because with Drupal, I've made sure I don't spawn more threads than my server's limited memory can handle (I'll get to the why's for this below). If you are serving only static/cached content, and don't need to have a bunch of memory-hogging httpd threads for a PHP application like Drupal, you may be able to live with KeepAlive (make sure the timeout is low, still!), and a much larger MaxClients setting.

MaxClients

Queuing requests may save your server from swapping.
This setting helps Apache fly when your server is getting hit hard, say by a post from Reddit, Hacker News, or some fast and furious marketing campaign.
MaxClients is pretty self-descriptive: it's a setting that tells Apache the maximum number of clients it should serve simultaneously. It's important that you choose a sane value for this setting to prevent any number of bad things from happening:
  • Set it too low and you might cause people to wait for Apache to respond to their request while your server is almost sitting idle, with plenty of RAM and CPU to spare.
  • Set it too high and watch your server die in a slow, painful death as Apache runs out of RAM and starts swapping to disk. And watch page response times go from milliseconds to seconds or even minutes.
There's a really simple way you can know exactly how high to set MaxClients:
(Total RAM - RAM used for Linux, MySQL, etc.) / Average httpd process size.
To get the average httpd process size, log into your server and run the following on the command line: ps aux | grep 'httpd' | awk '{print $6/1024 " MB";}'. This will output a list of process sizes. If you want to calculate the average on-the-fly, try the command ps aux | grep 'httpd' | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print avg " MB";}'. It's best to run this a few different times throughout a normal day to see if there's any major fluctuation in process size.
Let's say your average process is 50 MB (fairly common if you're using PHP and a CMS like Wordpress or Drupal!). You have a VPS with 2 GB of RAM, and you have about .5 GB allocated to MySQL (you can find the full amount with the command ps aux | grep 'mysql' | awk '{print $6/1024 " MB";}'). Let's leave a little overhead for Linux and other bits on the server, say .4 GB:
(2000 MB - 900 MB) / 50 MB = 22
You should set the MaxClients directive to 22, maybe even a little lower to allow for more overhead when your server is getting hammered. Apache's default is usually > 200—this means if your server gets hit by a more than 22 people in a short period of time, it will slow to a crawl, since Apache will gobble up all the RAM!
Setting the MaxClients value lower will allow Apache to simply queue up further requests until it gets a free thread (remember, also, that if you have KeepAlive on, threads will be locked up for [KeepAliveTimeout] seconds!). This might seem like a bad thing... but it's a lot better doing this and serving queued requests quickly (since Apache is working from RAM and not swap space), than trying to serve a hundred requests at once and having massive slowdowns for everyone!
Real-world example: One site I work with had a page pick up tons of traffic over the course of a few hours, and the web server (a small 2 GB VPS running LAMP) was getting hammered by up to 100 separate requests per second. We had the MaxClients setting a bit too high, and the server immediately started swapping. It was hard even connecting to the server via SSH, and when I checked top, the server was using about 4 GB of swap (yikes!), and the CPU was spiking around 45 (normally around .2-.3). Once we set MaxClients to a sane amount and restarted Apache, the server was able to get most pages served in 2-3 seconds (instead of 2-3 minutes—ifever). Once traffic died down, we were serving pages in less than 1 second again.

AllowOverride

AllowOverride is basically Apache's way of allowing developers to be lazy. Instead of using a global configuration file and includes, Apache lets you stick an '.htaccess' file in any directory, anywhere, and every time anyone requests any page through Apache, Apache will recursively scan every directory from the site's root to apply rules in .htaccess files.
This is very convenient—especially in situations like shared hosting, where the hosting provider can't be bothered to include hundreds of extra configuration directives in the main httpd.conf file, or (for security purposes) allow everyone on the server to have their own configuration files included via httpd.conf!
However, if you are running only one or two websites on a server, or you generally have full control of the server, you can turn off this convenient feature and simply add the rules into httpd.conf or an include (to add an include, just use something like Include /home/user/public_html/.htaccess inside the VirtualHosts directive for your server, along with the rule AllowOverride None.
Real-world example: The impact of this change on server performance varies greatly, and depends mostly on how many directory-levels deep you have files that are served on a given page request. For most people, though, there may be a file in something like /home/user/public_html/sites/sitename/files/images/cached/large/thumbnail/image.jpg. In this case, Apache has to recurse through 10 levels of directories, parsing all found .htaccess files, just to serve this one image file. For one Drupal site, though, which is a VPS with a virtualized disk on a SAN, I've measured 7-10% faster individual page loads.
Caveat: Many CMSes like Wordpress and Drupal rely on .htaccess rules for certain functionality, like 'Clean URLs', www-to-non-www redirects, file upload protections, and static content caching. Make sure you include any relevant .htaccess files in your VirtualHosts directive if you set AllowOverrides to None. See more: How to make Apache faster for Drupal.
Also, the real-world speedup you'll get when using a server that has a dedicated, real hard drive or SSD will be much smaller than a server that has a slow drive or uses NAS/SAN storage.

Conclusion

These are just three of 'low-hanging fruit' performance-related settings buried in your Apache httpd.conf file; many others will have a big impact on your site's performance as well. With proper tuning, and an eye towards memory usage, you can make Apache as scalable, fast and lightweight as almost any web server.


The problem

By default apache2 is configured to support 150 concurrent connections. This forces all parallel requests beyond that limit to wait. Especially if, for example, active sync clients maintain a permanent connection for push events to arrive.
To calculate the number of concurrent sessions each of your apache nodes must be able to provide, consider the total number of concurrent sessions in your OX cluster and divide it by the number of apache nodes involved in serving those sessions. Then add some room for statistical fluctuations.

The solution

This is an example configuration to provide 8000 concurrent connections. Please ensure that your apache is using the mpm_worker module. This allows us to serve lots of concurrent connections by using less RAM than with mpm_prefork as we are going to start much less processes.
<IfModule mpm_worker_module>
    ServerLimit             250
    StartServers             10
    MinSpareThreads          75
    MaxSpareThreads         250 
    ThreadLimit              64
    ThreadsPerChild          32
    MaxClients             8000
    MaxRequestsPerChild   10000
</IfModule>

Short explanation of the parameters:

ServerLimitDeclares the maximum number of running apache processes. If you change this value you have to restart the daemon.
StartServersThe number of processes to start initially when starting the apache daemon.
MinSpareThreads/MaxSpareThreadsThis regulates how many threads may stay idle without being killed. Apache regulates this on its own very well with default values.
ThreadsPerChildHow many threads can be created per process. Can be changed during a reload.
ThreadLimitThreadsPerChild can be configured as high as this value during runtime. If you change this value you have to restart the daemon.
MaxClientsThis declares how many concurrent connections we provide. Devided by ThreadsPerChild you get the suitable ServerLimit value. May be less than ServerLimit * ThreadsPerChild to reserve some resources that can be engaged during runtime with increasing MaxClients and reloading the configuration.
MaxRequestsPerChildDefines the number of Connections that a process can handle during its lifetime (keep-alives are counted once). After that it will be killed. This can be used to prevent possible apache memory leaks. If set to 0 the lifetime is infinite.

Haproxy 1.5 HTTPS termination and Load balancing

Create certificate files in /etc/haproxy

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/haproxy/apache.pem -out /etc/haproxy/apache.crt

 openssl req  $@  -new  -x509  -days  365  -nodes  -out  apache.pem -keyout  apache.pem

#here $@  =  '@' Expands to the positional parameters, starting from one.  When the expansion occurs within double quotes, each parameter expands to  a  separate  word.   That  is, "$@" is equivalent to "$1" "$2" ...

#chmod 600 /etc/apache2/apache.pem

cat   apache.pem   apache.key  >   apache.final.pem


#This is self signed

configuration file /etc/haproxy/haproxy.cfg

root@haserva:~# cat /etc/haproxy/haproxy.cfg
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 256

# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private

# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL).
ssl-default-bind-ciphers kEECDH+aRSA+AES:kRSA+AES:+AES256:RC4-SHA:!kEDH:!LOW:!EXP:!MD5:!aNULL:!eNULL
        ssl-default-bind-options no-sslv3

defaults
log global
mode http
option httplog
option dontlognull
option  forwardfor #enables the insertion of the X-Forwarded-For header to requests sent to servers.
        option redispatch
option http-server-close #reduces latency between HAProxy and your users by closing connections but maintaining keep-alives,Enable or disable HTTP connection closing on the server side,enables HTTP connection-close mode on the server side while keeping the ability to support HTTP keep-alive and pipelining on the client side.  This provides the lowest latency on the client side (slow network) and the fastest session reuse on the server side to save server resources
option tcp-smart-accept
option tcp-smart-connect
#option dontlog-normal
timeout connect 5000#amount of time HAProxy should spend trying to connect to a host so if a host died, HAProxy would try to connect to the same host for 30 seconds option specifies the maximum time to wait for a connection attempt to a VPS to succeed.
        timeout client  50000
        timeout server  50000
timeout http-keep-alive 10s
timeout check 5s
retries 3
compression algo gzip
compression type text/html text/html;charset=utf-8 text/plain text/css text/javascript application/x-javascript application/javascript application/ecmascript application/rss+xml application/atomsvc+xml application/atom+xml application/atom+xml;type=entry application/atom+xml;type=feed application/cmisquery+xml application/cmisallowableactions+xml application/cmisatom+xml application/cmistree+xml application/cmisacl+xml application/msword application/vnd.ms-excel application/vnd.ms-powerpoint
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
#frontend defn
frontend www-http
bind *:80
reqadd X-Forwarded-Proto:\ http
default_backend apache
frontend www-https
bind *:443 ssl crt /etc/haproxy/apache.final.pem
reqadd X-Forwarded-Proto:\ https
default_backend apache

#backend definitions
backend apache
redirect scheme https if !{ ssl_fc }
mode http
###statistics page
stats enable
stats auth demo:p@ssw0rd
        stats hide-version
stats uri /monitor
stats refresh 2s
###statistics page end

# balance source
# cookie SRV_ID prefix
# server web1 192.168.163.40:80 check cookie web1
# server web2 192.168.163.41:80 check cookie web2
balance roundrobin
server web1 192.168.163.40:80 check
server web2 192.168.163.41:80 check

central php session directory
..............................................
 vim /etc/php5/apache2/php.ini

session.save_path = "/gmount/phpsession/"       #here gmount/phpsession is new directory to store session by default phpsession is /var/lib/php5


Now copy ownership and file permission

chmod --reference=/var/lib/php5/ /gmount/phpsession/
chown root:root /gmount/phpsession



MariaDB Galera Cluster Monitoring

http://galeracluster.com/documentation-webpages/monitoringthecluster.html#monitoring-cluster

To check cluster integrity, for each node complete the following steps:
  1. Check that the node is part of the cluster:
Each node in the cluster should provide the same value. If you find a node that carries a different cluster state UUID, that node is not connected to the cluster.
At Node 1

MariaDB [(none)]> show status like 'wsrep_cluster_state_uuid';
MariaDB [(none)]> show status like 'wsrep_cluster_state_uuid';
+--------------------------+--------------------------------------+
| Variable_name            | Value                                |
+--------------------------+--------------------------------------+
| wsrep_cluster_state_uuid | e48cd2c2-ab6e-11e4-a8af-268a757dde7a |
+--------------------------+--------------------------------------+

1 row in set (0.00 sec)

Node 2 and Node 3 should return same UUID


  1. Check that the node belongs to the same component:
    show status like 'wsrep_cluster_conf_id';
    +-----------------------+-------+
    | Variable_name         | Value |
    +-----------------------+-------+
    | wsrep_cluster_conf_id | 4     |
    +-----------------------+-------+
    1 row in set (0.00 sec)
    
    Each node in the cluster should provide the same value. If you find a node that carries a different value, this indicates the cluster is partitioned. Once network connectivity is restored, the value will align itself with the others.
On the first node check cluster size:-


 > show status like 'wsrep_cluster_size';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| wsrep_cluster_size | 3     |
+--------------------+-------+

If the value equals the expected number of nodes in the cluster, all nodes are connected to the cluster.
Note

You only need to check the cluster size on one node.
Check primary cluster status
show status like 'wsrep_cluster_status';
+----------------------+---------+
| Variable_name        | Value   |
+----------------------+---------+
| wsrep_cluster_status | Primary |

The node should return a value of Primary. Other values indicate that the node is part of a nonoperational component. This can occur in cases of multiple membership changes and a loss of quorum or in the case of a split-brain condition.

  1. Check the node status:
    SHOW VARIABLES LIKE 'wsrep_ready';
    
    If the value is TRUE, the node can accept SQL load.
  2. If the wsrep_ready value is FALSE, check that the node is connected:
    SHOW VARIABLES LIKE 'wsrep_connected';
    
    If the value is OFF, the node has not connected to any of the cluster components. This may relate to misconfiguration. For instance, if the node uses invalid values forwsrep_cluster_address or wsrep_cluster_name.
    Check the error log for proper diagnostics.
  3. If the node is connected, but still cannot accept SQL load, check that the node is part of the Primary Component:
    SHOW VARIABLES LIKE 'wsrep_local_state_comment';
    
    If the the state comment is Joining, Waiting for SST, or Joined, the node is syncing with the cluster.