Linux admin

474 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
474
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Linux admin

  1. 1. Linux Admin RAID in Linux The term RAID is an acronym for the phrase, Redundant Array of Independent Disks. RAID is a way of combining the storage available across multiple disks and supplying users a single, unified virtual device. RAID can be used to provide:1. data integrity2. fault tolerance3. improved performance4. greater storage capacity Hard disks are mechanical devices involving moving parts and unfortunately tend to fail over time. There are also physical limits to the speed at which data can be read and/or written to disks. RAID helps mitigate this risk by protecting data stored on hard disks and improving disk performance by writing the data to multiple physical locations according to several different schemas, known as "RAID Levels". Furthermore, RAID can be provided by either dedicated, specialized hardware or by the operating system at a virtual layer. Hardware RAID vs. software RAID? Hardware RAID solutions exist that operate as dedicated devices, usually as PCI expansion cards or directly on the motherboard. The independent disks attach to the hardware interface. In a true hardware RAID, the operating system simply writes data to the hardware RAID controller which handles the multiplicitous reads and writes to the associated disks. Other so−called hardware RAIDs rely on special drivers to the operating system; these act more like software RAIDs in practice. With current technology, hardware RAIDconfigurations are generally chosen for very large RAIDs. Additionally, some operating systems, including Linux®, provide RAID functionality within a software layer.RAID partitions are logically combined and a virtual device appears to higher layers of the operating system in place of the multiple constituent devices. This solution is often a high−performance and inexpensive alternative available for RAID users. RAID levels There are many RAID levels. It will be impossible to list them all here. Here we mention the most common & most important RAID types, all of which are fully supported by Linux. RAID0 (Striping)
  2. 2. This level is achieved by grouping 2 or more hard disks into a single unit with the total sizeequaling that of all disks used.Practical example: 3 disks, each 80GB in size can be used in a 240GB RAID0 configuration.RAID0 works by breaking data into fragments and writing to all disk simultaneously. Thissignificantly improves the read and write performance.On the other hand, no single disk contains the entire information for any bit of datacommitted. This means that if one of the disks fails, the entire RAID is rendered inoperable,with unrecoverable loss of data.RAID0 is suitable for non-critical operations that require good performance, like the systempartition or the /tmp partition where lots of temporary data is constantly written. It is notsuitable for data storage.Usable Space in Raid level0 = (smallest disk) * (no. of disks)RAID1 (Mirroring)This level is achieved by grouping 2 or more hard disks into a single unit with the total sizeequaling that of the smallest of disks used.This is because RAID1 keeps every bit of data replicated on each of its devices in the exactlysame fashion, create identical clones. Hence the name, mirroring. Practical example: 2 disks,each 80GB in size can be used in a 80GB RAID1 configuration.
  3. 3. Usable space of Raid level1= smallest-diskOn a side note, in mathematical terms, RAID1 is an AND function, whereas RAID 0 is anOR. Because of its configuration, RAID1 reduced write performance, as every chunk of datahas to be written n times, on each of the paired devices. The read performance is identical tosingle disks.Redundancy is improved, as the normal operation of the system can bemaintained as long as any one disk is functional.RAID 1 is suitable for data storage, especially with non-intensive I/O tasks.RAID5This is a more complex solution, with a minimum of three devices used. Two or moredevices are configured in a RAID0 setup, while the third (or last) device is a parity device. Ifone of the RAID 0 devices malfunctions, the array will continue operating, using the paritydevice as a backup. The failure will be transparent to the user, save for the reducedperformance.RAID 5 improves the write performance, as well as redundancy and is useful in mission-critical scenarios, where both good throughput and data integrity are important. RAID 5 doesinduce a slight CPU penalty due to parity calculations.Usable Space for Raid Level5 = smallest-disk*(no of disk -1)Linear RAIDThis is a less common level, although fully usable. Linear is similar to RAID0, except thatdata is written sequentially rather than in parallel. Linear RAID is a simple grouping ofseveral devices into a larger volume, the total size of which is the sum of all members. Forinstance, three disks the sizes of 40, 60 and 250GB can be grouped into a linear RAID thetotal size of 350GB.Linear RAID provides no read/write performance, not does it provide redundancy; a loss ofany member will render the entire array unusable. It merely increases size. It’s very similar toLVM. Linear RAID is suitable when large data exceeding the individual size of any disk orpartition must be used.
  4. 4. Now, move backup to tape or other server:Nested RAID LevelsRAID0+1Exapmle of RAID Level 0+1A RAID 0+1 (also called RAID01), is a RAID level used for both replicating and sharingdata among disks.The minimum number of disks required to implement this level of RAID is3 (first, even numbered chunks on all disks are built – like in RAID0 – and then every oddchunk number is mirrored with the next higher even neighbour) but it is more common to usea minimum of 4 disks.The difference between RAID0+1 and RAID 1+0 is the location of each RAID system —RAID0+1 is a mirror of stripes although some manufacturers (e.g. Digital/Compaq/HP) useRAID0+1 to describe striped mirrors, consequently this usage is now deprecated so thatRAID0+1 and RAID1+0 are replaced by RAID10 whose definition correctly describes thecorrect and safe layout, i.e. striped mirrors.RAID1 + 0A RAID1+0, sometimes called RAID1&0 or RAID10, is similar to a RAID0+1 withexception that the RAID levels used are reversed — RAID10 is a stripe of mirrors.
  5. 5. Hard disks are mechanical devices involving moving parts and unfortunately tend to fail over time. There are also physical limits to the speed at which data can be read and/or written to disks. RAID helps mitigate this risk by protecting data stored on hard disks and improving disk performance by writing the data to multiple 4 THOUGHTS ON “LINUX ADMIN”1. Nitin Makasare on August 31, 2012 at 5:19 pm said: Best and formative topic. If possible explain how to recover data from H/W RAID if one of the disk fails in RAID-1 or RAID-5 Thanking you Reply ↓2. arvind on September 6, 2012 at 10:43 am said: this is very needful for us. one things is important , how can i convert data if one hdd is fail.
  6. 6. Reply ↓3. Praveen on September 11, 2012 at 1:28 pm said: Very helpful…. Thank you for sharing this…. Reply ↓4. baskar on September 13, 2012 at 7:48 am said: Hi, is it possible to create software RAID10 in linux?if so, how to do it? Regards Boss How To Install and Configure a File and Print Server in Windows Server 2003 You can create a Windows Server 2003 file server and print server manually, or you can use the wizards that are provided in the Configure Your Server Wizard administrative tool. How to Install a File Server on Windows Server 2003 by Using the Configure Your Server Wizard  Click Start, point to Administrative Tools, and then click Configure Your Server Wizard.  Click Next.  Click Next.  Click File server in the Server role box, and then click Next.
  7. 7.  On the “File Server Disk Quotas” page, configure any quotas you need to control disk-space usage on the server, and then click Next.  On the “File Server Indexing Service” page, click the indexing configuration that is appropriate for your server, and then clickNext.  Click Next.  Click Finish.  The Share a Folder Wizard starts. ClickNext.  Click Browse, locate the folder that you want to share, and then click OK.  Click Next.  Type a share name for the folder, and then click Next.  Click one of the basic permissions for the folder, or click Customize to set custom permissions on the folder. Click Finish.  Click Close.How to Manually Install a File Server on Windows Server 2003  Click Start, and then click Windows Explorer.  Locate the folder that you want to share.  Right-click the folder, and then click Sharing and Security.  Click Share this folder, and then accept the default name or type a different name for the share.  Optionally, configure the number of users who can connect, configure permissions for this folder, and then configure the caching options.  Click OK.  A little hand is displayed in the Windows Explorer window to indicate that the folder is being shared.  Quit Windows Explorer.Install a Windows Server 2003 Print ServerHow to Install a Print Server on Windows Server 2003 by Using the Configure YourServer Wizard  Click Start, point to Administrative Tools, and then click Configure Your Server Wizard.  Click Next.  Click Next.  Click Print server in the Server role box, and then click Next.
  8. 8.  On the “Printers and Printer Drivers” page, click the types of Windows clients that your print server will support, and then clickNext.  Click Next.  On the “Add Printer Wizard Welcome” page, click Next.  Click Local printer attached to this computer, click to clear theAutomatically detect and install my Plug and Play printer check box, and then click Next.  Click the port for your printer, and then click Next.  Click the printer make and model or provide the drivers from the printer manufacturer media, and then click Next.NOTE: If you are prompted to keep or not keep your existing printer driver, either keep the existing driver or replace the existing driver. If you replace the driver, you must provide the manufacturer driver for this printer. Click Next to continueLinux AdminHow To Add New Disk To The Hardware Raid Controller Without Rebooting The Server InLinuxFirst find out your RAID hardware as we will need appropriate OS utility to manage the samefrom the same vendor. In our case it was lsi which can be managed via Megacli utility.[root@server 8.02.21_Linux_MegaCLI]# lspci | grep -i raid07:00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator](rev 05)Lets first install the utilty :To do this we need to install the Megacli utility on our server Centos 6.2.Step:1. Install the below two packages.(downlaod from http://www.lsi.com/downloads/Public/MegaRAID%20Common%20Files/8.02.21_MegaCLI.zip) .#rpm -ivh Lib_Utils-1.00-09.noarch.rpm#rpm -ivh MegaCli-8.02.21-1.noarch.rpmStep:2. By default the utility is placed at location as below..[root@server 8.02.21_Linux_MegaCLI]# cd /opt/MegaRAID/MegaCli/[root@server MegaCli]# lsinstall.log MegaCli64 MegaSAS.logStep:3. Run the below command before adding the brand new disk drive.[root@server MegaCli]# /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll | grep -e“Enclosure Device ID” -e SlotEnclosure Device ID: 252Slot Number: 0
  9. 9. Enclosure Device ID: 252Slot Number: 1Step:4. Run the command again after injecting the new HDD in drive slot.[root@server MegaCli]# /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll | grep -e“Enclosure Device ID” -e SlotEnclosure Device ID: 252Slot Number: 0Enclosure Device ID: 252Slot Number: 1Enclosure Device ID: 252Slot Number: 3Step:5. Now you have the following information the Enclosure Device ID: 252 and SlotNumber: 3 for the newly added drive.Step:6. Once added the new drive will be in foreign state. Give the below command toclear the foreign status.[root@server MegaCli]#/opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -Clear -aALLStep:7. Add the new drive to the desired RAID level by running below command.#/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0 [252:3] -a0Options:-r1 = RAID1252 = Enclosure Device ID2 and 3 = Slot Number-a0 = AdapterIn our case :-r0 = RAID0252 = Enclosure Device ID3 = Slot Number-a0 = AdapterStep:8. tail the /var/log/messages for the new disksd 0:2:1:0: [sdb] Mode Sense: 1f 00 00 08sd 0:2:1:0: [sdb] Write cache: enabled, read cache: enabled, doesn’t support DPO or FUAsdb: sdb1 sdb2sd 0:2:1:0: [sdb] Attached SCSI diskNow you can use the new disk as any other normal drive.5 THOUGHTS ON “LINUX ADMIN”
  10. 10. 1. pradeep on July 21, 2012 at 11:22 am said: You are right mind blowing topic , it helped me a lot !!!!!!!!!!! Reply ↓2. Sanjay Negi on August 1, 2012 at 4:59 pm said: Thanks for sharing this information….. It is of great help to me…… Reply ↓3. Sanjay Negi on August 1, 2012 at 5:01 pm said: Thank you for sharing this very usefull information. It will enhance my knowledge of Linux…. Reply ↓
  11. 11. 4. Shiva on August 2, 2012 at 7:07 pm said: Thank you very much. Very good information. Reply ↓5. PRASAD RANADIVE on August 4, 2012 at 10:25 am said: Thank u for sharing a very usefull information. Windows Admin Configure NTP (Network Time Protocol) on Windows Server 2008 The Network Time Protocol (NTP) in Windows 2008 provides your server with the ability to control the system clocks on your Windows client machines. This keeps all machines on the network synchronized with the same system time. This is beneficial for Windows administrators who need to schedule time-sensitive services on the network. You set the Windows 2008 NTP service in the registry. Step 1- Click the Windows 2008 “Start” button and enter “regedit” into the search box. Press Enter to open the Windows registry editor. Step 2- Navigate to the “HKEY_LOCAL_MACHINESYSTEMCurrentControlSet ServicesW32TimeConfig“. registry key
  12. 12. Step 3- Double click the key value labeled “AnnounceFlags” in the center detail pane. Step 4- Enter “A” into the DWORD value text box. Click “OK” to save your settings. Close the Windows registry editor. Step 5- Click the Windows “Start” button and enter “cmd” into the text box. Press Enter to open the command prompt. Enter the following into the command prompt and press Enter: net stop w32time && net start w32time This restarts the NTP system time settings and loads the new registry values for your Windows 2008 server. 3 THOUGHTS ON “WINDOWS ADMIN”1. Sanjay Negi on August 1, 2012 at 4:55 pm said: This information provided is of great benefit to me.Now I can synchronize all the machines on my network with my sysrem time.This was very easy to understand and it was easy to follow the steps.Thank you.
  13. 13. Reply ↓2. santhosh on August 23, 2012 at 9:24 am said: this is very silmple and easy to learn Reply ↓3. Nitin Makasare on August 31, 2012 at 5:32 pm said: Nice and very easy steps to configure NTP Server. Thanks. Network Admin How to get netbios name in linux NetBios stands for Network Basic Input/Output System. It provides services related to the session layer of the OSI model allowing applications on separate computers to communicate over a local area network.NetBIOS provides three distinct services: 1. Name service for name registration and resolution. 2. Session service for connection-oriented communication. 3. Datagram distribution service for connectionless communication. Enabling NetBIOS over TCP/IP We can enable NetBT for computers running Windows Server 2003 or Windows XP by opening Network Connections, right-clicking a connection, clicking the Internet Protocol (TCP/IP) component, clicking Properties, clicking Advanced, clicking the WINS tab, and clicking the appropriate option in NetBIOS setting. Below Figure shows the WINS tab.
  14. 14. For the NetBIOS setting, you can choose any of the following options:* Default Enables NetBT if the network connection has a static IPv4 address configuration. Ifthe network connection uses the Dynamic Host Configuration Protocol (DHCP), it uses theDHCP options in the received DHCPOffer message to either disable NetBT or enable andconfigure NetBT. To disable NetBT using DHCP, configure the Disable NetBIOS overTCP/IP (NetBT) Microsoft vendor-specific option for the value of 2. This is the defaultsetting for LAN connections.* Enable NetBIOS over TCP/IP Enables NetBT, regardless of the DHCP options received.This is the default setting for remote connections (dial-up or virtual private network).* Disable NetBIOS over NetBIOS Disables NetBT, regardless of the DHCP optionsreceived
  15. 15. If We are using linux and want to administer a network full of windows machine, there is atool called nbtscan to easily scan through the network and list all machines with their netbiosname.To install nbtscan in linux(Centos):# yum install nbtscanTo use it on single machine(let’s say the machine’s ip is 10.0.0.100):# nbtscan 10.0.0.100To scan the whole class C and list netbios names:# nbtscan 10.0.0.0/24To scan ip range:# nbtscan 10.0.0.10-100To get all options to use nbtscan:# nbtscan -hDatabase AdminHow To take backup and restore mysql databases in LinuxTo backup(dump) single mysql database to a file , first we need to open the terminal and usethe below syntax# mysqldump -u <username> -p <databasename> > backup.sql
  16. 16. Username = this is your database username databasename = the name of your database which you want to backup backup.sql = the filename for your database backup Example: # mysqldump -u root -p plist > /root/backuplist.sql where -u is for username, -p is for mysqldump to ask for password, plist is the name of the database backuplist.sql is the file to dump the database. To restore back mysql database from dumpfile: Method:1 Open the terminal , use below command # mysql -u root -p plist < /root/backuplist.sql -u and -p are similar to above, plist is the name of the database and backuplist.sql is the name of the dumpfile. Method:2 From inside mysql console where we have to access mysql console first: mysql> source backuplist.sql or mysql> . backuplist.sql where backuplist is the dumpfile 2 THOUGHTS ON “DATABASE ADMIN”1. Sumit Basu on August 25, 2012 at 8:39 pm said: Really useful info I found…..Thanks to the developers.. Reply ↓
  17. 17. 2. Sachin Chavan on September 15, 2012 at 5:52 pm said: really nice in4mation…!!! Database Admin How To Enable Binary Logs In MYSQL Server In Linux The binary log contains events that describe database changes such as table creation operations or changes to table data. It also contains events for statements that potentially could have made changes (for example, a DELETE which matched no rows). The binary log also contains information about how long each statement took that updated data. The binary log has two important purposes: For replication, the binary log is used on master replication servers as a record of the statements to be sent to slave servers. The master server sends the events contained in its binary log to its slaves, which execute those events to make the same data changes that were made on the master. Certain data recovery operations require use of the binary log. After a backup has been restored, the events in the binary log that were recorded after the backup was made are re-executed. These events bring databases up to date from the point of the backup. Step:1 Stop the mysql service using below command # service mysqld stop Step:2 Edit the mysql configuration files (/etc/my.cnf) and add below lines log-bin = /var/lib/mysql/<application-name>-mysql-bin.log OR log-bin=mysql-bin expire_logs_days = 2 # binary logging format – mixed recommended binlog_format=mixed The logs will go to the mysql data directory and will have the mysql-bin prefix if we use “log-bin=mysql-bin” otherwise we can mentioned the location as we have done in above file. “expire_logs_days” system variable to expire binary log files automatically after a given number of days.
  18. 18. Step:3 Now start the mysql service using below command # service mysqld start ONE THOUGHT ON “DATABASE ADMIN”1. Sanjay Negi on August 1, 2012 at 5:07 pm said: This topic is indeed is very helpful for understanding the steps to enable binary logs In MYSQL server In Linux. Reply ↓ Programming Functions In Perl print length(“There’s more than one way to do it”), “n”; length() is a built-in function that tells how many characters are in a string. A function is a named sub-routine that accepts several arguments and returns a value that can be further evaluated as part of a greater expression, or used directly. To help us understand functions further, let’s inspect the perl function substr (short for “substring”).substr retrieves sub-strings of a given string. The first argument to it is a string, the second is the offset from which to take the substring, and the third is the length of the substring to be taken. The third one is optional and if unspecified, returns the substring till the end of the string. print substr(“A long string”, 3), “n”; print substr(“A long string”, 1, 4), “n”; print substr(“A long string”, 0, 6), “n”;
  19. 19. ong stringlonA longThe int() functionThis function takes a number and rounds it down to a near integer (= whole number). Here’san example:print “The whole part of 5.67 is ” . int(5.67) . “n”;More about stringsIn perl, strings and numbers are seamlessly converted into each other depending on thecontext in which they are used.print ((“5″ + “6″), “n”);print ((56 . 23), “n”);The output of this program is:115623Escape SequencesWe have already encountered the n “escape sequence” which can come inside strings anddesignates a newline character. There are many others in perl. Here is a list of the mostimportant ones:  – designates an actual backslash ()  ” – designates an actual double-quote character (“)  $ – an actual dollar sign (a real $ does something else)  @ – an actual at-sign (a non-escaped @ does something else)  n – a newline character  r – a carriage return sign  t – a tab character
  20. 20.  xDD – where “DD” are two hexadecimal digits – gives the character whose ASCII code is “DD”.Here’s an example to illustrate some of them:print “I said ”hi!” to myself, and received no reply.n”;print “This program will cost you $100 dollars.n”;print “The KDEGNOME holy war makes life in the Linux world ” .“more interesting.n”;whose output is:I said “hi!” to myself, and received no reply.This program will cost you $100 dollars.The KDEGNOME holy war makes life in the Linux world more interesting.Variables in PerlVariables are named cells stored in the computer memory that can hold any single Perl value.One can change the value that a variable holds, and one can later retrieve the last valueassigned as many times as wanted.Variables in Perl start with a dollar sign ($) and proceed with any number of letters, digitsand underscores (_) as long as the first letter after the dollar is a letter or underscore.To retrieve the value of a variable one simply places the variable name (again including thedollar sign) inside an expression.To assign value to a variable, one places the full variable name (including the dollar sign) infront of an equal sign (=) and places the value to the right of the equal sign. This form isconsidered a statement and should be followed by a semicolon. The value assigned may be anexpression that may contain other variables (including the assigned variable itself!).An example will illustrate it:$myvar = 17;$x = 2;print $myvar, ” * “, $x, ” = ” , ($myvar*$x), “n”;$x = 10;
  21. 21. print $myvar, ” * “, $x, ” = ” , ($myvar*$x), “n”;$x = 75;print $myvar, ” * “, $x, ” = ” , ($myvar*$x), “n”;$x = 24;print $myvar, ” * “, $x, ” = ” , ($myvar*$x), “n”;The output of this program is:17 * 2 = 3417 * 10 = 17017 * 75 = 127517 * 24 = 408Several things can be noticed:  The value of $x changes throughout the program. It’s perfectly fine, and usually even necessary to modify the value of a variable.  By using $myvar we can ensure, that assuming we wish to change its value, we will only have to change it in one place, not in every place it appears.“+=” and friendsPerl provides a shortcut for writing “$myvar = $myvar + $value”, or “$myvar = $myvar /$value” and similar operations. Here’s an example:$x = 1;$y = 0;print “2^”, $y, “=”, $x, “n”;$x *= 2; $y += 1;print “2^”, $y, “=”, $x, “n”;$x *= 2; $y += 1;print “2^”, $y, “=”, $x, “n”;$x *= 2; $y += 1;print “2^”, $y, “=”, $x, “n”;$x *= 2; $y += 1;print “2^”, $y, “=”, $x, “n”;$x *= 2; $y += 1;print “2^”, $y, “=”, $x, “n”;
  22. 22. Since the operations $x += 1 and $x -= 1 are so commonly used, they were also assigned aseparate operator. One can use $x++ and $x– to perform them. For example, the aboveprogram could have been written as:$x = 1;$y = 0;print “2^”, $y, “=”, $x, “n”;$x *= 2; $y++;print “2^”, $y, “=”, $x, “n”;$x *= 2; $y++;print “2^”, $y, “=”, $x, “n”;$x *= 2; $y++;print “2^”, $y, “=”, $x, “n”;$x *= 2; $y++;print “2^”, $y, “=”, $x, “n”;$x *= 2; $y++;print “2^”, $y, “=”, $x, “n”;Input in PerlIn order to receive a value from the user, perl supplies the <> operator. When entered, thisoperator reads a line from the command line, and returns it (along with the newlinecharacter).Here’s an example:print “Please enter your name:n”;$name = <>;chomp($name);print “Hello, “, $name, “!n”;Notice the chomp function which strips off the trailing newline character from the variable.You would usually want to use it, when getting input from the user.Here’s another example:print “Please enter a string:”;$string = <>;chomp($string);print “The string you entered contains “, length($string), ” characters.n”;
  23. 23. The For LoopThe for loop enables us to iterate over a sequence of numbers and repeat the same set ofoperations for each number.For example, the following program prints all the numbers from 1 to 100:for $i (1..100){print $i, “n”;}Some explanations about the syntax:  $i is the iteration variable. It receives the value 1, then the value 2, then 3 and so forth until it is equal to 100, afterwards the loop terminates.  The curly brackets ({ … }) encapsulate the loop block. The loop block is executed once for each value $i accepts. Within that block, called the loop body, you can use $i and you’ll get its current value.We can nest loops, so for example the following program prints the multiplication board:for $y (1 .. 10){for $x(1 .. 10){$product = $y*$x;# Add as much whitespace as needed so the number will occupy# exactly 4 characters.for $whitespace (1 .. (4-length($product))){print ” “;}print $product;}# Move to the next lineprint “n”;}
  24. 24. You may have noticed the program’s comments. In perl comments start with the sharp sign(#) and extend to the end of the line. Writing the multiplication boards with the labels thatindicate which numbers are being multiplied is left as an exercise to the reader.

×