pxeboot installations how to



wget http://192.168.10.105/pxebootCentos54_64bit.tgz
  • untar pxebootCentos54_64bit.tgz to your /boot
  • add the following to /etc/grub.conf
 title CentOS 5.4 Installation
root (hd0,0)
kernel /pxeboot/vmlinuz ro root=LABEL=/ ip=192.168.50.110 netmask=255.255.255.0 gateway=192.168.2.234
dns=192.168.2.234 hostname=centos44 text ks=http://202.162.242.200/ks.cfg ksdevice=eth0
initrd /pxeboot/initrd.img

this is the ks.fcg file http://192.168.10.105/ks.cfg

auth  --useshadow  --enablemd5
install
url --url=http://192.168.10.105/CentOS54X
lang en_US
keyboard us
network --bootproto=static --device=eth0 --ip=206.183.108.166 --netmask=255.255.255.0 --gateway=206.183.108.1 --nameserver=209.120.245.58 --hostname=dell860-535.rapidns.com --onboot=on
zerombr
rootpw --iscrypted $1$4kHiDPby$etAhqn01O83WXVXju0K/S/
firewall --disable
firstboot --disable
authconfig --enableshadow --enablemd5
selinux --disable
timezone Asia/Calcutta
bootloader --location=mbr --append="rhgb quiet"
zerombr yes
skipx

clearpart --all
part --ondrive=sda / --fstype ext3 --size=1 --grow
part --ondrive=sda /boot --fstype ext3 --size=200 --asprimary
part --ondrive=sda swap --size=7024


reboot

%packages
@base
@editors
@core
@development-libs
@development-tools
@sql-server
kernel-devel
emacs



  • make the above added kernel image to be default image to boot and reboot the server.
  • After reboot Centos 5.4 installation will begin.

Script removes all old files from particular directories

#!/bin/bash
#
# This Script removes all old files from particular directories
#
set -x
remFiles(){
  path=`echo $1`   # This is inefficient but We dont expect too many files
  days=$2
  dirs=$3
  for dir in $path;do
    if [ -z "$dirs" ];then
        find "$dir"   -mtime  +$days -type f -exec rm -vf {} \;
    else
        find "$dir"   -mtime  +$days -type d -exec rm -vfr {} \;
    fi
  done
}
remFiles "/net/serverbackup/backup/*" "2"


Important things to know in apache


Email

ServerAdmin

ServerAdmin webmaster@domain.com

Sets the email address for the server administrator - this will be used if you have setup the server to contact you on errors. It is also shown in the ServerSignature (if set to 'Email' - see below)

Domain Name

ServerName and ServerAlias

ServerName domain.com
ServerAlias www.domain.com

Sets the domain name for the virtual host. You can have as many aliases as required. For example, you can have domain.com and domain.net point to the same content.

Note this is not a rewrite rule (we'll look at those later) but the domains defined here will serve the same content (assuming you have set the DNS to point to your Slice IP).

Index Files

DirectoryIndex

DirectoryIndex index.html

Defines the index file (the 'home' page that is shown on entering the domain address). Useful if you have want the user to be directed to an alternate page or to a non-standard home page.

Do note this is not a good way of redirecting users as they may go directly to a non specified page such as domain.com/index.php whilst the DirectoryIndex will only work for those entering domain.com.

Documents

DocumentRoot

DocumentRoot /home/demo/public_html/domain.com/public

The location of the domain's public files. Use an absolute path name.

Log Files

ErrorLog and CustomLog

LogLevel warn
ErrorLog /home/demo/public_html/domain.com/log/error.log
CustomLog /home/demo/public_html/domain.com/log/access.log combined

Set the Log levels and the location for the Virtual Hosts log files. Very useful for easy analysis of the domain statistics.

Error Documents

ErrorDocument

ErrorDocument 404 /errors/404.html
ErrorDocument 403 /errors/403.html

Used for all the standard error messages.

In these examples I have an 'errors' folder in my public directory. I created each error document and place them in the 'errors' folder. The paths shown are relative to the DocumentRoot folder defined above.

If not defined, Apache will generated its own error pages. Custom error pages are more user friendly and can be customised as much, or as little, as you want.

Apache Footers

ServerSignature

ServerSignature On

Sets whether the server details are displayed in any server generated error pages or index lists. Options are On, Off and Email.

Note the level of detail in the signature is configured via ServerTokens which cannot be set in the Virtual Hosts file - only in the main apache2.conf. See the Apache configuration #2 article for more details.

If set to Email, the ServerAdmin email will be displayed.

cgi-bin

ScriptAlias

ScriptAlias /cgi-bin/ /home/demo/public_html/domain.com/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>

Enables the cgi-bin location as defined by the custom virtual hosts layout. You can, of course, leave the cgi-bin in the DocumentRoot location if you so wish.

Directory

<Directory xxx/xxx>

<Directory /home/demo/public_html/domain.com/public>
Options FollowSymLinks
</Directory>

Set the Options for the specified directory - the example shown allows the Option FollowSymLinks to be enable for the public directory of domain.com

Listed below are further Options that can be set:

Directory Browsing

Options

Options -Indexes

To turn off directory browsing use '-Indexes' or 'None'. To turn them on, use '+Indexes'.

SSI

Options

Options -Includes

This Option disables Server Side Inlcudes.

Symlinks

Options

Options -FollowSymLinks

Enable or disable the option to follow symlinks. Be careful with this option as it can lead to security risks (inadvertently linking to configuration folders).

Dejay Clayton made a good suggestion in using SymLinksIfOwnerMatch instead of FollowSymLinks.

The SymLinksIfOwnerMatch allows symbolic links to be followed only if the owner of the link is identical to the owner of the target file or directory. Thus preventing many of the security risks than a simple FollowSymlinks can create.

.htaccess

AllowOverride

AllowOverride None

Setting AllowOverride to none disables .htaccess support. Set to All to allow them.

You can also specify which .htaccess features to enable such as:

AllowOverride AuthConfig Indexes

The Apache AllowOverride docs has more information on the different features.

Remember to specifically protect your .htaccess file. This can be done in two ways:

Firstly rename it to something obscure and, secondly, deny access to the file from external sources:

AccessFileName .myobscurefilename
<Files ~ "^\.my">
Order allow,deny
Deny from all
Satisfy All
</Files>

No Options

Options

Options None

This will turn off all the available options.

Hierarchy

Remember that the Options directives can be set per directory like this:

<Directory />
AllowOverride None
Options None
</Directory>

<Directory /home/demo/public_html/domain.com/public>
AllowOverride All
</directory>

This will turn of all Options and disable .htaccess support for all directories.

However, the second Directory setting will override the first and allow .htaccess support for the domain.com/public directory.

Summary

The Virtual Hosts file is at once an easy tool to use and a very powerful one. My advice is to enter one setting and test it. Then enter the next setting and so on.

Once familiar you will see you have fine control over all of your web folders and files.





how to create linux ISO

BUILD Machines

Current Build machines are

192.168.40.100 <i386>
192.168.50.165 <x86_64>

Chose OS

Currently the build is done on centos5

Build Directories

On 192.168.40.100 <i386>

distros name

On 192.168.50.165 <x86_64>


distros name

Getting Started

eg to create a product TEST ( Test can be any of name you would like to give you distros  )

<arch> ---- i386 or x86_64

Create directory /test of desired <arch> machine.

$ cd /test
$ mkdir <arch>

Copy the centos <arch> cd to /test/<arch>

$ mount /dev/cdrom /media
$ cd /media
$ cp -ar * /test/<arch>/
$ cp .discinfo /test/<arch>/

NOTE : .discinfo file os imp without wich it will give a error of not valid centos

Editing stage2

Editing Default CentOS 5.2 stage2.img

Install squashfs rpm

$ rpm -ivh squashfs-tools-3.0-4.x86_64.rpm 

Copy the stage2.img file from the images folder of the cd

$ cp stage2.img /opt/ 

Make Directory

$ mkdir -p /opt/stage2

Mount the copied stage2.img

$ mount -t squashfs stage2.img /media/ -o loop

Copy Contents

$ cd /media
$ cp -arp * /opt/stage2
$ cp .buildstamp /opt/stage2
$ cd /opt/stage2

$ ls -a
.  ..  .buildstamp  etc  lib  lib64  modules  proc  usr  var

Now to start editing the stage2

All the python files are stored under /opt/stage2/usr/lib/anaconda

$  vi kickstart.py

Hash the lines this is so that kickstart will ask for network if not specified in ks file

       if len(filter(lambda nd: nd.bootProto == "query", self.ksdata.network)) == 0:
dispatch.skipStep("network")

Hash this line so as to ask for the welcome screen

            dispatch.skipStep("welcome")

Copy following image files   (stage2) into /opt/stage2/usr/share/anaconda/pixmaps

anaconda_header.png
first-lowres.png
first.png
progress_first-375.png
progress_first-lowres.png
progress_first.png
splash1.png
splash.png
syslinux-splash.png

Copy /opt/stage2/usr/share/anaconda/pixmaps/rnotes after deleting all the files already present

03-centos5-yum.png
06-centos5-support.png
08-centos5-wiki.png
05-centos5-centosplus.png
01-centos5-welcome.png
02-centos5-donate.png
09-centos5-virtualization.png
07-centos5-docs.png
04-centos5-repos.png

now ur nearly done all thats left is a nice new stage2.img file

$ cd /opt/stage2 
$ mksquashfs . ../stage2.img.new
$ mv stage2.img.new stage2.img

Copy the new stage2.img into /test/<arch>/images/

Creating the kickstart file for auto install

$ cd /test/<arch>
$ vi legacy-mpart.cfg

auth --useshadow --enablemd5
install
cdrom
lang en_US
keyboard us
zerombr
firstboot --disable
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
bootloader --location=mbr --driveorder=hda
skipx

reboot

%packages
@ msx_packages

Include for auto partition under skipx

clearpart --all                       
part /boot --fstype="ext3" --size=200
part swap --recommended
part / --fstype="ext3" --grow --size=1

Including Scripts

Copy the scripts dir into /test/

$ cd /test/scripts

Make changes in each script according to arch...

Creating Make file

Create a Makefile in /test/ dir

vi Makefile 

MKISOFS=/usr/bin/mkisofs
DATE:=$(shell date +"%d-%m-%Y")
CDDIR=/test
ARCH=x86_64
REPODIR=$(CDDIR)/$(ARCH)
RPMDIR=$(CDDIR)/$(ARCH)/CentOS
INSTDIR=$(CDDIR)/roots/installer/usr/local/net/_install
VER=$(shell scripts/version.sh)
#BUILDRPM=/usr/src/redhat/RPMS/$(ARCH)
BUILDRPM=/usr/src/redhat/RPMS/noarch

test: repoclean repo iso

repoclean:
rm -rf $(REPODIR)/repodata/filelists.xml.gz $(REPODIR)/repodata/other.xml.gz $(REPODIR)/repodata/primary.xml.gz $(REPODIR)/repodata/repomd.xml

svnco:
$(CDDIR)/scripts/svnco.sh $(CDDIR)
$(CDDIR)/scripts/premake $(CDDIR)

initrd:
$(CDDIR)/scripts/makeinitrd.sh $(CDDIR)

repo:
scripts/makecomps.sh $(REPODIR)

iso:
@$(MKISOFS) -o $(CDDIR)/images/MailServ_x64-$(DATE).iso -V MailServ-$(VER) -p 'EMS' -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4\
-boot-info-table -R -J -v -T $(REPODIR)

rpmtest:
$(CDDIR)/scripts/rpmtest.sh $(CDDIR)
$(CDDIR)/scripts/dupshow.pl $(RPMDIR)

dupshow:
$(CDDIR)/scripts/dupshow.pl $(RPMDIR)

isocheck:
$(CDDIR)/scripts/isocheck $(CDDIR)

Generating repos

$ cd /test/<arch>/CentOS/

Keep only the desired packages and delete the rest

Making Initrd

The Makefile includes initrd:

Please run

$ make initrd

This will pick up the kickstart file (legacy.cfg and include it into the initrd)

Isolinux edit

cd /test/<arch>/isolinux
$ vi isolinux.cfg

default linux
prompt 1
timeout 600
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
kernel vmlinuz
append ks=file:/legacy.cfg initrd=initrd.img
label mpart
kernel vmlinuz
append ks=file:/legacy-mpart.cfg initrd=initrd.img
label text
kernel vmlinuz
append initrd=initrd.img text
label ks
kernel vmlinuz
append ks initrd=initrd.img
label local
localboot 1
label memtest86
kernel memtest
append -

This is to prevent errors of cannot find kickstart file since it is in the initrd

Making CD

$ mkdir /test/images
make test




how load balancer works ( ldirector )


________
| |
| client |
|________|
CIP=SGW=192.168.2.62 (eth0)
|
|
__________ |
| | | (Virtual IP=192.168.2.110, eth0:110) listening on port 25
| director |---|
| (suse) | |
|__________| | Director IP=192.168.2.24 (eth0)
|
|
-----------------------------------
| |
| |
Real IP=192.168.2.214(eth0) Real IP=192.168.2.230(eth0)
(VIP=192.168.2.110, lo:0) (VIP=192.168.2.110, lo:0)
______|______ ______|______
| | | |
| realserver | | realserver |
|____________| |____________|



on the LVS server
cat  /etc/ha.d/ldirectord.cf

quiescent=yes
checktimeout=10
checkinterval=30
autoreload=yes
logfile="/var/log/ldirectord.log"

virtual=192.168.2.110:25
        real=192.168.2.214:25 gate 9
        real=192.168.2.230:25 gate 8
        service=smtp
        protocol=tcp
        scheduler=wrr




THE APACHE SERVER STATUS & ERROR CODES


Successful Client Requests
200 OK
201 Created
202 Accepted
203 Non-Authorative Information
204 No Content
205 Reset Content
206 Partial Content
Client Request Redirected
300 Multiple Choices
301 Moved Permanently
302 Moved Temporarily
303 See Other
304 Not Modified
305 Use Proxy
Client Request Errors
400 Bad Request
401 Authorization Required
402 Payment Required (not used yet)
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable (encoding)
407 Proxy Authentication Required
408 Request Timed Out
409 Conflicting Request
410 Gone
411 Content Length Required
412 Precondition Failed
413 Request Entity Too Long
414 Request URI Too Long
415 Unsupported Media Type
Server Errors
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
505 HTTP Version Not Supported


mysql questions

  1. How do you start and stop MySQL on Windows? - net start MySQL, net stop MySQL
  2. How do you start MySQL on Linux? - /etc/init.d/mysql start
  3. Explain the difference between mysql and mysqli interfaces in PHP? - mysqli is the object-oriented version of mysql library functions.
  4. What's the default port for MySQL Server? - 3306
  5. What does tee command do in MySQL? - tee followed by a filename turns on MySQL logging to a specified file. It can be stopped by
  6. command notee.
  7. Can you save your connection settings to a conf file? - Yes, and name it ~/.my.conf. You might want to change the permissions on the file to 600, so that it's not readable by others.
  8. How do you change a password for an existing user via mysqladmin? - mysqladmin -u root -p password "newpassword"
  9. Use mysqldump to create a copy of the database? - mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql
  10. Have you ever used MySQL Administrator and MySQL Query Browser? Describe the tasks you accomplished with these tools.
  11. What are some good ideas regarding user security in MySQL? - There is no user without a password. There is no user without a user name. There is no user whose Host column contains % (which here indicates that the user can log in from anywhere in the network or the Internet). There are as few users as possible (in the ideal case only root) who have unrestricted access.
  12. Explain the difference between MyISAM Static and MyISAM Dynamic. - In MyISAM static all the fields have fixed width. The Dynamic MyISAM table would include fields such as TEXT, BLOB, etc. to accommodate the data types with various lengths. MyISAM Static would be easier to restore in case of corruption, since even though you might lose some data, you know exactly where to look for the beginning of the next record.
  13. What does myisamchk do? - It compressed the MyISAM tables, which reduces their disk usage.
  14. Explain advantages of InnoDB over MyISAM? - Row-level locking, transactions, foreign key constraints and crash recovery.
  15. Explain advantages of MyISAM over InnoDB? - Much more conservative approach to disk space management - each MyISAM table is stored in a separate file, which could be compressed then with myisamchk if needed. With InnoDB the tables are stored in tablespace, and not much further optimization is possible. All data except for TEXT and BLOB can occupy 8,000 bytes at most. No full text indexing is available for InnoDB. TRhe COUNT(*)s execute slower than in MyISAM due to tablespace complexity.
  16. What are HEAP tables in MySQL? - HEAP tables are in-memory. They are usually used for high-speed temporary storage. No TEXT or BLOB fields are allowed within HEAP tables. You can only use the comparison operators = and <=>. HEAP tables do not support AUTO_INCREMENT. Indexes must be NOT NULL.
  17. How do you control the max size of a HEAP table? - MySQL config variable max_heap_table_size.
  18. What are CSV tables? - Those are the special tables, data for which is saved into comma-separated values files. They cannot be indexed.
  19. Explain federated tables. - Introduced in MySQL 5.0, federated tables allow access to the tables located on other databases on other servers.
  20. What is SERIAL data type in MySQL? - BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT
  21. What happens when the column is set to AUTO INCREMENT and you reach the maximum value for that table? - It stops incrementing. It does not overflow to 0 to prevent data losses, but further inserts are going to produce an error, since the key has been used already.
  22. Explain the difference between BOOL, TINYINT and BIT. - Prior to MySQL 5.0.3: those are all synonyms. After MySQL 5.0.3: BIT data type can store 8 bytes of data and should be used for binary data.
  23. Explain the difference between FLOAT, DOUBLE and REAL. - FLOATs store floating point numbers with 8 place accuracy and take up 4 bytes. DOUBLEs store floating point numbers with 16 place accuracy and take up 8 bytes. REAL is a synonym of FLOAT for now.
  24. If you specify the data type as DECIMAL (5,2), what's the range of values that can go in this table? - 999.99 to -99.99. Note that with the negative number the minus sign is considered one of the digits.
  25. What happens if a table has one column defined as TIMESTAMP? - That field gets the current timestamp whenever the row gets altered.
  26. But what if you really want to store the timestamp data, such as the publication date of the article? - Create two columns of type TIMESTAMP and use the second one for your real data.
  27. Explain data type TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP - The column exhibits the same behavior as a single timestamp column in a table with no other timestamp columns.
  28. What does TIMESTAMP ON UPDATE CURRENT_TIMESTAMP data type do? - On initialization places a zero in that column, on future updates puts the current value of the timestamp in.
  29. Explain TIMESTAMP DEFAULT '2006:09:02 17:38:44′ ON UPDATE CURRENT_TIMESTAMP. - A default value is used on initialization, a current timestamp is inserted on update of the row.
  30. If I created a column with data type VARCHAR(3), what would I expect to see in MySQL table? - CHAR(3), since MySQL automatically adjusted the data type.

Difference between ip virtual hosting and name virtual hosting

IP-based virtual hosts use the IP address of the connection to determine the correct virtual host to serve. Therefore you need to have a separate IP address for each host. With name-based virtual hosting, the server relies on the client to report the hostname as part of the HTTP headers. Using this technique, many different hosts can share the same IP address.

Name-based virtual hosting is usually simpler, since you need only configure your DNS server to map each hostname to the correct IP address and then configure the Apache HTTP Server to recognize the different hostnames. Name-based virtual hosting also eases the demand for scarce IP addresses. Therefore you should use name-based virtual hosting unless there is a specific reason to choose IP-based virtual hosting. Some reasons why you might consider using IP-based virtual hosting:
  • Some ancient clients are not compatible with name-based virtual hosting. For name-based virtual hosting to work, the client must send the HTTP Host header. This is required by HTTP/1.1, and is implemented by all modern HTTP/1.0 browsers as an extension. If you need to support obsolete clients and still use name-based virtual hosting, a possible technique is discussed at the end of this document.
  • Name-based virtual hosting cannot be used with SSL secure servers because of the nature of the SSL protocol.
  • Some operating systems and network equipment implement bandwidth management techniques that cannot differentiate between hosts unless they are on separate IP addresses.




Other Articles

Enter your email address: