Hive Training Plan

From Wiki

Jump to: navigation, search


Contents

What is chroot and how it works?

Chroot

hackman@gamelon:~$ ls -l /proc/self/root 
lrwxrwxrwx 1 hackman hackman 0 Jun  3 10:43 /proc/self/root -> //

[root@gamelon ~]# chroot /storage/chroot/
bash-4.0#
[root@gamelon ~]# ls -l /proc/1983/root 
lrwxrwxrwx 1 root root 0 Jun  3 10:44 /proc/1983/root -> /storage/chroot

Bind mounts

This is part of the man page of mount.

Since Linux 2.4.0 it is possible to remount part of the file hierarchy somewhere else. The call is

   mount --bind olddir newdir

or shortoption

   mount -B olddir newdir

or fstab entry is:

   /olddir /newdir none bind

After this call the same contents are accessible in two places. One can also remount a single file (on a single file).

This call attaches only (part of) a single filesystem, not possible submounts. The entire file hierarchy including submounts is attached a second place using

  mount --rbind olddir newdir
  

or short option

  mount -R olddir newdir

Note that the filesystem mount options will remain the same as those on the original mount point, and can-not be changed by passing the -o option along with --bind/--rbind. The mount options can be changed by a separate remount command, for example:

  mount --bind olddir newdir
  mount -o remount,ro newdir

Benefits of tmpfs

Our mount scheme

/
|-bin/
|-boot/
|-dev/
|-etc/
|-chroot/
|.....
|-home/
|     |-user1/
|     |      |-etc
|     |      |-ftp
|     |      |-mail
|     |      \-public_html
|     |
|     |-user2/
|     |      |-etc
|     |      |-ftp
|     |      |-mail
|     |      \-public_html
|     |
|     |-user3/
|     |      |-etc
|     |      |-ftp
|     |      |-mail
|     |      \-public_html
|     |....................
|
|-var/
|    |-suexec/
|    |       |-baseos
|    |       |       |-chroot
|    |       |       |-
|    |       |       |-
|    |       |       
|    |       |-user1/       => /var/suexec/baseos
|    |       |      |......................
|    |       |      |-chroot
|    |       |      |-home/ => /home/user1
|    |       |      |......................
|    |       |
|    |       |-user2/       => /var/suexec/baseos
|    |       |      |......................
|    |       |      |-home/ => /home/user2
|    |       |      |......................
|    |       |
|    |       |-user3/       => /var/suexec/baseos
|    |       |      |......................
|    |       |      |-home/ => /home/user3
|    |       |      |......................

What are rlimits and how they work?

Inheritance

UID  0       0       111        111
   init -> login -> shell -> application
UID   0       0        0            99          99        0         314
   init -> shell -> apache -> apache child -> shell -> suexec -> application
UID   0       0        0         314          314         314
   init -> shell -> crond -> crond child -> shell -> application
UID   0       0        0        314           314
   init -> shell -> sshd -> user shell -> application

Apache standard limits


Statistics collection

General idea

parent ( start timers )
  |- child (execute script)
parent ( end timers + collect times() )
parent ( send the collected information to cpustatsd using unix domain socket )
suexec -> cpustatsd -> DB <- [json] web interface
crond  -> cpustatsd -> DB <- [json] web interface

More information

If you are more interested in the statistics collection:

Apache modifications

Apache dynamic requests handling

1. Request 
    \/
2. Apache parent process
    \/
3. Apache child process
    \/
4. Identify file type and find its handler
    \/
5. Module that handles the file type (mod_php, mod_suphp, mod_perl, mod_python, mod_passanger)
    \/
6. Execute the application (owner of the process is the user with which Apache is running)

If at step 5 the chosed module is mod_cgi we have 2 more cases:

  mod_cgi without suexec
    \/
  Execute the application (owner of the process is the user with which Apache is running)
------------------------------
  mod_cgi with suexec
    \/
  run suexec with params (user, group and file to run)
    \/
  Execute the application (owner of the process is the user supplied on the command line)


BaseOS

PHP ini loading

phpXX/lib/php.ini
/home/USER/public_html/..../../php.ini
phpXX/etc/*.ini


Web Interfaces


Managing versions (RPM)

cPanel Plugins

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox