使用OpenIndiana作为储存服务器

个人觉得OmniOS生涩难用,而同为illumos的OpenIndiana更像是个通用发行版本,pkg的仓库也有常用的软件,关于OI的常见问题,请参考此处

OpenIndiana官网

Warning: OI-hipster-text-20161030.iso
安装mini版本的 OI 在sharenfs会报错,需要额外安装nfs service.

2.1 配置网络

初始化配置OpenIndiana,通过console界面操作:

#配置ssh允许root登录
sed -i 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config
svcadm restart ssh
#关闭nwam
svcadm disable network/physical:nwam
#显示网卡
dladm show-phys
#创建接口
ipadm create-if bge0
#查看接口
ipadm show-if
#dhcp
ipadm create-addr -T dhcp bge0/v4
#static
ipadm create-addr -T static -a 10.1.1.12/24 bge0/v4static
#查看IP地址
ipadm show-addr
 
# 修改IP
ipadm show-addr
ipadm delete-addr ADDROBJ
ipadm create-addr .....
 
# 添加永久默认路由
route -p add default 172.16.1.254
# 删除默认路由
route -p delete default 172.16.1.254

Note: 可以ssh登录进行配置了 !

2.2 完善网络配置

Note: OpenIndiana安装就能manual配置网络.

#配置默认路由
route -p add default 10.1.1.254
netstat -rn -finet
#配置DNS
echo 'nameserver 223.5.5.5' >> /etc/resolv.conf
cp /etc/nsswitch.conf{,.bak}
cp /etc/nsswitch.{dns,conf}
ping qq.com

2.3 系统自定义配置

# 安装常用软件
pkg update
pkg install vim rsync mtr SUNWcs routing nmap sudo smartmontools net-snmp zip unzip top bash-completion gnu-coreutils
 
#让vim更接近linux的vim
cat > /root/.vimrc <<'EOF'
syntax on
set bs=2
set hls
EOF
cat >> /etc/profile <<'EOF'
export EDITOR=vim
alias ll='ls -lh --color=auto'
#man color
export LESS_TERMCAP_mb=$(printf '\e[01;31m') # enter blinking mode - red
export LESS_TERMCAP_md=$(printf '\e[01;35m') # enter double-bright mode - bold, magenta
export LESS_TERMCAP_me=$(printf '\e[0m') # turn off all appearance modes (mb, md, so, us)
export LESS_TERMCAP_se=$(printf '\e[0m') # leave standout mode
export LESS_TERMCAP_so=$(printf '\e[01;33m') # enter standout mode - yellow
export LESS_TERMCAP_ue=$(printf '\e[0m') # leave underline mode
export LESS_TERMCAP_us=$(printf '\e[04;36m') # enter underline mode - cyan
EOF
 
source /etc/profile

2.4 系统用户创建

#创建用户,分配uid=1000以匹配linux客户端uid
groupadd -g 1000 mrco
useradd -g mrco -u 1000 mrco
id mrco

创建一个RAIDZ-1 zpool:

# 查看磁盘列表
echo | format
# 导入已存在的pool
# 若zpool有设备离线,加 -fm 参数
zpool import old_name new_name
# 创建raidz1 zpool
zpool create tank raidz c3t0d0 c3t1d0 c3t2d0 c3t3d0
# 查看ashift对齐
zdb | grep ashift
# 查看zpool状态
zpool status tank
# 创建dataset
zfs create -o casesensitivity=mixed -o nbmand=on -o utf8only=on tank/data
 
# 开启zfs压缩
zfs set compression=lz4 tank/data
# 关闭atime
zfs set atime=off tank/data
# 关闭数据去重
zfs set dedup=off tank/data

  • napp-it不能直接共享zpool根,需要先创建一个dataset,如 tank/dataset1
  • 直接对zpool根进行共享(不推荐),需要添加属性 root@10.1.1.0/24 , 即使root=* 也会导致nfs client没有写权限;
  • 共享nfs的时候,不加 root@10.1.1.0/24 会导致客户端看到的文件属组都是nobody;
# man share_nfs 可获取更多sharenfs参数
# share nfs with all rw
zfs set sharenfs=rw tank/backups
 
# single host
zfs set sharenfs='rw=@192.168.5.1' tank/backups
 
# share to a subnet
zfs set sharenfs='root=@10.1.1.0/24,rw=@10.1.1.0/24' tank/backups
zfs set sharenfs='rw=@192.168.5.0/24' tank/backups
 
# 多子网分享,':'分隔,@子网段.
zfs set sharenfs='rw=@10.1.1.0/24:@10.1.2.0/24,root=@10.1.1.0/24:@10.1.2.0/24' tank/backups
 
# 检查NFS
zfs get sharenfs tank/backups

4.1 OpenIndiana minimal使用sharenfs额外操作

经测试,minimal的ISO未安装nfs service,所以在 sharenfs 添加参数时会说这些参数无效,如下:

zfs set sharenfs=root=@10.1.1.0/24,rw=@10.1.1.0/24 tank/data
cannot set property for 'tank/data': 'sharenfs' cannot be set to invalid options

解决办法:

#安装nfs service
pkg install pkg://openindiana.org/service/file-system/nfs
#检查nfs service
zfs get sharenfs tank/data
svcs -a|grep nfs
 
输出:
disabled        2:17:28 svc:/network/nfs/cbd:default
disabled        2:17:28 svc:/network/nfs/client:default
disabled        2:28:11 svc:/network/nfs/log:default
online          2:29:11 svc:/network/nfs/mapid:default
online          2:29:11 svc:/network/nfs/status:default
online          2:29:11 svc:/network/nfs/rquota:default
online          2:29:11 svc:/network/nfs/nlockmgr:default
online          2:29:11 svc:/network/nfs/server:default

5.1 samba服务组件

  • samba - Takes care of the basic share mounting and file sharing capabilities.
  • wins - Starts the nmbd service, which makes the machine, and its shares, visible in your users' file browsers.
  • winbind - Starts the winbind service. From what I understand, this helps integrate UNIX with Microsoft Windows NT. I don't think you need it running unless you are using NT.

5.2 samba实现方式

OpenIndiana的samba实现有2种方式,个人更偏好 traditional Samba ,可以配置更多特性,比如vfs_recycle-bin.

  1. traditional Samba
    • pkg install samba; vim /etc/samba/smb.conf
  2. Solaris buiilt-in
    • zfs set sharesmb=name=myshare,description=My ZFS share yourpool/shares

5.2.1 traditional Samba

# 安装samba
pkg install samba
mkdir /var/log/samba
cp /etc/samba/smb.conf.default /etc/samba/smb.conf
 
# Create samba user
smbpasswd -a mrco
 
# Start the appropriate services(wins,winbind is optional.)
svcadm enable samba
svcadm enable wins
svcadm enable winbind
svcadm enable/disable/restart/ samba
 
# 检查服务
svcs -xv samba
svcs -xv wins
svcs -xv winbind
#清除服务维护状态
svcadm clear samba

5.2.2 Solaris buiilt-in samba


6.1 调整ARC参数

  • ARC的配置直接影响到zfs可以使用多少内存;

6.2 查看S.M.A.R.T

# smartctl需要参数 "-d sat,12" 才能正常检测出全部信息
/usr/sbin/smartctl -a -d sat,12 -T permissive /dev/rdsk/c3t2d0s0

6.3 pkg常用操作

#List configured publishers
pkg publisher
#Add a publisher
pkg set-publisher -g http://pkg.omniti.com/omniti-ms/ ms.omniti.com
#Remove a publisher
pkg unset-publisher ms.omniti.com
#change the repo URL for a publisher without removing it and re-adding it
pkg set-publisher -G http://old-url -g http://new-url <publisher-name>
#List all installed packages
pkg list
# list contents of package
pkg contents package-name
#Install a package
pkg install omniti/runtime/perl
#Upgrade the global zone
pkg update

其他:

#关机
shutdown -i5 -g0 -y

  • storage/zfs/openindiana/openindiana_as_nas.txt
  • 最后更改: 2019/04/16 18:31
  • (外部编辑)