公有云私有云对象桶信息配置

简介

公有云与私有云配置对象桶信息是有差异的

一. 公有云-阿里云为例

使用软件s3cmd

1
2
3
4
# 安装s3cmd
yum install -y epel-release && yum install -y s3cmd
# 安装qemu
yum install qemu-kvm libvirt virt-install bridge-utils -y

其他安装方式(ubuntu)

https://developer.aliyun.com/article/356106
https://www.s3express.com/download.htm (s3软件下载链接)

简介:
https://wangyan.org/blog/s3cmd-how-to-use.html

s3cmd 安装使用指南
s3cmd 是一款 Amazon S3 命令行工具。它不仅能上传、下载、同步,还能设置权限,下面是完整的安装使用指南。

1
2
3
4
5
6
7
8
9
10
11
12
一、安装方法

# 方法一:(Debian/Ubuntu )
wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | sudo apt-key add -
wget -O/etc/apt/sources.list.d/s3tools.list http://s3tools.org/repo/deb-all/stable/s3tools.list
apt-get update && sudo apt-get install s3cmd

# 方法二:
wget http://nchc.dl.sourceforge.net/project/s3tools/s3cmd/1.0.0/s3cmd-1.0.0.tar.gz
tar -zxf s3cmd-1.0.0.tar.gz -C /usr/local/
mv /usr/local/s3cmd-1.0.0/ /usr/local/s3cmd/
ln -s /usr/local/s3cmd/s3cmd /usr/bin/s3cmd

阿里云配置如下

https://github.com/zznn-cloud/zznn-cloud-blog-images/raw/main/Qexo/24/1/image_896f06a76b5634cec9f24ce6f7ec5119.png

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 初始化s3cmd
s3cmd --configure
# 执行
[root@3z6to251zh02kg system]# s3cmd --configure

Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.

Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.
# Access Key: LTAI5t9
# Secret Key: XD0f6iyM0nY8oUJZz
Default Region [US]: # hangzhou

Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.
S3 Endpoint [s3.amazonaws.com]: # oss-cn-hangzhou.aliyuncs.com (buckets域名在阿里云oss概览中查看)

Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used
if the target S3 system supports dns based buckets.
DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]: # %(bucket)s.oss-cn-hangzhou.aliyuncs.com
# %(bucket)s.oss-cn-hangzhou.aliyuncs.com
Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password:
Path to GPG program [/bin/gpg]:

When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP, and can only be proxied with Python 2.7 or newer
# Use HTTPS protocol [Yes]: Yes

On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can't connect to S3 directly
HTTP Proxy server name:

New settings:
Access Key: LTAI5t9EwR
Secret Key: XD0f6iyM0nJZz1
Default Region: hangzhou
S3 Endpoint: oss-cn-hangzhou.aliyuncs.com
DNS-style bucket+hostname:port template for accessing a bucket: %(bucket)s.oss-cn-hangzhou.aliyuncs.com
Encryption password:
Path to GPG program: /bin/gpg
Use HTTPS protocol: True
HTTP Proxy server name:
HTTP Proxy server port: 0

Test access with supplied credentials? [Y/n] y
Please wait, attempting to list all buckets...
Success. Your access key and secret key worked fine :-)

Now verifying that encryption works...
Not configured. Never mind.

Save settings? [y/N] y
Configuration saved to '/root/.s3cfg'

# 此时设置完成

客户端连接软件配置

https://github.com/zznn-cloud/zznn-cloud-blog-images/raw/main/Qexo/24/1/image_69abbafcc46e7ce35928521f13a67e58.png

此时即可访问阿里云对象存储。

二. 私有云 某云配置

1
2
3
4
5
6
7
8
9
10
11
12
13
# 创建buckets报错:原因版本不一致 需要将v2启用
解决:
vim /root/.s3cfg
signature_v2 = True
# 或新建文件输入:
vim ~/.s3cfg
[default]
access_key = 914c4
secret_key = qk45WMQg5VP4MBeAYE
host_base = http://111.111.87.99:7480
host_bucket = http://111.111.87.99:7480/914c48814
use_https = False
signature_v2 = True

三. 扩展s3cmd命令使用

1
2
3
4
5
6
7
8
9
10
11
12
# 命令使用
#创建bucket名称为s3://cem-demo
s3cmd -h # 查看命令详情
s3cmd put /etc/fstab s3://s3cmd-demo/fstab-demo # 上传文件将/etc目录下文件fstab上传
s3cmd ls s3://ceph-s3-bucket # 查看bucket里面有什么查看具体内容后面接目录
s3cmd put /etc s3://ceph-s3-bucket/fstab-demo/etc/ --recursive # 上传目录(递归的方式记得"/")
s3cmd get s3://ceph-s3-bucket/s3browser-6-4-1.rar # 下载命令

s3cmd rm s3://ceph-s3-bucket/fstab-demo # 删除文件命令
s3cmd rm s3://ceph-s3-bucket/fstab-demo/ --recursive # 删除目录命令
s3cmd mb s3://cmd-demo # 创建目录