Linux Network Block Device(NBD)安装配置过程
来源:互联网 发布:vscode md预览 编辑:程序博客网 时间:2024/05/17 06:34
Linux 版本:Ubuntu 12.04
安装环境:两台Linux虚拟机(一个安装nbd-server,一个安装nbd-client),ip地址分别为ip1,ip2。
关于Network Block Device(NBD)的介绍,参见网址:http://en.wikipedia.org/wiki/Network_block_device
NBD Server端的安装配置过程
1.安装nbd-server
# apt-get install nbd-server
安装过程可能会有如下提示,不用担心,可以忽略。
Not creating home directory `/etc/nbd-server'.
** Message: No configured exports; quitting.
nbd-server.
# dd if=/dev/zero of=/mnt/dhini bs=1024 count=36000关于这条命令的作用,可以自己百度。
3.格式化刚才创建的文件
# mke2fs /mnt/dhini
/mnt/dhini is not a block special device.Proceed anyway? (y,n) y(按照提示输入y即可)3.开启nbd-server进程
# nbd-server 1043 /mnt/dhininbd-server port file [size][kKmM] [-l authorize_file] [-r] [-m] [-c] [-a timeout_sec]
port nbd-server监听端口.
file 绑定的映像文件.
size 在客户端所见的块设备大小(单位可以是: k,K,m,M).
-r|--read-only 只读模式,客户端无法在块设备上进行写操作.
-m|--multi-file 多个文件,可以将多个映像文件作为一个块设备提供给客户端.
-c|--copy-on-write 所有客户端的写操作被会另存为一个文件,连接断开后,这个文件会被删除.
可以保证映像文件内容不会被修改.
-l|--authorize-file file 一个允许访问此nbd的主机列表文件.
-a|--idle-time 服务器断开与客户端连接前的最大空闲时间.
注意:运行命令可能会出现如下警告,不用担心,不影响后面的操作。
~# nbd-server 1043 /mnt/dhini
** (process:2407): WARNING **: Specifying an export on the command line is deprecated.
** (process:2407): WARNING **: Please use a configuration file instead.
服务器端暂时配置到这。
NBD client端的安装配置过程
1.加载nbd模块
modprobe nbd
查看是否加载成功
lsmod | grep nbd
查看nbd设备是否建立
ls /dev/nbd* -hl
2.安装nbd-client
apt-get install nbd-client
bd-client用法:
nbd-client [bs=blocksize] host port nbd_device [-swap]
bs 用于设置块大小,默认是1024,可以是512,1024.2048,4096
host 服务器的主机名或IP
port 服务器的监听端口
nbd_device 映射到本地的哪个nbd设备(如: /dev/nbd0)
-swap 指定nbd设备将用做swap空间
3.与nbd-server建立连接
nbd-client ip1 1043 /dev/nbd0
客户端配置暂时结束。
下面举一个client访问server创建文件的例子。
1.client端操作
client与server建立连接后,可以把server端的文件挂载到本地,并在本地进行操作,命令如下:
mkdir /mnt/nbd0
mount /dev/nbd0 /mnt/nbd0
cd /mnt/nbd0
touch test //创建一个文件。
client端操作结束后,要卸载刚才挂载的文件,并与server断开连接,命令如下:
umount /mnt/nbd0
nbd-client -d /dev/nbd0
2.server端操作
server只需挂载之前创建的用于client访问的文件到某一目录即可:
mkdir /mnt/nbd0
mount /mnt/dhini /mnt/nbd0
cd /mnt/nbd0
ls
可以看到你在client端创建的文件。NBD测试成功。
- Linux Network Block Device(NBD)安装配置过程
- Linux Block Device Architecture
- Linux Block Device Architecture
- Linux Block Device Architecture
- Linux Block Device Architecture
- Linux Block Device Architecture
- Linux Block Device Architecture
- linux虚拟机安装过程中卡在mount: block device /dev/sr0 is write-protected, mounting read-only
- QEMU KVM Libvirt手册(6) – Network Block Device
- linux内核编译过程及配置说明解释(6)--Networking support,Device drivers
- Centos7 安装编译nbd模块
- linux内核编译过程及配置说明解释(3)--loadable module support 与block layer
- NAPI In Linux Network Device Driver
- Writing Network Device Drivers for Linux
- Note: Linux network device driver construct
- linux network配置 转
- linux network 配置
- Linux NFS(Network File System 网络文件系统) 安装与配置
- [iOS高级] UICollectionView实现瀑布流效果
- JAVA九九乘法口诀
- Sicily 1151 魔板 Another Thought
- poj2349 Arctic Network(最小生成树)
- 20几岁,不要急着长大
- Linux Network Block Device(NBD)安装配置过程
- 查询执行完的JOB的消耗
- 插入排序,折半插入排序,希尔排序的代码
- 旅行-许巍
- Thread的run和start
- 使用C语言开发项目的一些心得
- mysql变量
- c++之初学(1)
- ubuntu-python-virtualenvwrapper-django全程安装