【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
前言
最近遇到了个需求,有一些大文件需要存放。由于文件非常大,完全不想存放在 Ceph 或是 GlusterFS 这样现有的高可用存储中,避免资源的浪费。于是想到用 ISCSI 挂载的方式来实现这一需求,开始寻找一款开源的 NAS 系统。
开源的 NAS 系统之前接触过很多,比如 XigmaNAS,FreeNAS,Nexenta,Rockstor,Openfiler,EasyNAS...
其中,支持 ISCSI 的有 XigmaNAS,FreeNAS,Nexenta,Openfiler
全部尝试下来发现,Nexenta 确实不错,但是占用不小,且社区版本支持的最大容量为 10 TB;Openfiler 虽然有点小问题,但是也能满足需求,不过已经不再更新了;FreeNAS 的话,功能强大,占用内存比较厉害,看起来太臃肿了;至于 XigmaNAS,由于界面太丑,设置项又繁多,完全没有使用的欲望。总之,这四款没有一个比较满意的。
本来打算采用 Nexenta 来做这件事儿,后来偶然间发现了 OviOS Linux 这个发行版。
OviOS Linux
OviOS Linux 是一款企业级专注于存储的发行版,根据其官网介绍,OviOS Linux 没有基于任何 LInux 发行版实现,针对于存储设计,从内核级别去掉了冗余的模块,没有额外的软件,也没有图形界面,甚至没有 WEB GUI。
在它的官网写着这样一句话很有意思:
Lightweight also means no GUI. A GUI just makes simple tasks simpler, and complex task impossible.
安装 OviOS Linux
硬件准备: 内存 4G + 系统盘,系统盘容量不需要很大,但是,请保证系统盘的高可用(如使用硬RAID或是其他高可用技术)
OviOS Linux 的安装非常简单,从 ISO 启动并使用 root 登录(默认密码为: ovios)后,执行以下命令
# 切换到 Linux Shell
ovios-shell> linuxcmd
# 执行安装程序
setup
之后按照引导即可完成 OviOS Linux 的安装。
设置网络
重启后,使用 ovios 用户(默认密码也是: ovios)登录到 CLI
# 查看网卡名称
ip a
# 切换到 ovios shell
su - root
# 执行网络设置
ovios-shell> netsetup
按照引导设置动态或是静态的 IP 地址。
设置 ISCSI 分享
创建存储池
本节操作均需要切换到 ovios shell 进行
OviOS Linux 使用 ZFS 创建存储池子,支持以下类型的存储池
- Add Raid0 (Stripped devices.) pool
- Add Raid1 (Mirrored devices. mirror) pool
- Add Raid5 (raidz) pool
- Add Raid6 (raidz2) pool
- Add Raid10 (mirrored stripped) pool
在开始之前,请将硬盘附加到 OviOS Linux 中。
# 查看所有磁盘
ovios-shell> storage
系统将会显示当前识别到的所有磁盘,指出当前 OviOS Linux 所在的磁盘,并警告创建存储池时不要使用 OviOS Linux 所在的磁盘。
# 创建存储池
ovios-shell> pool create
====================================================================================
= Create a storage pool for volumes and LUNs
= Do not use /dev/sda2 as it will wipe your OviOS installation
= Make sure you don't use disks which are part of exported pools either
====================================================================================
1. Add Raid0 (Stripped devices.) pool
2. Add Raid1 (Mirrored devices. mirror) pool
3. Add Raid5 (raidz) pool
4. Add Raid6 (raidz2) pool
5. Add Raid10 (mirrored stripped) pool
Choose a raid level for the new pool (Default: 1):2
Enter the name for the new pool: xshare
Enter devices to add to the pool: sdb sdc
Created pool newpool successfully
Enable compression? (Default: yes) [ y|n ] y
Enabling compression on xshare
You can list all storage pools using the 'pool list' command
开启 ISCSI
ovios-shell> option iscsi.enable on
ovios-shell> iscsi start
创建 ISCSI targets
ovios-shell> target create
==================================================================================
= This command creates an iSCSI target. You can create multiple targets
= and control what initiators can connect to them.
= You can map LUNs to specific targets, thus controlling
= which client has access to each LUN.
==================================================================================
The IQN will be appended by the OS. Enter a custom target name: ovios-tg01
Choose whether to setu ACLs, by adding initiators IPs or IQNs to the target. Thus the target will allow only specific initiators to connect.
If no innitiator IP or IQN is assigned to this target, all initiators will have access and will be able to connect.
Would you like to define an initiator that can access this target? (Default: no) [y|n] y
Enter IP or IQN of the initiator to access this target: 192.168.0.106
Add another initiator? (Default: no) [y | n]: y
Enter IP or IQN: iqn.2012-04.org.ovios:9bfhvndth004-tg01
Add another initiator? (Default: no) [y | n]: n
创建 LUNs
ovios-shell> lun_setup
Enter pool name: xshare
LUN will be created in xshare.
Enter LUN name: xlun
Enter LUN size in g for GB or m for MB etc. Example: 200g | 4T | 1000m: 30g
Create thin or thick provision LUN? (Default: thick) [thin | thick]:
Creating LUN xlun...
would you like to map the LUN to a target? [y|n] n
映射 LUN 到 ISCSI targets
ovios-shell> lun map
Enter pool name: xshare
Enter lun name: xlun
Enter target name: ovios-tg01
Mapping LUN xlun to target ovios-tg01 with LUN ID 1....
Command returned successfully
Updating iscsi config files...
LUN xlun mapped to target ID 1 with LUN ID 1.
来源:oschina
链接:https://my.oschina.net/u/4243574/blog/3144330