Ceph入门到精通-创建存储桶通知

这篇具有很好参考价值的文章主要介绍了Ceph入门到精通-创建存储桶通知。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

在存储桶级别创建存储桶通知。这些需要 与发送存储桶通知的目标一起发布。桶 通知是 S3 操作。

父主题:
存储桶管理

先决条件

  • 运行 IBM Storage Ceph 集群,带有 Ceph Object Gateway。

  • 正在运行的 HTTP 服务器、RabbitMQ 服务器或 Kafka 服务器。

  • 根级访问。

  • 用户访问密钥和私有密钥。

  • 终结点参数。

重要:IBM 支持事件,例如 、 、 和 。IBM 还支持事件,例如 和 。ObjectCreateputpostmultipartUploadcopyObjectRemoveobject_deletes3_multi_object_delete

下面列出了创建存储桶通知的两种方法:

  • 使用 boto 脚本

  • 使用 AWS CLI

程序

使用 boto 脚本

  1. 安装 python3-boto3 软件包:

    <span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><code class="language-plaintext-ibm">[user@client ~]$  dnf install python3-boto3</code></span></span></span>
  2. 创建 S3 存储桶。

  3. 创建一个 python 脚本,为 、 或 协议创建 SNS 主题:topic.pyhttpamqpkafka

    <span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><code class="language-plaintext-ibm">import boto3
    from botocore.client import Config
    import sys
    
    # endpoint and keys from vstart
    endpoint = 'http://127.0.0.1:8000'
    access_key='0555b35654ad1656d804'
    secret_key='h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=='
    
    client = boto3.client('sns',
            endpoint_url=endpoint,
            aws_access_key_id=access_key,
            aws_secret_access_key=secret_key,
            config=Config(signature_version='s3'))
    
    attributes = {"push-endpoint": "amqp://localhost:5672", "amqp-exchange": "ex1", "amqp-ack-level": "broker"}
    
    client.create_topic(topic_name="mytopic", Attributes=attributes)</code></span></span></span>
  4. Run the python script for creating topic:

    Example

    <span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><code class="language-plaintext-ibm"> python3 topic.py</code></span></span></span>
  5. Create a python script to create S3 bucket notification for and events:notification.pys3:objectCreates3:objectRemove

    Example

    <span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><code class="language-plaintext-ibm">import boto3
    import sys
    
    # bucket name as first argument
    bucketname = sys.argv[1]
    # topic ARN as second argument
    topic_arn = sys.argv[2]
    # notification id as third argument
    notification_id = sys.argv[3]
    
    # endpoint and keys from vstart
    endpoint = 'http://127.0.0.1:8000'
    access_key='0555b35654ad1656d804'
    secret_key='h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=='
    
    client = boto3.client('s3',
            endpoint_url=endpoint,
            aws_access_key_id=access_key,
            aws_secret_access_key=secret_key)
    
    # regex filter on the object name and metadata based filtering are extension to AWS S3 API
    # bucket and topic should be created beforehand
    
    topic_conf_list = [{'Id': notification_id, 
                        'TopicArn': topic_arn, 
                        'Events': ['s3:ObjectCreated:*', 's3:ObjectRemoved:*'],
                        }]
        client.put_bucket_notification_configuration(
            Bucket=bucketname,
              NotificationConfiguration={
                'TopicConfigurations': [
                  {
                    'Id': notification_name,
                    'TopicArn': topic_arn,
                    'Events': ['s3:ObjectCreated:*', 's3:ObjectRemoved:*']
                  }]})</code></span></span></span>
  6. Run the python script for creating the bucket notification:

    Example

    <span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><code class="language-plaintext-ibm"> python3 notification.py</code></span></span></span>
  7. Create S3 objects in the bucket.

  8. Fetch the notification configuration:

    Example

    <span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><code class="language-plaintext-ibm">endpoint = 'http://127.0.0.1:8000'
    access_key='0555b35654ad1656d804'
    secret_key='h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=='
    
    client = boto3.client('s3',
            endpoint_url=endpoint,
            aws_access_key_id=access_key,
            aws_secret_access_key=secret_key)
    
    # getting a specific notification configuration is an extension to AWS S3 API
    
    print(client.get_bucket_notification_configuration(Bucket=bucketname))</code></span></span></span>
  9. Optional: Delete the objects.

    1. Verify the object deletion events at the , , or receiver.httprabbitmqkafka

Using the AWS CLI

  1. Create topic:

    Syntax

    <span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><code class="language-plaintext-ibm"> aws --endpoint=_AWS_END_POINT_ sns create-topic --name NAME --attributes=ATTRIBUTES_FILE</code></span></span></span>

    Example

    <span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><code class="language-plaintext-ibm"> [user@client ~]$ aws --endpoint=http://localhost sns create-topic --name test-kafka --attributes=file://topic.json
    
     sample topic.json:
     {"push-endpoint": "kafka://localhost","verify-ssl": "False", "kafka-ack-level": "broker", "persistent":"true"}
     ref: https://docs.aws.amazon.com/cli/latest/reference/sns/create-topic.html</code></span></span></span>
  2. Create the bucket notification:

    Syntax

    <span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><code class="language-plaintext-ibm"> aws s3api put-bucket-notification-configuration --bucket BUCKET_NAME --notification-configuration NOTIFICATION_FILE</code></span></span></span>

    Example

    <span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><code class="language-plaintext-ibm"> [user@client ~]$ aws s3api put-bucket-notification-configuration --bucket my-bucket --notification-configuration file://notification.json
    
     sample notification.json
     {
         "TopicConfigurations": [
             {
                 "Id": "test_notification",
                 "TopicArn": "arn:aws:sns:us-west-2:123456789012:test-kafka",
                 "Events": [
                     "s3:ObjectCreated:*"
                 ]
             }
         ]
     }</code></span></span></span>
  3. Fetch the notification configuration:

    Syntax

    <span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><code class="language-plaintext-ibm"> aws s3api --endpoint=_AWS_ENDPOINT_ get-bucket-notification-configuration --bucket BUCKET_NAME</code></span></span></span>

    文章来源地址https://www.toymoban.com/news/detail-553020.html

    <span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><span style="background-color:#1e1e1e"><code class="language-plaintext-ibm"> [user@client ~]$ aws s3api --endpoint=http://localhost get-bucket-notification-configuration --bucket my-bucket
     {
         "TopicConfigurations": [
             {
                 "Id": "test_notification",
                 "TopicArn": "arn:aws:sns:default::test-kafka",
                 "Events": [
                     "s3:ObjectCreated:*"
                 ]
             }
         ]
     }</code></span></span></span>

到了这里,关于Ceph入门到精通-创建存储桶通知的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Ceph入门到精通-Ceph PG状态详细介绍(全)

    本文主要介绍PG的各个状态,以及ceph故障过程中PG状态的转变。 Ceph is still creating the placement group. Ceph 仍在创建PG。 activating The placement group is peered but not yet active. PG已经互联,但是还没有active。 active Ceph will process requests to the placement group. Ceph 可处理到此PG的请求。 clean Ceph re

    2024年02月14日
    浏览(28)
  • Ceph入门到精通-ceph故障处理 - osd down处理

    发现osd掉之后,我们首先要确认是哪个主机的哪块盘,来判断是这个盘坏了还是什么原因 来看一下是哪两块 登录对应机器确认下是哪块盘 2.我们发现盘还在,首先尝试能否重启ceph-osd服务 ,这里已经拉起来了 3.如果重启无望或者盘漂移,重新卸载安装 3.1 看看日志 是不是有

    2024年02月01日
    浏览(27)
  • Ceph入门到精通-Linux下Ceph源码编译和GDB调试

    Ceph版本:14.2.22 Linux版本:ubuntu-server 18.04     Ceph源码是托管在Github上,由于某些原因,国内访问Github网站很慢,所以需要从其他途径加速获取源码。Github官方给出了几个Github的镜像网站: https://github.com.cnpmjs.org/ https://hub.fastgit.org/ 本地需要修改~/.gitconfig文件,才可以从上面

    2024年02月12日
    浏览(23)
  • Ceph入门到精通-podman 入门实战

    目录 podman安装 podman制作本地镜像 podman(docker)命令回顾 podman快速入门 一入编程深似海,从此节操是路人。 最近使用podman,就想着写一篇总结性的笔记,以备后续参考。就如同写代码,不写注释,过了一段时间可能会想这是我写的吗?不会吧,还要理一下逻辑才能读懂,不利

    2023年04月24日
    浏览(32)
  • Ceph入门到精通-sysctl参数优化

    sysctl.conf  是一个文件,通常用于在 Linux 操作系统中配置内核参数。这些参数可以控制网络、文件系统、内存管理等各方面的行为。 99-xx.yml  可能是一个文件名,其中  99-  是一个特定的命名约定。在  sysctl.conf  文件中,通常会有一个特定的顺序来加载配置项。通常,以 

    2024年02月10日
    浏览(27)
  • Ceph入门到精通-LVS基础知识

    LB集群:    (Load  Balancing)即负载均衡集群,其目的是为了提高访问的并发量及提升服务器的性能,其    实现方式分为硬件方式和软件方式。   硬件实现方式:         常用的有 F5公司的BIG-IP系列、A10公司的AX系列、Citrix公司的 NetScaler系列等   软件实现方式:   

    2024年02月11日
    浏览(27)
  • Ceph入门到精通-如何编译安装Quagga?

    Quagga Quagga中文翻译斑驴,是一种先进的路由软件包,提供一套基于TCP/IP的路由协议。 – 使得操作系统变成专业的路由 – 使得操作系统具有与传统路由通过路由协议直接对接 – BGP – OSPF – RIP – IS-IS – MPLS – LDP – BFD – PIM-SSM – 传统路由以提供所有路由协议的过程程序的

    2024年02月11日
    浏览(31)
  • Ceph入门到精通-OSD waring 设置建议

    以下检查表明 OSD 节点存在问题。 1 在 /var/lib/ceph/osd 中找到的多个ceph_fsid值。 这可能意味着您正在托管许多集群的 OSD 此节点或某些 OSD 配置错误以加入 您期望的集群。 2 设置可能会导致数据丢失,因为如果 未达到最小值,Ceph 将不会确认对客户端的写入。 osd pool default 

    2024年02月11日
    浏览(38)
  • Ceph入门到精通-更换osd、扩容osd

    1. 1 查看故障盘osd id 1.2 销毁osd 1.3 更换故障硬盘 1.4 查看新硬盘盘符 1.5 擦除新硬盘 1.6 预备替换原osd 1.7 查看osd fsid 1.8 激活osd 3.1 停止所有osd服务 3.2 销毁所有osd 3.3 擦除磁盘数据 3.4 清除crush数据 3.5 删除osd应用 4. 调整PG

    2024年02月19日
    浏览(32)
  • Ceph入门到精通-Nginx超时参数分析设置

    nginx中有些超时设置,本文汇总了nginx中几个超时设置 Nginx 中的超时设置包括: “client_body_timeout”:设置客户端向服务器发送请求体的超时时间,单位为秒。 “client_header_timeout”:设置客户端向服务器发送请求头的超时时间,单位为秒。 “send_timeout”:设置服务器向客户端

    2024年02月07日
    浏览(32)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包