- 1. 简介
首先简单介绍一下 Linux 文件系统的最基本单元：inode。inode 译成中文就是索引节点，每个存储设备（例如硬盘）或存储设备的分区被格式化为文件系统后，应该有两部份，一部份是 inode，另一部份是 block，block 是用来存储数据用的。而 inode 呢，就是用来存储这些数据的信息，这些信息包括文件大小、属主、归属的用户组、读写权限等。inode 为每个文件进行信息索引，所以就有了 inode 的数值。linux 操作系统下可以使用 ls –id 命令来查看文件或者目录的 inode 值，一般”root”目录的 inode 值为 2,一个分区挂载到一个目录下时，这个”root”目录的 inode 值为 2
本文要介绍的命令是通过文件系统的 inode 值（一般是 2 ）来获取文件系统信息。在 ext3 和 ext4 文件系统中，每个文件都是通过 inode 来描述其数据存放的具体位置，当文件被删除以后，inode 的数据指针部分被清零，文件目录区没有太多变化。文件的读写都是通过 inode 来实现，当 inode 数据指针被清零以后，即便文件内容还在，也没有办法把文件内容组合出来。当 ext3 和 ext4 文件系统中的元数据 metadata 发生变化时，相应的元数据 metadata 在日志文件会有一份拷贝。比如一个文件被删除了，它的 inode 信息会在日志文件中先保存一份，然后把要删除文件 inode 相关信息清零。这个日志文件是循环使用的，当操作过多时，删除的文件的 inode 日志记录会被新的数据替换，这就彻底丧失了根据 inode 找回数据的机会了。如果是大量文件的删除，这个日志文件会被反复循环利用多次，只留给最后删除的那些文件的恢复机会。继续阅读
This post will show you how to write a function to compute md5 sum of a file using the hashlib module, the with statement and being memory efficient by not reading the whole file in memory.
from __future__ import with_statement from hashlib import md5 def md5sum(filename, buf_size=8192): m = md5() # the with statement makes sure the file will be closed with open(filename, 'b') as f: # We read the file in small chunk until EOF data = f.read(buf_size) while data: # We had data to the md5 hash m.update(data) data = f.read(buf_size) # We return the md5 hash in hexadecimal format return m.hexdigest() if __name__ == '__main__': import sys print md5sum(sys.argv)
Now let’s see how quick it is against the real md5sum using a test file of 10Go!
The real md5sum:
$ time md5sum /data/testfile b215f7bf5b09fa3e9848a6a66f3f3172 /data/testfile real 0m31.148s user 0m27.738s sys 0m3.408s
The python version of md5sum:
$ time python md5sum.py /data/testfile b215f7bf5b09fa3e9848a6a66f3f3172 real 0m27.791s user 0m24.514s sys 0m3.276s
The python based version is almost 4 seconds quicker than the C based version!
Log Parser is a tool that has been around for quite some time (almost six years, in fact). I can’t really do any better than the description on the official download page, so here it is: “Log parser is a powerful, versatile tool that provides universal query access to text-based data such as log files, XML files and CSV files, as well as key data sources on the Windows operating system such as the Event Log, the Registry, the file system, and Active Directory”.
Log Parser is a command line (yes, command line!) tool that uses a SQL dialect to extract information from data sources. In particular, I have found it to be invaluable for extracting information from the web server logs of the sites that I manage and develop.
First, about that SQL syntax Log Parser uses to query the data sources… many developers seem to have a natural aversion to SQL. In addition, many new data access frameworks attempt to abstract SQL away from the developer. However, I have always found SQL easy to work with and believe it to be an essential tool that every developer should at least have a working knowledge of. For Log Parser, all that is necessary is a basic understanding of the core SQL SELECT statement, as implemented within Microsoft’s SQL Server (that is, T-SQL). That means you should be familiar with the following elements of a SELECT statement: TOP, FROM, INTO, WHERE, ORDER BY, GROUP BY. That’s all you need to perform most Log Parser operations.
Curiously, Log Parser has never received the amount of attention that I think it deserves. Beyond a flurry of attention when it was first released, it seems to be mentioned rarely in official Microsoft communications or blogs. Despite that, it remains a viable and valuable tool for parsing not just web server log files, but all types of structured text-based data.
In this post, rather than explaining how to use Log Parser. I’ll give a number of examples of its use. In addition, I’ll document some useful locations where Log Parser information can be found on the web.继续阅读
How to allocate a large memory space for Informix shared memory segments on Red Hat Linux 3 (RHEL3).
You are using IBM® Informix® Dynamic server (IDS) on on Red Hat Linux 3. When you try to allocate more that 1.8 GB (Gigabytes) of shared memory, the following error message appears in the message log file.
13:52:26 shmat: [ENOMEM]: out of available data space, check system memory parameters (e.g. MAXMEM).
This article explains how to enable or disable an Informix Storage Manager (ISM) storage device using the nsradmin command.
Resolving The Problem
Before the ISM server can use a storage device for backup or restore operations, it must be enabled. There may be times when a storage device becomes disabled due to an error; for example, an I/O error on a file system storage device. You can use the nsradmin -c command to either re-enable the storage device once the problem has been corrected, or disable the storage device to prevent it from being used.
BEFORE YOU BEGIN
You need to be root or be listed as an ISM administrator in the output from the command:
You cannot enable or disable a storage device that has an ISM storage volume mounted on it. To view the status of the devices, run the command:
If needed, unmount the storage volume using the command:
ism_op -unmount <device_name>
The ism_show -devices command will show the new enabled/disabled status of the device.
Solution for WISS error during the onbar backup with ISM.
Following an operating system crash or the installation of an operating system patch, IBM Informix Storage Manager (ISM) fails to start and the following error appears in the daemon.log:
09/02/02 07:38:18 nsrd: server notice: started
09/02/02 07:38:19 nsrexecd: Can’t initialize
09/02/02 07:38:19 nsrexecd: SYSTEM error, resource
file /nsr/res/nsrla.res already
in use; check for another copy of
this server already running
09/02/02 07:38:19 nsrexecd: error initializing
09/02/02 07:38:19 nsrmmdbd: error adding btrees to
ss (an invalid slot number)
09/02/02 07:38:19 nsrmmdbd: WISS error, an invalid
09/02/02 07:38:19 nsrd: unable to start nsrmmdbd
09/02/02 07:38:19 nsrd: shutting down
09/02/02 07:38:19 nsrd: successful shutdown
This tutorial explains how to setup and use an SFTP server on CentOS. Before I start, let me explain what actually SFTP represents and what it is used for. Currently, most people know that we can use normal FTP for transferring, downloading or uploading data from a server to client or client to server. But this protocol is getting hacked easily (if TLS is not used) by anonymous intruders as it the ports are wide open to anyone. Therefore, SFTP has been introduced to as another alternative to meet the main purpose to strengthen the security level.
SFTP stands for SSH File Transfer Protocol or Secure File Transfer Protocol. It uses a separate protocol packaged with SSH to provide a secure connection.
For this tutorial, I am using CentOS 7 in the 64bit version. The same steps will work on CentOS 6 as well. The tutorial result will show how a client can be provided with access to the SFTP server but unable to login to the server itself by SSH.
Unlike normal FTP, there’s no need to install additional packages in order to use SFTP. We just require the prebuild SSHd package that got already installed during installation on the server. Therefore, just check to confirm if you already have the required SSH package. Below are the steps:
rpm -qa|grep ssh
The output should be similar to this:
[root@localhost ~]# rpm -qa|grep sshlibssh2-1.4.3-10.el7_2.1.x86_64openssh-7.4p1-13.el7_4.x86_64openssh-server-7.4p1-13.el7_4.x86_64openssh-clients-7.4p1-13.el7_4.x86_64
That’s all, now we’ll go on how to make the SFTP configuration.继续阅读