FTPサーバーを利用したファイル共有

以下のテキストは、執筆時当時の情報を元に書いたものであり、 現在の情勢にそぐわないことを含む場合があるので注意されたい。 また、テキストは最終提出原稿で校正を経る前のものなので、実際にUNIXUSER 本誌に記載されたものとは異なる。誤字脱字等そのままである。

致命的な誤り以外は加筆修正等は行なわないので情報の鮮度に気をつけつつ 利用して欲しい。

目次

註: 本記事は当初Part2として執筆したが前後の記事のバランスを 考えてPart3として掲載された。


Part II 



UNIXFAQ

	?
















(
)
	
	












()



 RAID-1 

RAID-1
HDD



()



/


(HDD)






1
1%21
20.01%
HDD

2HDD


HDD RAID-1 RAID(Redundent Array
of Independent/Inexpensive Disks) 
 RAID-0, RAID-1, RAID-3, RAID-4, RAID-5, RAID-0+1, ... 
 RAID-1 


RAID-1 
 
----[  RAID-1]-----------------------------------------

         ABCDE  ()
            
            
      __   __
     /  \         /  \ 
    |\__/|       |\__/|
    |    |       |    |
    | A  |       | A  |
    |    |       |    |
    | B  |       | B  |
    | C  |       | C  |
    | D  |       | D  |
    |    |       |    |
    | E  |       | E  |
    |    |       |    |
     \__/         \__/ 
-------------------------------------------------------------------------

RAID

	* Hardware RAID
	  RAID
	  
	  

	* Software RAID
	  OSRAID
	  UNIX
	  HDD
	  Hardware RAID 
	  OSRAID
	  

 RAID 
Hardware RAIDSoftware RAID 
DiskSuite(Solaris), RAIDframe(NetBSD, OpenBSD), ccd-driver(NetBSD,
FreeBSD, OpenBSD), vinum(FreeBSD), raidtools(Linux 2.4, etc.) 

 
RAID-1 


----[ 1 ccd-driver  RAID-1]-----------------------------------

NetBSD, FreeBSD, OpenBSD PC-UNIX
 ccd - Concatenated Disk Driver 


ccd() 
virtual disk ccd

	* ()
	* ()
	* 

 

(
)
----[    ]-----------------------------------

         ABCDE  ()
            
                                                 ()
      __   __                                 ____
     /  \         /  \                               /    \
    |\__/|       |\__/|                             /      \
    |    |       |    |  (      )        |\      /|
    | A  |       |    |  ()        | \____/ |
    |    |       |    |                          |        |
    |    |       | B  |                            |   A    |
    | C  |       |    |                            |   B    |
    |    |       | D  |                            |   C    |
    |    |       |    |                            |   D    |
    | E  |       |    |                            |   E    |
    |    |       |    |                             \      /
     \__/         \__/                               \____/
-------------------------------------------------------------------------

ccd-driver

ccd ccd-driver config

           pseudo-device  ccd  4    # concatenated disk devices

FreeBSD(4.x)ccd


IDE
IDEIDE

disklabel(8) HDD
 /dev/wd1e, /dev/wd2e 

 /etc/ccd.conf 


	# /etc/ccd.conf
	# Configuration file for concatenated disk devices

	# ccd           ileave  flags   component devices
	ccd0            64      6	/dev/wd1e /dev/wd2e

flags 0x4 (C1-1)

 [C1-1 ccdconfig(8)flags]
           CCDF_SWAP      0x01      Interleave should be dmmax
           CCDF_UNIFORM   0x02      Use uniform interleave
           CCDF_MIRROR    0x04      Support mirroring
           CCDF_PARITY    0x08      Support parity (not implemented yet)



	# ccdconfig -C

ccd0 /dev/ccd0 

/dev/ccd0c  newfs 

ccd0 disklabel

8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  c: 58879232        0    unused        0     0         # (Cyl.    0 - 28749*)
  e:  2032622        0    4.2BSD     1024  8192    16   # (Cyl.    0 - 992*)
  f: 12195738  2032622    4.2BSD     1024  8192    16   # (Cyl.  992*- 6947*)
  g: 44650872 14228360    4.2BSD     1024  8192    16   # (Cyl. 6947*- 28749*)

ccd0(58879232blocks=28GB)
 ccd0e(990MB), ccd0f(6GB), ccd0g(21GB) 


ccd

HDD


2(wd2)


 /etc/ccd.conf 

	# ccd           ileave  flags   component devices
	#ccd0           64      6	/dev/wd1e /dev/wd2e
	ccd0            64      2	/dev/wd1e

flags4
 /dev/wd2e ccd.conf 

   	# ccdconfig -C 
	# mount /dev/ccd0c /mnt





HDDccd0
ccd-driver 

ccd0
ccd0DiskSuitevinum



 Software RAID 
HDD
2


--[ 1 ]--------------------------------------------------------







	* 
	* MOCD-R(W)
	* HDD

MOCD-R



HDD


  
  
  dump/restore, tar 
  

    

    
    mt(1)man page
     

----[  ]------------------------------
			(raw)
	*BSD			/dev/rst*, /dev/nrst*
	CAMFreeBSD	/dev/rsa*, /dev/nrsa*
	Linux			/dev/st*,  /dev/nst*
	SunOS 4.x		/dev/rst*, /dev/nrst*
	SunOS 5.x		/dev/rmt/*, /dev/rmt/*n
----------------------------------------------------------------------

    n
    
    
    n
    (No rewind)
    n
    

    
    dump/restoretar
    
    
    mt
    

     /dev/nrst0 3
    

	(/bin/sh)
	# TAPE=/dev/nrst0
	# export TAPE
	# mt fsf 3

    mtTAPE
    mtmt
     
----[  mt]------------------------------
			
	rewind			
	fsf N			N
	bsf N			N
	asf N			
	offline			
	erase			
----------------------------------------------------------------------

    erase
     C-c 
    

    dump/restore
    dump
    
    
    
    

	# dump 0Buf (KB) /dev/nrst0 /home

----[  dump]------------------------------
			
	-0 .. -9		
	-B R			(-b)
	-b B			B(kilobytes)
	-f FILE			
	-u			
----------------------------------------------------------------------

    0
    0
    
    
    (-B)
    
    
    
    ()
    
    
    FreeBSDdump
     -a 
    

    dumprestore
    

	# restore rf /dev/nrst0

    
    restore(8)man page
    

    tar
    tartarTAPE
    
    

    	(/bin/sh)
	# TAPE=/dev/nrst0
	# export TAPE
	# cd /
	# tar cv /home

    /home  /dev/nrst0 
    tarx
    

    	# mt rewind
	# tar xvp

    
    
    
    

	# tar cv

    
    (:cxqwerty
    )

  HDD

  
  DDS4
  1
  DDS41
  
  IDE
  
  IDE
  100GB(7200rpm)380GB(5400rpm)2
  
  
  

    HDD

    HDD
    
    
    
    (/home)(/mirror/home)
    ()/mirror/home 
    NFS

----[ ]--------------------------------------------------------------
 +-------------- host-1 ----------------+
 |                (/)                   |
 |   +-------+-----+---+-------+        |
 | (/etc)  (/home)  (/usr)   (/mirror)  |
 |             \                +---+   |
 |              (home)|
 +---------------------------------------              
-------------------------------------------------------------------------

     /home  /mirror/home 
    
     /home 
    /mirror/home 
    3.5
    12
    

    
    (
    )
    
    
    
    
     /mirror/home
    

    2
    
    3

----[ ]--------------------------------------------------------------
  +-------------------+           +---------------------+
  |       /home       | 5   | /mirror/daily/home  |
  |                   | |                     |
  +-------------------+           +---------------------+
                                    4
  +---------------------+           +---------------------+
  |/mirror/monthly/home | 3   | /mirror/weekly/home |
  |                     | |                     |
  +---------------------+           +---------------------+
-------------------------------------------------------------------------

    
    
     /mirror/daily/home  
    /mirror/weekly/home dailyweekly
    
    1 
    1
    rsync
    
    

    HDD

    
    

	* 
	  
	* 
	  

    MB
    
    
    
    
    cp 
     cp -r 
    
    ()
----[ ]----------------------------------------------------------------
 
 cptar
 man
 UNIX
 
 
---------------------------------------------------------------------------

    
    
     src/ /dest/ (
     /dest/src/ )
    (?)

	* tar

	  
	  .tar  tar pipe
	  

	  # tar cf - src | (cd /dest; tar xvpf -)

	  pipe(|)
	  /destcd
	  tar /dest 
	   src/  tar 
	  UNIX/usr/local 
	  tarpipe
	  

	* GNU tar

	  PC-UNIX tar  GNU tar 
	  
	  

	  # tar -cf - src --atime-preserve | tar -xvpf - -C /dest

	  --atime-preserve atime(
          )
          
           --atime-preserve 
          pipegtar -C 
           /dest 
          src/ 

	  --one-file-system 
	  (
	  )
	  

	  # tar -zcf rootfs.tar.gz -C / . --one-file-system

	   rootfs.tar.gz 
	  --one-file-system 1
	   l 

	* GNU cp

	  GNUcpcp
	  GNU tar 
	   --one-file-system 
	  
	  

	  # cp -a src /dest

	   -a (archive)

	* rsync

	  
	  
	  

	  # rsync -aH src /dest

    
    
    
     GNU cp rsync
    

	* GNU cp

	   -a  u 
	  

	  # cp -auf src /dest

	  freadonly (force 
	  )
	  tar  GNU cp 
	  ()
----[ ]----------------------------------------------------------------
 GNU cptar
 
---------------------------------------------------------------------------
	  
    GNU cp 
    rsync

	* rsync

	  
	  
	  

	  # rsync -auH --delete src /dest

	  

    

    
    cron
    

    

	*  tar 
	*  rsync 

    

     tar 

    /etc 
    
    cvs
    
     tar 
    

    tar.gz
     tar.gz 
    
    ( )
----[ ]--------------------------------------------------------------
 etc.tar.gz
 etc.tar.gz
 2etc.tar.gz
 3etc.tar.gz
 4etc.tar.gz
 5etc.tar.gz   5
 6etc.tar.gz   !
     :
-------------------------------------------------------------------------

    syslog
    
    /var/log/messages 
    /var/log/messages.0.gz 
    messages.0.gz  messages.1.gz messages.1.gz  messages.2.gz 
    3
    
    

	* 
	* 
	  ()
	* 
	  
	* 
	  

    
    
    /etc 
     

----[ ]--------------------------------------------------------------
     1	#!/bin/sh
     2	# /etc 
     3	# tar.gz /mirror/systemfiles/ 
     4	umask 077
     5	today=`date '+%Y%m%d'`
     6	backupdir=/mirror/systemfiles/
     7	
     8	# 
     9	cd /
    10	tar vzcf $backupdir/etc-$today.tar.gz etc
    11	
    12	# 01
    13	find $backupdir -name 'etc-*01.tar.gz' -exec touch '{}' \;
    14	
    15	# 5
    16	find $backupdir -atime +5 -exec rm '{}' \;
-----------------------------------------------------------------------------

     /etc 
     /mirror/systemfiles/ 
    
     
    

     /etc kernelkernel config
    LAN
    

     rsync 

     2
    rsync

----[ ]--------------------------------------------------------------
  +-------------------+       +---------------------+
  |       /home       | 5   | /mirror/daily/home  |
  |                   | |                     |
  +-------------------+           +---------------------+
                                    4  
                                  +---------------------+
                                  | /mirror/weekly/home |
                                  |                     |
                                  +---------------------+
-------------------------------------------------------------------------

    
    23
     crontab 
    

	#minute hour    mday    month   wday    who     command
	#
	0	5	*	*	*	root	/etc/backup-1
	#
	0	4	*	*	*	root	/etc/backup-2

    /etc/backup-1, /etc/backup-2 

	--[/etc/backup-1]--------------------------------------------
	#!/bin/sh
	PATH=$PATH\:/usr/local/bin
	rsync -auvH --delete /home /mirror/daily

	--[/etc/backup-1]--------------------------------------------
	#!/bin/sh
	PATH=$PATH\:/usr/local/bin
	rsync -auvH --delete /mirror/daily/home /mirror/weekly


  

  
  
  
  
  
  

  
  
  
  
  
  
  

  firewall 
  WWWGlobal IP
  WWW
  
  

### Private IP Network  Global Zone www
###

    NFS

    NFS
    
    

----[  NFS]------------------------------------------------
 +----------- File Server --------------+
 |                (/)                   |
 |   +-------------+------+-----------+ |    +------- Backup Server -------+
 |                        |             |    |           (/)
 |                    (/home) ||   +------+-----+
 |                    export            |    | (/mnt)       (/mirror)
 |                                      |    |             -+---+-----
 |                                      |    |            (home) 

fileserver:/home  backupserver:/mnt mount
 backupserver:/mirror/home 
-----------------------------------------------------------------------------

    
    

	* 
	* File Server export
	* Backup Server  readonly 
	  (File Serverreadonly)

    NFS
    

    rsync

    NFS
    rsync

    rsync  rsh 
    -essh ssh 
    
    SSH
    cron
    

	* (sv) sv:/home 
	  (mi) mi:/mirror/sv/home 
	  

     

----[ ]--------------------------------------------------------------
        sv                                mi
  +-------------------+           +---------------------+
  |       /home       |  rsync    | /mirror/sv/home     |
  |                   | |                     |
  +-------------------+           +---------------------+
 sv /home  mi  /mirror/sv/home rsync

-------------------------------------------------------------------------
    SSHOpenSSH 2.x 

    rootmisvroot
    mi root RSA
     /etc/sshd_config 
    PermitRootLogin 

	------[  mi  /etc/sshd_config]------
	# PermitRootLogin
	PermitRootLogin	without-password

    without-password 
    /etc/passwdRSA(
    DSA)
----[ ]--------------------------------------------------------------
sshd(8)PermitRootLogin nossh
RSAroot

without-password 
-------------------------------------------------------------------------

    miRSAsvroot
    rootssh-keygen 
    -f  svmi_rsaid 

	sv# ssh-keygen -f ~/.ssh/svmi_rsaid
	Generating RSA keys:  Key generation complete.
	Enter passphrase (empty for no passphrase): 
	Enter same passphrase again: 
	Your identification has been saved in /root/.ssh/svmi_rsaid.
	Your public key has been saved in /root/.ssh/svmi_rsaid.pub.
	The key fingerprint is:
	12:34:56:78:9a:bc:de:f0:12:34:56:78:9a:bc:de:f0 root@sv

    root
     /root /root/.ssh/svmi_rsaid.pub RSA
    mi ~root/.ssh/  authorized_keys 
    svmirootRSAauthentication 
    

	sv# ssh -i ~/.ssh/svmi_rsaid mi
	Last login: Sat May 26 21:10:12 2001
	Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
        The Regents of the University of California.  All rights reserved.
	FreeBSD 4.3-RELEASE (mi) #1: Thu May 24 00:34:54 JST 2001

     sv 
    /etc/passwd
    

	*  mi:~root/.ssh/authorized_keys 
	* misshd(sshd_config)  RSAAuthentication 
	  

    

     rsync 
    

	sv# rsync -e 'ssh -i /root/.ssh/svmi_rsaid' -auvzH --delete \
	    /home mi:/mirror/sv/home

    ()
    (2)
    
	----[/etc/svmi-backup.sh]-------------
	#!/bin/sh
	PATH=$PATH\:/usr/local/bin \
	RSYNC_RSH="ssh -i $HOME/.ssh/svmi_rsaid" \
	rsync -auvzH --delete /home mi:/mirror/sv/home

    cron

	#minute hour    mday    month   wday    who     command
	0	3	*	*	*	root	/etc/svmi-backup.sh

    3 sv  mi 
    rsync-z()
    2GB128kbps
    xDSLLAN
    rsync
    

----[ 2 ?]--------------------

 sv  mi ssh


misvmisv
root
root


svRSAmi 
~root/.ssh/authorized_keys 
miroot
svrootroot
miroot
svroot
RSAsvroot
RSA



rsync
cron


rsync --password-file 

root



 ssh-agent 
 ssh-agent 
svmi
 Tips OpenSSH 2.x 


  1. svmi RSA Key ( ssh-keygen -p 
     )

  2. ssh-agent ssh-add svmi 
       sv# eval `ssh-agent`
       sv# ssh-add ~/.ssh/svmi_rsaid
     

  3. () ssh-agent svmi_rsaid  RSA key 
      SSH_AUTH_SOCK 
      rsync [C-2-1]

---[ C-2-1]-----------------------------------------------------
#!/bin/sh
SSHsockprefix=/tmp/ssh		# ssh-agent socket file prefix()
ReportTo=root			# ssh-agent
dotsshdir=/root/.ssh/		# ~root/.ssh 
# ~root/.ssh/svmi_rsaid.pub fingerprint
svmi_id=`awk '{print $3}' $dotsshdir/svmi_rsaid.pub|head -1`
PATH=/usr/local/bin:$PATH

setSocket () {	# $1fingerprintagent
  patn="$1"
  SSH_AUTH_SOCK=''
  socks=`echo ${SSHsockprefix}*/*agent*`
  case $socks in
    *\*) ;;
    *)
      for socket in $socks; do
	if SSH_AUTH_SOCK=$socket ssh-add -L | fgrep $patn > /dev/null; then
	  SSH_AUTH_SOCK=$socket
	  export SSH_AUTH_SOCK
	  return
	fi
      done
      ;;
  esac
}

# setSocket() $SSH_AUTH_SOCK 
setSocket "$svmi_id"

if [ ${#SSH_AUTH_SOCK} = 0 ]; then
  # ssh-add
  cat <<_EOM_ | Mail -s "DNS sync failure" $ReportTo
Hi, this is /home rsyncer on `hostname`.
Authorized keys not registered in ssh-agent.
Please invoke ssh-agent with identity keys.

 # eval \`ssh-agent\`
 # ssh-add /root/.ssh/svmi_rsaid
_EOM_
  exit 1
fi

# for debug
## ssh-add -l; ssh mi w
# SSH_AUTH_SOCKrsync
rsync -auvzH --delete -e ssh /home mi:/mirror/sv
----------------------------------------------------------------------

(^^;)

  * mi sshd_config sshd
  * sv
    (tcp_wrappers
     sshd)
  * root@svmiroot
    (svmirror )
  * misudosvmirror rsync NOPASSWD 
     sudoers 
	(sudoers:)
	svmirror	mi= NOPASSWD: /usr/local/bin/rsync
  * sudorsync
	( /etc/sudorsync)
	#!/bin/sh
	exec /usr/local/bin/sudo /usr/local/bin/rsync "$@"
  * mi ~svmirror/.ssh/authorized_keys  sv rootRSAkey
  * sv 
       rsync -e 'ssh -l svmirror -i /root/.ssh/svmi_rsaid' \
	     --rsync-path=/etc/sudorsync \
	     -auvzH --delete /home mi:/mirror/sv
    

sv


root
WWWwww


----[ 2 ]---------------------------------------------------


yuuji@gentei.org
Fingerprint16 = FF F9 FF CC E0 FE 5C F7 19 97 28 24 EC 5D 39 BA
HIROSE Yuuji - ASTROLOGY / BIKE / EPO / GUEST BOOK / YaTeX [Tweet]