LoginSignup
2
2

More than 5 years have passed since last update.

SmartOS Tips

Last updated at Posted at 2014-05-02

運用してるのでナレッジのメモ

パッケージ管理

pkgin コマンドを導入する
http://wiki.smartos.org/display/DOC/Installing+pkgin

# cd /
# curl -k http://pkgsrc.joyent.com/sdc6/2012Q2/x86_64/bootstrap.tar.gz | gzcat | tar -xf -
# pkg_admin rebuild
# pkgin -y up

munin 導入

この方法たぶん外道
Global zone にいれるためには pkgin からの munin インストールじゃだめ(munin ユーザ追加できないから)
perl, cpans, gmake があれば OK

# pkgin in gmake perl
# ln -s /opt/local/bin/gmake /opt/local/bin/make
# cpan HTML::Template Log::Log4perl Net::Server Net::Server::Fork Net::CIDR

munin 最新版おとしてくる

# mkdir -p /opt/local/src
# cd /opt/local/src
# wget http://sourceforge.net/projects/munin/files/latest/download?source=files
# tar zxvf munin-2.0.11.1.tar.gz
# cd munin-2.0.11.1

Makefile.config を少し書き換え

#
# the base of the Munin installation.
#
PREFIX     = /opt/local


# Where Munin keeps its configurations (server.conf, client.conf, ++)
CONFDIR    = /opt/local/etc/munin

# Where to put internal binaries and plugin repository
LIBDIR     = $(PREFIX)/lib/munin

# Location of PID files and other statefiles. On the server, must be
# writable by the user "munin".
STATEDIR   = $(DESTDIR)/var/run

# User to run munin as
USER       := root
GROUP      := root

# Default user to run the plugins as
PLUGINUSER := root


# Default user to run the cgi as
CGIUSER := root

# bash にしないと各 plugin が local 組み込み関数を使えなくてエラーログはきまくる(一応動くけどきもちわるい)
#GOODSH     := $(shell PATH=`getconf PATH 2>/dev/null || echo $(PATH)` LANG=C sh -c 'type sh | sed "s/.* //"')
GOODSH      := /bin/bash

make してインストールと初期設定

# make
# make install-common-prime install-node-prime install-plugins-prime
# vi /opt/local/etc/munin/munin-node.conf
    # set access controls
# munin-node-configure --shell | sh -x

svnadm 用にファイル準備

# mkdir -p /opt/custom/smf
# cat /opt/custom/smf/munin-node.xml

<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
  <service name='network/munin-node' type='service' version='0'>
    <create_default_instance enabled='true'/>
    <single_instance/>
    <exec_method name='start' type='method' exec='/opt/local/sbin/munin-node' timeout_seconds='0'>
      <method_context/>
    </exec_method>
    <exec_method name='stop' type='method' exec=':kill' timeout_seconds='0'>
      <method_context/>
    </exec_method>
  </service>
</service_bundle>

あとは取り込んでサービス化

# svccfg -v import /opt/custom/smf/munin-node.xml
svccfg: Taking "initial" snapshot for svc:/network/munin-node:default.
svccfg: Taking "last-import" snapshot for svc:/network/munin-node:default.
svccfg: Refreshed svc:/network/munin-node:default.
svccfg: Successful import.

# svcadm disable network/munin-node
# svcadm enable network/munin-node

thanks

プラグイン

disk, memory 監視は munin-exchange から拾ってきたやつつかう

# cd /opt/local/lib/munin/plugins
# curl --insecure -O https://raw.github.com/munin-monitoring/contrib/master/plugins/zfs/zfs_usage_
# curl --insecure -O https://raw.github.com/munin-monitoring/contrib/master/plugins/system/solaris-memstat

# chmod +x /opt/local/lib/munin/plugins/zfs_usage_ 
# chmod +x /opt/local/lib/munin/plugins/solaris-memstat

# cd /opt/local/etc/munin/plugins

# ln -s /opt/local/lib/munin/plugins/zfs_usage_ zfs_usage_zones
# ln -s /opt/local/lib/munin/plugins/solaris-memstat solaris-memstat

ゲストの IP 変更

普通にゲスト OS 内の IP 設定を変更しただけではだめ。

# vmadm get XXXXXXXXXXXXXXXXXX | json nics
# cat updatenic.json
{
    "update_nics": [
        {
            "mac": "XXXXXXXXXXXXXX",
            "ip": "XXX.XXX.XXX.XXX"
        }
    ]
} 
# cat updatenic.json |  vmadm update XXXXX

thanks http://wiki.smartos.org/display/DOC/Using+vmadm+to+manage+virtual+machines

コマンドメモ

Linux とちょっと違うので

用途 補足
システムを落とす shutdown -y -g0 -i5 -g = 実施ディレイ秒, -i = ランレベル(5だと落とす)
ifconfig dladm show-phys Link Aggregation もこれでやるっぽい
top prstat
設定値更新 vmadm update property=value ...

ディスクのリサイズ

zfs のボリュームサイズを拡張して、gparted の live cd たちあげてリサイズという流れ

# TARGET=47d4ee79-fa6f-499f-afd8-5c6ff0fff05e


# zfs get volsize zones/${TARGET}-disk0
# zfs set volsize=80g zones/${TARGET}-disk0
# zfs get volsize zones/${TARGET}-disk0


# curl -L -o gparted-live-0.14.1-6.iso http://downloads.sourceforge.net/project/gparted/gparted-live-stable/0.14.1-6/gparted-live-0.14.1-6-i486.iso?r=http%3A%2F%2Fgparted.sourceforge.net%2Fdownload.php&ts=1356867356&use_mirror=jaist
# cp gparted-live-0.14.1-6.iso /zones/${TARGET}/root/

# vmadm boot ${TARGET} order=cd,once=d cdrom=/gparted-live-0.14.1-6.iso,ide
# vmadm info ${TARGET} vnc

VM マイグレーション

移行元でスナップショットをとって転送

zfs snapshot -r zones/${UUID}@migration
zfs snapshot -r zones/${UUID}-disk0@migration
zfs send -R zones/${UUID}@migration  | ssh root@192.168.0.100 zfs recv zones/${UUID}
zfs send -R zones/${UUID}-disk0@migration  | ssh root@192.168.0.100 zfs recv zones/${UUID}-disk0
scp /etc/zones/${UUID}.xml root@192.168.0.100:/etc/zones/

移行先で vm リストに追加

# echo "${UUID}:installed:/zones/${UUID}:${UUID}" >> /etc/zones/index
# vmadm boot ${UUID}

移行元を後始末

# vi /etc/zones/index // リストから消す
# zfs destroy -r zones/${UUID}
# zfs destroy -r zones/${UUID}-disk0

頻繁にマイグレを行う場合はスナップショットの取り扱いに注意
誤って古いもので上書きしてしまう恐れ有り

初期ブートから VNC 接続まで

zones の ${UUID}/root/ 配下に ISO こぴーしてから boot & vnc ポート確認

# vmadm boot ${UUID} order=cd,once=d cdrom=/CentOS-6.3-x86_64-minimal.iso,ide
# vmadm show vnc

外からやってるときは OSX のローカルから SSH ポートフォワーディングつくって接続

% ssh -l ${UNAME} -L ${LOCAL_PORT}:${HOST_MACHINE}:${VM_PORT} -i ${KEY} ${DOMAIN}

USB Key のアップデート

何からの OS で USB キーをマウントして、内部の Platform ディレクトリを最新イメージ内の Platform と入れ替えれば OK

mDNSResponder がエラーをはく

コンソールに出てることがあるが無視していい。

mDNSResponder: [ID 702911 daemon.error] ERROR: getOptRdata - unknown opt 4
a) safely ignore these
b) disable multicast dns with "svcadm disable dns/multicast:default"
=85 this is iPhones and iPads and other apple (Bonjour) devices on your 
network waking up and going to sleep all the time, probably.
"Option 4" is bonjour sleep protocol, saying "i'm going to sleep now for a 
bit.  If you really need me, please send a wake-on-lan packet, ok?"  It's 
relatively new, and specific, and a lot of devices running "stock" 
multicast zeroconf dns services don't know about "option 4."
http://www.kdump.cn/forums/viewtopic.php?id=561
2
2
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
2
2