Solarisメモ

sudoの代わりはpfexec
====================
* 現場では`su -`してましたが、`pfexec`コマンドあるんですよ。

ネットワーク設定
====================
* `hostname.インターフェース名` というファイルにIPアドレスを記入する。

```bash:
$ ls -l /etc/hosts
lrwxrwxrwx 1 root root 12 2009-11-08 19:25 /etc/hosts -> ./inet/hosts
```

```bash:
$ cat /etc/hostname.bge0 
192.168.10.191
```

```bash:
$ cat /etc/netmasks
192.168.10.0    255.255.255.0
```

```bash:
$ cat /etc/defaultrouter
192.168.10.1
```

smb.confの場所
====

* /etc/sfw/smb.conf

```bash:
$ pfexec svcadm restart svc:/network/samba:default
```

disk
============

fstabではなくvfstab
----

```bash:
$ cat /etc/vfstab 
#device         device          mount           FS      fsck    mount   mount
#to mount       to fsck         point           type    pass    at boot options
#
/devices        -               /devices        devfs   -       no      -
/proc           -               /proc           proc    -       no      -
ctfs            -               /system/contract ctfs   -       no      -
objfs           -               /system/object  objfs   -       no      -
sharefs         -               /etc/dfs/sharetab       sharefs -       no      -
fd              -               /dev/fd         fd      -       no      -
swap            -               /tmp            tmpfs   -       yes     -

/dev/zvol/dsk/rpool/swap        -               -               swap    -       no      -
```

ソフトウェアRAID
----
現場ではハードウェアRAIDでした。ハードウェアRAIDの状態は`/var/adm/messages`で確認だったか
raidの同期状態がわかります。[zpoolについてはこちら](http://jp.fujitsu.com/platform/server/sparcenterprise/technical/document/pdf/zfs_apply.pdf)

```bash:
$ zpool status
  pool: rpool
 state: ONLINE
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        rpool       ONLINE       0     0     0
          mirror    ONLINE       0     0     0
            c8d0s0  ONLINE       0     0     0
            c9d0s0  ONLINE       0     0     0

errors: No known data errors
```

容量とか
----

```bash:
$ pfexec prtvtoc /dev/rdsk/c8d0s0
* /dev/rdsk/c8d0s0 partition map
*
* Dimensions:
*     512 bytes/sector
*     126 sectors/track
*     255 tracks/cylinder
*   32130 sectors/cylinder
*   60799 cylinders
*   60797 accessible cylinders
*
* Flags:
*   1: unmountable
*  10: read-only
*
* Unallocated space:
*       First     Sector    Last
*       Sector     Count    Sector 
*           0     32130     32129
*
*                          First     Sector    Last
* Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
       0      2    00      32130 1953375480 1953407609
       2      5    01          0 1953407610 1953407609
       8      1    01          0     32130     32129
```

ディスクの状態
----

```bash:
$ zfs list
NAME                        USED  AVAIL  REFER  MOUNTPOINT
rpool                       646G   267G   448G  /rpool
rpool/ROOT                 5.63G   267G    19K  legacy
rpool/ROOT/opensolaris     5.63G   267G  4.84G  /
rpool/dump                 1023M   267G  1023M  -
rpool/export               16.6G   267G    21K  /export
rpool/export/home          16.6G   267G  16.4G  /export/home
rpool/export/home/username   199M   267G   190M  /export/home/username
rpool/swap                 1023M   268G   448M  -
```

homeディレクトリがnfsを想定して用意されているかな？
----
* /rpool/export/home/{ユーザー名}/

diskのクローン・・・
----
* Linuxの1CDからddしたらいいよ。RAIDドライバの関係でHDDを認識しづらいのでRedHadのCDがオススメ。

アプリケーションディレクトリが綺麗
----
* /usr/gnu/bin
* /usr/bin
* /usr/X11/bin
* /usr/sbin
* /sbin
* /usr/php/bin/
* /usr/mysql/bin/
* /usr/apache2/2.2/bin/

ハードウェア情報表示
----

```bash:
$ prtdiag -v
System Configuration: Dell Inc.                 PowerEdge SC430              
BIOS Configuration: Dell Inc.                 A02 02/06/2006

==== Processor Sockets ====================================

Version                          Location Tag
-------------------------------- --------------------------
Pentium 4                        Microprocessor

==== Memory Device Sockets ================================

Type        Status Set Device Locator      Bank Locator
----------- ------ --- ------------------- ----------------
DDR         in use 0   DIMM_1              
DDR         empty  0   DIMM_3              
DDR         in use 0   DIMM_2              
DDR         empty  0   DIMM_4              

==== On-Board Devices =====================================
Broadcom 5751 NetXtreme Gigabit Controller

==== Upgradeable Slots ====================================

ID  Status    Type             Description
--- --------- ---------------- ----------------------------
1   available PCI Express      SLOT1  
2   available PCI Express      SLOT2  
3   available PCI              SLOT3  
4   available PCI Express      SLOT4  
5   available PCI              SLOT5  
```

ハードウェアエラー確認
----

```bash:
$ iostat -En
c8d0             Soft Errors: 0 Hard Errors: 0 Transport Errors: 0 
Model: SAMSUNG HD103SI Revision:  Serial No: S1XGJ90S415430  Size: 1000.20GB <1000202305536 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0 
Illegal Request: 0 
c9d0             Soft Errors: 0 Hard Errors: 0 Transport Errors: 0 
Model: SAMSUNG HD103SI Revision:  Serial No: S1XGJ90S415427  Size: 1000.20GB <1000202305536 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0 
Illegal Request: 0 
c7t0d0           Soft Errors: 0 Hard Errors: 9 Transport Errors: 0 
Vendor: TSSTcorp Product: DVD-ROM TS-H352C Revision: DE02 Serial No:  
Size: 0.00GB <0 bytes>
Media Error: 0 Device Not Ready: 9 No Device: 0 Recoverable: 0 
Illegal Request: 0 Predictive Failure Analysis: 0
```

boot環境
====

```bash:
$ beadm list
BE          Active Mountpoint Space Policy Created          
--          ------ ---------- ----- ------ -------          
opensolaris NR     /          6.28G static 2009-07-18 19:06 
```

```bash:
$ bootadm list-menu
The location for the active GRUB menu is: /rpool/boot/grub/menu.lst
default 0
timeout 30
0 OpenSolaris 2009.06
```

```bash:
$ pfexec bootadm set-menu default=0
$ pfexec  bootadm set-menu timeout=2
```

パッケージ
====

* [OpenSolaris パッケージ管理メモ](https://www.upken.jp/kb/opensolaris-package-adm)

```bash:pkglistの確認
$ pkg list
NAME (PUBLISHER)                              VERSION         STATE      UFIX
BRCMbnx                                       0.5.11-0.111    installed  ----
FSWxorg-fonts-core                            0.5.11-0.111    installed  ----
NVDAgraphics                                  0.180.44-0.111  installed  ----
SUNW1394                                      0.5.11-0.111    installed  ----
...
```

```bash:
$ pkg publisher
発行元                             タイプ 状態   URI
opensolaris.org          (優先)     起点   online   http://pkg.opensolaris.org/release/
extra                                 起点   online   https://pkg.sun.com/opensolaris/extra/
```

```bash:release番号確認
$ cat /etc/release 
                         OpenSolaris 2009.06 snv_111b X86
           Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
                        Use is subject to license terms.
                              Assembled 07 May 2009
```

重たいプロセス確認
====

```bash:メモリ使用量順
$ prstat -a -s size
   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP       
  1289 gdm       280M   29M sleep   59    0   3:47:09 0.0% gdmgreeter/1
  4782 webservd   64M   19M sleep   59    0   0:00:02 0.0% httpd/1
  4794 webservd   64M   20M sleep   59    0   0:00:04 0.0% httpd/1
  5715 webservd   63M   12M sleep   59    0   0:00:01 0.0% httpd/1
 NPROC USERNAME  SWAP   RSS MEMORY      TIME  CPU                             
    55 root      168M   94M   4.6%  13:28:21 0.1%
    10 webservd  116M   38M   1.9%   0:00:07 0.0%
     1 gdm        43M  183M   8.9%   3:47:09 0.0%
     2 mysql      47M   34M   1.7%   0:02:15 0.0%
     5 username 6384K   20M   1.0%   0:00:02 0.1%

Total: 78 processes, 238 lwps, load averages: 0.01, 0.05, 0.06
```

```bash:CPU使用量順
$ prstat -a -s cpu
   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP       
  1266 root       45M   11M sleep   59    0   7:56:37 0.1% Xorg/1
 12723 username 5520K 2936K cpu1    49    0   0:00:00 0.1% prstat/1
  1289 gdm       280M   29M sleep   59    0   3:47:09 0.0% gdmgreeter/1
   453 root       34M   13M sleep   59    0   2:54:33 0.0% poold/9
 NPROC USERNAME  SWAP   RSS MEMORY      TIME  CPU                             
    51 root      163M   92M   4.5%  13:28:23 0.1%
     5 username 6384K   20M   1.0%   0:00:02 0.1%
     1 gdm        43M  183M   8.9%   3:47:09 0.0%
     2 mysql      47M   34M   1.7%   0:02:15 0.0%

Total: 74 processes, 234 lwps, load averages: 0.02, 0.03, 0.05
```

メモリ搭載量を確認
====

```bash:
$ prtconf 
System Configuration:  Sun Microsystems  i86pc
Memory size: 2047 Megabytes
System Peripherals (Software Nodes):

i86pc
    scsi_vhci, instance #0
    isa, instance #0
...
```

CPUを確認
====

```bash:
$ psrinfo -v
Status of virtual processor 0 as of: 08/05/2013 11:20:53
  on-line since 11/29/2012 17:58:26.
  The i386 processor operates at 2793 MHz,
	and has an i387 compatible floating point processor.
Status of virtual processor 1 as of: 08/05/2013 11:20:53
  on-line since 11/29/2012 17:58:29.
  The i386 processor operates at 2793 MHz,
	and has an i387 compatible floating point processor.
```

システム周り
====
ダンプデバイスの確認
----

```Bash:
$ pfexec dumpadm 
      Dump content: kernel pages
       Dump device: /dev/zvol/dsk/rpool/dump (dedicated)
Savecore directory: /var/crash/sab
  Savecore enabled: no
```

eeprom
----

```Bash:
$ eeprom 
ata-dma-enabled=1
atapi-cd-dma-enabled=1
ttyb-rts-dtr-off=false
ttyb-ignore-cd=true
ttya-rts-dtr-off=false
ttya-ignore-cd=true
ttyb-mode=9600,8,n,1,-
ttya-mode=9600,8,n,1,-
lba-access-ok=1
keyboard-layout=Unknown
console=text
```

gdm有効/無効
====

```Bash
$ pfexec svcadm disable gdm
$ pfexec svcadm enable gdm
```

ログの確認方法
====
* logディレクトリが綺麗に整理されているのでLinuxよりよっぽど見やすいです。
* アプリケーションのログ： /var/{apache,mysql,samba,php}/
* 認証のログ： /var/log/authlog
* `$ grep -v info /var/adm/messages`でハードウェアの異常が見つけやすい。