centos freebs(centos 8)

老铁们,大家好,相信还有很多朋友对于centos freebs和centos 8的相关问题不太懂,没关系,今天就由我来为大家分享分享centos freebs以及centos 8的问题,文章篇幅可能偏长,希望可以帮助到大家,下面一起来看看吧!

【fio】CentOS.x上磁盘性能测试工具fio的安装和使用

Summary: Multithreaded IO generation tool

Description: fio is an I/O tool that will spawn a number of threads or processes doing a particular type of io action as specified by the user.  fio takes a number of global parameters, each inherited by the thread unless otherwise parameters given to them overriding that setting is given.

The typical use of fio is to write a job file matching the io load one wants to simulate.

多线程IO生成工具

fio是一个I/ O工具,它将产生许多线程或正在执行的进程,由用户指定的特定类型的io操作。 

fio需要一个全局参数的数量,每个参数都由线程继承,否则给他们的参数将覆盖该设置。 

fio的典型用法是编写与io负载匹配的需要模拟的作业文件。

官网地址:

# yum-y install libaio gtk2 libaio-devel gtk2-devel

# yum-y install fio

# yum info fio

# rpm-ql fio| grep"bin"

应用使用IO通常有二种方式:同步和异步。 

同步的IO一次只能发出一个IO请求,等待内核完成才返回,这样对于单个线程iodepth总是小于1,但是可以透过多个线程并发执行来解决,通常我们会用16-32根线程同时工作把iodepth塞满。

异步的话就是用类似libaio这样的Linux native aio一次提交一批,然后等待一批的完成,减少交互的次数,会更有效率。

注意:性能测试建议直接通过写裸盘的方式进行测试,会得到较为真实的数据,但直接测试裸盘会破坏文件系统结构,导致数据丢失,请在测试前确认磁盘中数据已备份。

# fio  -direct=1 -iodepth=64 -rw=read -ioengine=libaio -bs=4k -size=10G -numjobs=1 -name=./fio.test

"-direct=1",代表采用非 buffered I/O文件读写的方式,避免文件读写过程中内存缓冲对性能的影响

"-iodepth=64"和"-ioengine=libaio"这两个参数,这里指文件读写采用异步 I/O(Async I/O)的方式,也就是进程可以发起多个 I/O请求,并且不用阻塞地等待 I/O的完成。稍后等 I/O完成之后,进程会收到通知。这种异步 I/O很重要,因为它可以极大地提高文件读写的性能。在这里我们设置了同时发出 64个 I/O请求

"-rw=read,-bs=4k,-size=10G",这几个参数指这个测试是个读文件测试,每次读 4KB大小数块,总共读 10GB的数据。最后一个参数是"-numjobs=1",指只有一个进程/线程在运行。所以,这条 fio命令表示我们通过异步方式读取了 10GB的磁盘文件,用来计算文件的读取性能。

我们看到在上图中测试中, I/O性能是 15.9MB/s的带宽,IOPS(I/O per second)是 4076左右。

fio压测工具和io队列深度理解和误区

fio– IO压力测试工具

fio安装使用方法

fio模拟MySQL服务器IO压力脚本

fio使用详解

Fio Output Explained

CentOS下SWAP分区建立及释放内存详解

方法一:

一、查看系统当前的分区情况:

free-m

二、创建用于交换分区的文件:

dd if=/dev/zero of=/whatever/swap bs=block_size(10M)count=number_of_block(3000)

三、设置交换分区文件:

mkswap/export/swap/swapfile

四、立即启用交换分区文件:

swapon/whateever/swap

五、若要想使开机时自启用,则需修改文件/etc/fstab中的swap行:

/whatever/swap swap swap defaults 0 0

方法二

增加交换分区空间的方法:

1.查看一下/etc/fstab确定目前的分区

2.swapoff/dev/hd**

3.free看一下是不是停了.

4.fdisk删了停掉的swap分区

5.重新用FDISK建一个新的SWAP分区

6.mkswap/dev/hd**把新的分区做成swap

7.swapon/dev/hd**打开swap

8.修改/etc/fstab

操作实例:

1.查看系统Swap空间使用

# free

total used free shared buffers cached

Mem: 513980 493640 20340 0 143808 271780

-/+ buffers/cache: 78052 435928

Swap: 1052248 21256 1030992

2.在空间合适处创建swap文件

# mkdir swap

# cd swap

# dd if=/dev/zero of=swapfile bs=1024 count=10000

10000+0 records in

10000+0 records out

# ls-al

total 10024

drwxr-xr-x 2 root root 4096 7月 28 14:58.

drwxr-xr-x 19 root root 4096 7月 28 14:57..

-rw-r--r-- 1 root root 10240000 7月 28 14:58 swapfile

# mkswap swapfile

Setting up swapspace version 1, size= 9996 KiB

3.激活swap文件

# swapon swapfile

# ls-l

total 10016

-rw-r--r-- 1 root root 10240000 7月 28 14:58 swapfile

# free

total used free shared buffers cached

Mem: 513980 505052 8928 0 143900 282288

-/+ buffers/cache: 78864 435116

Swap: 1062240 21256 1040984

生成1G的文件

# dd if=/dev/zero of=swapfile bs=10M count=3000

创建为swap文件

#mkswap swapfile

让swap生效

#swapon swapfile

查看一下swap

#swapon-s

[root@cluster/]# swapon-sFilenameTypeSizeUsedPriority/dev/sda3               partition10201161728-1/state/partition1/swap/swapfile    file307199920-2

加到fstab文件中让系统引导时自动启动

#vi/etc/fstab

/state/partition1/swap/swapfil swap swap defaults 0 0

完毕。

二,LINUX释放内存

细心的朋友会注意到,当你在linux下频繁存取文件后,物理内存会很快被用光,当程序结束后,内存不会被正常释放,而是一直作为caching.这个问题,貌似有不少人在问,不过都没有看到有什么很好解决的办法.那么我来谈谈这个问题.

先来说说free命令

[root@cluster/]# free-m

total   used   free  shared buffers  cached

Mem:    31730  31590   139    0    37  27537

-/+ buffers/cache:   4015  27714

Swap:   30996    1  30994

其中:

total内存总数

used已经使用的内存数

free空闲的内存数

shared多个进程共享的内存总额

buffers Buffer Cache和cached Page Cache磁盘缓存的大小

-buffers/cache的内存数:used- buffers- cached

+buffers/cache的内存数:free+ buffers+ cached

可用的memory=free memory+buffers+cached

有了这个基础后,可以得知,我现在used为163MB,free为86,buffer和cached分别为10,94

那么我们来看看,如果我执行复制文件,内存会发生什么变化.

[root@cluster/]# cp-r/etc~/test/

[root@cluster/]# free-m

total   used   free  shared buffers  cached

Mem:    31730  31590   139    0    37  27537

-/+ buffers/cache:   4015  27714

Swap:   30996    1  30994

在我命令执行结束后,used为244MB,free为4MB,buffers为8MB,cached为174MB,天呐都被cached吃掉了.别紧张,这是为了提高文件读取效率的做法.

引用[url][/url]为了提高磁盘存取效率, Linux做了一些精心的设计,除了对dentry进行缓存(用于VFS,加速文件路径名到inode的转换),还采取了两种主要Cache方式:Buffer Cache和Page Cache。前者针对磁盘块的读写,后者针对文件inode的读写。这些Cache有效缩短了 I/O系统调用(比如read,write,getdents)的时间。

那么有人说过段时间,linux会自动释放掉所用的内存,我们使用free再来试试,看看是否有释放?

[root@cluster/]# free-m

total   used   free  shared buffers  cached

Mem:    31730  31590   139    0    37  27537

-/+ buffers/cache:   4015  27714

Swap:   30996    1  30994

MS没有任何变化,那么我能否手动释放掉这些内存呢???回答是可以的!

/proc是一个虚拟文件系统,我们可以通过对它的读写操作做为与kernel实体间进行通信的一种手段.也就是说可以通过修改/proc中的文件,来对当前kernel的行为做出调整.那么我们可以通过调整/proc/sys/vm/drop_caches来释放内存.操作如下:

[root@cluster/]# cat/proc/sys/vm/drop_caches

0

首先,/proc/sys/vm/drop_caches的值,默认为0

[root@cluster/]# sync

手动执行sync命令(描述:sync命令运行 sync子例程。如果必须停止系统,则运行 sync命令以确保文件系统的完整性。sync命令将所有未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O和读写映射文件)

[root@server test]# echo 3/proc/sys/vm/drop_caches

[root@server test]# cat/proc/sys/vm/drop_caches

3

将/proc/sys/vm/drop_caches值设为3

[root@server test]# free-m

total   used   free  shared buffers  cached

Mem:     249    66   182    0    0    11

-/+ buffers/cache:    55   194

Swap:    511    0   511

再来运行free命令,发现现在的used为66MB,free为182MB,buffers为0MB,cached为11MB.那么有效的释放了buffer和cache.

有关/proc/sys/vm/drop_caches的用法在下面进行了说明

/proc/sys/vm/drop_caches(since Linux 2.6.16)

Writing to this file causes the kernel to drop clean caches,

dentries and inodes from memory, causing that memory to become free.

To free pagecache, use echo 1/proc/sys/vm/drop_caches;

to free dentries and inodes, use echo 2/proc/sys/vm/drop_caches;

to free pagecache, dentries and inodes, use echo 3/proc/sys/vm/drop_caches.

Because this is a non-destructive operation and dirty objects

这几天发现linux系统内存一直涨,即使把apache和mysql关闭了,内存也不释放,可以使用以下脚本来释放内存:

脚本内容:

#!/bin/sh

# cache释放:

# To free pagecache:

/bin/sync

/bin/sync

#echo 1/proc/sys/vm/drop_caches

# To free dentries and inodes:

#echo 2/proc/sys/vm/drop_caches

# To free pagecache, dentries and inodes:

echo 3/proc/sys/vm/drop_caches

利用系统crontab实现每天自动运行:

crontab-e

输入以下内容:

00 00***/root/Cached.sh

每天0点释放一次内存,这个时间可以根据自己需要修改设置

在运行./Cached.sh时如果提示错误:Permission denied权限的问题,可以运行

Centos如何增加swap分区文件Centos增加swap分区文件的方法

准备学习ORACLE,搭建环境的时候老是提示SWAP空间不足,特意记录下增加SWAP空间的方法!

Linux中增加swap分区文件的步骤方法:

1、检查当前的分区情况(使用free-m或cat/proc/swaps):

[root@db2 root]# free-m

total used free shared buffers cached

Mem: 1006 84 922 0 11 38

-/+ buffers/cache: 35 971

Swap: 0 0 0

[root@db2 root]#

2、增加交换分区文件及大小:

检查没有swap,下面就需要增加:

判定新交换文件的大小,将大小乘以1024来判定块的大小。例如,大小为64MB的交换文件的块大小为65536,在 shell提示下以根用户身份键入以下命令,其中的 count等于想要的块大小。

[root@db2 root]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000

1024000+0 records in

1024000+0 records out

[root@db2 root]#

使用以下命令来设置交换文件:

[root@db2 root]# mkswap/home/swap

Setting up swapspace version 1, size= 1023996 KiB

[root@db2 root]#

3、启用交换分区文件:

要立即启用交换文件而不是在引导时自动启用,使用以下命令:

[root@db2 root]# swapon/home/swap

检查增加后的交换情况:

[root@db2 root]# free-m

total used free shared buffers cached

Mem: 1006 994 12 0 4 929

-/+ buffers/cache: 60 946

Swap: 999 0 999

[root@db2 root]#

要在引导时启用,编辑/etc/fstab文件来包含以下行(/home/swap swap swap defaults 0 0):

[root@db2 root]# vi/etc/fstab

LABEL=// ext3 defaults 1 1

LABEL=/boot/boot ext2 defaults 1 2/home/swap swap swap defaults 0 0

none/dev/pts devpts gid=5,mode=620 0 0

none/proc proc defaults 0 0

none/dev/shm tmpfs defaults 0 0

LABEL=/usr/usr ext3 defaults 1 2

/dev/sda5 swap swap defaults 0 0

/dev/cdrom/mnt/cdrom iso9660 noauto,owner,kudzu,ro 0 0

/dev/fd0/mnt/floppy auto noauto,owner,kudzu 0 0

/home/swap swap swap defaults 0 0

系统下次引导时,它就会启用新建的交换文件

再次检查添加后的情况:

[root@db2 oracledb]# free-m

total used free shared buffers cached

Mem: 1006 979 27 0 6 917

-/+ buffers/cache: 54 952

Swap: 999 0 999

[root@db2 oracledb]#

阅读剩余
THE END