linux操作系统优化方案

上传人:ail****e3 文档编号:58214731 上传时间:2022-02-26 格式:DOC 页数:24 大小:1.15MB
收藏 版权申诉 举报 下载
linux操作系统优化方案_第1页
第1页 / 共24页
linux操作系统优化方案_第2页
第2页 / 共24页
linux操作系统优化方案_第3页
第3页 / 共24页
资源描述:

《linux操作系统优化方案》由会员分享,可在线阅读,更多相关《linux操作系统优化方案(24页珍藏版)》请在装配图网上搜索。

1、按照传统,Linux不同的发行版本和不同的内核对各项参数及设置均做了改动,从而使得系统能够获得更好的性能。下 边将分四部分介绍在 Red Hat Enterprise Linux AS和SUSE LINUX Enterprise Server系统下,如何用以下几种技巧进行性 能的优化:1、Disabling daemons (关闭 daemons)2、Shutting down the GUI (关闭 GUI)3、Changing kernel parameters 改变内核参数)4、Kernel parameters (内核参数)5、Tuning the processor subsyste

2、m(处理器子系统调优)6、Tuning the memory subsystem (内存子系统调优)7、Tuning the file system (文件系统子系统调优)& Tuning the network subsystem (网络子系统调优)1 关闭 daemons有些运行在服务器中的daemons后台服务),并不是完全必要的。关闭这些 daemons可释放更多的内存、减少启动时间 并减少CPU处理的进程数。减少daemons数量的同时也增强了服务器的安全性。缺省情况下,多数服务器都可以安全 地停掉几个daemonsTable 10-1 列出了 Red Hat Enterprise

3、Linux AS下的可调整进程.Table 10-2列出了 SUSE LINUX Enterprise Server 下的可调整进程Table 10-1 Red Hat Enterprise Linux AS: Tuiiabfe daemons started by defaultDaemonsDescriptionapmdAdvanced power management daemonautofsAutomatically mounts file systems on demand (that is, mounts a CD-ROM automatically)cupsCommon UNIX

4、 Printing SystemhpojHP OfficeJet supportisdnISDN modem supportnetfsUsed in support of exporting NFS sharesnfslockUsed for file locking with NFSpcmciaPCMCIA support on a serverportmapDynamic port assignment for RPC services (such as NIS 2nd NFS)rtinsdRed Hat Network update service for checking for up

5、dates and security erratasmn dmailMail Transport AgentxfsFont server for X Windows注意:关闭xfs daemon将导致不能启动X,因此只有在不需要启动 GUI图形的时候才可以关闭xfs daemon。使用startx 命令前,开启xfs daemon,恢复正常启动X。Table 10-2 SUSE LINUX Enterprise Server: Tunable daemons started by defaultdaemonDescriptionalsasoundSound daemonisdnISDN mod

6、em supporthwscanDetects and con figures hardware changesportmapDynamic port assignment for RPC services (such as NIS and NFS)postfixMail Transport AgenlsplashSplash screen setupfbsetFramebuffer setupsplashjateStarts before shutdownsplash_earlyKills animation after the network startsxdmX Display mana

7、ger可以根据需要停止某个进程,如要停止sendmail进程,输入如下命令:Red Hat: /sbin/service sendmail stopSUSE LINUX: /etc/init.d/sendmail stop也可以配置在下次启动的时候不自动启动某个进程,还是sendmail :Red Hat: /sbin/chkconfig sendmail offSUSE LINUX: /sbin/chkconfig -s sendmail off除此之外,LINUX还提供了图形方式下的进程管理功能。对于Red Hat,启动GUI,使用如下命令:/usr/bin/redhat-config-s

8、erVces 或者鼠标点击 Main Menu - System SettingServer Settings - Services* Service 匸orthgurlion-! x| Eile /.iew 生thru Edit Ftunterel Heli o aStart Slop tmii Save BertCurTcnitl Rurnirig in Riimcyel: 5CdEins Hunlerclz Stda0回 口0回 1-1bcrr5S2Orha loonchagen-jdpcupsdayiimedcjlicntmd i& used tor nrohtonng battery

9、 status and bgginy it via sysbg It be u seft lor UiLfttirg down ih色 maihiine when the battery i$ bw.To change the current state.highlight the daemon andgmclick Stop. The check mark indicates the daemon will start at the next rebootFigure 10-1 Red Hat Service Configuition GUI提示:并非所有的daemons都会显示在该配置界面

10、,如要看到全部的daemons使用如下命令:/sbin/chkconfig -list对于SUSE LINUX,图形界面是YaST2,可用如下命令来启动/sbin/yast2 runlevel或者如Figure 10-2所示用鼠标点击Browse: WST/ - YaST modules- System - Runlevel editorFigure 10-2 SUSE LINUX YaST tunlevel oditor2关闭GUI只要有可能,就不要在 Linux server上启动GUI图形,通常在Linux server上,没有必要启动GUI。所有的管理任务均 可在命令行方式下完成、或者

11、通过重定向X和Web浏览器界面。有几个可用的基于 Web的工具(例如webmin, Linuxconf, 和 SWAT).需要的时候启动GUI,用完马上关闭GUI。多数情况,服务器运行在runlevel 3,即在机器启动的时候不进入 GUI。命令 行方式下,执行 startx来启动 Xserver.1. 查看 runlevel 的命令:runlevel会显示出上次和当前的 runlevel (如N 5表示没有上次的runlevel (N),当前的runlevel是5).2. 在不同的runlevels之间切换,使用命令init如切换到run level 3,键入命令init 3下边是对Linu

12、x中不同runlevels的简要描述-0 -Halt停机(不要将0设置为缺省,否则服务器启动后就会马上关闭)-1 - Single user mode 单用户模式-2 - Multi-user不带NFS的多用户模式(如果没有网络,相当与3)-3 - Full multi-user mode完全多用户模式-4 -Unused未使用-5 - X11-6 -Reboot重启(不要将6设置为缺省,否则服务器会不断地重启)修改文件/etc/inittab来设置机器启动的runlevel,女口 Figure 10-3* * * (1ines not di splayed)二 _ 存 The default

13、 runlevel is defined here id ;3;i nitdefault: 亠一To start Linux without starting the GUI, set the runlevel to 3.# First script to be executed, si:bootwai t:/etc/1nit,d/bootif not booting inemergency (-b) mode# /etc/init.d/rctakes care ofrunlev&l handling# runlevel 0 is# runlevel 1 is# runlevel 2 is#

14、runlevel 3 IsSystem halt (Do not use this for initdefaultl) Single user modeLocal multiuser without remote network (e*g* NFS) Full multluser with network雀 runlevel 4 is# runlevel 5 is# runlevel 6 isNot usedFull multiuser with network and xdmSystem reboot (Do not use this for mitdefaul 11)* 0 i nes n

15、ot di spl dyed)# getty-programs for the normal runlevels” ::# The id” field MUST be the same as the lastTo only provide three consoles and thereby save memory, comment out the mi ngetty entries for 4,5, and 6.* characters of the device (after 幅tty* l:2345:respawn:/sbin/mingetty -noclear ttyl2:2345:r

16、espawn:/sbin/mingetty tty?3:2345:respawn:/sbin/imngetty tty3厶#4:2345:respawn:/sbi n/mingetty tty4雀5:2345;respawn:/sbin/mingetty tty5#6:2345:respawn:/sbin/mingetty tty6*-L 9600 ttySO vtl02#S0:12345:respawn:/s b in/agetty*.* (1ines not displayed)Figure 10-3 /etc/inittab, modified (only part of the fil

17、e is display&d)对于 SUSE LINUX Enterprise Server,执行 YaST runlevel 命令改变缺省 runlevel 值.如图 Figure 10-2。缺省情况下,保存了 6个控制台:F1F6。为节省内存,可以减少为3个。使用mingetty ttyx命令来实现,如图Figure 10-3提示:即便是已经关闭了 GUI,依然可以远程连接并启动 GUI,可以使用ssh-x3改变内核参数Linux内核是操作系统的核心,对所有的Linux发行版本是通用的。内核参数可以改变,在命令行下执行sysctl 命令。提示:缺省情况下,LINUX内核包括不必重启就可以使

18、用sysctl命令的必要的模块。尽管如此,如果你在安装系统的 时候选择移除该功能,那么你只有重新启动LINUX,才可以使得改变生效。SUSE LINUX 提供了图形界面下的修改方式。使用如下命令来启动powertweak 工具:/sbin/yast powertweak使用如下命令启动基于字符的管理菜单:/sbin/yast2 powertweakFigure 10-4 SUSE LINUX powertweakRed Hat也提供了图形界面下更改sysctl参数的方式:/usr/bin/redhat-config-proc10-5FigureFigure 10-5 Pled Hat kern

19、&i tuningParameter storage locations内核参数保存在/proc(特别是/proc/sys),提供了内核、处理器、内存、网络及其他组件的相关参数。每个执行的进程 都有一个以相应PID命名的目录。Figure 10-3列出了一些包括内核信息的文件。Me 10-3files in procFile/di rectoryPurpose/proc/loadavgInformation about the load of the server in 1-minute, 5-nninute, and 15-minute intervals. The uptlne comma

20、nd ge恰 information from this file./proakcore(SUSE LINUX Enterprise Server only) Contains data to generate a core dump at run time, for kernel debugging purposes. The command to create the core dump is gdb as in;#gdb /usr/src/linux/yml1nux /proc/kcore/prOC/StatKernel statistics as process, swap and d

21、isk I/O./proc/cpuinfoInformation about the installed CPUs./proc/memintoInformation about memory usage. The frw command uses ihis information./proc/sys/abi/*Used to provide $叩port for foreign11 binaries, not native to Linux: those compiled under other UNIX variants such as SCO UnixWare 7, SCO OpenSer

22、ver, and SUN Solaris 2. By defaut this s叩pod is installed, although it can te removed during installation./proc/sys/fsfUsed to increase the number of open files the OS allows and to handle quota./proc/sys/kernel1For tuning purposes, you can enable hotplug. manipulate shared memory, and specify the m

23、aximum number of pid tiles and level of debug in syslog./proc/sys/nel/*Tuning of network in general IPV4 and IPV6./proc/sys/vm/*Management of cache memory and buffer4内核的参数Table 10-5 列出了 Red Hat V2.4 与性能关系密切的一些内核参数。Table 10-5 Red Hat parameters that are most levant to performance tuningParameterDescr

24、iption / example of usenet.ipv4 inelj)eeLgc_maxtimeHow often the garbage collector (gc) should pass over the inet peer storage memory pool during low or absent memory pressure. Default is 120. measured in jiffies.sysctl net ipv4 inetjeerjcmaxtime240net.ipv4 ineljieeLgc.mintimeSets the minimum time t

25、hat the garbage collector can pass cleaning memory. If your server is heavily loaded, you may want to increase this value. Default is 10, measured in jiffies.sysctlnet. ipv4. i netpeerjcmi ntimes80net.ipv4.ineLpeeLmaxttlThe maximum time-to-live for the inet peer entries. New entries will expire afte

26、r this period of time. Default is 600, measured in jiffies.sysctl -w net ipv4. inetjeermaxttls500net.ipv4inet_peer_minttlThe minimum time-to-live for inet peer entries. Set to a high enough value to cover fragment time to live in the reassembling side of fragmented packets. This minimum time must be

27、 smaller than net.ipv4.inetj)eerjhreshold. Default is 120, measured in jiffies.sysctl w net ipv4. inet_peerjintt 1 s80net.ipv4. inetj)eerjhresholdSet the size of inet peer storage. When this limit is reached, peer entries will be thrown away, using the inetj)eeLgc_mhtime timeout. Default is 65644.sy

28、sctl -w net ipv4. inetpeerJhreshol d=65644vmJiugetlb_poolThe hugetlb feature works in the same way as bigpages, but after hugetlb allocates memory, only the physical memory can be accessed by hugetlb or shm allocated with SHM_HUGETLB. It is normally used with databases such as Oracle or DB2 Default

29、is 0.sysctl -w vm.hugetlbj)ool-4608vmjnactive.cleanpercentDesignates the percent of inactive memory that should be cleaned. Default is 5%.sysctl -w vm.i nactiveclean_percent-30vm.pagecacheDesignates how much memory should be used for page cache. This is important for databases such as Oracle and DBZ

30、 Default is 115100.This parameters three values are: Minimum percent o1 memory used 1or page cache. Default is 1%. Ihe initial amount ot memory for cache, Default is 15%. Maximum percent of memoryfor page cache. Defaultis 100%.sysctl -w vmfpagecacheBl 50 1005处理器子系统调优CPU经常是性能的瓶颈。(超线程功能)。Hyper- Thread

31、ing 在 和 SUSE LINUX Enterprise ServerHyper-Threading的操作系统和软件处理器对于应用和数据库服务器来讲是最重要的硬件子系统之一。然而在这些系统中,在配有Xeon处理器的高端服务器中,你可以启用或者关闭Hyper-Threading操作系统里将一颗处理器虚拟化为两颗使用。Red Hat Ent erprise Linux AS都支持该功能,从而可以使处理器在同一时刻执行两个线程或者进程。对于支持来说,不需要增加CPU时钟频率即可使性能得到明显的改进。例如,在4路的服务器上起用Hyper- Threading 功能并使用性能监测工具(如top )来检

32、测,可以看到8颗处理器。如图Figure 10-610:22:45 up 23:401 5 users 373 processes: 370 Hoping, CPU states: cpu usertotal 36.U,load average: 26-49, 12.03, IO.242 running* 1 zombie, 0 stoppedelliO 11 ?- 4 Uli W i 0000 0 00-0 u u u u .u- u u u k PPPPPPPP26 7J*带诛导9 4 8 4 7 .4 3 3- Illi -5- 3 34-34-F3 r3O-43 52458344k a

33、ctive,nicesystemirqsoftirqiow&it。卫9刃W4.14L6%0朋5尿3*20朋乙氏0血血般0.0OM1忌0殳8*盘0朋2*5%0*9%1。妙0心0型2据0血9*能0尼2型2.5%Oj能g尿乙比丄能11工0.儁LK1 提h能12山00.5%used,5046892kfree,Okshrd.34604klnactiveidle 47駅 50 31矗 54.2% 血佩 53.6% 53.6% 554%91940k buff1868016k cachedSwap: 2040244k av 0k used, 2040244k freeFigure 10-& Output of

34、 top on a four-way server wiih Hyper-Threading enabled提示,对于 Hyper- Threading :_基于SMP内核的LINUX 才可以支持Hyper-Threading_安装的CPU数量越多,从Hyper- Threading获得的性能上的提高就越少。可获得的性能提高大约为:-2 颗物理 CPU: 15-25%-4 颗物理 CPU: 1-13%-8 颗物理 CPU: 0-5%-如需更多的关于Hyper-Threading信息,可浏览:s/hyperthreading/server/EM64T是Int el IA-32处理器的64-bit

35、扩展。意思是,处理器能够支持更多的内存并支持 64-bit应用同时完全兼容 现存的 32-bit 应用。Red Hat Enterprise Linux 3 Updat e 2 和 SUSE LINUX Enterprise Server 9支持这种新的处理器。如需更多的EM64T信息,可浏览:ext ensions/选择正确的内核Red Hat Ent erprise Linux AS 和 SUSE LINUX Enterprise Server都包括有若干个内核包,如 Table 10-6 所列。选择合适的内核对性能非常重要。labie 10-6 Available k&neis with

36、in the distittutionKernel typeDescriptionSMPKernel has support for SPv1P and Hyper-Threaded machines.Hugemem(Red Hat Enterprise Linux AS only) Support for machines with greater than 12 GB of memory. Includes support for NUMA.StandardSingle processor machines.6内存子系统的调优内存子系统的调优不是很容易,需要不停地监测来保证内存的改变不会对

37、服务器的其他子系统造成负面影响。如果要改 变虚拟内存参数(在/proc/sys/vm),建议您每次只改变一个参数然后监测效果。对与虚拟内存的调整包括以下几个项 目:_配置Linux内核如何更新dirty buffers到磁盘。磁盘缓冲区用于暂存磁盘的数据。相对于内存来讲,磁盘缓冲区的 速度很慢。因此,如果服务器使用这类内存,性能会成问题。当缓冲区内的数据完全dirt y,使用:sysctl -wvm.bdflush=30 500 0 0 500 3000 60 20 0vm.bdflush 有9个参数,但是建议您只改变其中的3个:1 nfract ,为排队写入磁盘前,bdflush daemo

38、n允许的缓冲区最大百分比2 ndirty ,为bdflush即刻写的最大缓冲区的值。如果这个值很大,bdflush需要更多的时间完成磁盘的数据更新。7 nfract_sync ,发生同步前,缓冲区变dirty的最大百分比。配置kswapd daemon ,指定Linux的内存交换页数量sysctl -w vm.kswapd=1024 32 64三个参数的描述如下:-tries_base相当于内核每次所交换的 页”的数量的四倍。对于有很多交换信息的系统,增加这个值可以改进性能。-tries_min 是每次kswapd swaps 出去的pages的最小数量。-swap_cluster 是kswa

39、pd即刻写如的pages数量。数值小,会提高磁盘I/O的性能;数值大可能也会对请求队列产生负面影响。如果要对这些参数进行改动,请使用工具vmstat检查对性能的影响。其它可以改进性能的虚拟内存参数为:_ buffermem_ freepages_ overcommit_memory_ page-cluster_ pagecache_ paget able_cache7文件系统的调优总体而言,所有数据都要从磁盘获取并都要保存到磁盘。磁盘访问速度通常以毫秒来计算,比其它组件要慢 上千倍(如内存、PCI操作是以纳秒或者微秒来计算的)。Linux文件系统定义了数据存储和访问的方式。Linux可用的文件

40、系统有多种,它们的性能和可扩展性各不相同。除了保存和管理磁盘数据,文件系统还负 责保证数据的完整性。新版的 Linux缺省安装已经包括日志文件系统(journaling file systems ),日志文 件系统可防止系统崩溃时导致的数据不一致问题。对文件系统元数据(metadat a)的更改都被保存在一份单独的日志里,当发生系统崩溃时可以根据日志正确地恢复数据。除此之外,日志使系统重新启动时不必进行 文件系统的检查,从而缩短了恢复时间。同其他方面的计算一样,性能和完整性是相互平衡的。然而,因Linux服务器多用于企业环境及数据中心,因此要求具备更高的可用性。这里,我们将介绍 Red Hat

41、 Enterprise Linux AS 和 SUSE LINUX Ent erprise Server的文件系统及其性能调优。7.1安装Linux前,硬件方面的考虑当前Linux的发行版本对CPU、硬盘和内存方面均有明确的安装要求。然而,对于如何设置磁盘子系统的说 明远远不够。由于Linux服务器被广泛的应用于各种环境,数据中心的服务器整合,我们首先要回答的问题 就是:该服务器的功能是什么? ”磁盘子系统可能是整个服务器系统性能的主要方面。了解服务器的功能是判断I/O子系统对性能产生多大影响的关键。下面几种服务器的磁盘I/O性能是非常重要的:_文件和打印服务器要求在用户和磁盘子系统之间快速地

42、移动数据。因文件服务器的功能是向客户端发送数 据,所以要快速读取所有的数据。_数据库服务器的最终目标是从磁盘上的数据仓库里查找和获取数据。即便有足够的内存,多数数据库服务 器依然需要大量的磁盘I/O将数据读入内存和更新磁盘数据。下面几种服务器的磁盘I/O性能不是最重要的:_邮件服务器用于电子邮件的存储和转发,通常产生较大的通信量。对这类服务器来讲,网络性能更为重要。_ Web服务器用于发布静态和动态的 Web页面,网络和内存子系统的性能非常重要。磁盘技术的选择除了理解服务器功能,还要了解磁盘容量的部署。下面是当前几种可选的磁盘技术及其容量、特点:技术花费功能容量及其限制EIDE最低直连、本地存

43、储低端服务器,如X305每控制器最多2块盘SCSI低直连、本地存储 中、高端服务器, 如 x346 、 x365已经使用了 10年的标准;对数据线长度、传输带宽和磁盘数量均有限制 单个通道的并发访问的数量也有所限制,限制了 群集功能SATA低中端数据存储应用2002年开始出现,是EIDE技术的延续; 点对点协议,每个驱动器都有一个独立的通道,增强扩展能力;连续的磁盘访问性能可与SCSI相比;支持RAIDiSCSI较低中端数据存储,如Web/文件服务器定位于中端存储和远程启动;节省基础架构的开销提供了 TCP/IP/Et hernet的灵活性和可靠性;TCP/IP的高延迟影响性能;目前 Red

44、Hat Enterprise Linux还不支持Fibre Channel高高端的企业存储, 如数据库服务器低延迟、高吞吐量,长传输距离可达 10公里2 Gbps传输速率;路径冗余功能提高可靠性;一 个光纤环路支持127个设备,共享带宽,实现大 规模群集磁盘的数量磁盘的数量多少会影响到系统性能。对磁盘容量的需求通常是考虑磁盘数量的唯一因素,而忽视了吞吐量的因素。好的性能是依赖于提供I/O读写的磁头数量。可通过RAID技术来实现,包括软RAID和硬件RAID。许多型号的xSeries服务器提供了硬件 RAID支持,Linux还提供了软RAID功能。2.4 Linux kernel的软 RAID是

45、通过md设备驱动实现的,支持 EIDE或SCSI硬盘。支持的RAID级别为RAID-0, RAID-1, 和RAID-5,可以在初始安装配置或者用 mdadm工具配置。Table 10-8 列出了可选的IBMRAID控制器:肖维 f 0B A威腕帕 IBM RAID CMollersStorage controllerProduct nameFeaturesServeRAID tamilyServeRAID 7TEntry-level 4-port SATA controller, supports RAID level0,1.10.日 nd 5ServeRAID 6M2-channel Ul

46、ta32O SCSI with 14 disk drives par channel supports RAD levels 0,1,10,IE. 5, 50. and 6EE.ServeRAID 61Cost-effective :Lzero channel using lhe onboard SCSI chips st. supports standard RAID levels 0.00,1.110,5.50 a rd IBM-exclusive 1E.; 5EE; andlEO.DS4000 (formerly known asFAStT)DS4100 (FAStTlOO)Entry-

47、level storage server with su叩ort for 叩 to 56 SATA drives and dual active 2 GB RAID controllers.FAStT200Compact 3U$ize with full integrated Fibre Channel tedinology supporting up to 10 internal FC disk drivesand a max cf 66 with additional external enclosures available in both single and dual (HA) co

48、ntroller models.DS4300 (FASU6D0)Models indude single and dual controller supporting from 14 FCup to 112 FC or SAIA deks witf) lurbomodel. Ki rbo model also provides a 2 GB cacheDS4400 (FAStTTOO)Dual adive RAID oontrollersH transfer rates of 2 Gbps and support for up to 224 drives for a maximum physi

49、cal capacity of 32 TB: 2 GB battery-backed controller cache.DS4500 |FAStT900)Dual active 2 GB RAID controllers, up to795 MBps throughput and support for up Io 32 TB of FC disk storage or 56 TB of SATA siorage; 2 GB battery-packed controller cache can siipport high-performanee applications such as. O

50、LTP and dala mining.提示:通常增加硬盘数量是提高磁盘性能的一个最有效方法。更多的内容,请参考如下文档的第121页Chapter 7,“Disk subsyst em_ IBM TotalStorage Disk Solutions for xSeries, SG24-6874-00 _ IBM Eserver xSeries ServeRAID Technology raid.html7.2 Ext3:Red Hat的缺省文件系统从Red Hat 7.2 开始,缺省文件系统为Ext3。相对于Ext2,增加了日志。其主要特点为:_ Availability (可用性):Ext

51、3提供数据的写一致功能。即意外宕机情况下,不需要检查数据的一致性, 使系统恢复时间从几小时缩短为几秒钟。_ Data integrit y (数据完整性):通过 mount命令定义日志方式:data=journal ,所有的数据,包括文 件数据和元数据,都被定义为日志型。_ Speed (速度):通过定义日志方式:dat a=writeback,可以选择获得数据完整性还是写速度的优势来满 足不同的业务需求。_ Flexibilit y (灵活性):从 Ext2 升级到 Ext3 非常简单,且不需要重新格式化硬盘。使用命令 tune2fs 并 编辑文件 /etc/fst ab ,便可完成升级。注

52、意, Ext3 可被 mount 为不带日志属性的 ext2 文件系统。另外,许多第三方厂家兼容 Ext3 file syst ems ,如 PartitionMagic 。7.3 R eiserFS: SUSE LINUX的缺省文件系统从 SUSE LINUX 7.1 开始,缺省安装的文件系统即为由 Hans Reiser 开发的 ResierF S 。在其设计之初便包 括如下性能方面的考虑 From its initial design, key performanceaspect s have included:_ 日志文件系统( Journaling )的设计提高了可靠性和恢复速度。_

53、 使用平衡树数据结构可以同时存储内容数据和安全元数据,使其获得更快的访问速度。_ 有效地利用磁盘空间,与其他文件系统不同, ResierF S 不依赖于数据块的大小。 Efficient use of disk space because, unlike other file systems, this file systemdoes not rely on block sizes.目前 SUSE LINUX Ent erprise Server 8 的 ReiserF S 为 V3.6 ,下一代文件系统是 Reiser4 。 Reiser4 提 供的是不间断的文件系统 ,通过实现 “atom

54、ic ”文件系统避免系统崩溃 ,保证完成 I/O 操作;使用新的访问算法 来获取 2 到 5 倍的性能提高。提示 : Red Hat Enterprise Linux AS不支持 ReiserFS7.4 通过 Linux kernel对文件系统调优缺省文件系统的设置或许适合大多数应用环境。尽管如此,我们还是提供了如下几个提高磁盘性能的方法: 访问时间更新linux 文件系统当文件被访问,创建, 更新的时候会保留纪录。默认的, 当文件读写操作的时候,系统会更新 last-time-read 属性。因为写操作是比较耗费资源的操作,减少不必要的 i/o 可以整体上提高磁盘性能。 在挂接文件系统的时候

55、, 加入 noatime 参数可以禁止 inode 节点访问时间的修改。 如果文件更新时间对于特 定的应用不是很重要的话,比如 web 服务,就可以把 noatime 参数加入 /etc/fst ab 文件中 比如:/dev/sdb1 /mountlocation ext3 defaults,noatime 1 2推荐利用单独的分区作为挂接点并打开 noatime 开关Tuning the elevator algorithm(调整阶梯算法)磁盘 I/O 阶梯算法产生于 V2.4 kernel 。它是通过控制 I/O 请求获得服务前在队列中等待时间, 来调整块 I/O 的运算法则。这是由调整阶

56、梯算法的读写值实现的。通过增加延迟(更大的读、写值), I/O 请求在队列中等待更长时间, 给 I/O scheduler 更好地完成 I/O 操作,改进性能。对应用于大量磁盘 I/O 的 Linux 服务器,要在吞吐量和延迟方面找到一个合理的平衡点。 Linux 文件系统使 用块设备,因此改进块读写的频率可以改进文件系统的性能。一个准则是,小缓存、平横的长延迟读写有利 于大量磁盘 I/O 的 Linux 服务器。阶梯算法的调整是一个交互的过程,首先要获得基准性能曲线,然后改动 设置,观察效果。 Example 10-1 给出了如何用 /sbin/elvtune 命令显示当前设置以及如何改动读

57、写队列的 数值。提示:Red Hat建议您将读延迟(-r)调整为写延迟(-w)的一半做过改动之后,确保 /sbin/elvtune call 被加到 /etc/rc.d/rc.local (Red Hat)或者/etc/init.d/boot.local(SUSE LINUX)中,使设置在系统重新启动后生效。redhat推荐调整升降算法来让读延迟是写延迟的一半注意,2.6核心的linux指出elvtune命令已经作废,取而代之的是调整/sys/block 结构Example 1 1 Finding current defaults for your instatlation and chang

58、ing themroot0x232 root # elvtune /dev/sda/dev/sda elevator ID2readHatency:2048wri te_latency i81921024 -v 2048 /dev/sdamax bomb segments:6root(?x232 root elvtune -r/dev/sda elevator ID2readlatency:1024wrltejatency:2048max bomb segments:6选择Ext3文件系统的日志模式Ext3文件系统可选三种日志模式,使用mount命令来完成:_ dat a=journal文件数

59、据和元数据均设置为日志方式,性能开销比较大_ dat a=ordered (缺省设置)顺序写入,先写文件数据,再写元数据_ dat a=writeback提供最快的访问速度,但是牺牲了数据的一致性。元数据仍然被记录到日志,从而确保元数据的完整。文件数 据会在系统崩溃之后恢复到原先的状态。三种方法改变日志模式:_使用mount 命令:mount -o data=writeback /dev/sdb1 /mnt/mountpoint这里 /dev/sdb1是挂载的文件系统_在/etc/fstab文件的选项中:/dev/sdb1 /testfs ext3 defaults,journal=write

60、back 0 0_ 更改root分区的data=ordered,更改上述/etc/fst ab 文件,执行 mkinit rd命令来扫描/etc/fstab 文件并创建新的印象文件。升级 grub或lilo指向新的印象文件。更多有关Ext3的介绍,请参考:Tuning R eiserFS (调整 ReiserFS )ReiserFS的优势之一是支持大量的小文件。取代传统Linux文件系统的块结构,ReiserF S使用树型结构,保存小文件的全部内容和大文件的结尾。ReiserF S不使用固定的块大小,避免出现碎片而浪费磁盘空间。挂载ReiserFS 文件系统时,有一个选项可以改进系统性能,但是

61、会消耗更多的磁盘空间。使用notail来关闭“tail packing 选项,具体方法如下:Example 10-2 Example of fnounting a ReiserFS file sys tem with the notaii option/dev/sdbl /testfs reslerfs notail 0 0Setting bdflush通过调整虚拟内存子系统也可以改进文件系统性能。Bdflush内核进程保证dirt y buffers (任何当前被修改的只存在于易失性内存的数据)与磁盘一致。修改/proc/sys/vm/bdflush 变量,来改变写入磁盘速率,避免 磁盘竞争问题。对/proc下的任何修改即刻生效,但是重新启动后会恢复到原来状态。在/etc/rc.d/rc.local文件中加入echo命令使所做的修改永久生效。1. 对于 2.4 Linux kernels ,在 /proc/sys/vm/bdflush包括九个变量: nfract : dirtybuffers在buffer cache

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!