Monday, December 27, 2010

Linux Boot Chart

http://www.bootchart.org/download.html
http://bootchart.svn.sourceforge.net/viewvc/bootchart/trunk/bootchart/INSTALL

http://www.improvedsource.com/view.php/Boot_Fedora_Linux_Faster_How_I_Modified_Fedora_To_Boot_In_Under_25_Seconds/2/

Tuesday, November 23, 2010

Oracle General

http://www.kods.net/dba-skills-needed/
http://www.articles.freemegazone.com/oracle_CBO.php

https://updates.oracle.com/Orion/SimpleSearch/process_form?search_type=patch&patch_number=3283405&plat_lang=48P&display_type=&search_style=8&orderby=3&direction=d&old_type_list=&gobuttonpressed=&sortcolpressed=&tab_number=&c_release_parent=product&c_product_child=release

Oarcle Backup & Restore

http://oracledba.ezpowell.com/oracle/BackupAndRecovery.html
http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/backrec.htm
http://tamimdba.wordpress.com/2010/01/02/how-to-backup-and-restore-the-oracle-control-file/
http://download.oracle.com/docs/cd/E13789_01/bh.100/e13797/backuprecover.htm

Export Import:
http://www-it.desy.de/systems/services/databases/oracle/impexp/impexp.html.en

RMAN:

http://www.dbasupport.com/oracle/ora10g/backup_guide01.shtml

Oracle Patching Step by Step

http://www.articles.freemegazone.com/oracle-patching-secrets.php?ref=2
http://wiki.oracle.com/page/Patching+Hints+and+Tips
http://wiki.sdn.sap.com/wiki/display/HOME/Oracle++Patch+Install

Monday, November 22, 2010

Oracle RMAN backup

http://kr.forums.oracle.com/forums/thread.jspa?threadID=1091499&tstart=240
http://www.oracle-base.com/articles/10g/RMANEnhancements10g.php
http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10734/osbackup.htm
http://sqltech.cl/doc/oas10gR3/core.1013/b25209/br_intro.htm

Oracle Replication

http://www.akadia.com/services/ora_replication_guide.html

oracle EM Console

http://oradbapro.blogspot.com/2009/03/oracle-em-console-10g.html

Oracle Performance Tuning

http://www.oracle-base.com/articles/10g/SpaceObjectTransactionManagement10g.php#segment_advisor
http://www.orafaq.com/forum/mv/msg/84315/246965/136607/#msg_246965
http://www.orafaq.com/faq/performance_tuning

http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/toc.htm

http://www.orafaq.com/wiki/Category:Performance_Tuning

Oracle Patching

http://www.iselfschooling.com/mc4articles/mc4orapatch.htm
http://searchoracle.techtarget.com/tip/How-to-apply-an-Oracle-patch
http://www.akadia.com/services/ora_silent_install.html

Saturday, October 9, 2010

Oracle Instance

Clapton

http://www.arikaplan.com/oracle/ari111897b.html

http://www.devx.com/dbzone/Article/20713

http://www.pcs-computing.com/support/oracle_mkdb.html

 

 

 

 

Oracle: Instance creation checklist

 

 
  For all of you people out there that are really dbas, forgive me. This is a work in progress. I'm currently reading the Oracle 8i Handbook and I need a place to stash all the things they tell me to do when creating databases. Hopefully, once I'm done, this'll be a pretty complete document. In the mean time, it's what it is.

Later - much later

Well, studying has progressed. I'm to the point where I'm verifying/troubleshooting the checklist. If anyone has suggestions/comments/concerns, please send 'em. Please realize that I built this checklist on a Pentium 200 with one disk drive, so the details below aren't what would match a production environment. It's not the sizes or the specific environment that I'm after - more the steps that should be taken for most database creation exercises.
  1. Install Oracle
  2. Create instance
    1. Create the appropriate directory structure for your environment. Using the Oracle installed defaults, I have:
      ls -ld /oracle/admin/${ORACLE_SID}/*
      
      drwxr-xr-x   2 oracle   oinstall     1024 Mar 20 20:49 /oracle/admin/BITE/adhoc/
      
      drwxr-xr-x   2 oracle   oinstall     1024 Mar 20 20:49 /oracle/admin/BITE/arch/
      
      drwxr-xr-x   2 oracle   oinstall     1024 Mar 21 12:39 /oracle/admin/BITE/bdump/
      
      drwxr-xr-x   2 oracle   oinstall     1024 Mar 20 20:49 /oracle/admin/BITE/cdump/
      
      drwxr-xr-x   2 oracle   oinstall     1024 Mar 21 12:39 /oracle/admin/BITE/create/
      
      drwxr-xr-x   2 oracle   oinstall     1024 Mar 20 20:49 /oracle/admin/BITE/exp/
      
      drwxr-xr-x   2 oracle   oinstall     1024 Mar 21 12:36 /oracle/admin/BITE/pfile/
      
      drwxr-xr-x   2 oracle   oinstall     1024 Mar 20 20:49 /oracle/admin/BITE/udump/
      
    2. Update the user's environment (Oracle?). Either .kshrc, .bashrc, or .cshrc
      egrep -i "ora|nls" ~/.bashrc
      
      ORACLE_HOME="/oracle/product/8.1.5"
      
      ORACLE_BASE="/oracle"
      
      ORACLE_SID=BITE
      
      ORACLE_TERM=vt100
      
      LD_LIBRARY_PATH=${ORACLE_HOME}/lib
      
      ORA_NLS33=${ORACLE_HOME}/ocommon/nls/admin/data
      
      NLS_LANG="american"
      
      export SQLPATH=${HOME}:${HOME}/orabin
      
      PATH=${ORACLE_HOME}/bin:${PATH}
      
      export ORACLE_HOME ORACLE_BASE ORACLE_SID ORACLE_TERM
      
      export LD_LIBRARY_PATH ORA_NLS33 NLS_LANG 
      
    3. Copy an init.ora file to the OS default file location. Edit it as appropriate.
    4. Copy, create, edit, or otherwise enter manually, the create database statement
      create database "BITE"
      
              maxdatafiles 254
      
              maxlogfiles 32
      
              character set US7ASCII
      
              national character set US7ASCII
      
      datafile '/oracle/oradata/bite/system01.dbf' size 200m
      
      logfile '/oracle/oradata/bite/redo01.log' size 500k,
      
              '/oracle/oradata/bite/redo02.log' size 500k,
      
              '/oracle/oradata/bite/redo03.log' size 500k,
      
              '/oracle/oradata/bite/redo04.log' size 500k
      
  3. Run cat scripts:
    1. ${ORACLE_HOME}/rdbms/admin/catalog.sql
    2. ${ORACLE_HOME}/rdbms/admin/catproc.sql
    3. ${ORACLE_HOME}/rdbms/admin/catexp.sql
    4. catdbsyn.sql (Oracle 7.3 and lower): Creates the data dictionary views
    5. ${ORACLE_HOME}/sqlplus/admin/pupbld.sql
      1. Oracle 8.05 and lower
      2. Creates product_user_profile table & prevents annoying errors.
      3. Except, I had to run it on my Linux 8i (8.1.5) box.
    6. helpins.sql (Oracle 8.05 and lower): Creates and populates help utility.

  4. Create second system based rollback segment:

    create rollback segment r0
    tablespace system;
    alter rollback segment r0 online;

  5. Create tablespaces (Obviously you should size them per your needs)
    1. Rollback segment tablespace:
      create tablespace rbs
      
      datafile '/oracle/oradata/bite/rbs01.dbf' size 10m
      
      default storage (initial 128k next 128k pctincrease 0 maxextents unlimited)
      
    2. Index tablespace:
      create tablespace indexes
      
      datafile '/oracle/oradata/bite/index01.dbf' size 30m
      
      default storage (initial 50k next 50k pctincrease 0 maxextents unlimited);
      
    3. Temporary tablespace:
      create tablespace temp
      
      datafile '/oracle/oradata/bite/temp01.dbf' size 10m
      
      temporary
      
      default storage (initial 256k next 256k pctincrease 0 maxextents unlimited)
      
    4. Users tablespace:
      create tablespace users
      
      datafile '/oracle/oradata/bite/users01.dbf' size 50m
      
      default storage (initial 50k next 50k pctincrease 0 maxextents unlimited)
      
    5. Other tablespaces as local and OFA standards dictate.
  6. Create additional rollback segments in RBS tablespace
    1. Commands:
      
      
      create rollback segment r1
      
      tablespace RBS;
      
      alter rollback segment r1 online;
      
      
      
      create rollback segment r2
      
      tablespace RBS;
      
      alter rollback segment r2 online;
      
      
      
      create rollback segment r3
      
      tablespace RBS;
      
      alter rollback segment r3 online;
      
      
      
      create rollback segment r4
      
      tablespace RBS;
      
      alter rollback segment r4 online;
    2. Edit init.ora file to add private rollback segments.
      rollback_segments = (r1, r2, r3, r4)
      
  7. Deactivate the second system based rbs.

    alter rollback segment r0 offline;
  8. Change sys/system passwords
    1. sys
    2. system
    3. outln
    4. dbsnmp
  9. Alter system's default tablespace
    alter user system 
    
       quota 0 on system
    
       temporary tablespace TEMP;
    
    alter user sys temporary tablespace TEMP;
    
  10. Create example tables, if desired.
    1. ${ORACLE_HOME}/sqlplus/admin/pupbld.sql
    2. Lock the user accounts if not actively using them.
      set heading off
      
      spool /tmp/biteme.sql
      
      select 'alter user '||username||' account lock;'
      
      from dba_users
      
      where username in ('ADAMS','BLAKE','CLARK','JONES','SCOTT');
      
      spool off
      
      @/tmp/biteme
      
  11. Create users
    1. Constraints
      1. Default tablespace = USERS
      2. Default temporary tablespace = TEMP
    2. Example:
      create user dkoleary
      
      identified by ${passwd}
      
      default tablespace users
      
      quota unlimited on users
      
      temporary tablespace temp
      
      quota unlimited on temp;
      
      
      
      grant resource, dba, connect to dkoleary;
      
      
  12. Update Net8 configuration.
  13. Create/load database tables as needed.

Friday, October 8, 2010

Oracle Install

Oracle & PHP Installfest guide - Oracle 10gR2 on RHEL4 - OTN Night 2005
-----------------------------------------------------------------------
Installing Oracle 10g (10.2.0.1) on RHEL4

*** This guide is for test purposes only - not production ***

Boot from RHEL4 disc1
press enter for graphical install
 ** Need at least 512MB RAM / 2.5GB Space **
+ Automaticaly or Manually partition your hard drive with Disk Druid
 /tmp = 512MB ext3 fixed size
 /boot = 128MB ext3 fixed size
 swap = 1024MB fixed size
 / = fill to maximum allowable size

+ Accept defaults for GRUB boot loader, and configure networking.

+ Most Linux distros and RHEL4 ship with default security preferences locked down.
For testing purposes I typically turn off the firewall and disable SE Linux.

+ Set language preferences and root password

+ Select 'Customize software to be installed'
 - make sure the packages essential for installing Oracle are selected.
  Desktop : X Window System; Gnome or KDE
  Editors : at least one editor - vi etc.
  Graphical Internet : a web browser - firefox
  Development : Development Tools, and Compat Legacy Languages

For post-install configuration login as root
--------------------------------------------
+ create groups
 /usr/sbin/groupadd oinstall
 /usr/sbin/groupadd dba
 /usr/sbin/groupadd oper

+ create OS user oracle with group permissions and home /opt/oracle
 /usr/sbin/useradd -g oinstall -G dba,oper -d /opt/oracle oracle

+ set user oracle's password
 /usr/bin/passwd oracle

+ Append user oracle's bash profile with PATH and ORACLE:BASE,HOME and SID information
 vi /opt/oracle/.bash_profile

 umask 022
 PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
 LD_LIBRARY_PATH=/usr/lib:/usr/X11R6/lib

 ORACLE_BASE=/opt/oracle
 ORACLE_HOME=$ORACLE_BASE/product/10gR2
 ORACLE_SID=orcl
 PATH=$ORACLE_HOME/bin:$PATH

 export PATH LD_LIBRARY_PATH ORACLE_BASE ORACLE_HOME ORACLE_SID

+ Create the directory for the software installation and assign ownership to oracle:oinstall
 chown -R oracle:oinstall /opt
 chmod -R 775 /opt

+ Make sure the correct kernel parmeters are appended to sysctl.conf
 vi /etc/sysctl.conf (these can be easily copied from the Quick Installation Guide
                              for Linux x86 doc on the Oracle10g CD)
 kernel.shmall = 2097152
 kernel.shmmax = 2147483648
 kernel.shmmni = 4096
 kernel.sem = 250 32000 100 128
        net.core.rmem_default = 262144
 net.core.rmem_max = 262144
 net.core.wmem_default = 262144
 net.core.wmem_max = 262144
 fs.file-max = 65536
 net.ipv4.ip_local_port_range = 1024 65000

+ set the kernel parameters or reboot
 /sbin/sysctl -p

Login in to xwindows session as user oracle
-------------------------------------------
+ Mount the Oracle10g CD and run the installer
 mount /media/cdrom
 (cd $HOME && /media/cdrom/runInstaller)
 - follow the installer instructions 
 - use password mgmt to unlock DBuser scott & set password 'tiger'
+ open http://localhost.localdomain:1158/em in a browser or
 As root # vi /etc/oratab  change :N to :Y 
           # cp /etc/oratab /var/opt/oracle/oratab
+ This enables the oracle user to dbshut, dbstart and lsnrctl start 
 
 
 
 
Ref:
http://www.oracle-base.com/articles/11g/OracleDB11gR1InstallationOnEnterpriseLinux4and5.php 
http://www.oracle.com/technetwork/articles/smiley-rac10g-install-082032.html
http://www.oracle.com/technetwork/articles/smiley-10gdb-install-092939.html 
http://www.akadia.com/services/ora_linux_install_10g.html
http://www.oracle-base.com/articles/10g/OracleDB10gR2InstallationOnRHEL5.php
======
RAC
http://www.oracle-base.com/articles/10g/OracleDB10gR2RACInstallationOnCentos4UsingVMware.php
http://decipherinfosys.wordpress.com/2007/01/24/estimating-projecting-the-size-of-a-table-in-oracle/ 
http://anuj-singh.blogspot.com/2008/01/oracle-11g-installation-on-suse-103.html 

Friday, October 1, 2010

JVM Monitoring

http://cupi2.uniandes.edu.co/web/javadoc/j2se/1.5.0/docs/tooldocs/share/jstatd.html
http://www.herongyang.com/Java-Tools/jstat-JVM-Statistics-Monitoring-Tool.html
http://prefetch.net/blog/index.php/2008/01/16/monitoring-garbage-collection-with-jstat/
http://www.opennms.org/wiki/JVM_Monitoring_using_SNMP
http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html
http://support.hyperic.com/display/hypcomm/Set+up+Java+JVM+Monitoring

=======
http://www.ibm.com/developerworks/library/j-rtm1/index.html?ca=dgr-jw22javaruntime1&S_TACT=105AGX59&S_CMP=GR
http://www.ibm.com/developerworks/library/j-rtm2/index.html
 http://www.ibm.com/developerworks/library/j-rtm3/index.html
===========
http://tomcat.apache.org/tomcat-5.5-doc/monitoring.html
http://code.google.com/p/javamelody/
http://www.eginnovations.com/web/java-monitoring.htm
---------------
http://www.hyperic.com/products/tomcat-monitoring
http://www.torsten-horn.de/techdocs/jmx.htm
http://www.bpurcell.org/blog/index.cfm?entry=967&mode=entry

JVM Performance Tuning

http://www.javaworld.com/javaforums/showflat.php?Number=30206&page=44
http://java.sun.com/performance/jvmstat/
http://www.caucho.com/resin-3.0/performance/jvm-tuning.xtp
http://publib.boulder.ibm.com/infocenter/javasdk/v5r0/index.jsp?topic=/com.ibm.java.doc.diagnostics.50/diag/appendixes/cmdline/cmdline_x.html
http://forums.sun.com/thread.jspa?threadID=756468
------
http://viralpatel.net/blogs/2009/01/jvm-java-increase-heap-size-setting-heap-size-jvm-heap.html
------
http://download.oracle.com/javase/1.5.0/docs/tooldocs/share/jstat.html

Monday, May 17, 2010

Migration

http://searchsqlserver.techtarget.com/SQL-Server-PerfMon-counters-for-tracking-Windows-memory
http://www.freesoftwaremagazine.com/community_posts/skegness_grammar_school_using_gnu_linux_and_thin_clients_across_school

http://www.tomshardware.com/reviews/migrating-windows-linux,780.html

http://www.linuxlinks.com/Software/ProductivityTools/Notes/
http://www.linux.com/archive/feature/113755
http://www.eweek.com/c/a/Linux-and-Open-Source/Reverse-Migration-From-Linux-to-Windows/

Perfmon

http://www.cse.msu.edu/~enbody/perfmon/index.html

http://supportconnectw.ca.com/public/impcd/r11/optimization/Indicators%20for%20Performance%20Tuning.htm

http://perfmon.sourceforge.net/

http://www.hpl.hp.com/research/linux/perfmon/perfmon.php4

Friday, May 7, 2010

Nmap Free Security Scanner For Network Exploration & Hacking

EXAMPLES:
  nmap -v -A scanme.nmap.org
  nmap -v -sP 192.168.0.0/16 10.0.0.0/8
  nmap -v -iR 10000 -P0 -p 80

Thursday, May 6, 2010

Subnetting

http://mantikore.wordpress.com/2008/10/20/concept-of-subnetting-2/
http://www.firewall.cx/ip-subnetting-basic-concepts.php

http://www.akadia.com/services/ip_routing_on_subnets.html

Linux SCSI & Driver

Memory trouble shooting

http://rimuhosting.com/howto/memory.jsp
http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html
http://www.performancewiki.com/cpu-tuning.html

Linux Installation /Kickstart/ Deployment

http://www.centos.org/docs/5/html/Installation_Guide-en-US/s1-kickstart2-file.html





http://aaltonen.us/2004/03/01/tip-boot-from-usb-key-addendum/
http://www.pendrivelinux.com/install-fedora-9-to-a-flash-drive-using-windows/
http://syslinux.zytor.com/wiki/index.php/ISOLINUX
http://www.ehow.com/how_5062890_convert-linux-boot-iso-usb.html
http://www.instalinux.com/howto.php
http://www.redhat.com/download/howto_download.html
 http://www.linuxquestions.org/questions/linux-general-1/how-to-install-linux-from-iso-files-126605/
 http://www.linuxquestions.org/questions/linux-software-2/boot-an-iso-without-a-cd-off-a-hard-disk-258518/

Inetd

http://linuxmafia.com/linux/suse-linux-internals/chapter11.html

Disk / RAID optimization

http://wiki.centos.org/HowTos/Disk_Optimization
http://www.pcguide.com/ref/hdd/perf/raid/concepts/perfStripe-c.html

Logparser

Boot time parameters

HD Hard Drive Upgrade

http://bumwine.com/tivo.html
http://techblogbydave.blogspot.com/2008/07/tivo-hd-hard-drive-upgrade-best-way.html

Wednesday, April 14, 2010

Hard Disk-mount-recovery-raid-file systems

FILE SYSTEMS:
-----------------------


MOUNT:
-------------


RAID:
----------

LVM:
--------
Hard Disk Cloning , Recovery, Upgrading:
------------------------------------------------------

VMware

http://www.dailyhypervisor.com/2009/04/30/installing-vmware-esx-4-in-text-mode/

http://www.dailyhypervisor.com/2009/05/28/vsphere-install-and-upgrade-best-practices-kb-articles-and-links/

http://www.dailyhypervisor.com/2009/12/01/vsphere-4-0-quick-start-guide-released/

http://www.dailyhypervisor.com/2010/01/25/creating-an-automated-esxi-installer/
http://www.dailyhypervisor.com/tag/installation/

Cloud Project

http://www.techhead.co.uk/how-to-configure-openfiler-v23-iscsi-storage-for-use-with-vmware-esx

http://www.petri.co.il/use-openfiler-as-free-vmware-esx-san-server.htm

http://www.openqrm.com/?q=node/112

Friday, March 19, 2010

Sunday, March 14, 2010

Interwoven

http://www.scribd.com/doc/23210131/ts-671sp1-clt-win-v01-en

http://interwoven-teamsite.blogspot.com/2008/02/installing-teamsite-67.html

http://www.epic-ide.org/faq.php
http://www.scribd.com/doc/23210155/upgrade-technical-supplement
http://www.ibm.com/developerworks/aix/library/au-cmsaix/index.html

awk example

http://www.linuxquestions.org/questions/programming-9/file-size-shell-script-377486/
http://www.ibm.com/developerworks/library/l-awk1.html
http://www.mindbend.org/scripts
http://www.thegeekstuff.com/2010/02/awk-conditional-statements/
ll | awk '/Pyrami/ {print $9}'

awk -F":" '{ print $1 }' /etc/passwd 
ll| awk '{if($9=="test"){ print $9} else print "6"}'


IFS=$'\012';
 for d in `find . -type d`;
 do s=$(ls -AlF $d | grep -v / | awk '{ $5 = $5/1024; sum += $5; } END \
 { print sum}') c=$(ls -AF $d|wc -l) ;
printf "%-20s" ${c} ${s}KB ${d} >>usage; printf "\n">>usage; done
ls -al | awk '{sum = sum + $5} END {print sum}'




find . \( -name "CORE_*" -o -name "c-*" \) -mtime -1 -exec ls -l {} \; |awk '/^-/ {total += $5} END {printf "%15.2f\n",total}'

find /path -mtime +1 -printf "%s\n"|awk '{sum+=$0}END{print sum}'

Saturday, March 13, 2010

Cpu Load

http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages
http://www.linuxjournal.com/article/9001
http://en.wikipedia.org/wiki/Load_%28computing%29

http://digg.com/linux_unix/Linux_tip_How_do_I_find_out_Linux_CPU_utilization
http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html





some more ref:
----------------
http://cpulimit.sourceforge.net/


http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html

http://www.cyberciti.biz/tips/linux-limiting-or-restricting-smp-cpu-activation-in-smp-mode.html

http://www.cyberciti.biz/faq/cpu-usage-limiter-for-linux/

boot parameter:
-------------------
http://www.cyberciti.biz/tips/10-boot-time-parameters-you-should-know-about-the-linux-kernel.html


security:
--------------
http://www.cyberciti.biz/tips/linux-security.html

Sunday, March 7, 2010

TCP/IP & OSI Stack

http://www.interfacebus.com/Design_OSI_Stack.html

http://www.tutorialsweb.com/networking/osi-model-application-layer.htm
http://www.networkdictionary.com/protocols/osimodel.php

monitorCpuUsage

http://bashcurescancer.com/monitor-cpu-abusers-with-this-simple-script.html

http://httpd.apache.org/docs/1.3/misc/descriptors.html

Mysql Monitoring Script

Mysql to CVS file:


--------------------------------------------------------------------
>>>>>>>>>>SELECT * FROM user where User='root' INTO OUTFILE '/tmp/root_user.txt';

>>>>>>>>>>LOAD DATA INFILE '/tmp/root_user.txt' INTO TABLE user

>>>>>>>>>select User,Host from user where User='root';



>>>>>>>>>mysql -u uid -ppwd -D dbname << EOQ | sed -e 's/        /,/g' | tee list.csv
select id, concat("\"",name,"\"") as name
from students
EOQ


command[check_mysqld]=/usr/lib/nagios/plugins/check_mysql_query -q 'select 1+2' -u nagiosCheck -p 'password' -w 3:3 -c 3:3


--------------------------------------------------------------------

http://tlug.dnho.net/node/209
http://dev.mysql.com/doc/refman/4.1/en/select.html
http://forums.mysql.com/read.php?93,217055,220349#msg-220349
http://eoslist.com/open_source/directory/database.html
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

Regular Expression

http://www.franz.com/support/documentation/7.0/doc/regexp.htm
http://www.regexlab.com/en/regref.htm
http://gravity.tbates.org/reexamp.html
http://support.yessoftware.com/kb_article.asp?article_id=63
http://www.regular-expressions.info/conditional.html

What is innoDB


nnoDB.
innoDB is a table type in mySQL.
InnoDB provides MySQL with a transaction-safe storage engine with commit, rollback, and crash recovery capabilities. InnoDB does locking on the row. These features increase multi-user concurrency and performance. There is no need for lock escalation in InnoDB because row-level locks in InnoDB fit in very little space.
advantages of innoDB table type are :
* InnoDB tables are transactional: they provide rollback and commit capabilities.
* InnoDB is the only table type in MySQL which supports foreign key constraints.
* InnoDB tables are fast, even faster than MyISAM tables in many simple benchmarks. See the benchmark page.
* InnoDB tables have row level locking: they allow higher concurrency than MyISAM tables which use table level locking, or BDB tables, which use page level locking. High concurrency is reflected in high multiuser performance.
* InnoDB tables provide an Oracle-style consistent read, also known as multiversioned concurrency control. SELECTs do not need to set any locks and need not interfere with inserts and updates to the same table. No other MySQL table type has this property.
* There is a true hot backup tool available for InnoDB, which allows you to make backups of a running database in background, without setting any locks or disturbing database operation.
* Multiversioning also allows you to dump tables from your database with SELECT INTO OUTFILE without setting locks on the tables: the database can keep working while a backup is made.
* InnoDB tables have automatic crash recovery. You do not need to repair your tables if the operating system or the database server crashes, when there is no disk image corruption.
* InnoDB tables can be any size, also on those operating systems where file size is restricted to < 2 GB.
Enabling and Checking innoDB type in mySQL
innoDB type is supported my all mySQL versions starting from mySQL 4.0.x
Go to the file /etc/my.cnf file and either comment out the line or delete the line ’skip-innodb’ and innodb will be enabled.
You can check either your mySQL supports the innoDB type by giving the following command at mysql prompt.
mysql> show variables like ‘have_innodb’;
+—————+——-+
| Variable_name | Value |
+—————+——-+
| have_innodb | YES |
+—————+——-+
1 row in set (0.00 sec)


MySQL has two primary storange engines: MyISAM and InnoDB. Each has its own performance characteristics and considerations. In the broadest sense MyISAM is good for read-heavy data and InnoDB is good for write-heavy data, though there are cases where the opposite is true. The biggest gotcha is how the two differ with respect to the COUNT function.
MyISAM keeps an internal cache of table meta-data like the number of rows. This means that, generally, COUNT(*) incurs no additional cost for a well-structured query. InnoDB, however, has no such cache. For a concrete example, let’s say we’re trying to paginate a query. If you have a query SELECT * FROM users LIMIT 5,10, let’s say, running SELECT COUNT(*) FROM users LIMIT 5,10 is essentially free with MyISAM but takes the same amount of time as the first query with InnoDB. MySQL has a SQL_CALC_FOUND_ROWS option which tells InnoDB to calculate the number of rows as it runs the query, which can then be retreived by executing SELECT FOUND_ROWS(). This is very MySQL-specific, but can be necessary in certain situations, particularly if you use InnoDB for its other features (e.g., row-level locking, stored procedures, etc.).



Links:

Friday, March 5, 2010

Sysadmin's Guide

 http://www.ibm.com/developerworks/linux/library/l-10sysadtips/?S_TACT=105AGX54&S_CMP=C0115&ca=dnw-1002&open&cm_mmc=4633-_-n-_-vrm_newsletter-_-10731_101108&cmibm_em=dm:0:6992641

 http://linuxhelp.blogspot.com/2008/03/two-repositories-of-linux-and-unix.html


 http://linuxhelp.blogspot.com/2009/01/linux-commands-10-useful-tricks-for.html

Linux console Screen

http://www.rackaid.com/resources/linux-screen-tutorial-and-how-to/
http://www.cyberciti.biz/tips/linux-screen-command-howto.html
http://magazine.redhat.com/2007/09/27/a-guide-to-gnu-screen/
http://www.pixelbeat.org/lkdb/screen.html
http://www.linuxjournal.com/article/6340


Alternative of screen: tmux
--------------------------------------------

http://tmux.sourceforge.net/

Wednesday, March 3, 2010

Introduction

rndc is a nameserver control utility that comes along with the bind package. It uses digital signature to communicate with nameserver. It is used to reload the configuration file and zones, flush the DNS cache, to see the status of nameservers etc.

Configuring rndc

The bind package has utilities to configure rndc with the nameserver. The binary rndc-confgen generates the configuration file for rndc. To generate the configuration file for rndc, run the binary as,
[root@localhost ~]# rndc-confgen
# Start of rndc.conf
key "rndckey" {
        algorithm hmac-md5;
        secret "YAytbNi94tMD26FPxes3Yg==";
};

options {
        default-key "rndckey";
        default-server 127.0.0.1;
        default-port 953;
};
# End of rndc.conf

# Use with the following in named.conf, adjusting the allow list as needed:
# key "rndckey" {
#       algorithm hmac-md5;
#       secret "YAytbNi94tMD26FPxes3Yg==";
# };
#
# controls {
#       inet 127.0.0.1 port 953
#               allow { 127.0.0.1; } keys { "rndckey"; };
# };
# End of named.conf
[root@localhost ~]#
Copy the configuration directives between # Start of rndc.conf and # End of rndc.conf into the file /etc/rndc.conf. We need to configure nameserver to accept the commands issued from rndc utility. For that, copy the directives between # Use with the following in named.conf, adjusting the allow list as needed: and # End of named.conf to /etc/named.conf file removing the leading '#' symbol. The nameserver is now ready to be managed by rndc. Just restart the named service and issue the following command.
[root@localhost ~]# rndc reload
server reload successful
[root@localhost ~]#
You will get server reload successful message, if rndc is able to communicate with the nameserver.

Configuration statements

The key statement specifies the key name being used to communicate with nameserver. The clauses algorithm and secret in the key statement specify the name of algorithm and the the key respectively.
The statement options in rndc.conf specifies the default server and the key to be used, when command rndc is used without specifying any server name.
The control statement in named.conf allows rndc to update the nameserver listening on IP 127.0.0.1 via port 953 using the key "rndckey" from localhost, ie from the server itself.
The rndc-confgen has option to specify the size of the key in bytes. By default, the size is 128. The HMAC-MD5 key can also be generated by using the utility dnssec-keygen. To generate the key with size 128 bytes,
[root@localhost ~]# dnssec-keygen -a HMAC-MD5 -b 128 -n host rndckey
Krndckey.+157+41716
[root@localhost ~]#

The corresponding key can be found in files
Krndckey.+157+41716.key  and
Krndckey.+157+41716.private


Advanced Configuration

Using rndc, we can manage the nameserver remotely. Only thing is both rndc and remote nameserver should use the same digital signature and remote server should accept commands from the server from which it is going to be managed. We can extend the above mentioned configuration to do it.
Using the binary dnssec-keygen, create a new key for managing the remote server and name it as "rndcremotekey". Of course you may use any name for the key as long as the name matches in both servers. To configure rndc to use key "rndcremotekey" to manage the remote server, add the following entries in /etc/rndc.conf file.
# Add the key generated with command 'dnssec-keygen'

key "rndcremotekey" {
        algorithm hmac-md5;
        secret "mSqfSp6rKNHQwVG3JVHfzw==";
};

# Remote nameserver to be managed

server  {
        key "rndcremotekey";
};
You need to replace with the IP address of the remote nameserver.
We have now configured rndc to use key "rndcremotekey" when controlling the remote nameserver.
For the remote server to accept commands, add the following entries in /etc/named.conf file in the remote nameserver.
# Remote nameserver should use the same key

key "rndcremotekey" {
        algorithm hmac-md5;
        secret "mSqfSp6rKNHQwVG3JVHfzw==";
};

# Control statement to accept rndc commands

controls {
        inet  port 953
        allow { ; } keys { "rndcremotekey"; };
};
Replace and with the corresponding server IP addresses.
Once done, restart named service in remote nameserver. You can then manage the remote server from the rndc server. To test the configuration, type the following in rndc server.
[root@localhost ~]# rndc -s  reload
server reload successful
[root@localhost ~]#

Using rndc

After the configuration, you may use rndc to reload, flush cache and see the status of nameserver as
[root@localhost ~]# rndc reload
server reload successful
[root@localhost ~]# rndc flush
[root@localhost ~]# rndc status
number of zones: 6
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
recursive clients: 0/1000
tcp clients: 0/100
server is up and running
[root@localhost ~]#
To see more command line options, just type the command "rndc" in shell. You will see a handful of useful options.

Conclusion

Though startup script /etc/rc.d/init.d/named has option to reload the configuration than restarting named service, rndc provides more options. For example, reload, refresh or retransfer a single zone, flush dns cache without restarting the named service, flush a single name from cache, see the server status etc. So to manage nameserver efficiently, it is necessary to configure rndc utility properly.

Install GNU/Linux without any CD, floppy, USB-key, nor any other removable media

 http://syslinux.zytor.com/wiki/index.php/PXELINUX

  http://marc.herbert.free.fr/linux/win2linstall.html


 http://www.novell.com/coolsolutions/feature/11802.html

mysql replication

Monday, March 1, 2010

Virtual Machine Architecture

A virtual machine can support individual processes or a complete system depending on the abstraction level where virtualization occurs. Some VMs support flexible hardware usage and software isolation, while others translate from one instruction set to another. Virtualizing a system or component -such as a processor, memory, or an I/O device - at a given abstraction level maps its interface and visible resources onto the interface and resources of an underlying, possibly different, real system. Consequently, the real system appears as a different virtual system or even as multiple virtual systems. Interjecting virtualizing software between abstraction layers near the HW/SW interface forms a virtual machine that allows otherwise incompatible subsystems to work together. Further, replication by virtualization enables more flexible and efficient and efficient use of hardware resources.






Kernel Compilation

# cd /usr/src/linux-2.6.18.8/
# cp ./.config ../kernel.2.6.18.8.config
# make clean
# make mrproper
# cp ../kernel.2.6.18.8.config ./.config

yum install ncurses-devel

make mrproper
make oldconfig
make menuconfig
make
make modules_install
make install

or

make bzImage
bzImage inside arch/i386/boot

make modules.

make modules_install.


It will install three files into /boot directory as well as modification to your kernel grub configuration file:

    * System.map-2.6.25
    * config-2.6.25
    * vmlinuz-2.6.25

# cd /boot
# mkinitrd -o initrd.img-2.6.25 2.6.25



make -j bzImage
make -j modules
make -j modules-Install

j=2*cpu no

sh /usr/src/linux-2.6.32.3/arch/x86/boot/install.sh 2.6.32.3 arch/x86/boot/bzImage \
                System.map "/boot"


====================================================
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-53.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-53.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
        initrd /initrd-2.6.18-53.el5.img


title new
        root (hd0,0)
        kernel /mynewkernel ro root=/dev/hda3

====================================================





http://tldp.org/HOWTO/Module-HOWTO/copyright.html
https://www.linuxquestions.org/questions/slackware-14/cant-make-menuconfig-as-non-root-ncurses-not-found-543858/
http://www.cyberciti.biz/tips/compiling-linux-kernel-26.html
http://www.linuxchix.org/content/courses/kernel_hacking/lesson4
http://bobcares.com/blog/?p=162









Open Filer iSCSI SAN Commands

 http://www.oracle.com/technology/pub/articles/hunter_rac10gr2_iscsi.html

 http://www.tbaumi.de/blog/?p=244

http://akns.wordpress.com/2009/01/19/software-iscsi-initiator-against-target-openfiler/


--------------------
http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=1008083&sliceId=2&docTypeID=DT_KB_1_1&dialogID=54682501&stateId=0%200%2055404225


http://greg.porter.name/wiki/HowTo:Openfiler


http://docs.sun.com/app/docs/doc/817-5093/fqnls?a=view


http://www.petri.co.il/use-openfiler-as-free-vmware-esx-san-server.htm









Storage

http://www.storagesearch.com/auspexart.html
http://www.linux.com/archive/feed/53578

Saturday, February 27, 2010

Hard & Soft Mount

This is a UNIX terminology as to what the client does when
it can't talk to an NFS Server. If you just mount a file
system without specifying hard or soft, the default is a
hard mount. Hard mounts are preferable because of the
stateless nature of NFS. If a client sends an I/O request to
the server (such as an ls -la), and the server gets
rebooted, the client will wait until the server comes back
on line. This preserves data transfers in the event of a
server failure. There are disadvantages to this, as a simple
mount request could hang. A soft link will return with an
error and fail. This kills the wait time, but can cause
problems with data transfers. 

Hard mount
-- If the NFS file system is hard mounted the NFS daemons will try repeatedly to contact the server. The NFS daemon retries will not time out will affect system performance and you cannot interrupt them.
Soft mount
-- If the NFS file system is soft mounted NFS will try repeatedly to contact the server until either:
  • A connection is established
  • The NFS retry threshold is met
  • The nfstimeout value is reached

NIS setup

http://bradthemad.org/tech/notes/redhat_nis_setup.php

Everything On NFS

The Network File System (NFS) is used to distribute filesystems over a network. The server exports the filesystem and the client imports it. There are now two ways to run a NFS server. The traditional method is by running the user space NFS daemon. The newer option is the kernel based kernel-nfsd, which was introduced with kernel version 2.2. SuSE supports both methods. The user space daemon has built a reputation for reliability, but has limitations in terms of speed. The kernel based NFS daemon is faster, but not as well tested as the older one.


Step By Step Configure NFS server and NFS client:
====================================

NFS server setup:
------------------------------

#rpm –Uhv nfs-utils-0.3.1-13.i386.rpm

-------
#vi /etc/exports
/home   192.168.0.0/24(rw,no_root_squash,anonuid=500,anongid=100,sync)

-------

verify:
-----------
# /usr/sbin/exportfs –a
# showmount    -ad


NFS client setup:
----------------------------

#mount –t nfs compaq:/export /mnt/nfs

-------
#vi /etc/fstab
hostA:/export /mnt/nfs mfs soft 0 0
-------


Automount NFS & Setting which uses NIS:
================================

#rpm -Uhv autofs-3.1.7-28.i386.rpm

------------
#vi /etc/auto.master
/nfs /etc/auto.home --timeout 60
-------------

---------------
#vi /etc/auto.home
home -rw,hard,intr,nolock compaq:/home
--------------

--------------
#vi /var/yp/Makefile
all: passwd group hosts rpc services netid protocols mail \
shadow auto.home \
--------------
cd /var/yp
make

Verify:
----------
# ypcat auto.home
-rw,hard,intr,nolock compaq:/home





Important Commands:
=================

*   mount -t nfs

*   rpcinfo     [information about the RPC service that is running on a system]
*   showmount -a (on the server)      [Number of connection]
*   showmount -e [Displays a list of exported directories.]
*   netstat -s       [fragmentation  socket buffers]
*   nfsstat -cr
*   nfsstat [ -cmnrsz ]
  pstack [This command displays a stack trace for each process. ]

      /usr/bin/pgrep nfsd

      /usr/bin/pstack PID

      /usr/sbin/dtrace -Fs       
      startsrc -s biod
      /usr/sbin/exportfs -v
      /usr/bin/rusers  [Remote Users]

*   tracepath
*   snoop       [This command is often used to watch for packets on the network.]
*   truss        [You can use this command to check if a process is hung.]




Directories & Files:
===============
/etc/exports
#  /var/lib/nfs/rmtab
#  /etc/rmtab      [    Contains information about the current state of all exported directories.]
#  /etc/xtab   [Lists currently exported directories.]
/etc/fstab


Process & Daemons:
=======================

Daemon                                   Description
--------------------                        ---------------------
*** nfsd ->           The NFS daemon which services requests from the NFS clients.
*** mountd ->     The NFS mount daemon which carries out the requests that nfsd passes on to it.
*** rpcbind ->     This daemon allows NFS clients to discover which port the NFS server is using.

rpc.mountd — The running process that receives the mount request from an NFS client and checks to see if it matches with a currently exported file system.
 
*    rpc.nfsd — The process that implements the user-space components of the NFS service. It works with the Linux kernel to meet the dynamic demands of NFS clients, such as providing additional server threads for NFS clients to use.

*    rpc.lockd — A daemon that is not necessary with modern kernels. NFS file locking is now done by the kernel. It is included with the nfs-utils package for users of older kernels that do not include this functionality by default.

*    rpc.statd — Implements the Network Status Monitor (NSM) RPC protocol. This provides reboot notification when an NFS server is restarted without being gracefully brought down.
 
*    rpc.rquotad — An RPC server that provides user quota information for remote users.
 



NFS:
====

http://docstore.mik.ua/orelly/networking_2ndEd/nfs/
http://docs.sun.com/app/docs/doc/819-1634/rfsrefer-45?a=view
http://docs.sun.com/app/docs/doc/819-1634/rfsadmin-215?a=view
http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/ref-guide/ch-nfs.html
http://www.linux.org/docs/ldp/howto/NFS-HOWTO/server.html



NFS Performance Tuning:
====================

http://www.ncsa.illinois.edu/UserInfo/Resources/Hardware/IBMp690/IBM/usr/share/man/info/en_US/a_doc_lib/aixbman/prftungd/2365ca3.htm
http://tldp.org/HOWTO/NFS-HOWTO/performance.html


Commands :
==========

http://docs.sun.com/app/docs/doc/819-1634/rfsrefer-37?a=view
http://publib.boulder.ibm.com/infocenter/powersys/v3r1m5/index.jsp?topic=/iphcg/showmount.htm
http://www.regatta.cs.msu.su/doc/usr/share/man/info/ru_RU/a_doc_lib/cmds/aixcmds5/aixcmds502.htm#ToC


Configuration:
===========
http://www.labtestproject.com/linnet/index.html
http://highervisibilitywebsites.com/step-step-set-nfs-share
http://www.freebsd.org/doc/handbook/network-nfs.html
http://www.troubleshooters.com/linux/nfs.htm

 

Thursday, February 25, 2010

Setup a transparent proxy with Squid in three easy steps

Steps to Compile a Kernel

First download and install the kernel source to your machine. Then move to that directory. In redhat linux the source is usually installed in a directory named linux-2.x.xx.xxx in the /usr/src directory. And a soft link to that directory is created by the name linux-2.4 (Assuming it is the source of the linux 2.4 kernel). So the kernel source is installed in /usr/src/linux-2.4 directory.
Now move to this directory.
# cd /usr/src/linux-2.4
The next step is creating the configuration file (.config). This can be done in three ways.
# make config - brings up a command-line console mode interface.
# make menuconfig - brings up a ncurses based GUI Interface.
# make xconfig - brings up a X GUI based user friendly interface.
You may use any one of the above three commands.Depending upon the command that was executed, you will get a relevent interface using which you can configure your kernel before it is compiled.For example, you can select the proper processor type in the configuration dialog. Another thing is you can decide whether to build a functionality directly in the kernel or load it as a module when the kernel needs it.This will optimise your kernel for your computer and will help decrease the size of your kernel. The end result is your linux machine starts much faster.
After you have made the changes to the settings, you have to save and exit.Then all the changes you made to the configuration file has been saved at /usr/src/linux-2.4/.config
Now the next step is to make the dependencies. For that execute the following commands.
# make dep
# make clean
The first of these commands builds the tree of interdependencies in the kernel sources. These dependencies may have been affected by the options you have choosen in the configure step. The 'make clean' purges any now-unwanted files left from previous builds of the kernel.
The next step is the actual compilation of the kernel. Here you can opt to create a compressed image by executing the command
# make bzImage
Or if you opt for a non compressed image then you can execute the command
#make zImage
The time taken for compilation of the kernel depends on the speed of your machine. In my machine (Celeron 333MHz) it took around 15-20 mins.
After the compilation is complete, you can find your newly compiled kernel here : /usr/src/linux-2.4/arch/i386/boot/bzImage .
If you have enabled loadable modules support in the kernel during configuring, then you have to now execute the commands
# make modules
# make modules_install
Loadable modules are installed in the /lib/modules directory.
Now to start using your newly compiled kernel, you have to copy the kernel into the /boot directory.
# cp /usr/src/linux-2.4/arch/i386/boot/bzImage /boot/bzImage-mykernel-sept2004
Now open your boot configuration file (I used lilo) in your favourate editor and insert the following lines to boot linux using your new kernel.
# vi /etc/lilo.conf
//Inside lilo.conf file
image=/boot/bzImage-mykernel-sept2004
label=myker
root=/dev/hda3
read-only
My root is located at /dev/hda3 which I found out using the command
# df /
Now don't forget to execute the 'lilo' command to update the changes in the boot loader. Reboot your machine and in the lilo prompt, select 'myker' and press enter to start loading your newly compiled kernel.

Links:
 http://bobcares.com/blog/?p=162
 http://linuxhelp.blogspot.com/2004/08/steps-to-compile-kernel.html#axzz0gcGYpoAR

Suspend and resume any program using SIGSTOP UNIX

If you've ever been running a program that requires a lot of CPU or hits the disk heavily, and then wanted to be able to use your computer for something else for a few minutes, this is the hint for you.

Most UNIX people know they can use Control-Z and the bg and fg commands to control whether or not their programs are running. What many often don't know is that you can do the same thing using signals. For instance, let's say I am doing a long build in Project Builder, but I need to use my computer for a few minutes at full speed to do something else. Here's how to accomplish that:
  1. Find the process ID of the program you want to suspend using either the ps wwwaux command from the shell or via Process Viewer (in /Applications -> Utilities):
    /Users/sam:> ps auxwww | grep Project
    sam        814   0.0  0.6   114984   5900  ??  S     4:24PM
      0:01.56  /Developer/Applications/Project Builder.app/
      Contents/MacOS/Project Builder -psn_0_5636097
    Here the id is 814 (line breaks were added above for narrower display width).

  2. Use the kill command and send it a SIGSTOP signal:
    /Users/sam:> kill -SIGSTOP 814
    The program will now stop doing whatever it was doing and you can then do a quick render or whatever it was that needed the whole machine.
To resume your program right back where it was, just use the kill command and send it a SIGCONT signal:
/Users/sam:> kill -SIGCONT 814
It's as easy as that. I'm sure some enterprising individual could make a graphical program that does this for you, but I'm a UNIX user at heart.




Links:
http://www.macosxhints.com/article.php?story=20030915193440334


Linux Software RAID Management

raidtools has been the standard software RAID management package for Linux since the inception of the software RAID driver. Over the years, raidtools have proven cumbersome to use, mostly because they rely on a configuration file (/etc/raidtab) that is difficult to maintain, and partly because its features are limited. In August 2001, Neil Brown, a software engineer at the University of New South Wales and a kernel developer, released an alternative. Hismdadm (multiple devices admin) package provides a simple, yet robust way to manage software arrays. mdadm is now at version 1.0.1 and has proved quite stable over its first year of development. There has been much positive response on the Linux-raid mailing list andmdadm is likely to become widespread in the future. This article assumes that you have at least some familiarity with software RAID on Linux and that you have had some exposure to the raidtools package.
Installation


Download the most recent mdadm tarball, issue make install to compile, and install mdadmand its documentation. In addition to the binary, some manual pages and example files are also installed.

# tar xvf ./mdadm-1.0.1.tgz

# cd mdadm-1.0.1.tgz

# make install

Alternatively, you can download and install the package file found under the RPM directory at the same URL (http://www.cse.unsw.edu.au/~neilb/source/mdadm/).

# rpm -ihv mdadm-1.0.1-1.i386.rpm

mdadm has five major modes of operation. The first two modes, Create and Assemble, are used to configure and activate arrays. Manage mode is used to manipulate devices in an active array. Follow or Monitor mode allows administrators to configure event notification and actions for arrays. Build mode is used when working with legacy arrays that use an old version of the md driver. I will not cover build mode in this article. The remaining options are used for various housekeeping tasks and are not attached to a specific mode of operation, although the mdadm documentation calls these options Misc mode.
Creating an Array

Create (mdadm --create) mode is used to create a new array. In this example I use mdadmto create a RAID-0 at /dev/md0 made up of /dev/sdb1 and /dev/sdc1:

# mdadm --create --verbose /dev/md0 --level=0

--raid-devices=2 /dev/sdb1 /dev/sdc1

: array /dev/md0 started.

mdadm: chunk size defaults to 64K mdadm

The --level option specifies which type of RAID to create in the same way that raidtools uses the raid-level configuration line. Valid choices are 0,1,4 and 5 for RAID-0, RAID-1, RAID-4, RAID-5 respectively. Linear (--level=linear) is also a valid choice for linear mode. The --raid-devices option works the same as the nr-raid-disks option when using /etc/raidtab and raidtools.

In general, mdadm commands take the format:

mdadm [mode]  [options]

Each of mdadm's options also has a short form that is less descriptive but shorter to type. For example, the following command uses the short form of each option but is identical to the example I showed above.

# mdadm -Cv /dev/md0 -l0 -n2 -c128 /dev/sdb1 /dev/sdc1

-C selects Create mode, and I have also included the -v option here to turn on verbose output. -l and -n specify the RAID level and number of member disks. Users of raidtoolsand /etc/raidtab can see how much easier it is to create arrays using mdadm. You can change the default chunk size (64KB) using the --chunk or -c option. In this previous example I changed the chunk size to 128KB. mdadm also supports shell expansions, so you don't have to type in the device name for every component disk if you are creating a large array. In this example, I'll create a RAID-5 with five member disks and a chunk size of 128KB:

# mdadm -Cv /dev/md0 -l5 -n5 -c128 /dev/sd{a,b,c,d,e}1

mdadm: layout defaults to left-symmetric

mdadm: array /dev/md0 started.

This example creates an array at /dev/md0 using SCSI disk partitions /dev/sda1, /dev/sdb1,/dev/sdc1, /dev/sdd1, and /dev/sde1. Notice that I have also set the chunk size to 128 KB using the -c128 option. When creating a RAID-5, mdadm will automatically choose the left-symmetric parity algorithm, which is the best choice.

Use the --stop or -S command to stop running array:

# mdadm -S /dev/md0

/etc/mdadm.conf

/etc/mdadm.conf is mdadms' primary configuration file. Unlike /etc/raidtab, mdadm does not rely on /etc/mdadm.conf to create or manage arrays. Rather, mdadm.conf is simply an extra way of keeping track of software RAIDs. Using a configuration file with mdadm is useful, but not required. Having one means you can quickly manage arrays without spending extra time figuring out what array properties are and where disks belong. For example, if an array wasn't running and there was no mdadm.conf file describing it, then the system administrator would need to spend time examining individual disks to determine array properties and member disks.

Unlike the configuration file for raidtools, mdadm.conf is concise and simply lists disks and arrays. The configuration file can contain two types of lines each starting with either theDEVICE or ARRAY keyword. Whitespace separates the keyword from the configuration information. DEVICE lines specify a list of devices that are potential member disks. ARRAYlines specify device entries for arrays as well as identifier information. This information can include lists of one or more UUIDs, md device minor numbers, or a listing of member devices.

A simple mdadm.conf file might look like this:

DEVICE /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

ARRAY /dev/md0 devices=/dev/sda1,/dev/sdb1

ARRAY /dev/md1 devices=/dev/sdc1,/dev/sdd1

In general, it's best to create an /etc/mdadm.conf file after you have created an array and update the file when new arrays are created. Without an /etc/mdadm.conf file you'd need to specify more detailed information about an array on the command in order to activate it. That means you'd have to remember which devices belonged to which arrays, and that could easily become a hassle on systems with a lot of disks. mdadm even provides an easy way to generate ARRAY lines. The output is a single long line, but I have broken it here to fit the page:

# mdadm --detail --scan

ARRAY /dev/md0 level=raid0 num-devices=2

UUID=410a299e:4cdd535e:169d3df4:48b7144a

If there were multiple arrays running on the system, then mdadm would generate an array line for each one. So after you're done building arrays you could redirect the output of mdadm --detail --scan to /etc/mdadm.conf. Just make sure that you manually create a DEVICEentry as well. Using the example I've provided above we might have an /etc/mdadm.conf that looks like:

DEVICE /dev/sdb1 /dev/sdc1

ARRAY /dev/md0 level=raid0 num-devices=2

UUID=410a299e:4cdd535e:169d3df4:48b7144a

Starting an Array

Assemble mode is used to start an array that already exists. If you created an/etc/mdadm.conf you can automatically start an array listed there with the following command:

# mdadm -As /dev/md0

mdadm: /dev/md0 has been started with 2 drives.



The -A option denotes assemble mode. You can also use --assemble. The -s or --scanoption tells mdadm to look in /etc/mdadm.conf for information about arrays and devices. If you want to start every array listed in /etc/mdadm.conf, don't specify an md device on the command line.

If you didn't create an /etc/mdadm.conf file, you will need to specify additional information on the command line in order to start an array. For example, this command attempts to start/dev/md0 using the devices listed on the command line:

# mdadm -A /dev/md0 /dev/sdb1 /dev/sdc1

Since using mdadm -A in this way assumes you have some prior knowledge about how arrays are arranged, it might not be useful on systems that have arrays that were created by someone else. So you may wish to examine some devices to gain a better picture about how arrays should be assembled. The examine options (-E or --examine) allows you to print the md superblock (if present) from a block device that could be an array component.

# mdadm -E /dev/sdc1

/dev/sdc1:

4efc Version :

Magic : a92 b00.90.00

88b68:1bb79088:9a73ebcc:2ab430da Creation

UUID : 84 7 Time : Mon Sep 23 16:02:33 2002 Raid Level : raid0

Device Size : 17920384 (17.09 GiB 18.40 GB) Raid D evices : 4 Total Devices : 4 Preferred Minor : 0

Update Time : Mon Sep 23 16:14:52 2002

State : clean, no-errors

Devices : 4 Faile

Active Devices : 4 Working d Devices : 0 Spare Devices : 0

nts : 0.10

Checksum : 8ab5e437 - correct Eve

Chunk Size : 128K

Number Major Minor RaidDevice State

this 1 8 33 1 active sync /dev/sdc1

0 0 8 17 0 active sync /dev/sdb1 1 1 8 33 1 active sync /dev/sdc1

3 3 8 65 3 active sync /dev/sde

2 2 8 49 2 active sync /dev/sdd11


mdadm's examine option displays quite a bit of useful information about component disks. In this case we can tell that /dev/sdc1 belongs to a RAID-0 made up of a total of four member disks. What I want to specifically point out is the line of output that contains the UUID. A UUID is a 128-bit number that is guaranteed to be reasonably unique on both the local system and across other systems. It is a randomly generated using system hardware and timestamps as part of its seed. UUIDs are commonly used by many programs to uniquely tag devices. See the uuidgen and libuuid manual pages for more information.

When an array is created, the md driver generates a UUID for the array and stores it in the md superblock. You can use the UUID as criteria for array assembly. In the next example I am going to activate the array to which /dev/sdc1 belongs using its UUID.

# mdadm -Av /dev/md0 --uuid=84788b68:1bb79088:9a73ebcc:2ab430da /dev/sd*

This command scans every SCSI disk (/dev/sd*) to see if it's a member of the array with the UUID 84788b68:1bb79088:9a73ebcc:2ab430da and then starts the array, assuming it found each component device. mdadm will produce a lot of output each time it tries to scan a device that does not exist. You can safely ignore such warnings.
Managing Arrays

Using Manage mode you can add and remove disks to a running array. This is useful for removing failed disks, adding spare disks, or adding replacement disks. Manage mode can also be used to mark a member disk as failed. Manage mode replicates the functions of raidtools programs such as raidsetfaulty, raidhotremove, and raidhotadd.

For example, to add a disk to an active array, replicating the raidhotadd command:

# mdadm /dev/md0 --add /dev/sdc1

Or, to remove /dev/sdc1 from /dev/md0 try:

# mdadm /dev/md0 --f ail /dev/sdc1 --remove /dev/sdc1

Notice that I first mark /dev/sdc1 as failed and then remove it. This is the same as using theraidsetfaulty and raidhotremove commands with raidtools. It's fine to combine add, fail, and remove options on a single command line as long as they make sense in terms of array management. So you have to fail a disk before removing it, for example.
Monitoring Arrays

Follow, or Monitor, mode provides some of mdadm's best and most unique features. Using Follow/Monitor mode you can daemonize mdadm and configure it to send email alerts to system administrators when arrays encounter errors or fail. You can also use Follow mode to arbitrarily execute commands when a disk fails. For example, you might want to try removing and reinserting a failed disk in an attempt to correct a non-fatal failure without user intervention.

The following command will monitor /dev/md0 (polling every 300 seconds) for critical events. When a fatal error occurs, mdadm will send an email to sysadmin. You can tailor the polling interval and email address to meet your needs.

# mdadm --monitor --mail=sysadmin --delay=300 /dev/md0

When using monitor mode, mdadm will not exit, so you might want to wrap it around nohupand ampersand:

# nohup mdadm --monitor --mail=sysadmin --delay=300 /dev/md0 &

Follow/Monitor mode also allows arrays to share spare disks, a feature that has been lacking in Linux software RAID since its inception. That means you only need to provide one spare disk for a group of arrays or for all arrays. It also means that system administrators don't have to manually intervene to shuffle around spare disks when arrays fail. Previously this functionality was available only using hardware RAID. When Follow/Monitor mode is invoked, it polls arrays at regular intervals. When a disk failure is detected on an array without a spare disk, mdadm will remove an available spare disk from another array and insert it into the array with the failed disk. To facilitate this process, each ARRAY line in/etc/mdadm.conf needs to have a spare-group defined.

DEVICE /dev/sd*

ARRAY /dev/md0 level=raid1 num-devices=3 spare-group=database



UUID=410a299e:4cdd535e:169d3df4:48b7144a

-group=database UUID=59b6e564:739d4d28:ae0aa308:71147fe7

ARRAY /dev/md1 level=raid1 num-device=2 spare

In this example, both /dev/md0 and /dev/md1 are part of the spare group database. Just assume that /dev/md0 is a two-disk RAID-1 with a single spare disk. If mdadm is running in monitor mode (as I showed earlier), and a disk in /dev/md1 fails, mdadm will remove the spare disk from /dev/md0 and insert it into /dev/md1.



Links:
---------

http://archive.networknewz.com/2003/0113.html

http://tldp.org/HOWTO/Software-RAID-HOWTO-5.html

http://unthought.net/Software-RAID.HOWTO/Software-RAID.HOWTO-5.html

 Linux Interview  Linux booting process EXT4 XFS file system runlevel scan disk hba driver systool -c fc_host lspci -nn | grep -i hba single...