每天学五分钟 Liunx 0001 | 存储篇:swap
swap
swap 构建
[root@test test]# fdisk /dev/sdb The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (2-4, default 2):
No free sectors available
[root@test test]# lvdisplay | grep test
LV Path /dev/lianhuasheng/test
LV Name test
[root@test test]# free
total used free shared buff/cache available
Mem: 65692228 56611752 631264 56492 8449212 7650528
Swap: 0 0 0 [root@test test]# mkswap /dev/lianhuasheng/test
mkswap: /dev/lianhuasheng/test: warning: wiping old ext4 signature.
Setting up swapspace version 1, size = 204796 KiB
no label, UUID=2ed9b70d-b267-4c26-9159-1bfb273c7d7c [root@test test]# free
total used free shared buff/cache available
Mem: 65692228 56359176 1139968 56492 8193084 7902468
Swap: 0 0 0
[root@test test]# free -h
total used free shared buff/cache available
Mem: 62G 54G 511M 55M 7.9G 7.0G
Swap: 0B 0B 0B
[root@test test]# swapon /dev/lianhuasheng/test
[root@test test]# free -h
total used free shared buff/cache available
Mem: 62G 54G 941M 55M 7.7G 7.2G
Swap: 199M 0B 199M
[root@test lianhuasheng]# dd if=/dev/zero of=/root/lianhuasheng/swap/lianhuasheng.swap bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 0.356955 s, 1.5 GB/s [root@test swap]# ll -h lianhuasheng.swap
-rw-r--r--. 1 root root 512M Apr 1 00:12 lianhuasheng.swap [root@test swap]# mkswap lianhuasheng.swap
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=510ba316-c6e5-4993-b616-e72969cd6322 [root@test swap]# free -h
total used free shared buff/cache available
Mem: 62G 53G 663M 47M 8.0G 7.3G
Swap: 199M 199M 16K [root@test swap]# swapon lianhuasheng.swap swapon: /root/lianhuasheng/swap/lianhuasheng.swap: insecure permissions 0644, 0600 suggested.
[root@test swap]# free -h
total used free shared buff/cache available
Mem: 62G 54G 304M 47M 8.1G 7.1G
Swap: 711M 200M 511M
[root@test swap]# swapoff /dev/lianhuashengl/test
[root@test swap]# free -h
total used free shared buff/cache available
Mem: 62G 53G 761M 54M 8.0G 7.4G
Swap: 511M 511M 60K [root@test swap]# swapoff lianhuasheng.swap [root@test swap]# free -h
total used free shared buff/cache available
Mem: 62G 54G 888M 55M 7.6G 7.1G
Swap: 0B 0B 0B
磁盘性能
[root@test lianhuasheng]# dd if=/dev/zero of=/root/lianhuasheng/swap/lianhuasheng.swap bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 0.356955 s, 1.5 GB/s
[root@test swap]# dd if=lianhuasheng.swap of=/dev/null bs=1M
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 1.07563 s, 499 MB/s
[root@test swap]# dd if=/dev/sda2 of=disk bs=1K
^C2729809+0 records in
2729808+0 records out
2795323392 bytes (2.8 GB) copied, 11.4058 s, 245 MB/s
[root@test swap]# dd if=lianhuasheng.swap of=/dev/null bs=1M iflag=direct
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 1.7492 s, 307 MB/s
[root@test swap]# dd if=/dev/zero of=lianhuasheng.swap bs=1M count=1024 oflag=direct
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 2.5872 s, 415 MB/s
[root@test swap]# dd if=/dev/sda2 of=disk bs=1K iflag=direct oflag=direct
^C328136+0 records in
328135+0 records out
336010240 bytes (336 MB) copied, 93.313 s, 3.6 MB/s
sync && echo 3 > /proc/sys/vm/drop_caches
[root@test swap]# free -h
total used free shared buff/cache available
Mem: 62G 56G 1.0G 55M 5.0G 4.8G
Swap: 0B 0B 0B [root@test swap]# sync && echo 3 > /proc/sys/vm/drop_caches [root@test swap]# free -h
total used free shared buff/cache available
Mem: 62G 54G 7.3G 55M 901M 7.2G
Swap: 0B 0B 0B [root@test swap]# dd if=lianhuasheng.swap of=/dev/null bs=1M iflag=direct
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 3.54052 s, 303 MB/s [root@test swap]# dd if=lianhuasheng.swap of=/dev/null bs=1M iflag=direct
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 3.49309 s, 307 MB/s
[root@test test]# hdparm -t /dev/sda2 /dev/sda2:
Timing buffered disk reads: 1334 MB in 3.00 seconds = 444.43 MB/sec
[root@test test]# hdparm -T /dev/sda2 /dev/sda2:
Timing cached reads: 17748 MB in 2.00 seconds = 8888.37 MB/sec
内存和磁盘| buffer cache 和 page cache
[root@test test]# free -wh
total used free shared buffers cache available
Mem: 31G 8.9G 10G 1.6G 326M 11G 20G
Swap: 511M 371M 140M
buffers
Memory used by kernel buffers (Buffers in /proc/meminfo) cache
Memory used by the page cache and slabs (Cached and Slab in /proc/meminfo)
每天学五分钟 Liunx 0001 | 存储篇:swap的更多相关文章
- 如何从40亿整数中找到不存在的一个  webservice  Asp.Net Core 轻松学-10分钟使用EFCore连接MSSQL数据库  WPF实战案例-打印  RabbitMQ与.net core(五) topic类型 与 headers类型 的Exchange
		如何从40亿整数中找到不存在的一个 前言 给定一个最多包含40亿个随机排列的32位的顺序整数的顺序文件,找出一个不在文件中的32位整数.(在文件中至少确实一个这样的数-为什么?).在具有足够内存的情况 ... 
- 五分钟学Java:如何才能学好Java Web里这么多的技术
		原创声明 本文作者:黄小斜 转载请务必在文章开头注明出处和作者. 系列文章介绍 本文是<五分钟学Java>系列文章的一篇 本系列文章主要围绕Java程序员必须掌握的核心技能,结合我个人三年 ... 
- 零元学Expression Blend 4 - Chapter 42 五分钟快速完成扇形变圆形动画
		原文:零元学Expression Blend 4 - Chapter 42 五分钟快速完成扇形变圆形动画 零元学Expression Blend 4 - Chapter 42 五分钟快速完成扇形变圆形 ... 
- 《sed的流艺术之一》-linux命令五分钟系列之二十一
		本原创文章属于<Linux大棚>博客,博客地址为http://roclinux.cn.文章作者为rocrocket. 为了防止某些网站的恶性转载,特在每篇文章前加入此信息,还望读者体谅. ... 
- GC算法精解(五分钟让你彻底明白标记/清除算法)
		GC算法精解(五分钟让你彻底明白标记/清除算法) 相信不少猿友看到标题就认为LZ是标题党了,不过既然您已经被LZ忽悠进来了,那就好好的享受一顿算法大餐吧.不过LZ丑话说前面哦,这篇文章应该能让各位彻底 ... 
- zookeeper-架构设计与角色分工-《每日五分钟搞定大数据》
		本篇文章阅读时间5分钟左右 点击看<每日五分钟搞定大数据>完整思维导图 zookeeper作为一个分布式协调系统,很多组件都会依赖它,那么此时它的可用性就非常重要了,那么保证可用性的同 ... 
- 「每日五分钟,玩转JVM」:线程共享区
		前言 上一篇中,我们了解了JVM中的线程独占区,这节课我们就来了解一下JVM中的线程共享区,JVM中的线程共享区是跟随JVM启动时一起创建的,包括堆(Heap)和方法区()两部分,而线程独占区的程序计 ... 
- 五分钟搭建一个基于BERT的NER模型
		BERT 简介 BERT是2018年google 提出来的预训练的语言模型,并且它打破很多NLP领域的任务记录,其提出在nlp的领域具有重要意义.预训练的(pre-train)的语言模型通过无监督的学 ... 
- Python专题——五分钟带你了解map、reduce和filter
		本文始发于个人公众号:TechFlow,原创不易,求个关注 今天是Python专题第6篇文章,给大家介绍的是Python当中三个非常神奇的方法:map.reduce和filter. 不知道大家看到ma ... 
- 一门能让你五分钟学会的语言-Brainfuck
		看到标题,不出意外的话,你肯定开始骂我了:**标题党,什么编程语言五分钟就能学会? 其实我本来也是不相信的,但是学过了才知道这是真的. 1.Brainfuck 看到这个小标题,不要误会,我没有骂人. ... 
随机推荐
- 组合式api-跨层级组件通信provide和inject
			vue2的provide和inject:https://v2.cn.vuejs.org/v2/api/#provide-inject 主要作用: 跨层级传递数据(响应和非相应数据都可以).方法(函数) ... 
- Java线程池ThreadPoolExecutor源码解析
			Java线程池ThreadPoolExecutor源码解析 1.ThreadPoolExecutor的构造实现 以jdk8为准,常说线程池有七大参数,通常而言,有四个参数是比较重要的 public T ... 
- 【李南江】从零玩转TypeScript
			前言 老套路肯定是 需要知道TS是干啥用的啦. 1.什么是TypeScript(TS)? TypeScript简称TS TS和JS之间的关系其实就是Less/Sass和CSS之间的关系 就像Less/ ... 
- cp {,bak}用法(转载)
			cp filename{,bak} cp filename{,.bak} 这个命令是用来把filename备份成filename.bak的 等同于命令 cp filename filename.bak ... 
- 用Python写一个简单的TCP客户端和服务端
			在渗透测试过程中,经常需要创建一个TCP客户端,用来测试服务.发送数据.进行 fuzz 等等.如果黑客潜伏在某大型企业的内网环境中,则不太可能直接获取网络工具或编译器,有时甚至连复制/粘贴或者连接外网 ... 
- GDAL从二进制数据流中构造数据集
			目录 1. 概述 2. 实现 1. 概述 参看<从二进制数据流中构造GDAL可以读取的图像数据>这篇文章.这个问题的内涵在于,处理图像时都会将其读取成宽X高X波段的三维数组的内存Buffe ... 
- 玩转Sermant开发,开发者能力机制解析
			本文分享自华为云社区<开发者能力机制解析,玩转Sermant开发>,作者:华为云开源 . 前言: 在<Sermant框架下的服务治理插件快速开发及使用指南>中带大家一起体验了S ... 
- 容器、Docker、虚拟机,别再傻傻分不清
			摘要:容器技术起源于Linux,是一种内核虚拟化技术,提供轻量级的虚拟化,以便隔离进程和资源.尽管容器技术已经出现很久,却是随着Docker的出现而变得广为人知. 容器技术起源于Linux,是一种内核 ... 
- 云小课|GaussDB如何进行性能调优
			阅识风云是华为云信息大咖,擅长将复杂信息多元化呈现,其出品的一张图(云图说).深入浅出的博文(云小课)或短视频(云视厅)总有一款能让您快速上手华为云.更多精彩内容请单击此处. 摘要:GaussDB性能 ... 
- 详解CNN实现中文文本分类过程
			摘要:本文主要讲解CNN实现中文文本分类的过程,并与贝叶斯.决策树.逻辑回归.随机森林.KNN.SVM等分类算法进行对比. 本文分享自华为云社区<[Python人工智能] 二十一.Word2Ve ... 
