Swift -- How to Use

on keystone auth node:

1. Add a user for using Swift

# add swiftservice tenant

keystone tenant-create --name swiftservice --description "Swift Users Tenant"


# add swiftoperator role

keystone role-create --name swiftoperator


# add a user

keystone user-create --tenant swiftservice --name USER-NAME --pass USER-PASSWORD


# add the user in swiftoperator role

keystone user-role-add --user USER-NAME --tenant swiftservice --role swiftoperator


on client side:

1. yum -y install python-keystoneclient python-swiftclient


2. Load environment variables first

vi ~/keystonerc_swift

export OS_USERNAME=USER-NAME
export OS_PASSWORD=USER-PASSWORD
export OS_TENANT_NAME=swiftservice
export OS_AUTH_URL=http://controller:35357/v2.0/


chmod 600 ~/keystonerc_swift
source ~/keystonerc_swift
echo "source ~/keystonerc_swift " >> ~/.bash_profile


3. show status

swift stat


4. Create a Container for files

swift post test_container

swift list


5. Upload a file in local to a Container

swift upload test_container test.txt

swift list test_container


6. Download a file from Swift Storage to local

rm -rf test.txt

swift download test_container test.txt


7. Delere a file on Storage

swift delete test_container test.txt
swift list test_container


8. Delete a Container on Storage

swift delete test_container

swift list



你可能感兴趣的:(swift)