小编dor*_*and的帖子

如何在日志文件中保留最后 50 行

我尝试在我的文件中保留最后 50 行,每分钟保存一次温度。我使用了这个命令:

tail -n 50 /home/pi/Documents/test > /home/pi/Documents/test
Run Code Online (Sandbox Code Playgroud)

但结果是空的测试文件。我想,它会列出测试文件的最后 50 行并将其插入到测试文件中。当我使用此命令时:

tail -n 50 /home/pi/Documents/test > /home/pi/Documents/test2
Run Code Online (Sandbox Code Playgroud)

它工作正常。test2 文件中有 50 行。

有人能解释一下问题出在哪里吗?

command-line logs tail

26
推荐指数
4
解决办法
2万
查看次数

来自 /dev/zero 和 /dev/urandom 的不同文件大小

我想通过dd命令创建随机的 1G 测试文件。

dd status=progress if=/dev/zero of=/tmp/testfile.zer bs=100M count=10
dd status=progress if=/dev/urandom of=/tmp/testfile1.ran bs=100M count=10
dd status=progress if=/dev/urandom of=/tmp/testfile2.ran bs=100M count=20
Run Code Online (Sandbox Code Playgroud)

输出是:

-rw-rw-r-- 1 dorinand dorinand  320M dub 21 12:37 testfile1.ran
-rw-rw-r-- 1 dorinand dorinand  640M dub 21 12:37 testfile2.ran
-rw-rw-r-- 1 dorinand dorinand 1000M dub 21 12:37 testfile.zer
Run Code Online (Sandbox Code Playgroud)

为什么生成的输出测试文件要/dev/urandom小三倍?我希望 testfile1.ran 的大小为 1000M,testfile2.ran 的大小为 2000M。任何人都可以为什么会发生这种情况?我应该如何生成随机测试文件?

linux dd

10
推荐指数
1
解决办法
2189
查看次数

解释 ZFS 系统输出

我有zdb -DDD geek1命令输出:

[root@zfs-test centos]# zdb -DDD geek1
DDT-sha256-zap-duplicate: 8193 entries, size 290 on disk, 141 in core

bucket              allocated                     referenced
______   ______________________________ ______________________________
refcnt   blocks   LSIZE   PSIZE   DSIZE   blocks   LSIZE   PSIZE DSIZE
------   ------   -----   -----   -----   ------   -----   ----- -----
     2       8K      1G      1G   1023M      24K      3G      3G 3.00G
   16K        1    128K    128K    128K      16K      2G      2G 2.00G


DDT histogram (aggregated over all DDTs):

bucket              allocated                     referenced
______   ______________________________ ______________________________
refcnt   blocks   LSIZE   PSIZE   DSIZE   blocks …
Run Code Online (Sandbox Code Playgroud)

linux zfs

4
推荐指数
1
解决办法
897
查看次数

ZFS 重复数据删除不起作用

我已经创建了 pool tank1 和 fs tank/home。

[root@zfs]# zfs list
NAME         USED  AVAIL  REFER  MOUNTPOINT
tank1       3.22G   381G  32.0K  /tank1
tank1/home  3.22G  16.8G  1.95G  /tank1/home
Run Code Online (Sandbox Code Playgroud)

我在/dev/zerotank1 /home 中创建了两个 1G 文件,其中.Deduplication 已打开,压缩已关闭:

# zfs get all | egrep 'dedup|compression'
tank1             compression           off                    default
tank1             dedup                 on                     local
tank1/home        compression           off                    default
tank1/home        dedup                 on                     inherited from tank1

# zpool list
NAME    SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
tank1   596G  4.84G   591G         -     0%     0%  1.00x  ONLINE  - …
Run Code Online (Sandbox Code Playgroud)

linux zfs

3
推荐指数
1
解决办法
1756
查看次数

DRBD 没有 cat /proc/drbd 的输出

我同步我的新磁盘,输出drbdtop

Resource: myres: (Overall danger score: 14)
Local Disc(Primary):
volume 0 (/dev/drbd0): UpToDate(normal disk state)
volume 1 (/dev/drbd1): UpToDate(normal disk state)
volume 2 (/dev/drbd2): Inconsistent(data is not accessible or usable until resync is complete)

Connection to zfs.user.osdc2(Secondary): Connected(connected to zfs.user.osdc2)
volume 0: 
UpToDate(normal disk state)
volume 1:
UpToDate(normal disk state)
volume 2:
Replication:SyncTarget(local volume is being synchronized with data from zfs.user.osdc2) 95.6% remaining   UpToDate(normal disk state)  
Run Code Online (Sandbox Code Playgroud)

但是cat /proc/drbd关于我的资源没有输出。仅有的:

version: 9.0.9-1 (api:2/proto:86-112)
GIT-hash: f7b979e7af01813e031aac579140237640c94569 build by mockbuild@, …
Run Code Online (Sandbox Code Playgroud)

drbd

2
推荐指数
1
解决办法
2909
查看次数

标签 统计

linux ×3

zfs ×2

command-line ×1

dd ×1

drbd ×1

logs ×1

tail ×1