How to turn off linux ports?

2006年8月22日 20点44分 没有评论

In some Linux distributions, there is a file named “/etc/inetd.conf”. inetd is such a procession that monitors the requirement from the network,and call the corresponding program to done with them. “inetd.conf” tells the inetd procession which ports should be listened, and what service should be started for these using ports.

So, we could turn off the ports just adding “#” before the line indicated the port in “inetd.conf” file. and then send out “SIGHUP” to inetd. For all doing:
1. # chmod 600 /etc/inetd.conf
2. idenfity the owner is root:
# stat /etc/inetd.conf
3. # vi /etc/inetd.conf
4. # killall -HUP inetd
after the above steps, we must set the “inetd.conf” to be un-changed.
5. $ chattr +i /etc/inetd.conf

Check the local network setting:
# cat /etc/sysconfig/network

分类: 科技 标签:

TX/RX, byte and bit, /etc/hosts

2006年8月22日 20点31分 没有评论

Issue the ifconfig command, the output line will contain the string “TX” and “RX”.
Here “T” means transmit, and “R” is receive.

Difference between byte and bit:
1 byte = 8bit
1 kilobyte = 2^10 bytes = 1024 bytes
1 megabyte = 2 ^20 bytes = 1,048,576 bytes
1 gigabyte = 2 ^ 30 bytes = 1,073,741,824 bytes

when letter “b” is used to indicate capacity, it is byte; when the letter “b” descripts speed or transfer rate, it is also bit.
for example,
80GB harddisk, here “B” is byte.
1Gbps Network device, “b” is bit.

/etc/hosts: as the system start up, it will require some hosts’ name in /etc/hosts before doing the same thing through DNS service.
for example:
# cat /etc/hosts
IP ADDRESS HOSTNAME ALIAS
192.168.123.32 Phillip

分类: 科技 标签:

copy ext2 files to reiserfs

2006年8月17日 9点15分 没有评论

Just image,there are two machines which are connected to each other through network device. One is install RH9.0, and the other is SuSE 9.0 which used reiserfs formation.

If data are transferring from RH9.0 machine to SuSE by NFS service, it also means copying ext2 to reiserfs formations.

As we all know, reiserfs has log information acts more powerful than ext2, so I think reiserfs has larger storage space than ext2.

The question is, what’s happening when transfer between ext2 and reiserfs? Does the data file in ext2 be re-written to reiserfs formation?

It only sees it as a file. It doesn’t matter what file system that are used. It will place the files on the drive and add any information that it needs to for reiserfs. The same can be said if you were copying from reiserfs to ext2. It would just place the files on the drive without the extra information.

It will be fine to just copy it over. I have never heard of it causing any trouble and don’t see how it could really. This would not work if you were using dd though.

I’ve ever heard of that copy files from Linux(ext2) to MS-Windows directory(NTFS) through smb service, it could be atteched more extra information, does this matter the data integration?

Permissions and ownerships differ, nothing else. Those aren’t kept IN the file, though, but in a separate area of the file-system. As far as the file-content goes, this is completely file-system and transport agnostic. There’s no piece of ext2 coming to your reiser partition, and NTFS won’t pollute ext2.

分类: 科技 标签:

How does this RAID 0 work?

2006年8月17日 9点13分 没有评论

I used two IDE harddisks(one is ST 40G’/dev/hdb’,and the other is WD 120G’/dev/hdc’) to build soft RAID 0 on Linux.As I read from book,RAID 0 is a striping array which data will be written to the disks in sequence,that’s also what call it “stripe”. This array should be idenfied by the smallest disks capacity for spreading data in stripe mode. So, I think the capacity of RAID0 is equal to twice of smallest one. In the way, my soft RAID0 should be 80G(2x40G)

The following lines are issued to create RAID0:
# mdadm -C /dev/md0 –level 0 -n /dev/hdb /dev/hdc
# cat /proc/mdstat
Personalities : [raid0]
md0 : active raid0 hdb[0] hdc[1]
159142336 blocks 64k chunks

I found the capacity of my soft raid 0 is 160G.It made me confused,how does RAID0 work as the end of writing over 40G in each disk?

The size of a RAID0 array is equal to the sum of the sizes of the individual volumes. The way the stripes works is that the first 80gigs will be striped between the two drives–resulting in roughly twice the read/write speed of the slower drive. The remaining 80gigs will be on the larger drive only–it will be only as fast as the larger drive.

You don’t really have any control over whether certain files are in the “fast” half or the “slow” half. If you’re particularly concerned about performance, it may make more sense to split the larger drive into multiple partitions–one 40gig partition to RAID0 with the other drive, and one 80gig partition to be “slow” storage.

分类: 科技 标签:

use ‘dd’ to create identified size file

2006年8月17日 9点06分 没有评论

Use ‘dd’ to create identified size file:
# dd if=/dev/urandom of=targerfile bs=1M count=100
Here, the created file size will be the result of ‘bs’ x ‘count’, in other word:
size = bs x count

分类: 科技 标签:

vmstat -n

2006年8月15日 8点57分 没有评论

# vmstat -n

if the ‘vs’ and ‘sy’ values under CPU are high, and the idle time value under CPU is closed to zero. Your server’s CPU is heavily loaded, Try using a faster machine as your NFS server. Do not use a gateway or a terminal server as an NFS or NTS server.

分类: 科技 标签:

cp_cmp testing script and net state monitor

2006年8月10日 9点13分 没有评论

I wrote the following scripts to copy and compare bigfiles:
#!/bin/bash
# test script
# /mnt/bigfile is 150G,and /NFS_test is mounted from remote host
# mount 192.168.123.78:/Test /NFS_test

# set counter
COUNTER=0

# loop
while :
do
# copy local file “a” to remote host “b”,and then cmp
echo “—————————-” >> /root/NFS_Rep/time
echo “cp a–>b from: `date`” >> /root/NFS_Rep/time
cp -v /mnt/bigfile /NFS_test/bigfile1 >> /root/NFS_Rep/cp_ab 2>&1
echo “cp a–>b end: `date`” >> /root/NFS_Rep/time
echo ” ” >> /root/NFS_Rep/time

# sleep time
sleep 60

#starrt cmp
echo “cmp a–>b from: `date`” >> /root/NFS_Rep/time
cmp -l /mnt/bigfile /NFS_test/bigfile1 >> /root/NFS_Rep/cmp_ab 2>&1
echo “cmp a–>b end: `date`”>> /root/NFS_Rep/time
echo ” ” >> /root/NFS_Rep/time

# sleep time
sleep 60

# copy local file “a” to remote host “c”,and then cmp
echo “cp a–>c from: `date`” >> /root/NFS_Rep/time
cp -v /mnt/bigfile /NFS_test/bigfile2 >> /root/NFS_Rep/cp_ac 2>&1
echo “cp a–>c end: `date`” >> /root/NFS_Rep/time
echo ” ” >> /root/NFS_Rep/time

#sleep time
sleep 60

#start cmp
echo “cmp a–>c from: `date`” >> /root/NFS_Rep/time
cmp -l /mnt/bigfile /NFS_test/bigfile2 >> /root/NFS_Rep/cmp_ac 2>&1
echo “cmp a–>c end: `date`” >> /root/NFS_Rep/time
echo ” ” >> /root/NFS_Rep/time

#sleep time
sleep 60

# compare “b” and “c”
echo “cmp b–>c from: `date`” >> /root/NFS_Rep/time
cmp -l /NFS_test/bigfile1 /NFS_test/bigfile2 >> /root/NFS_Rep/cmp_bc 2>&1
echo “cmp b–>c end: `date`” >> /root/NFS_Rep/time
echo “—————————-” >> /root/NFS_Rep/time

# delete “b” and “c”
rm -rf /NFS_test/bigfile1
rm -rf /NFS_test/bigfile2

# reset the counter
COUNTER=`expr $COUNTER + 1`
echo “The loop counter is $COUNTER” > /root/NFS_Rep/counter.rep
done

This script would create 7 report files in /root/NFS_Rep directory: cp_ab,cmp_ab,cp_ac.cmp_ac,cmp_bc,counter.rep,time.
Note,I’ve made some mistakes when wrote $ as &, and the cmp showed error when it had taken a very long time to complete copy bigfile(150G), how sadly I am! This issue gave me a good lesson, it was better to use small files to test the scripts beforn running it in order to checking the code and saving time. Late, I modified the script again with adding “date” marks.

Due to the network configuration of “192.168.123.78” changed automatically in the day before yesterday, I was very caring the remote host’s net state, so writing the following script:
# !/bin/bash
# test 192.168.123.78
while :
do
if ping -c 1 192.168.123.78 > /dev/null 2>&1
then
echo “At `date` : The status:192.168.123.78 is ok” > /root/net_report
sleep 300
else
echo “At `date` : Warning, the remote host maybe lost!!!” >> /root/net_report
wall “Warning, the remote host 192.168.123.78 maybe lost!!!”
fi
done

This script will monite the remote host’s network, and create report.

分类: 科技 标签:

mount Soft RAID when restart system

2006年8月9日 13点11分 没有评论

In the morning, I rebooted my computer, and found soft raid 0 made yesterday had been unavailable.Even I tried the steps like yesterday doing, but the RAID still could not be rebuild.

Later,More tell me using the following command to remount the RAID:
# mdadm -A /dev/md0 /dev/hdb /dev/hdc
and then check the /proc/mdstat, yes, not only the RAID was found but also, all the date on the RAID are still here!

RAID has two forms, striping and partity.In fact,RAID 0 was not really RAID because it isn’t redundant. RAID has good write and read performance. There are two important parameters: Strip, and chunk size. Strip means the whole array’s transfer rate per second, which is always used by hardware controllers. Chunk size,belong to Linux kernel, is the single disk’s rate.

RAID1 is mirroing, good read performance nearly twice of the single one, but not good at writing performance for writing data to two disks at time.RAID 2,RAID3 are useless, and RAID 4 just like RAID 5,which has one dedicated disk to save paritition information.

分类: 科技 标签:

Make soft RAID on linux and create big file

2006年8月8日 9点05分 没有评论

For we want to test big file transation in NFS, Spring gave me two IDE harddisk and ask me to install them in my computer which os is centos4.3. There were some trouble during the recognizing harddisk, only two IDE harddisks could be found, the other one disappeared even I changed the jumps. I feel a litter disappointed but not gave up. I put the “disappear” harddisk in the primary IDE connectors, it was recognize rightly! What’s wrong?

I looked at the mainboard carefully, then found that this board has four IDE connectors:Primary IDE,Slave IDE, Primary RAID IDE and Slave RAID IDE,I just put the third harddisk in the Slave RAID IDE slot! After changed the cable to slave IDE slot, everything is ok. The system found three harddisk as I wanted.

How to make soft RAID on linux?
First I downloaded RAID tools(raidtools), and edited the /etc/raidtab file as the following:
[root@localhost ~]# vi /etc/raidtab
raiddev /dev/md0
raid-level 0
nr-raid-disks 2
chunk-size 32
persistent-superblock 1
device /dev/hdb
raid-disk 0
device /dev/hdc
raid-disk 1
and then issued the “mdraid /dev/md0”, note, “/dev/md0” had been created when installed the “raidtools” package.It failed with some error messages which said /dev/hdb had been part of RAID? Why? My second IDE harddisk was just taken in the computer! Later, More explained that perhaps the system created /dev/hdb automaticlly when I installed the Centos 4.3. I’m still confused with what he said.

Other way to make soft RAID was the “mdadm” program, downloaded from Internet,and installed it.Then I used the following steps to create soft RAID 0 successfully:
# cat /proc/partitions Checking HD partitions
# cat /proc/mdstat Checking RAID stat
# ls /dev/mapper
# dmsetup lower level logical volume management
# dmsetup table
# dmsetup remove pdc_jbaiadif remove /dev/hdb
# mdadm -C /dev/md0 –lever 0 -n /dev/hdb /dev/hdc (After issuing this step, there was still error saying /dev/hdb had been used as RAID, so I planed to stop RAID first)
# mdadm /dev/md0 –stop
Then,create RAID again:
# mdadm -C /dev/md0 –lever 0 -n /dev/hdb /dev/hdc
OK, the RAID 0 was created successfully.

How to create very large file by “dd” command?
Since I made RAID 0 to merge two harddisk’s capacies together(150G), I wanted to create a big file as large as 150G.
First, format the RAID partition and mount it to /mnt:
# mkfs /dev/md0
# mount /dev/md0 /mnt
Second, using “dd” command to create file:
# dd if=/dev/urandom of=targetfile_name
A large file would be created when full of the /mnt capacity.

分类: 科技 标签:

Good bye, Shenzhen

2006年7月30日 6点33分 没有评论

Good bye, Shenzhen.
I’ll always return.

分类: 生活 标签: