1 环境准备
1.1 版本
Linux系统版本:Ubuntu Server 12.04.1 LTS;
Swift版本:1.0(稍后安装);
Python版本:2.7.3(稍后安装);
Python-swiftclient版本:1.3.0(稍后安装)。
1.2 节点IP
IP:192.168.1.107。
1.3 替换镜像(可选步骤)
网速较慢或者安装软件失败的情况下,可以考虑替换成国内的镜像:
vsroot@ubuntu:~$ sudo sed -i's#us.archive.ubuntu.com#mirrors.163.com#g' /etc/apt/sources.list
vsroot@ubuntu:~$ sudo apt-get update
1.4 系统时间
vsroot@ubuntu:~$ date #查看系统时间是否正确,正确的话则忽略下面两步
vsroot@ubuntu:~$ sudo date -s"2013-11-04 15:05:57" #设置系统时间
vsroot@ubuntu:~$ sudo hwclock –w #写入硬件时间
1.5 关闭防火墙
请确保已关闭SELinux。
vsroot@ubuntu:~$ sudo ufw disable #关闭防火墙
2 通用的OS配置
2.1 创建Swift用户
vsroot@ubuntu:~$ sudo useradd -mk/home/swift -s /bin/bash swift
vsroot@ubuntu:~$ sudo passwd swift # 不妨把用户swift的密码设置成swift
编辑/etc/sudoers,在文件末尾添加以下内容:
vsroot@ubuntu:~$ sudo vim /etc/sudoers
# User alias specification
swift ALL=(ALL) NOPASSWD:ALL
之后就可以切换到swift用户进行后续操作了:
vsroot@ubuntu:~$ su swift
2.2 安装Swift依赖库
swift@ubuntu:~$ sudo apt-get install curlgcc memcached rsync sqlite3 xfsprogs git-core libffi-dev python-setuptools
swift@ubuntu:~$ sudo apt-get installpython-coverage python-dev python-nose python-simplejson python-xattrpython-eventlet python-greenlet python-pastedeploy python-netifaces python-pippython-dnspython python-mock
2.3 安装Swift相关软件
swift@ubuntu:~$ sudo add-apt-repositorycloud-archive:grizzly
swift@ubuntu:~$ sudo apt-get update
swift@ubuntu:~$ sudo apt-get install swiftpython-swiftclient openssh-server
2.4 创建Swift工作目录
swift@ubuntu:~$ sudo mkdir -p /etc/swift
swift@ubuntu:~$ sudo chown -R swift:swift/etc/swift/
2.5 创建Swift配置文件
swift@ubuntu:~$ cat>/etc/swift/swift.conf <<EOF
[swift-hash]
# random unique strings that can neverchange (DO NOT LOSE)
swift_hash_path_prefix = `od -t x8 -N 8 -An </dev/random`
swift_hash_path_suffix = `od -t x8 -N 8 -An </dev/random`
EOF
2.6 设置IP的环境变量
根据自身真实IP设置如下:
swift@ubuntu:~$ export LOCAL_NET_IP=192.168.1.107
考虑到export命令只对当前用户的当前会话生效,也可以考虑将环境变量写到/etc/profile中:
swift@ubuntu:~$ sudo vim /etc/profile
swift@ubuntu:~$ source /etc/profile #当前会话立即生效
2.7 创建Swift服务目录并修改开机配置文件
swift@ubuntu:~$ sudo mkdir -p/var/cache/swift /var/cache/swift2 /var/cache/swift3 /var/cache/swift4
swift@ubuntu:~$ sudo chown swift:swift/var/cache/swift*
swift@ubuntu:~$ sudo mkdir -p/var/run/swift
swift@ubuntu:~$ sudo chown swift:swift/var/run/swift
swift@ubuntu:~$ sudo vim /etc/rc.local
sudo mkdir -p /var/cache/swift/var/cache/swift2 /var/cache/swift3 /var/cache/swift4
sudo chown swift:swift /var/cache/swift*
sudo mkdir -p /var/run/swift
sudo chown swift:swift /var/run/swift
exit 0
3 配置Proxy服务
3.1 安装swift-proxy库
swift@ubuntu:~$ sudo apt-get installswift-proxy memcached
3.2 配置memcached并监听默认的端口
swift@ubuntu:~$ sudo perl -pi -e "s/-l127.0.0.1 /-l $LOCAL_NET_IP/" /etc/memcached.conf # 替换成自己的IP
3.3 重启memcached服务器
swift@ubuntu: ~$ sudo service memcachedrestart
最好检查一下memcached服务是否已经正常启动。
3.4 创建Proxy服务器配置文件
swift@ubuntu:~$ cat>/etc/swift/proxy-server.conf <<EOF
[DEFAULT]
bind_port = 8080
workers = 1
user = swift
log_facility = LOG_LOCAL1
eventlet_debug = true
[pipeline:main]
# Yes, proxy-logging appears twice. This isnot a mistake.
pipeline = healthcheck proxy-logging cachetempauth proxy-logging proxy-server
[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true
[filter:tempauth]
use = egg:swift#tempauth
user_admin_admin = admin .admin.reseller_admin
user_test_tester = testing .admin
user_test2_tester2 = testing2 .admin
user_test_tester3 = testing3
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:cache]
use = egg:swift#memcache
memcache_servers = $LOCAL_NET_IP:11211
[filter:proxy-logging]
use = egg:swift#proxy_logging
EOF
3.5 确保所有配置文件都属于swift用户
swift@ubuntu:~$ sudo chown -R swift:swift/etc/swift
4 配置Storage服务
4.1 安装包
swift@Ubuntu:~$ sudo apt-get installswift-account swift-container swift-object xfsprogs
4.2 为StorageNode的每个存储设备安装XFS逻辑卷
swift@ubuntu:~$ sudo fdisk /dev/sdb # 建立单独分区
swift@ubuntu:~$ sudo mkfs.xfs /dev/sdb1
如果文件系统小于100MiB或有大量小型档案,建议使用512字节区块;其余情况建议使用4KiB区块。
swift@ubuntu:~$ sudo vim /etc/fstab
/dev/sdb1 /mnt/sdb1 xfsnoatime,nodiratime,nobarrier,logbufs=8 0 0
swift@ubuntu:~$ sudo mkdir -p /mnt/sdb1
swift@ubuntu:~$ sudo mount /mount/sdb1
如果磁盘大于1T,上面的mount命令可以加上-o inode64以达到更好的性能。
swift@ubuntu:~$ sudo mkdir -p /mnt/sdb1/1/mnt/sdb1/2 /mnt/sdb1/3 /mnt/sdb1/4
swift@ubuntu:~$ sudo chown swift:swift /mnt/sdb1/*
swift@ubuntu:~$ sudo mkdir -p /srv
swift@ubuntu:~$ for x in {1..4}; do ln -s/mnt/sdb1/$x /srv/$x; done
swift@ubuntu:~$ sudo mkdir -p/etc/swift/object-server /etc/swift/container-server /etc/swift/account-server/srv/1/node/sdb1 /srv/2/node/sdb2 /srv/3/node/sdb3 /srv/4/node/sdb4/var/run/swift
swift@ubuntu:~$ sudo chown -R swift:swift /etc/swift /srv/[1-4]//var/run/swift
4.3 创建rsync配置文件
swift@ubuntu:~$ sudo su #切换用户后,需重新定义LOCAL_NET_IP
root@ubuntu:~$ cat >/etc/rsyncd.conf<<EOF
uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = $LOCAL_NET_IP
[account6012]
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/account6012.lock
[account6022]
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/account6022.lock
[account6032]
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/account6032.lock
[account6042]
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/account6042.lock
[container6011]
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/container6011.lock
[container6021]
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/container6021.lock
[container6031]
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/container6031.lock
[container6041]
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/container6041.lock
[object6010]
max connections = 25
path = /srv/1/node/
read only = false
lock file = /var/lock/object6010.lock
[object6020]
max connections = 25
path = /srv/2/node/
read only = false
lock file = /var/lock/object6020.lock
[object6030]
max connections = 25
path = /srv/3/node/
read only = false
lock file = /var/lock/object6030.lock
[object6040]
max connections = 25
path = /srv/4/node/
read only = false
lock file = /var/lock/object6040.lock
EOF
root@ubuntu:~$ su swift #切换用户后,需重新定义LOCAL_NET_IP
4.4 修改rsync标签
swift@ubuntu:~$ sudo perl -pi -e's/RSYNC_ENABLE=false/RSYNC_ENABLE=true/' /etc/default/rsync
4.5 启动rsync服务
swift@ubuntu:~$ sudo service rsync restart
如果服务不能正常启动,请检查rsync配置文件。
确认rsync是否已连接所有服务:
swift@ubuntu:~$ rsync rsync://pub@$LOCAL_NET_IP/
4.6 创建account、container和object rings配置文件
swift@ubuntu:~$ cat >/etc/swift/account-server/1.conf <<EOF
[DEFAULT]
devices = /srv/1/node
mount_check = false
disable_fallocate = true
bind_port = 6012
workers = 1
user = swift
log_facility = LOG_LOCAL2
recon_cache_path = /var/cache/swift
eventlet_debug = true
[pipeline:main]
pipeline = recon account-server
[app:account-server]
use = egg:swift#account
[filter:recon]
use = egg:swift#recon
[account-replicator]
vm_test_mode = yes
[account-auditor]
[account-reaper]
EOF
swift@ubuntu:~$ cat > /etc/swift/account-server/2.conf<<EOF
[DEFAULT]
devices = /srv/2/node
mount_check = false
disable_fallocate = true
bind_port = 6022
workers = 1
user = swift
log_facility = LOG_LOCAL3
recon_cache_path = /var/cache/swift2
eventlet_debug = true
[pipeline:main]
pipeline = recon account-server
[app:account-server]
use = egg:swift#account
[filter:recon]
use = egg:swift#recon
[account-replicator]
vm_test_mode = yes
[account-auditor]
[account-reaper]
EOF
swift@ubuntu:~$ cat > /etc/swift/account-server/3.conf<<EOF
[DEFAULT]
devices = /srv/3/node
mount_check = false
disable_fallocate = true
bind_port = 6032
workers = 1
user = swift
log_facility = LOG_LOCAL4
recon_cache_path = /var/cache/swift3
eventlet_debug = true
[pipeline:main]
pipeline = recon account-server
[app:account-server]
use = egg:swift#account
[filter:recon]
use = egg:swift#recon
[account-replicator]
vm_test_mode = yes
[account-auditor]
[account-reaper]
EOF
swift@ubuntu:~$ cat > /etc/swift/account-server/4.conf<<EOF
[DEFAULT]
devices = /srv/4/node
mount_check = false
disable_fallocate = true
bind_port = 6042
workers = 1
user = swift
log_facility = LOG_LOCAL5
recon_cache_path = /var/cache/swift4
eventlet_debug = true
[pipeline:main]
pipeline = recon account-server
[app:account-server]
use = egg:swift#account
[filter:recon]
use = egg:swift#recon
[account-replicator]
vm_test_mode = yes
[account-auditor]
[account-reaper]
EOF
swift@ubuntu:~$ cat >/etc/swift/container-server/1.conf <<EOF
[DEFAULT]
devices = /srv/1/node
mount_check = false
disable_fallocate = true
bind_port = 6011
workers = 1
user = swift
log_facility = LOG_LOCAL2
recon_cache_path = /var/cache/swift
eventlet_debug = true
[pipeline:main]
pipeline = recon container-server
[app:container-server]
use = egg:swift#container
[filter:recon]
use = egg:swift#recon
[container-replicator]
vm_test_mode = yes
[container-updater]
[container-auditor]
[container-sync]
EOF
swift@ubuntu:~$ cat > /etc/swift/container-server/2.conf<<EOF
[DEFAULT]
devices = /srv/2/node
mount_check = false
disable_fallocate = true
bind_port = 6021
workers = 1
user = swift
log_facility = LOG_LOCAL3
recon_cache_path = /var/cache/swift2
eventlet_debug = true
[pipeline:main]
pipeline = recon container-server
[app:container-server]
use = egg:swift#container
[filter:recon]
use = egg:swift#recon
[container-replicator]
vm_test_mode = yes
[container-updater]
[container-auditor]
[container-sync]
EOF
swift@ubuntu:~$ cat > /etc/swift/container-server/3.conf<<EOF
[DEFAULT]
devices = /srv/3/node
mount_check = false
disable_fallocate = true
bind_port = 6031
workers = 1
user = swift
log_facility = LOG_LOCAL4
recon_cache_path = /var/cache/swift3
eventlet_debug = true
[pipeline:main]
pipeline = recon container-server
[app:container-server]
use = egg:swift#container
[filter:recon]
use = egg:swift#recon
[container-replicator]
vm_test_mode = yes
[container-updater]
[container-auditor]
[container-sync]
EOF
swift@ubuntu:~$ cat > /etc/swift/container-server/4.conf<<EOF
[DEFAULT]
devices = /srv/4/node
mount_check = false
disable_fallocate = true
bind_port = 6041
workers = 1
user = swift
log_facility = LOG_LOCAL5
recon_cache_path = /var/cache/swift4
eventlet_debug = true
[pipeline:main]
pipeline = recon container-server
[app:container-server]
use = egg:swift#container
[filter:recon]
use = egg:swift#recon
[container-replicator]
vm_test_mode = yes
[container-updater]
[container-auditor]
[container-sync]
EOF
swift@ubuntu:~$ cat >/etc/swift/object-server/1.conf <<EOF
[DEFAULT]
devices = /srv/1/node
mount_check = false
disable_fallocate = true
bind_port = 6010
workers = 1
user = swift
log_facility = LOG_LOCAL2
recon_cache_path = /var/cache/swift
eventlet_debug = true
[pipeline:main]
pipeline = recon object-server
[app:object-server]
use = egg:swift#object
[filter:recon]
use = egg:swift#recon
[object-replicator]
vm_test_mode = yes
[object-updater]
[object-auditor]
EOF
swift@ubuntu:~$ cat > /etc/swift/object-server/2.conf<<EOF
[DEFAULT]
devices = /srv/2/node
mount_check = false
disable_fallocate = true
bind_port = 6020
workers = 1
user = swift
log_facility = LOG_LOCAL3
recon_cache_path = /var/cache/swift2
eventlet_debug = true
[pipeline:main]
pipeline = recon object-server
[app:object-server]
use = egg:swift#object
[filter:recon]
use = egg:swift#recon
[object-replicator]
vm_test_mode = yes
[object-updater]
[object-auditor]
EOF
swift@ubuntu:~$ cat >/etc/swift/object-server/3.conf <<EOF
[DEFAULT]
devices = /srv/3/node
mount_check = false
disable_fallocate = true
bind_port = 6030
workers = 1
user = swift
log_facility = LOG_LOCAL4
recon_cache_path = /var/cache/swift3
eventlet_debug = true
[pipeline:main]
pipeline = recon object-server
[app:object-server]
use = egg:swift#object
[filter:recon]
use = egg:swift#recon
[object-replicator]
vm_test_mode = yes
[object-updater]
[object-auditor]
EOF
swift@ubuntu:~$ cat >/etc/swift/object-server/4.conf <<EOF
[DEFAULT]
devices = /srv/4/node
mount_check = false
disable_fallocate = true
bind_port = 6040
workers = 1
user = swift
log_facility = LOG_LOCAL5
recon_cache_path = /var/cache/swift4
eventlet_debug = true
[pipeline:main]
pipeline = recon object-server
[app:object-server]
use = egg:swift#object
[filter:recon]
use = egg:swift#recon
[object-replicator]
vm_test_mode = yes
[object-updater]
[object-auditor]
EOF
5 配置打印信息(可选步骤)
5.1 创建配置文件
swift@ubuntu:~$ cat >/etc/rsyslog.d/10-swift.conf <<EOF
# Uncomment the following to have a logcontaining all logs together
#local1,local2,local3,local4,local5.* /var/log/swift/all.log
# Uncomment the following to have hourlyproxy logs for stats processing
#$templateHourlyProxyLog,"/var/log/swift/hourly/%$YEAR%%$MONTH%%$DAY%%$HOUR%"
#local1.*;local1.!notice ?HourlyProxyLog
local1.*;local1.!notice/var/log/swift/proxy.log
local1.notice /var/log/swift/proxy.error
local1.* ~
local2.*;local2.!notice/var/log/swift/storage1.log
local2.notice /var/log/swift/storage1.error
local2.* ~
local3.*;local3.!notice/var/log/swift/storage2.log
local3.notice /var/log/swift/storage2.error
local3.* ~
local4.*;local4.!notice/var/log/swift/storage3.log
local4.notice /var/log/swift/storage3.error
local4.* ~
local5.*;local5.!notice/var/log/swift/storage4.log
local5.notice /var/log/swift/storage4.error
local5.* ~
EOF
5.2 修改配置文件
swift@ubuntu:~$ sudo perl -pi -e 's/$PrivDropToGroupsyslog/$PrivDropToGroup adm/' /etc/rsyslog.conf
swift@ubuntu:~$ mkdir -p/var/log/swift/hourly
swift@ubuntu:~$ sudo chown -R syslog.adm/var/log/swift
swift@ubuntu:~$ sudo chmod -R g+w/var/log/swift
5.3 启动日志服务
swift@ubuntu:~$ sudo service rsyslogrestart
6 启动Swift服务
6.1 创建resetswift
swift@ubuntu:~$ sudo su
root@ubuntu:~$ mkdir -p ~/bin
root@ubuntu:~$ cat > ~/bin/resetswift <<EOF
#!/bin/bash
swift-init all stop
find /var/log/swift -type f -exec rm -f {}\;
sudo umount /mnt/sdb1
sudo mkfs.xfs -f /dev/sdb1
sudo mount /mnt/sdb1
sudo mkdir /mnt/sdb1/1 /mnt/sdb1/2/mnt/sdb1/3 /mnt/sdb1/4
sudo chown swift:swift /mnt/sdb1/*
mkdir -p /srv/1/node/sdb1 /srv/2/node/sdb2/srv/3/node/sdb3 /srv/4/node/sdb4
sudo rm -f /var/log/debug /var/log/messages/var/log/rsyncd.log /var/log/syslog
find /var/cache/swift* -type f -name*.recon -exec rm -f {} \;
sudo service rsyslog restart
sudo service memcached restart
EOF
6.2 创建remakerings
root@ubuntu:~$ cat> ~/bin/remakerings <<EOF
#!/bin/bash
cd /etc/swift
rm -f *.builder *.ring.gz backups/*.builderbackups/*.ring.gz
swift-ring-builder object.builder create 103 1
swift-ring-builder object.builder add r1z1-$LOCAL_NET_IP:6010/sdb11
swift-ring-builder object.builder add r1z2-$LOCAL_NET_IP:6020/sdb21
swift-ring-builder object.builder add r1z3-$LOCAL_NET_IP:6030/sdb31
swift-ring-builder object.builder add r1z4-$LOCAL_NET_IP:6040/sdb41
swift-ring-builder object.builder rebalance
swift-ring-builder container.builder create10 3 1
swift-ring-builder container.builder add r1z1-$LOCAL_NET_IP:6011/sdb11
swift-ring-builder container.builder addr1z2-$LOCAL_NET_IP:6021/sdb2 1
swift-ring-builder container.builder addr1z3-$LOCAL_NET_IP:6031/sdb3 1
swift-ring-builder container.builder addr1z4-$LOCAL_NET_IP:6041/sdb4 1
swift-ring-builder container.builderrebalance
swift-ring-builder account.builder create10 3 1
swift-ring-builder account.builder addr1z1-$LOCAL_NET_IP:6012/sdb1 1
swift-ring-builder account.builder addr1z2-$LOCAL_NET_IP:6022/sdb2 1
swift-ring-builder account.builder addr1z3-$LOCAL_NET_IP:6032/sdb3 1
swift-ring-builder account.builder addr1z4-$LOCAL_NET_IP:6042/sdb4 1
swift-ring-builder account.builderrebalance
EOF
其中,10代表partition的数目为2的10次幂,这个数字取决于你希望一个ring中会有多少个partition。3代表每个object的副本数。最后一个参数1,代表一个partition至少在1小时之后才能被移动。
注意,这里需要根据存储设备实际情况来设定:
① DEVICE需要根据Storage Node上的/etc/rsyncd.conf中的path来设置,例如path为/srv/1/node/,查看/srv/1/node/下存在目录sdb1上的话,则DEVICE值为sdb1;
② ZONE从1开始计数,逐次加1;当一个Storage Node存在多个DEVICE时,可以设为同一个ZONE(推荐),也可以设为多个ZONE;
③ 如果每个挂载分区的大小都一样,WEIGHT(权重)不妨均设置成100。
6.3 创建startmain和startrest
root@ubuntu:~$ cat > ~/bin/startmain<<EOF
#!/bin/bash
swift-init main start
EOF
swift@ubuntu:~$ cat > ~/bin/startrest<<EOF
#!/bin/bash
swift-init rest start
EOF
root@ubuntu:~$ chmod +x ~/bin/*
root@ubuntu:~$ vim ~/.bashrc # 添加在最后
exportSWIFT_TEST_CONFIG_FILE=/etc/swift/test.conf
export PATH=${PATH}:~/bin
root@ubuntu:~$ . ~/.bashrc
6.4 启动Swift服务
root@ubuntu:~$ remakerings
root@ubuntu:~$ startmain
7 HTTP测试
7.1 获得X-Storage-Url和X-Auth-Token
root@ubuntu:~$ curl -v -H 'X-Storage-User: test:tester' -H 'X-Storage-Pass: testing' http://$LOCAL_NET_IP:8080/auth/v1.0
7.2 检测是否可以使用HEAD 命令查询account 状态
命令格式如下:
curl -k -v -H 'X-Auth-Token:<token-from-x-auth-token-above>' <url-from-x-storage-url-above>
具体示例如下:
curl -k -v -H 'X-Auth-Token: AUTH_tk9e8c4b51a25a4e0d96d88b5478633151' http://$LOCAL_NET_IP:8080/v1/AUTH_test
7.3 检测swift 命令是否工作正常
swift@ubuntu:~$ swift -A http://$LOCAL_NET_IP:8080/auth/v1.0 -U test:tester -K testing stat
预期输出应为zerocontainers、zero objects和zero bytes。
7.4 Swift常用命令
swift@ubuntu:~$ swift -A http://$LOCAL_NET_IP:8080/auth/v1.0 -U test:tester -K testing list #列出根目录的细节
swift@ubuntu:~$ swift -A http://$LOCAL_NET_IP:8080/auth/v1.0 -U test:tester -K testing list subfolder1 #列出一级子目录subfolder1的细节
swift@ubuntu:~$ swift -A http://$LOCAL_NET_IP:8080/auth/v1.0 -U test:tester -K testing upload subfolder1 /etc/swift/*.builder #把本地指定文件上传到一级子目录subfolder1中
swift@ubuntu:~$ swift -A http://$LOCAL_NET_IP:8080/auth/v1.0 -U test:tester -K testing delete subfolder1 etc/swift/account.builder #删除一级子目录subfolder1下的某个指定文件
swift@ubuntu:~$ sudo swift -A http://$LOCAL_NET_IP:8080/auth/v1.0 -U test:tester -K testing download subfolder1 #把一级子目录subfolder1中的资源都下载到本地当前目录
8 FTP测试
8.1 下载并安装ftp-cloudfs
方法一:
swift@ubuntu:~$ git clone https://github.com/cloudfs/ftp-cloudfs.git
swift@ubuntu:~$ cd ftp-cloudfs/
swift@ubuntu:~$ python setup.py install
swift@ubuntu:~$ sudo apt-get installpython-pip
swift@ubuntu:~$ pip install ftp-cloudfs
方法二:
swift@ubuntu:~$ sudo apt-get installpython-virtualenv
swift@ubuntu:~$ virtualenv ENV
swift@ubuntu:~$ source ENV/bin/activate
swift@ubuntu:~$ sudo apt-get installpython-pip
swift@ubuntu:~$ pip install --upgrade pip
swift@ubuntu:~$ pip install ftp-cloudfs
8.2 启动ftp-cloudfs服务
单用户情况下,可以使用如下命令启动ftp-cloudfs服务:
swift@ubuntu:~$ ftpcloudfs -b $LOCAL_NET_IP -a http://$LOCAL_NET_IP:8080/auth/v1.0 -f
多用户情况下,推荐使用如下命令启动ftp-cloudfs服务,性能会相对好些:
swift@ubuntu:~$ ftpcloudfs -b $LOCAL_NET_IP -a http://$LOCAL_NET_IP:8080/auth/v1.0 --memcache=$LOCAL_NET_IP:11211 --log-file /tmp/ftpcloufs.log
这里使用了memcache作为共享缓存。此外,我们把FTP相关的log输出到/tmp/ftpcloufs.log中便于查看。如果作为产品发布,建议还是使用--syslog。
如果要停止ftp-cloudfs服务,可以使用这条命令:
swift@ubuntu:~$ kill `cat/tmp/ftpcloudfs.pid`
8.3 Windows客户端FTP访问
可以在Windows客户端安装FTP工具(例如FileZilla),或者直接通过IE浏览器简单访问ftp://192.168.1.107:2021。
主机:192.168.1.107
用户名:test:tester
密码:testing
端口:2021
预期可以访问成功,并能够正常地上传、下载、新建、删除、重命名文件和目录等。
8.4 Linux客户端FTP访问
swift@ubuntu:~$ftp 192.168.1.107 2021
然后输入用户名密码,就可以访问成功并正常使用了。
常用的几个FTP命令如下:
cd remote-dir:进入远程主机目录。
ls [remote-dir] [local-file]:显示远程目录remote-dir,并存入本地文件local-file(和dir命令相同)。
mkdir dir-name:在远程主机中建一目录。
rmdir dir-name:删除远程主机目录。
rename [from] [to]:更改远程主机文件名。
delete remote-file:删除远程主机文件。
mdelete [remote-file]:删除远程主机文件。
get remote-file [local-file]:将远程主机文件remote-file传至本地文件local-file。
mget remote-files:传输多个远程文件。
put local-file [remote-file]:将本地文件local-file传送至远程主机。
mput local-file:将多个文件传输至远程主机。
pwd:显示远程主机的当前工作目录。
bye:退出ftp会话过程(和quit命令相同)。