1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OpenVzで動かすNFSサーバ(unfsd)

Last updated at Posted at 2014-03-03
/etc/exports
/var/log 192.168.11.0/24(ro,async,no_root_squash)
/tmp 192.168.11.0/24(ro,async,no_root_squash)
syntaxチェック
$ /usr/sbin/unfsd -T
  • 何も出力されなければOK
unfsd起動
$ sudo service portmap start
$ sudo /usr/sbin/unfsd
/etc/rc.localにスタートアップ登録
/usr/sbin/unfsd -T && runuser -l root -c "/usr/sbin/unfsd"

設定ファイル作った

puppet
class unfs3::centos5() {
  package { ['unfs3']:
    ensure => installed,
  }
  service { 'portmap':
    ensure => running,
    enable => true,
  }
  file { '/etc/exports':
    owner  => 'root',
    group  => 'root',
    mode   => 644,
    notify  => Reload['unfs3'],
    source => "puppet:///etc/exports";
  }
  file { '/etc/init.d/unfs3':
    owner  => 'root',
    group  => 'root',
    mode   => 755,
    source => "puppet:///etc/init.d/unfs3";
  }
  file { ['/etc/rc0.d/K86unfs3',
          '/etc/rc1.d/K86unfs3',
          '/etc/rc2.d/S14unfs3',
          '/etc/rc3.d/S14unfs3',
          '/etc/rc4.d/S14unfs3',
          '/etc/rc5.d/S14unfs3',
          '/etc/rc6.d/K86unfs3']:
    ensure => link,
    target => '/etc/init.d/unfs3',
  }
  reload { 'unfs3':
    command => '/usr/sbin/unfs3 -T && /etc/init.d/unfs3 restart',
  }
}
/etc/init.d/unfs3
# !/bin/sh

unfsd_configtest() {
  if [ ! -r /etc/exports ]; then
    exit
  elif ! grep -v -e '^#' -e '^$' /etc/exports | grep -q '/' ; then
    exit # no uncommented shares in /etc/exports
  fi
  if [ -x /usr/sbin/unfsd ]; then
    /usr/sbin/unfsd -T
  fi
}

unfsd_start() {
  unfsd_configtest

  echo -n "Starting UNFS server daemon(s):"

  if [ -x /sbin/portmap ]; then
    if ! ps axc | grep -q portmap ; then
      echo -n "  /sbin/portmap"
      /sbin/portmap
    fi
  
    if [ -x /usr/sbin/unfsd ]; then
      echo "  /usr/sbin/nfsd"
      /usr/sbin/unfsd
    fi
  else
    echo "WARNING:  Cannot start RPC portmapper daemon needed for UNFS."
    echo "          /sbin/portmap (a required daemon) is not executable"
    echo "          or is not present on your system."
    echo
  fi
}

unfsd_stop() {
  echo "Stopping UNFS server daemon..."
  killall unfsd 2> /dev/null
  sleep 1
  killall -9 unfsd 2> /dev/null # make sure :)
}

unfsd_restart() {
  unfsd_stop
  sleep 1
  unfsd_start
}

case "$1" in
'start')
  unfsd_start
  ;;
'stop')
  unfsd_stop
  ;;
'restart')
  unfsd_restart
  ;;
'configtest')
  unfsd_configtest
  ;;
*)
  echo "usage $0 start|stop|restart|configtest"
esac
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?