tag:blogger.com,1999:blog-316209392009-07-02T09:40:17.091-07:00Admin linuxOpen Minds, Open Hearts, Open Doors... Open SourcePrabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.comBlogger56125tag:blogger.com,1999:blog-31620939.post-50674923065048636072009-07-02T09:36:00.000-07:002009-07-02T09:40:17.101-07:00MYSQL: slow queries logMySQL has built-in functionality that allows you to log SQL queries to a file , You can enable the full SQL queries logs to a file or only slow running queries log. It is easy for us to troubleshoot/ debug the sql statement if SQL queries log enable , The slow query log is used to find queries that take a long time to execute and are therefore candidates for optimization.<br /><br />To enable you just need to add some lines to your my.cnf file, and restart. Add the following:<br /><br /> * To enable slow Query Log only<br /><br /><span style="font-weight:bold;">log-slow-queries = /var/log/mysql/mysql-slow.log<br />long_query_time = 1</span><br /><br />After enabling slow query, mysqld writes a statement to the slow query log file and it consists of all SQL statements that took more than long_query_time seconds to execute. The time to acquire the initial table locks is not counted as execution time. mysqld only log after SQL statements has been executed and after all locks have been released, so log order might be different from execution order. The minimum and default values of long_query_time are 1 and 10, respectively.<br /><br /> * To enable full Log Query<br /><br /><span style="font-weight:bold;">log=/var/log/mysqldquery.log</span><br /><br />The above will log all queries to the log file.<br /><br />Selecting Queries to Optmize<br />• The slow query log<br />– Logs all queries that take longer than long_query_time<br />– Can also log all querie s that don’t use indexes with<br /> --<span style="font-weight:bold;">log-queries-not-using-indexes</span><br />– To log slow administatve commands use<br /> --<span style="font-weight:bold;">log-slow-admin-statements</span><br />– To analyze the contents of the slow log use<br /> mysqldumpslow<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-5067492306504863607?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-39294172929295390402009-06-30T11:26:00.000-07:002009-06-30T11:27:32.054-07:00MYSQL: Query Execution Basics1. <span style="font-style:italic;"><span style="font-weight:bold;">The client sends the SQL statement to the server.</span></span><br /> -> The protocol is halfduplex, which means that at any given time the MySQL server can be either sending or receiving messages, but not both. It also means there is no way to cut a message short.<br />The client sends a query to the server as a single packet of data. This is why the max_packet_size configuration variable is important if you have large queries. Once the client sends the query, it doesn’t have the ball anymore; it can only wait for results. The response from the server usually consists of many packets of data.When the server responds, the client has to receive the entire result set. It cannot simply fetch a few rows and then ask the server not to bother sending the rest. If the client needs only the first few rows that are returned, it either has to wait for all of the server’s packets to arrive and then discard the ones it doesn’t need, or disconnect ungracefully. Neither is a good idea, which is why appropriate LIMIT clauses are so important.Here’s another way to think about this: when a client fetches rows from the server, it thinks it’s pulling them. But the truth is, the MySQL server is pushing the rows as it generates them. The client is only receiving the pushed rows; there is no way for it to tell the server to stop sending rows. The client is “drinking from the fire hose,” so to speak. <br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_NLkmGwwWuto/SkpWv-UYJZI/AAAAAAAABGU/-AIlLWeNb4s/s1600-h/mysql-arc.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 354px;" src="http://4.bp.blogspot.com/_NLkmGwwWuto/SkpWv-UYJZI/AAAAAAAABGU/-AIlLWeNb4s/s400/mysql-arc.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5353186489265563026" /></a><br /><br />2. <span style="font-style:italic;"><span style="font-weight:bold;">The server checks the query cache. If there’s a hit, it returns the stored result from the cache; otherwise, it passes the SQL statement to the next step.</span></span><br /> -> Before even parsing a query, MySQL checks for it in the query cache, if the cache is enabled. This operation is a case sensitive hash lookup. If the query differs from a similar query in the cache by even a single byte, it won’t match, and the query processing will go to the next stage.<br />If MySQL does find a match in the query cache, it must check privileges before<br />returning the cached query. This is possible without parsing the query, because<br />MySQL stores table information with the cached query. If the privileges are OK,<br />MySQL retrieves the stored result from the query cache and sends it to the client,<br />bypassing every other stage in query execution. The query is never parsed, optimized,<br />or executed.<br /><br />3. <span style="font-style:italic;"><span style="font-weight:bold;">The server parses, preprocesses, and optimizes the SQL into a query execution<br />plan.</span></span><br /> -> MySQL’s parser breaks the query into tokens and builds a “parse tree”<br />from them. The parser uses MySQL’s SQL grammar to interpret and validate the<br />query. For instance, it ensures that the tokens in the query are valid and in the proper order, and it checks for mistakes such as quoted strings that aren’t terminated. The preprocessor then checks the resulting parse tree for additional semantics that the parser can’t resolve. For example, it checks that tables and columns exist, and it resolves names and aliases to ensure that column references aren’t ambiguous.Next, the preprocessor checks privileges. This is normally very fast unless your server has large numbers of privileges.<br /> -> The parse tree is now valid and ready for the optimizer to turn it into a query execution plan. A query can often be executed many different ways and produce the same result. The optimizer’s job is to find the best option. MySQL uses a cost-based optimizer, which means it tries to predict the cost of various execution plans and choose the least expensive. The unit of cost is a single random four-kilobyte data page read.<br /><br />4. <span style="font-style:italic;"><span style="font-weight:bold;">The query execution engine executes the plan by making calls to the storage engine API.</span></span><br /> -> The parsing and optimizing stage outputs a query execution plan, which MySQL’s<br />query execution engine uses to process the query. The plan is a data structure; it is<br />not executable byte-code, which is how many other databases execute queries. In contrast to the optimization stage, the execution stage is usually not all that complex: MySQL simply follows the instructions given in the query execution plan.<br />Many of the operations in the plan invoke methods implemented by the storage<br />engine interface, also known as the handler API. Each table in the query is represented by an instance of a handler. If a table appears three times in the query, for example, the server creates three handler instances. Though we glossed over this before, MySQL actually creates the handler instances early in the optimization stage. The optimizer uses them to get information about the tables, such as their column names and index statistics.<br /><br />5. <span style="font-style:italic;"><span style="font-weight:bold;">The server sends the result to the client.</span></span><br /> -> The final step in executing a query is to reply to the client. Even queries that don’t return a result set still reply to the client connection with information about the query, such as how many rows it affected.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-3929417292929539040?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-46953945402925395602009-06-14T03:21:00.000-07:002009-06-30T10:06:48.503-07:00How do I Use the Linux Top Command?The Unix top command is designed to help users determine which processes are running and which applications are using more memory or processing power than they should be.<br /><br />The top command is very easy to use but you should know the things in details. The output of to is :<br /><br />top output:<br /><br /><blockquote>top - 22:09:08 up 14 min, 1 user, load average: 0.21, 0.23, 0.30<br />Tasks: 81 total, 1 running, 80 sleeping, 0 stopped, 0 zombie<br />Cpu(s): 9.5%us, 31.2%sy, 0.0%ni, 27.0%id, 7.6%wa, 1.0%hi, 23.7%si, 0.0%st<br />Mem: 255592k total, 167568k used, 88024k free, 25068k buffers<br />Swap: 524280k total, 0k used, 524280k free, 85724k cached<br /><br /> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND<br /> 3166 apache 15 0 29444 6112 1524 S 6.6 2.4 0:00.79 httpd<br /> 3161 apache 15 0 29444 6112 1524 S 5.9 2.4 0:00.79 httpd<br /> 3164 apache 15 0 29444 6112 1524 S 5.9 2.4 0:00.75 httpd<br /> 3169 apache 15 0 29444 6112 1524 S 5.9 2.4 0:00.74 httpd<br /> 3163 apache 15 0 29444 6112 1524 S 5.6 2.4 0:00.76 httpd<br /> 3165 apache 15 0 29444 6112 1524 S 5.6 2.4 0:00.77 httpd<br /> 3167 apache 15 0 29444 6112 1524 S 5.3 2.4 0:00.73 httpd<br /> 3162 apache 15 0 29444 6112 1524 S 5.0 2.4 0:00.77 httpd<br /> 3407 root 16 0 2188 1012 816 R 1.7 0.4 0:00.51 top<br /> 240 root 15 0 0 0 0 S 0.3 0.0 0:00.08 pdflush<br /> 501 root 10 -5 0 0 0 S 0.3 0.0 0:01.20 kjournald<br /> 2794 root 18 0 12720 1268 560 S 0.3 0.5 0:00.73 pcscd<br /> 1 root 15 0 2060 636 544 S 0.0 0.2 0:03.81 init<br /> 2 root RT -5 0 0 0 S 0.0 0.0 0:00.00 migration/0<br /> 3 root 34 19 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0<br /> 4 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/0<br /> 5 root 10 -5 0 0 0 S 0.0 0.0 0:00.07 events/0</blockquote><br /><span style="font-style:italic;"><span style="font-weight:bold;"><br />The first line in top:</span></span><br /><br /><span style="font-weight:bold;">top - 22:09:08 up 14 min, 1 user, load average: 0.21, 0.23, 0.30</span><br /><br />“22:09:08″ is the current time; “up 14 min” shows how long the system has been up for; “1 user” how many users are logged in; “load average: 0.21, 0.23, 0.30″ the load average of the system (1minute, 5 minutes, 15 minutes).<br /><br />Load average is an extensive topic and to understand its inner workings can be daunting. The simplest of definitions states that load average is the cpu utilization over a period of time. A load average of 1 means your cpu is being fully utilized and processes are not having to wait to use a CPU. A load average above 1 indicates that processes need to wait and your system will be less responsive. If your load average is consistently above 3 and your system is running slow you may want to upgrade to more CPU’s or a faster CPU.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">The second line in top:</span><br /></span><br /><span style="font-weight:bold;">Tasks: 82 total, 1 running, 81 sleeping, 0 stopped, 0 zombie</span><br /><br />Shows the number of processes and their current state.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">The third lin in top:</span></span><br /><br /><span style="font-weight:bold;">Cpu(s): 9.5%us, 31.2%sy, 0.0%ni, 27.0%id, 7.6%wa, 1.0%hi, 23.7%si, 0.0%st</span><br /><br />Shows CPU utilization details. “9.5%us” user processes are using 9.5%; “31.2%sy” system processes are using 31.2%; “27.0%id” percentage of available cpu; “7.6%wa” time CPU is waiting for IO.<br /><br />When first analyzing the Cpu(s) line in top look at the %id to see how much cpu is available. If %id is low then focus on %us, %sy, and %wa to determine what is using the CPU.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">The fourth and fifth lines in top:</span></span><br /><br /><span style="font-weight:bold;">Mem: 255592k total, 167568k used, 88024k free, 25068k buffers<br />Swap: 524280k total, 0k used, 524280k free, 85724k cached</span><br /><br />Describes the memory usage. These numbers can be misleading. “255592k total” is total memory in the system; “167568K used” is the part of the RAM that currently contains information; “88024k free” is the part of RAM that contains no information; “25068K buffers and 85724k cached” is the buffered and cached data for IO.<br /><br />So what is the actual amount of free RAM available for programs to use ?<br /><br />The answer is: free + (buffers + cached)<br /><br />88024k + (25068k + 85724k) = 198816k<br /><br />How much RAM is being used by progams ?<br /><br />The answer is: used - (buffers + cached)<br /><br />167568k - (25068k + 85724k) = 56776k<br /><br />The processes information:<br /><br />Top will display the process using the most CPU usage in descending order. Lets describe each column that represents a process.<br /><br /><span style="font-weight:bold;"> PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND<br />3166 apache 15 0 29444 6112 1524 S 6.6 2.4 0:00.79 httpd</span><br /><br />PID - process ID of the process<br /><br />USER - User who is running the process<br /><br />PR - The priority of the process<br /><br />NI - Nice value of the process (higher value indicates lower priority)<br /><br />VIRT - The total amount of virtual memory used<br /><br />RES - Resident task size<br /><br />SHR - Amount of shared memory used<br /><br />S - State of the task. Values are S (sleeping), D (uninterruptible sleep), R (running), Z (zombies), or T (stopped or traced)<br /><br />%CPU - Percentage of CPU used<br /><br />%MEM - Percentage of Memory used<br /><br />TIME+ - Total CPU time used<br /><br />COMMAND - Command issued<br />Interacting with TOP<br /><br />Now that we are able to understand the output from TOP lets learn how to change the way the output is displayed.<br /><br />Just press the following key while running top and the output will be sorted in real time.<br /><br />M - Sort by memory usage<br /><br />P - Sort by CPU usage<br /><br />T - Sort by cumulative time<br /><br />z - Color display<br /><br />k - Kill a process<br /><br />q - quit<br /><br />If we want to kill the process with PID 3161, then press “k” and a prompt will ask you for the PID number, and enter 3161.<br />Command Line Parameters with TOP<br /><br />You can control what top displays by issuing parameters when you run top.<br /><br />- d - Controls the delay between refreshes<br /><br />- p - Specify the process by PID that you want to monitor<br /><br />-n - Update the display this number of times and then exit<br /><br />If we want to only monitor the http process with a PID of 3166<br /><br />$ top -p 3166<br /><br />If we want to change the delay between refreshes to 5 seconds<br /><br />$ top -d 5<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-4695394540292539560?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-26706729353100335992009-04-17T23:00:00.000-07:002009-04-17T23:15:32.285-07:00Block IP addresses using IPtables<span style="font-weight:bold;">Block a particular</span><br />#service iptables start<br />#iptables -I INPUT -s 10.1.24.4 -j DROP<br /><br /><span style="font-style:italic;">This command will simply drop any packet coming from the address 10.1.24.4 </span><br /><br /><span style="font-weight:bold;">To list the chains:</span><br />#iptables -L -n<br /><br /><span style="font-weight:bold;">To make persist :</span><br /><br />#service iptables status<br />#iptables-save (copy output)<br />#emacs /etc/sysconfig/iptables (paste output)<br />#service iptables restart<br /><br />make sure iptables service start on default.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-2670672935310033599?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-56562959271126986362009-03-30T06:16:00.000-07:002009-03-31T02:25:38.457-07:00creating bulk users in linuxToday I have configured NX server.<br />Now, Next task is to create users and really its very time consuming and boring task.<br /><br />Usually you use <span style="font-weight:bold;">useradd</span> command to create a new user or update default new user information from command line.<br /><br />So i have explore Linux and searched on Google , I have found few scripts to do this. But later I have found one good and easy solution.<br /><br />Here is that, <br /><br />Update and create new users in bulk.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">newusers</span></span> command reads a file of user name and clear-text password pairs and uses this information to update a group of existing users or to create new users. Each line is in the same format as the standard password file.<br /><br />This command is intended to be used in a large system environment where many accounts are updated at a single time (batch mode). Since username and passwords are stored in clear text format make sure only root can read/write the file. Use chmod command:<br /><span style="font-style:italic;"><span style="font-weight:bold;"># touch /root/bulk-user-add.txt<br /># chmod 0600 /root/bulk-user-add.txt</span></span><br /><br />Create a user list as follows. Open file:<br /><span style="font-style:italic;"><span style="font-weight:bold;"># emacs /root/bulk-user-add.txt</span></span><br /><br />Append username and password:<br />sanjay:mypass99:555:555:Sanjay Singh:/home/Sanjay:/bin/bash<br />frampton:mypass99n:556:556:Frampton Martin:/home/Frampton:/bin/bash<br />----<br />--<br />---<br />barun:mypass99:560:560:Barun Ghosh:/home/Barun:/bin/bash<br /><br />Now create users in batch:<br /><span style="font-style:italic;"><span style="font-weight:bold;"># newusers /root/bulk-user-add.txt</span></span><br /><br />Read man page of newusers for more information.<br />May be I will automate entire procedure using a php<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-5656295927112698636?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com2tag:blogger.com,1999:blog-31620939.post-23248702835660772152009-03-24T11:04:00.000-07:002009-03-24T11:18:39.694-07:00Boot time parameters of Linux kernel<span style="font-style:italic;"><span style="font-weight:bold;">Boot time parameters you should know about the Linux kernel.</span></span><br /><br />The Linux kernel accepts boot time parameters as it starts to boot system. This is used to inform kernel about various hardware parameter.<br /><br /><span style="font-weight:bold;">The kernel command line syntax</span><br />name=value1,value2,value3…<br />Where,<br /> * name : Keyword name, for example, init, ro, boot etc<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Common Boot time parameters</span></span><br /><span style="font-weight:bold;">init</span><br />This sets the initial command to be executed by the kernel. Default is to use /sbin/init, which is the parent of all processes.<br />To boot system without password pass /bin/bash or /bin/sh as argument to init<br />init=/bin/bash<br /><br /><span style="font-weight:bold;">single</span><br />The most common argument that is passed to the init process is the word 'single' which instructs init to boot the computer in single user mode, and not launch all the usual daemons<br /><br /><span style="font-weight:bold;">root=/dev/device</span><br />This argument tells the kernel what device (hard disk, floppy disk) to be used as the root filesystem while booting. For example following boot parameter use /dev/sda1 as the root file system:<br />root=/dev/sda1<br />If you copy entire partition from /dev/sda1 to /dev/sdb1 then use<br />root=/dev/sdb1<br /><br /><span style="font-weight:bold;">ro</span><br />This argument tells the kernel to mount root file system as read-only. This is done so that fsck program can check and repair a Linux file system. Please note that you should never ever run fsck on read/write file system.<br /><br /><span style="font-style:italic;">rw</span><br />This argument tells the kernel to mount root file system as read and write mode.<br /><br /><span style="font-weight:bold;">panic=SECOND</span><br />Specify kernel behavior on panic. By default, the kernel will not reboot after a panic, but this option will cause a kernel reboot after N seconds. For example following boot parameter will force to reboot Linux after 10 seconds<br />panic=10<br /><br /><span style="font-weight:bold;">maxcpus=NUMBER</span><br />Specify maximum number of processors that an SMP kernel should make use of. For example if you have four cpus and would like to use 2 CPU then pass 2 as a number to maxcpus (useful to test different software performances and configurations).<br /><span style="font-style:italic;">maxcpus=2</span><br /><br /><span style="font-weight:bold;"><span style="font-weight:bold;">debug</span></span><br />Enable kernel debugging. This option is useful for kernel hackers and developers who wish to troubleshoot problem<br /><br /><span style="font-weight:bold;">selinux [0|1]</span><br />Disable or enable SELinux at boot time.<br />• Value 0 : Disable selinux<br />• Value 1 : Enable selinux<br /><br /><span style="font-weight:bold;">raid=/dev/mdN</span><br />This argument tells kernel howto assembly of RAID arrays at boot time. Please note that When md is compiled into the kernel (not as module), partitions of type 0xfd are scanned and automatically assembled into RAID arrays. This autodetection may be suppressed with the kernel parameter "raid=noautodetect". As of kernel 2.6.9, only drives with a type 0 superblock can be autodetected and run at boot time.<br /><br /><span style="font-weight:bold;">mem=MEMEORY_SIZE</span><br />This is a classic parameter. Force usage of a specific amount of memory to be used when the kernel is not able to see the whole system memory or for test. For example:<br /><span style="font-style:italic;">mem=1024M</span><br />The kernel command line is a null-terminated string currently up to 255 characters long, plus the final null. A string that is too long will be automatically truncated by the kernel, a boot loader may allow a longer command line to be passed to permit future kernels to extend this limit (H. Peter Anvin ).<br />Other parameters<br />initrd /boot/initrd.img<br />An initrd should be loaded. the boot process will load the kernel and an initial ramdisk; then the kernel converts initrd into a "normal" ramdisk, which is mounted read-write as root device; then /linuxrc is executed; afterwards the "real" root file system is mounted, and the initrd file system is moved over to /initrd; finally the usual boot sequence (e.g. invocation of /sbin/init) is performed. initrd is used to provide/load additional modules (device driver). For example, SCSI or RAID device driver loaded using initrd.<br /><br /><span style="font-weight:bold;">hdX =noprobe</span><br />Do not probe for hdX drive. For example, disable hdb hard disk:<br />hdb=noprobe<br />If you disable hdb in BIOS, Linux will still detect it. This is the only way to disable hdb.<br /><br /><span style="font-weight:bold;">ether=irq,iobase,[ARG1,ARG2],name</span><br />Where,<br />• ether: ETHERNET DEVICES<br />For example, following boot argument force probing for a second Ethernet card (NIC), as the default is to only probe for one (irq=0,iobase=0 means automatically detect them).<br />ether=0,0,eth1<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">How to begin the enter parameters mode?</span></span><br />You need to enter all this parameter at Grub or Lilo boot prompt. For example if you are using Grub as a boot loader, at Grub prompt press 'e' to edit command before booting.<br />1) Select second line<br />2) Again, press 'e' to edit selected command<br />3) Type any of above parameters.<br />See an example of "recovering grub boot loader password", for more information. Another option is to type above parameters in grub.conf or lilo.conf file itself.<br /><br /><a href="http://www.cyberciti.biz/howto/question/static/linux-kernel-parameters.php">More detail</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-2324870283566077215?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-87843113741314901372009-03-22T00:18:00.000-07:002009-03-22T00:57:17.375-07:00MYSQL REPLICATION & DISASTER RECOVERYMySQL’s built-in replication capability is the foundation for building large, high performance applications on top of MySQL. Replication lets you configure one or more servers as slaves, or replicas, of another server.<br /><br /><span style="font-weight:bold;">1. Setting up Replication:</span><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_NLkmGwwWuto/ScXvTIsI7QI/AAAAAAAABEM/qooPJfKksXw/s1600-h/MYSQL.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 203px;" src="http://4.bp.blogspot.com/_NLkmGwwWuto/ScXvTIsI7QI/AAAAAAAABEM/qooPJfKksXw/s400/MYSQL.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5315918047209909506" /></a><br />Three threads are involved in Replication: One on the master and two on the slave.<br />• The I/O thread on the slave connects to the master and requests the binary update log. The Binary log dump thread on the master sends the binary update log to the slave on request.<br />• Once on the slave, the I/O thread reads the data sent by the master and copies it to the relay log in the data directory.<br />• The third thread, also on the slave, is the SQL Thread, which read and executes the queries from the relay log to bring the slave in alignment with the master.<br /><br /><span style="font-weight:bold;">2. Replication with example:</span><br /><br />Version: Both master and slave should be the same version. Otherwise replication will be improper.<br />Network Configuration Settings<br />Master Server IP Address: 10.5.1.10<br />Slave Server Primary IP Address (Ethernet eth0): 10.5.1.11<br />Slave Server Secondary IP Address (Ethernet eth1): 10.5.1.10 (By default it is disabled)<br /><br /><span style="font-weight:bold;">3. MySQL Replication Installation:</span><br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step1:</span></span><br /><br />Install MySQL on master 1 and slave 1. Configure network services on both systems, like<br />Master 1/Slave 2 IP: 10.5.1.10<br />Master 2/Slave 1 IP: 10.5.1.11<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step2:</span></span><br /><br />On Master 1, make changes in my.cnf:<br />[mysqld]<br />logbin= mysqlbin<br />binlogdodb=<database name> # input the database which should be replicated or ignore this command to replicate all the databases.<br />binlogignoredb= mysql # input the database that should be ignored for replication<br />serverid=1<br />auto_increment_increment=2<br />auto_increment_offset=1<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step 3:</span></span><br /><br />On master 1, create a replication slave account in mysql.<br />mysql> grant replication slave on *.* to 'replication'@10.5.1.11 identified by 'slave';<br />Restart the mysql master1.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step 4:</span></span><br /><br />Now edit my.cnf on Slave1 or Master2:<br />[mysqld]<br />serverid =2<br />masterhost= 10.5.1.10<br />masteruser= replication<br />masterpassword= slave<br />masterport= 3306<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step 5:</span></span><br /><br />Restart th MySQL Slave 1.<br />Login to the MySQL command prompt and start the slave replication.<br />[root@Slavetest ~]# mysql -u root -p<br />Enter password: xxxxx (Please consult MySQL Administrator/IT Manager)<br />Welcome to the MySQL monitor. Commands end with; or \g.<br />Your MySQL connection id is 250<br />Server version: 5.0.54a-enterprise-gpl-log MySQL Enterprise Server (GPL)<br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br />mysql><br />mysql> start slave;<br />mysql> show slave status\G;<br />*************************** 1. row ***************************<br />Slave_IO_State: Waiting for master to send event<br />Master_Host: 10.5.1.10<br />Master_User: replication<br />Master_Port: 3306<br />Connect_Retry: 60<br />Master_Log_File: mysql-bin.000018<br />Read_Master_Log_Pos: 2953<br />Relay_Log_File: slavetest-relay-bin.000065<br />Relay_Log_Pos: 235<br />Relay_Master_Log_File: mysql-bin.000018<br />Slave_IO_Running: Yes<br />Slave_SQL_Running: Yes<br />Replicate_Do_DB:<br />Replicate_Ignore_DB:<br />Replicate_Do_Table:<br />Replicate_Ignore_Table:<br />Replicate_Wild_Do_Table:<br />Replicate_Wild_Ignore_Table:<br />Last_Errno: 0<br />Last_Error:<br />Skip_Counter: 0<br />Exec_Master_Log_Pos: 2953<br />Relay_Log_Space: 235<br />Until_Condition: None<br />Until_Log_File:<br />Until_Log_Pos: 0<br />Master_SSL_Allowed: No<br />Master_SSL_CA_File:<br />Master_SSL_CA_Path:<br />Master_SSL_Cert:<br />Master_SSL_Cipher:<br />Master_SSL_Key:<br />Seconds_Behind_Master: 0<br />1 row in set (0.00 sec)<br />mysql><br />Above highlighted rows must be indicate related log files and Slave_IO_Running and<br />Slave_SQL_Running: must be to YES.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step 6:</span></span><br /><br />On Master 1:<br />[root@TESTDB~]# mysql -u root -p<br />Enter password: xxxxx (Please consult MySQL Administrator/IT Manager)<br />Welcome to the MySQL monitor. Commands end with; or \g.<br />Your MySQL connection id is 250<br />Server version: 5.0.54a-enterprise-gpl-log MySQL Enterprise Server (GPL)<br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br />mysql><br />mysql> show master status;<br />+------------------------------------+-----------+--------------------+------------------------+<br />| File | Position | Binlog_Do_DB | Binlog_Ignore_DB|<br />+------------------------------------+-----------+--------------------+------------------------+<br />|MysqlMYSQL01-bin.000008| 410 | | mysql |<br />+------------------------------------+-----------+--------------------+------------------------+<br />1 row in set (0.00 sec)<br />The above scenario is for master-slave, now we will create a slave master scenario for the same systems and it will work as master master.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step 7:</span></span><br /><br />Edit on Master 2/ Slave 1, edit my.cnf and master entries into it:<br />[mysqld]<br />logbin=mysqlbin #information for becoming master added<br />binlogignoredb=mysql<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step 8:</span></span><br /><br />Create a replication slave account on master2 for master1:<br />mysql> grant replication slave on *.* to 'slavereplication'@10.5.1.10 identified by 'slave';<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step 9:</span></span><br /><br />Edit my.cnf on master1 for information of its master.<br />[mysqld]<br />auto_increment_increment=2<br />auto_increment_offset=1 #information for becoming slave.<br />masterhost= 10.5.1.11<br />masteruser= slavereplication<br />masterpassword= slave<br />masterport= 3306<br />master_connect_retry=60<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step 10:</span></span><br /><br />Restart both mysql master1 and master2.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step 11:</span><br /></span><br /><br />Monitor Mysql Replication using :<br />• show slave status\G<br />• show processlist\G<br />• show master status;<br /><br /><br /><span style="font-weight:bold;">4. Fail over Configuration Procedure :<br /></span><br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step1: </span></span><br /><br />Login to Slave Server Using Secure Shell in Linux or Putty tool<br />[root@TESTDB ~]# ssh 10.5.1.11<br />root@10.5.1.11 password: xxxxx<br />Last login: Tue Oct 7 15:30:41 2008 from 10.5.1.10<br />[root@slavetest ~]#<br />or Use Putty Tool in Windows<br />Enter the slave IP address and user name and password<br />After login into slave machine proceed the below steps.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step2:</span></span><br /><br />Connect the Ethernet Interface cable.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step3:</span></span> <br /><br />Enable the secondary Ethernet interface<br />[root@slavetest ~]# ifup eth1<br />Step4: Login into Mysql<br />[root@slavetest ~]# mysql -u root -p<br />Enter password: xxxxx (Please consult MySQL Administrator/IT Manager)<br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 250<br />Server version: 5.0.54a-enterprise-gpl-log MySQL Enterprise Server (GPL)<br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br />mysql><br />You Will get Welcome message and mysql prompt as show above.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step5:</span></span><br /><br />Check the Slave Status<br />mysql> show slave status\G<br />*************************** 1. row ***************************<br />Slave_IO_State: Waiting for master to send event<br />Master_Host: 10.5.1.10<br />Master_User: replication<br />Master_Port: 3306<br />Connect_Retry: 60<br />Master_Log_File: mysql-bin.000018<br />Read_Master_Log_Pos: 2953<br />Relay_Log_File: slavetest-relay-bin.000065<br />Relay_Log_Pos: 235<br />Relay_Master_Log_File: mysql-bin.000018<br />Slave_IO_Running: Yes<br />Slave_SQL_Running: Yes<br />Replicate_Do_DB:<br />Replicate_Ignore_DB:<br />Replicate_Do_Table:<br />Replicate_Ignore_Table:<br />Replicate_Wild_Do_Table:<br />Replicate_Wild_Ignore_Table:<br />Last_Errno: 0<br />Last_Error:<br />Skip_Counter: 0<br />Exec_Master_Log_Pos: 2953<br />Relay_Log_Space: 235<br />Until_Condition: None<br />Until_Log_File:<br />Until_Log_Pos: 0<br />Master_SSL_Allowed: No<br />Master_SSL_CA_File:<br />Master_SSL_CA_Path:<br />Master_SSL_Cert:<br />Master_SSL_Cipher:<br />Master_SSL_Key:<br />Seconds_Behind_Master: 0<br />1 row in set (0.00 sec)<br />mysql><br />Above Result will display Slave Replication status.<br />Make sure that the slave has processed any statements in their relay log. On slave, issue STOP SLAVE IO_THREAD, then check the output of SHOW PROCESSLIST until you see Has read all relay log; waiting for the slave I/O thread to update it. When this is true for all slaves, they can be reconfigured to the new setup.<br />mysql> Stop Slave io_thread;<br />mysql> show processlist\G<br />*************************** 1. row ***************************<br />Id : 203<br />User: slavereplication<br />Host: 10.5.1.10:59795<br />db : NULL<br />Command: Binlog Dump<br />Time: 158086<br />State: Has sent all binlog to slave; waiting for binlog to be updated<br />Info: NULL<br />*************************** 2. row ***************************<br />Id: 230<br />User: system user<br />Host:<br />db: NULL<br />Command: Connect<br />Time: 152220<br />State: Has read all relay log; waiting for the slave I/O thread to update it<br />Info: NULL<br />*************************** 3. row ***************************<br />Id: 251<br />User: root<br />Host: localhost<br />db: NULL<br />Command: Query<br />Time: 0<br />State: NULL<br />Info: show processlist<br />3 rows in set (0.00 sec)<br />mysql><br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step6:</span></span><br /><br />Making Slave as Master server<br />mysql> show master status;<br />+----------------------+----------+-------------------+-----------------------------+<br />| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |<br />+----------------------+----------+-------------------+-----------------------------+<br />| mysql-bin.000006 | 783 | | mysql,mysql |<br />+----------------------+----------+-------------------+-----------------------------+<br />1 row in set (0.00 sec)<br />mysql><br />(Note : This is very important make a note down of mysql log file and position when the slave becomes master).<br />mysql> stop slave;<br />This command will stop the slave replication. Now it is ready to serve as a master, start the application in the server.<br /><br /><span style="font-weight:bold;">5. Restoration Procedure:</span><br /><br />Note: Bring down the secondary Ethernet interface eth1 down in slave server before your plan to restore. Now once the original master server problem has been fixed and making it as live server. When Master is up again, you must issue the CHANGE MASTER, so that Master becomes a slave of S1 and picks up each Web Client writes that it missed while it was down.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step1:</span></span><br /><br />Connect to the Current Master server<br />[root@TESTDB ~]# ssh 10.5.1.11<br />root@10.5.1.11's password: xxxxxxx<br />Last login: Tue Oct 7 15:30:41 2008 from 10.5.1.10<br />[root@mastertest ~]#<br />or<br />Use Putty Tool in Windows<br />Enter the slave IP address and user name and password<br />After login into machine proceed the below steps.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;"><br />Step 2:</span></span><br /><br />Unplug the secondary Ethernet Interface in current Master.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step3: </span><br /></span><br />Disable the secondary Ethernet Interface in current Master.<br />[root@mastertest ~]# ifdown eth1<br />Now Boot the Original Master Server and if the Ethernet cable is UN-plugged. Plug the Ethernet Interface in the Original Master server.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step4:</span></span><br /><br />Login To Original_Mater Server Using Secure Shell in Linux or Putty tool<br />[root@TESTDB ~]# ssh 10.5.1.10<br />root@10.5.1.10's password: xxxxxxx<br />Last login: Tue Oct 7 15:30:41 2008 from 10.5.1.10<br />[root@mastertest ~]#<br />Or Use Putty Tool in Windows<br />Enter the slave IP address and user name and password<br />After login into machine proceed the below steps.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step5:</span></span><br /><br />Login into Mysql<br />[root@slavetest ~]# mysql -u root -p<br />Enter password: xxxxx (Please consult MySQL Administrator/IT Manager)<br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 250<br />Server version: 5.0.54a-enterprise-gpl-log MySQL Enterprise Server (GPL)<br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br />mysql><br />You Will get Welcome message and mysql prompt as show above.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step6:</span></span><br /><br />Configure Old_master as a Slave Server of Current_Master Server<br />mysql>change master to <br />>master_host=10.5.1.11', (slave server ip address)<br />>master_user='slavereplication', (slavereplication-mysql replication user created in the<br />slave server)<br />>master_password='slave', (slave- mysql replication user password created in the<br />slave server)<br />>master_log_file='mysql-bin.0000xx', (xx: position of current_master server log file name as shown in show master status, at the time of<br />making slave as master)<br />> master_log_pos=xx; (xx:position of current_master log position as shown<br />in show master status, at the time of making slave as master)<br />mysql><br />mysql>start slave;<br />Now it will get updates, which are missed during the failure. Once all update has been finished make master a master again.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;"><br />Step7:</span> </span><br /><br />To make Master a master again (because it is the most powerful machine, for example), use the preceding procedure as if Slave 1 was unavailable and Master was to be the new master.<br />[root@mastertest ~]# service mysql stop<br />[root@mastertest ~]# cd /var/lib/mysql<br />[root@mastertest ~]# mv master.info relay-log.info servername-relay.bin* /root<br />[root@mastertest ~]# service mysql start<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Step8: </span></span><br /><br />Making original Slave as a slave replication server<br /><br />[root@slavetest ~]# mysql -u root -p<br />Enter password: xxxxx (Please consult MySQL Administrator/IT Manager)<br />Welcome to the MySQL monitor. Commands end with ; or \g.<br />Your MySQL connection id is 250<br />Server version: 5.0.54a-enterprise-gpl-log MySQL Enterprise Server (GPL)<br />Type 'help;' or '\h' for help. Type '\c' to clear the buffer.<br />mysql> start slave;<br /><span style="font-weight:bold;"><br />6. Replication Files:</span><br /><br />Let’s take a look at some of the files replication uses. You already know about the binary log and the relay log, but there are several other files too. Where MySQL places them depends mostly on your configuration settings. Different MySQL versions place them in different directories by default. You can probably find them either in the data directory or in the directory that contains the server’s .pid file (possibly /var/run/mysqld/ on Unix-like systems). <br />Here they are:<br />• mysql-bin.index : A server that has binary logging enabled will also have a file named the same as the binary logs, but with a .index suffix. This file keeps track of the binary log files that exist on disk. It is not an index in the sense of a table’s index; rather, each line in the file contains the filename of a binary log file. You might be tempted to think that this file is redundant and can be deleted (after all, MySQL could just look at the disk to find its files), but don’t. MySQL relies on this index file, and it will not recognize a binary log file unless it’s mentioned here.<br /><br />• mysql-relay-bin.index : This file serves the same purpose for the relay logs as the binary log index file does for the binary logs.<br /><br />• master.info : This file contains the information a slave server needs to connect to its master. Don’t delete it, or your slave will not know how to connect to its master after it restarts. This file contains the replication user’s password, in plain text, so you may want to restrict its permissions.<br /><br />• relay-log.info: This file contains the slave’s current binary log and relay log coordinates (i.e., the slave’s position on the master). Don’t delete this either, or the slave will forget where it was replicating from after a restart and might try to replay statements it has already executed. <br /><br /><br />These files are a rather crude way of recording MySQL’s replication and logging state. Unfortunately, they are not written synchronously, so if your server loses power and the files haven’t yet been flushed to disk, they can be inaccurate when the server restarts.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-8784311374131490137?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-42764925450643893472008-11-20T01:57:00.001-08:002008-11-20T02:33:43.275-08:00move you bookmarks between computersMost of time I face problem when I lose my bookmarks. Its important to take backup of bookmarks which easily transfer between systems. After doning 10min of search I comeup with 3 method.<br />a. Export &amp; Import Method.<br /><ul><li>From the Firefox browser, click on on the "Bookmarks" menu located at the top of the window. Next, click on the "Organize Bookmarks"</li><li>This brings you to a separate window which lists all existing bookmarks (favorite websites). From the File menu at the top, you have the option to Import and Export.</li><li>If you need to import external bookmarks and merge them into Firefox, do so by clicking "Import" from the File menu. This allows you to import your favorites from Internet Explorer, or just an existing file you had saved in the past. Choose the desired option, and hit "Next" to search for your bookmarks. When done, click "Finish." </li><li>If you need to externally save existing Firefox bookmarks, click on the "Export" option from the File menu. Once you choose a save destination, you're all set.</li></ul><p>b. Keep your bookmark online, few sites gives service to keep the bookmarks online and it will sync data between your firefok and there server. Just you need to create account there one of such site is <a href="http://www.mybookmarks.com/">http://www.mybookmarks.com/</a>.</p><p>c. This will take backup of all your Firefox Extentions along with bookmarks. What you need to do install FEBE (<a href="http://www.blogger.com/www.customsoftwareconsult.com/extensions/febe/febe.html">Firefox Environment Backup Extension</a>). There is another extension CLEO(<a href="http://www.blogger.com/www.customsoftwareconsult.com/extensions/cleo/cleo.html">Compact Library Extension Organizer</a>) that can be used to combine all the extension and make it as a single extension file. it can also be very help full if you have your own custom made extension.</p><p>source :</p><p><a href="http://mozilla.gunnars.net/firefox_bookmarks_tutorial.html">http://mozilla.gunnars.net/firefox_bookmarks_tutorial.html</a></p><p><a href="http://prabhanjan-panigrahi.blogspot.com/2008/11/backup-your-firefox-extentions-and.html">http://prabhanjan-panigrahi.blogspot.com/2008/11/backup-your-firefox-extentions-and.html</a></p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-4276492545064389347?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com1tag:blogger.com,1999:blog-31620939.post-66307776132686356762008-09-25T05:32:00.000-07:002008-09-25T05:48:20.723-07:00Performance : Alternative PHP Cache (APC)1. yum install php-pecl-apc<br /><br />If for some reason centosplus repo is not enabled then:<br />1. cd /usr/src/<br />2. wget http://pecl.php.net/get/APC-3.0.19.tgz<br />3. tar xvzf APC-3.0.19.tgz<br />4. cd APC-3.0.19<br />5. yum install php-devel<br />6. yum install automake<br />7. yum install libtool httpd-devel*<br />8. /usr/bin/phpize<br />9. ./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config<br />10. make<br />11. make install<br />12. ls /usr/lib64/php4/ or /usr/lib64/php/modules/<br />13 #emacs /etc/php.ini<br /> extension=apc.so<br /> apc.enabled=1<br /> apc.shm_segments=1<br /> apc.shm_size=128<br /> apc.ttl=7200<br /> apc.user_ttl=7200<br /> apc.num_files_hint=1024<br /> apc.mmap_file_mask=/tmp/apc.XXXXXX<br /> apc.enable_cli=1<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-6630777613268635676?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-42560573070944294162008-09-15T06:25:00.000-07:002008-09-15T06:45:07.812-07:00Understanding LVM<span style="font-weight: bold;">LVM terminology:</span><br />a. <span style="font-weight: bold; font-style: italic;">Physical Volume (PV)</span> : A PV is nothing more than a physical medium with some administrative data added to it - once you have added this, LVM will recognise it .<br />b. <span style="font-weight: bold;">Physical Extents (PE)</span> :- Physical Extents are like really big blocks, often with a size of megabytes.<br />c. <span style="font-weight: bold; font-style: italic;">Volume Group (VG) </span>- A VG is made up of a number of Physical Extents (which may have come from multiple Physical Volumes or hard drives). While it may be tempting to think of a VG as being made up of several hard drives (/dev/hda and /dev/sda for example), it's more accurate to say that it contains PEs which are provided by these hard drives.<br />d. <span style="font-weight: bold; font-style: italic;">Logical Volumes (LV)</span> - A logical volume functions like a normal partition -- it have a filesystem such as Ext3, and a mount point. From , Volume Group, PEs can be assigned to a logical Volume (LV).<br /><br /><span style="font-weight: bold;">Creating Physical volumes:</span><br /><span style="font-style: italic;">#pvcreate /dev/sda3</span><br /><br />Multiple physical volumes<br /><span style="font-style: italic;">#pvcreate /dev/sda9 /dev/sda10</span><br /><br /><br /><span style="font-weight: bold;">Creating a volume group:</span><br /><span style="font-style: italic;">#vgcreate home2 /dev/sda3</span><br /><br />Multiple physical volumes to make up a volume group<br /><span style="font-style: italic;">#vgcreate home3 /dev/sda9 /dev/sda10</span><br /><br /><span style="font-weight: bold;">Creating logical volume:</span><br /><span style="font-style: italic;">#lvcreate --size 1G -n downloads home2</span><br />now,<br /><span style="font-style: italic;">#mkfs.ext3 /dev/home2/downloads</span><br /><span style="font-style: italic;">#mkdir /home/downloads</span><br /><span style="font-style: italic;">#mount -t ext3 /dev/home2/downloads /home/downloads</span><br />Add a line to the /etc/fstab file<br /><span style="font-style: italic;">/dev/home2/downloads /home/downloads ext3 defaults 1 2</span><br /><br /><span style="font-weight: bold;">Resizing logical volumes:</span><br /><span style="font-style: italic;">#umount /home/downloads</span><br /><span style="font-style: italic;">#lvextend -L +1G /dev/home2/downloads</span><br /><span style="font-style: italic;">#resize2fs /dev/home2/downloads</span><br /><br />Similar to the lvextend there is the lvreduce command:<br /><span style="font-style: italic;">#lvreduce -L -500M /dev/home2/downloads</span><br /><span style="font-style: italic;">#resize2fs /dev/home2/downloads</span><br /><br /><span style="font-weight: bold;">Modifying volume groups:</span><br />a. unmount the logical volumes within your volume group.<br />b. <span style="font-style: italic;">#vgextend home2 /dev/sda5 /dev/sda7</span><br />(The volume group home2 is now made up of sda3, sda5, and sda7)<br /><br /><span style="font-weight: bold;">Remove a volume group</span><br />a. Unmount your logical volume<br />b. <span style="font-style: italic;">#vgremove home2</span><br /><br /><pre>A Physical Volume, containing Physical Extents:<br /><br />+-----[ Physical Volume ]------+<br />| PE | PE | PE | PE | PE | PE |<br />+------------------------------+<br /><br />A Volume Group, containing 2 Physical Volumes (PVs) with 6 Physical Extents:<br /><br />+------[ Volume Group ]-----------------+<br />| +--[PV]--------+ +--[PV]---------+ |<br />| | PE | PE | PE | | PE | PE | PE | |<br />| +--------------+ +---------------+ |<br />+---------------------------------------+<br /><br />We now further expand this:<br /><br />+------[ Volume Group ]-----------------+<br />| +--[PV]--------+ +--[PV]---------+ |<br />| | PE | PE | PE | | PE | PE | PE | |<br />| +--+---+---+---+ +-+----+----+---+ |<br />| | | | +-----/ | | |<br />| | | | | | | |<br />| +-+---+---+-+ +----+----+--+ |<br />| | Logical | | Logical | |<br />| | Volume | | Volume | |<br />| | | | | |<br />| | /home | | /var | |<br />| +-----------+ +------------+ |<br />+---------------------------------------+<br /></pre><br /><br />You can use the lvdisplay command see logical vloume's status.<br /><a href="http://www.ibm.com/developerworks/library/l-lvm2/index.html"><br />http://www.ibm.com/developerworks/library/l-lvm2/index.html</a><br /><a href="http://www.linux.com/feature/118645">http://www.linux.com/feature/11864</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-4256057307094429416?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com1tag:blogger.com,1999:blog-31620939.post-451209384206897982008-09-15T05:16:00.000-07:002008-09-15T05:24:03.561-07:00Roaming Profile on samba with PDC controller, windows as client1. Make these change in samba configuration file : emacs /etc/samba/smb.conf<br />Important terms to understand<br /> a. wins support = yes<br /> b. domain master = yes<br /> c. netbios name = samba<br /> d. workgroup = OFFICE<br /> e. domain logons = yes<br /><br />2. Samba root access<br />#smbpasswd -a<br /><br />3. Add new user :<br />#useradd prabhat (adding linux user)<br />#passwd prabhat<br />#smbpasswd -a prabhat (converting linux user into samba user)<br /><br />4. On the windows machine,Aadd window machine in 'OFFICE' domain of samba.<br />On desktop, Right click on "My Computer" -> "properties" -> "Network identificatation" tab -> "change"<br />while joing it will ask for username password "root" &amp; "OFFICE" (see serial no 2.)<br /><br /><br />Important Points:<br />1. There will be one and only one PDC over network.<br />2. The machine name must be unique over network.<br />3. While login from client domain name must be 'OFFICE'<br /><br /><br />#emacs /etc/samba/smb.conf<br /><blockquote style="font-style: italic;">[global]<br /> log file = /var/log/samba/%m.log<br /> log level = 2<br /> load printers = yes<br /> idmap gid = 16777216-33554431<br /> socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192<br /> winbind use default domain = no<br /> template shell = /bin/false<br /> wins support = yes<br /> dns proxy = no<br /> netbios name = samba<br /> domain master = yes<br /> preferred master = yes<br /> cups options = raw<br /> server string = Samba PDC<br /> idmap uid = 16777216-33554431<br /> workgroup = OFFICE<br /> os level = 64<br /> domain logons = yes<br /> add user script = /usr/sbin/useradd -m '%u'<br /> delete user script = /usr/sbin/userdel -r '%u'<br /> add group script = /usr/sbin/groupadd '%g'<br /> delete group script = /usr/sbin/groupdel '%g'<br /> add user to group script = /usr/sbin/usermod -G '%g' '%u'<br /> set primary group script = /usr/sbin/usermod -g '%g' '%u'<br /> add machine script = /usr/sbin/useradd -s /bin/false -d /dev/null '%u'<br /> logon script = scripts\logon.bat<br /> passdb backend = tdbsam<br /> printcap name = /etc/printcap<br /> security = user<br /> max log size = 50<br /> hosts allow = 10.1.<br /><br />[homes]<br /> comment = Home Directories<br /> valid users = %S<br /> browseable = No<br /> writable = Yes<br /><br /># Un-comment the following and create the netlogon directory for Domain Logons<br />[netlogon]<br /> comment = Network Logon Service<br /> logon path = \\%L\profiles\%U<br /> logon home = \\%L\%U\.9xprofile<br /> logon drive = p:<br /> browseable = no<br /> writable = no<br />; share modes = no</blockquote><br /><br />Concept:<br /><a href="http://searchenterpriselinux.techtarget.com/tip/0,289483,sid39_gci1151921,00.html">http://searchenterpriselinux.techtarget.com/tip/0,289483,sid39_gci1151921,00.html</a><br />Practial Implement:<br /><a href="http://searchenterpriselinux.techtarget.com/tip/0,289483,sid39_gci1151926,00.html">http://searchenterpriselinux.techtarget.com/tip/0,289483,sid39_gci1151926,00.html</a><br />Read section : "Joining" a Samba Domain<br /><a href="http://www.rmschneider.com/writing/xp_and_samba.html">http://www.rmschneider.com/writing/xp_and_samba.html</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-45120938420689798?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-81376234877675858392008-07-23T05:24:00.000-07:002008-07-23T05:49:29.086-07:00NFS server Redhat 5<span style="font-weight: bold;">Making NFS server Live:</span><br /><br /><span style="font-style: italic; font-weight: bold;">Server side (Server IP 10.1.31.1):</span><br />1. Check nfs-utils is installed or not using<br /> <span style="font-weight: bold; font-style: italic;">#yum list nfs-utils</span><br />2. Edit /etc/exports , add dir you want share with netrwork information and permision<br /> <span style="font-style: italic; font-weight: bold;"># vi /etc/exports</span><br /> <span style="font-weight: bold; font-style: italic;">/var/ftp/pub 10.1.0.0/16(rw,sync,no_root_squash)</span><br />3. Restart nfs service<br /> <span style="font-weight: bold; font-style: italic;"># service nfs retstart</span><br />or<br /> <span style="font-weight: bold; font-style: italic;"># service nfs reload</span><br />4. Check port &amp; shared dir using<br /> <span style="font-weight: bold; font-style: italic;"># rcpinfo -p</span><br /><span style="font-weight: bold; font-style: italic;"> # export -v</span><br /><span style="font-weight: bold; font-style: italic;"> # service portmap status</span><br /><br /><span style="font-weight: bold; font-style: italic;">Client Side (Client IP : 10.1.0.0/16, eg 10.1.31.67):</span><br />1. mount shared nfs folder<br /> <span style="font-style: italic; font-weight: bold;"># mount 10.1.31.3:/var/ftp/pub /mnt</span><br />2. Do static mount using /etc/fstab<br /> <br /><span style="font-weight: bold; font-style: italic;"> # vi /etc/fstab</span><br /><span style="font-weight: bold; font-style: italic;"> 10.1.31.1:/var/ftp/pub /mnt nfs defaults 0 0</span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-8137623487767585839?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com1tag:blogger.com,1999:blog-31620939.post-86477499696565759672008-07-16T04:17:00.000-07:002008-07-16T05:14:49.604-07:00Creating RAID Partition<span style="font-size:100%;">Creating RAID-5<o:p></o:p></span> <p class="MsoNormal" style="font-family:arial;"><span style="font-size:100%;"><o:p></o:p>For this you need 3 Partition, 2 partitions with same size and 3rd partition </span><span style="font-size:100%;">is 10% </span><span style="font-size:100%;">greater than 1st or 2nd( <span style="font-style: italic;">since 1 &amp; 2nd partition of same size.</span>). You can use fdisk command to create partition and make sure </span><span style="font-size:100%;">partition </span><span style="font-size:100%;"> type must be FD. In fdisk command use option <span style="font-weight: bold; font-style: italic;">t</span> to change partition type.</span></p>eg. I have created <span style="font-size:100%;">/dev/sda1, </span><span style="font-size:100%;">/dev/sdb1 and </span><span style="font-size:100%;">/dev/sdc1.</span> <p class="MsoNormal" style="font-family:arial;"><span style="font-size:100%;"><o:p> </o:p>Once you created 3 partitions use this to make RAID 5:<o:p><br /></o:p><span style="font-weight: bold; font-style: italic;">#mdadm --create /dev/md0 --level=5 --raid-device=3 /dev/sd{a1,b1,c1}</span><o:p></o:p></span></p> <p class="MsoNormal" style="font-family:arial;"><span style="font-size:100%;"><o:p> </o:p>Check the RAID partition using:<o:p></o:p><br /><span style="font-weight: bold; font-style: italic;">#less /proc/mdstat</span><o:p></o:p></span></p> <p class="MsoNormal" style="font-family:arial;"><span style="font-size:100%;"><o:p> </o:p>Or you can see detail information's using:<o:p></o:p><br /><span style="font-weight: bold; font-style: italic;">#mdadm --detail /dev/md0</span><o:p></o:p></span></p> <p class="MsoNormal" style="font-family:arial;"><span style="font-size:100%;"><o:p> </o:p>To rebuild corrupted partation use:<o:p></o:p><br /><span style="font-weight: bold; font-style: italic;">#mdadm /dev/md0 -r /dev/sdb0</span></span></p><p style="font-family: arial;" class="MsoNormal"></p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-8647749969656575967?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-11418790953544506182008-07-10T04:39:00.000-07:002008-07-11T07:49:34.328-07:00Swap Filesystem CreationPartition Creation for Swap filesystem<br />1. fdisk -l<br />2. fdisk /dev/sda<br />3. Type p &amp; Press Enter<br />4. Type n &amp; Press Enter<br />5. Just Press Enter for 1st Cylinder size<br />6. Type +sizeM for last Cylinder size<br />7. Type p &amp; Press Enter<br />8. Type t &amp; Press Enter<br />9. t2 /dev/sda12<br />10. Type 82 &amp; Press Enter<br />11. Type p &amp; Press Enter<br />12. Type w &amp; Press Enter<br />13. partprobe<br />14. swapon -s<br />15. swapoff /dev/sda7 => Swapoff the another swap partition<br />16. swapon -s<br /><br />Creation of a new Swap Filesystem<br />1. mkswap -v1 /dev/sda12<br />2. swapon /dev/sda12<br />3. swapon /dev/sda7<br />Here /dev/sda7 &amp; /dev/sda12 are swap partition.<br /><br />For automounting the either or swap partition do the following :<br /><br />1. vi /etc/fstab<br />2. Add the following line :-<br /><br />/dev/sda12 swap swap defaults 0 0<br /><br />Note :- Partition Id identifies what type of filesystem will have to create. Id is Hexacode number. Maximum 4 partition can be create 3 primary &amp; 1 Extended.<br /><br />Filesystem ID<br />Ext2 / Ext3 ( Linux) 83<br />Swap 82<br />Fat32 C<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-1141879095354450618?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-62527168576943930292008-07-10T03:48:00.000-07:002008-07-11T01:54:34.729-07:00Linux partition using fdisk<span style="font-weight: bold;font-family:arial;font-size:100%;" >Linux partition using fdisk</span><span style=";font-family:arial;font-size:100%;" ><br /><br />1. fdisk -l => To check what type of Hard Disk i.e. Sata ( /dev/sda ) or Pata ( /dev/hda ) <br />2. fdisk /dev/sda<br />3. Type n then Enter => For new Partition<br />4. Just press Enter => For 1st Cylinder<br />5. Type +size and press Enter => For Last Cylinder for Example +1000M. Size can be in terms of M or K<br />6. Type p => To print the partition<br />7. Type w => To save the new partition. It's save in the hard disk but kernel partition table not updated. (/dev/sda11 is created in my system , might be different in your system)<br />8. Type partprobe &amp; Press Enter => To update the kernel.<br />9. mkfs.ext3 -b 2048 /dev/sda11 => Here b is the block &amp; is \block size in bytes &amp; /dev/sda11 is new partition has created<br />11. e2label /dev/sda11 data=> data is Label name<br />12. e2label /dev/sda11<br />13. mkdir /data => To mount the partition /dev/sda11 /data is a directory<br />14. mount /dev/sda11 /data<br />15. ls /data<br />To make this above mount point for /dev/sda11 permanent write entry in the /etc/fstab file by the following way :-<br /><br />1.vi /etc/fstab<br />2. LABEL=data /data ext3 defaults 0 0<br /><br />=> defaults means how will it be mount by which criteria rw,exec,acl etc. First 0 is for dump value i.e. Whether there will be automatic dumping or not means or off. Next 0 is fsck sequence value i.e. If there is any improperly shutdown occurs then the system again then which file it will check for consistency.0 means it doesn't check.</span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-6252716857694393029?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-47685150680798244662008-05-02T18:47:00.000-07:002008-05-02T18:54:18.055-07:00instant Messenger: Openfire, Spark & web chat (Fastpath)-> Openfire<br />1 . lynx http://www.igniterealtime.org/downloads/download-landing.jsp?file=openfire/openfire-3.4.5-1.i386.rpm<br />2 . rpm -ivh openfire-3.4.5-1.i386.rpm<br />3 . /etc/rc.d/init.d/openfire status<br />4 . /etc/rc.d/init.d/openfire start<br />5. Make sure that the firewall is stopped.<br />6 . http://www.grmtech.com:9090/<br />7 . From the plugin tab in the web based admin control panel: installed Asterisk-IM Openfire<br /><br />-> Spark<br />Download and install on client system.<br /><a href="http://www.igniterealtime.org/downloadServlet?filename=spark/spark_2_5_8.exe">http://www.igniterealtime.org/downloadServlet?filename=spark/spark_2_5_8.exe</a><br /><br />-> web chat<br />Go to plugin tab in the web based admin control panel:<br />1.Click on 'Available Plugins'<br />2. Install the following plugin<br /> a. Spark Fastpath Webchat<br /> b. Fastpath Service<br /> c. Monitoring Service (its is a optional)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-4768515068079824466?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-44978728933742394932008-05-02T18:44:00.000-07:002008-05-02T18:45:50.103-07:00How to make a linux server act as a gateway1. turned on IP forwarding in sysctl.conf by setting the value to 1<br />2. gave the ip tables command for nat masquerade.<br />iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE<br />iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE<br />Checked that the commands took effect by:<br />iptables-save<br />and then made the entries from iptables-save inside the file /etc/sysconfig/iptables<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-4497872893374239493?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-22508157279917435722008-05-02T18:42:00.000-07:002008-05-02T18:44:32.187-07:00Check and Rebuilding failed Linux software RAID# cat /proc/mdstat<br /># mdadm -D /dev/md0<br />Detail : http://sitearticles.com/cms/show/43.html<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-2250815727991743572?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-16015529198473068622008-05-02T18:35:00.000-07:002008-05-02T18:41:08.208-07:00ssh commands to log in without the password<span style="font-weight: bold; font-style: italic;">ssh commands to log in without the password</span><br /># ssh-keygen -t rsa<br />* This will generate your id_rsa and id_rsa.pub in the .ssh directory in your home directory<br />* copy the id_rsa.pub to the .ssh directory of the remote host you want to logon to as authorized_keys2<br />* If you have more than one host from which you want to connect to the remote host, you need to add the local host's id_rsa.pub as one line in the authorized_keys2 file of the remote host command for the 1and1 servers is:<br /># scp .ssh/id_rsa.pub u35894953@217.160.226.69:./.ssh/authorized_keys2<br /><br />:)<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-1601552919847306862?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com1tag:blogger.com,1999:blog-31620939.post-25076515450345471392008-04-13T23:30:00.000-07:002008-04-14T02:12:40.693-07:00Apache: Proxy and ReverseProxy ServerRedirect your all traffic:<br />Case:<br />example.com A record is point to server with IP10.1.31.7 (mean its resolves to IP 10.1.31.7 ), but you are running your web server from example.com on server with IP 10.1.31.8.<br />So, you want all traffic coming to 10.1.31.7 will redirect to 10.1.31.8.<br /><br />Do the following changes on server have IP 10.1.31.7 :<br />1. Run<span style="font-weight: bold;"> apache</span>.<br />2. Do the following entry in apache.<br />a. <span style="font-weight: bold;">NameVirtualHost 10.1.31.7</span><br />b<span style="font-weight: bold; font-style: italic;"> &lt;VirtualHost 10.1.31.7:80 &gt; </span><br /><span style="font-weight: bold; font-style: italic;">ServerName example.com</span><br /><span style="font-weight: bold; font-style: italic;">ServerAlias www.example.com</span><br /><span style="font-weight: bold; font-style: italic;">DocumentRoot /home/test</span><br /><span style="font-weight: bold; font-style: italic;">ProxyRequests off</span><br /><span style="font-weight: bold; font-style: italic;">ProxyPass / http://www.example.com/</span><br /><span style="font-weight: bold; font-style: italic;">ProxyPassReverse / http://www.example.com/</span><br /><span style="font-weight: bold; font-style: italic;">&lt;Location /&gt; </span><br /><span style="font-weight: bold; font-style: italic;">ProxyPassReverse / </span><br /><span style="font-weight: bold; font-style: italic;">&lt;/Location&gt; </span><br /><span style="font-weight: bold; font-style: italic;">&lt;/VirtualHost&gt; </span><br />3. Do the following entry in /etc/hosts.<br /><span style="font-weight: bold; font-style: italic;"> 10.1.31.8 example.com</span><br /><span style="font-weight: bold; font-style: italic;"> 10.1.31.8 www.example.com</span><br />(<span style="font-style: italic;">make sure once you #ping example.com from 10.1.31.7 it resolver's to 10.1.31.8</span>).<br /><br /><span style="font-style: italic;">Note: its redirect only http request not https.</span><br /><br />more you can see on <a href="http://www.akadia.com/services/apache_redirect.html">this link</a><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-2507651545034547139?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-16451549042840804392008-04-12T06:55:00.000-07:002008-04-12T07:03:51.273-07:00Removing all blank lines, leading and trailing blank spacesRemoving all blank lines, leading and trailing blank spaces :<br /><span style="font-weight: bold;">#sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g' prabhat.txt > kumar.txt</span><br /><br /><span style="font-style: italic;">This command will create new file (kumar.txt) on which it removes blank lines, leading and trailing blank spaces.</span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-1645154904284080439?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-35123096184772760502008-04-11T00:29:00.000-07:002008-04-11T01:47:39.457-07:00Changing Run LevelsOn production environment normal run level 3 is used and it get rarely changed.<br /><a href="http://en.wikipedia.org/wiki/Runlevel">Runlevel and usage</a>:<br /><ul><li>0 — Halt</li><li>1 — Single-user mode</li><li>2 — Not used (user-definable)</li><li>3 — Full multi-user mode</li><li>4 — Not used (user-definable)</li><li>5 — Full multi-user mode (with an X-based login screen)</li><li>6 — Reboot</li></ul><span style="color: rgb(0, 0, 0); font-weight: bold; font-style: italic;">Check run level using :-</span><br />#<span style="font-weight: bold;">who -r</span><span style="font-family:monospace;"> or</span> #<span style="font-weight: bold;">runlevel<br /><br /></span><span style="font-weight: bold; font-style: italic;">Change run level using:-</span><br />#<span style="font-weight: bold;">telinit 5</span> or<br />open file<br />#<span style="font-weight: bold;">emacs /etc/inittab</span><br />Look for the default runlevel called initdefault which look like as follows:<br />id:<span style="font-weight: bold;">3</span>:initdefault:<br />Replace run level x with y (<span style="font-style: italic;">where x is current run level and y you want to set</span>).<br /><br /><span style="font-weight: bold; font-style: italic;">Set services in run level using :</span><br />#<b class="APPLICATION">ntsysv </b><span class="APPLICATION">or<br />#</span><tt style="font-weight: bold;" class="COMMAND">chkconfig </tt><tt class="COMMAND">or</tt><tt style="font-weight: bold;" class="COMMAND"><br /></tt><tt class="COMMAND">#</tt><span class="APPLICATION"></span><b class="APPLICATION">serviceconf</b><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-3512309618477276050?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-39291430471043112002008-04-01T04:42:00.000-07:002008-04-01T04:48:47.272-07:00How To: Transfer your PuTTY settings between computersPutty stores its settings in the Windows registry. To save a backup of your Putty settings, you'll need to export this registry key to a file. <br /><br />HKEY_CURRENT_USER\Software\SimonTatham<br /><br />Steps :<br />1. Click Start->Run and type "RegEdt32" in the "Open" dialog. Click "Ok"<br />2. One RegEdt32 starts, you'll be presented with an application.<br />3. Press "Ctrl+F" to bring up the Find dialog. Enter the name of the key, "SimonTratham" in the "Find What" field, and make sure only "Keys" is checked in the "Look At" section of the dialog. Finally, click "Find Next"<br />4. The search may take a while, reminding us that the Windows Registry is a large and mysterious place where dragons be. Let's use these few seconds to reflect on the fact that you should never, ever, never change things in the registry unless you are absolutely, positively, totally, completely, 100% dead sure that you know exactly what you're doing. When the search completes we'll see the key name for which we're looking.<br />5. Click File->Export. Give your file an appropriate name like, "putty.reg" and click "Save"<br />6. We're done! Save the putty.reg file somewhere safe. The file doesn't contain any passwords or actual SSH key values so, it's relatively safe from prying eyes. Still, it does contain your configuration and that kind of data is a private matter.<br /><br /><br />Importing Your PuTTy Configuration:<br />Windows will ask you for confirmation that you want to import this set of registry values. We know this file is safe, because we created it but, you should never import registry information from an unknown source<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-3929143047104311200?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-50148684188787399102008-03-19T06:32:00.000-07:002008-03-19T06:38:45.593-07:00Remove all empty directories$ cleanlinks<br /> <br />this is supported on few flavor of Linux (XFree86), you can use this script.<br /><br /><span style="font-style:italic;">#/bin/bash<br />DIR="$1"<br /> [ -d $DIR ] && [ $(ls -l $DIR | wc -l) -eq 1 ] && rmdir $DIR || :</span><br /><br />$ script.sh dir1<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-5014868418878739910?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0tag:blogger.com,1999:blog-31620939.post-71009232848860048822008-03-19T06:20:00.000-07:002008-03-19T06:52:33.885-07:00Removing blank line from fileUsing sed.<br />$ sed '/^$/d' withblankline.txt > withoutblankline.txt<br />Using grep.<br />$ grep -v '^$' withblankline.txt > withoutblankline.txt<br /><br />Use following for loop (shell script) to remove all blank lines from all files stored in /home/prabhat/data directory:<br /><blockquote><br />#!/bin/sh<br />files="/home/prabhat/data/*.txt"<br />for f in $files<br />do<br />sed '/^$/d' $i > $i.out<br />mv $i.out $i<br />done<br /></blockquote><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/31620939-7100923284886004882?l=adminlinux.blogspot.com'/></div>Prabhat Kumarhttp://www.blogger.com/profile/05143104910338701470aim.prabhat@gmail.com0