In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to use Rest api to manage Ceph gateways". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use Rest api to manage Ceph gateways.
Background
To develop micro-services based on Ceph RadosGW, it is necessary to implement the functions that callers can create users and obtain user information through rest api.
Realize
Ceph's RadosGW has this function itself, and these functions such as creating users, obtaining user information, obtaining usage, and so on are called Admin Operation (administrative operations). We can access and perform management operations directly through the URL of RadosGW plus / admin. For example, if the URL of RadosGW is http://192.168.1.2:8080, then the URL of management operations is http://192.168.1.2:8080/admin.
The authorization of administrative operations is the same as the authorization mechanism of S3, except that after the S3 user is created, the administrative rights need to be attached to the responding user. As follows, we will create a user with administrative privileges.
Execute the following statement in the Ceph cluster (of course, you can replace it with the user name and key you need):
$sudo radosgw-admin user create-uid= "my_s3_user"-display-name= "my_user_display_name"-access-key= "my_admin_access_key"-secret-key= "my_admin_secret_key" $sudo radosgw-admin-id admin caps add-caps= "buckets=*;users=*;usage=*;metadata=*"-uid= "my_s3_user"
As above, a user with administrative privileges is created, and then you can use the api (click Browse) provided on the official website.
In addition, if you don't want to use Rest api directly, you can also use some packaged third-party libraries. Here, I introduce a third-party library for Java (click to browse), which is exactly the one I am using right now.
The following sample code creates an S3 user, obtains the S3 certificate, and sets a quota.
Private static void testRadosAdmin () {String accessKey = "my_admin_access_key"; String secretKey = "my_admin_secret_key"; String adminEndpoint = "http://109.105.115.102:7480/admin"; RgwAdmin rgwAdmin = new RgwAdminBuilder (). AccessKey (accessKey) .secretKey (secretKey) .build (); String userId =" 8eeb3bb0-eda0-48f9-a18f-c04daecb5e69 " User user = null; / / create a user user = rgwAdmin.createUser (userId) If (user! = null) {/ / get user S3Credential for (S3Credential credential: user.getS3Credentials ()) {System.out.println ("userid:" + credential.getUserId () + ", getAccessKey:" + credential.getAccessKey () + ", getSecretKey:" + credential.getSecretKey () } / / set user quota, such as maxObjects and maxSize (KB) rgwAdmin.setUserQuota (userId, 1000, 1024 * 1024 * 5); Optional quota = rgwAdmin.getUserQuota (userId); if (quota.isPresent ()) {System.out.println ("quota KB:" + quota.get (). GetMaxSizeKb ()) }} else {System.out.println ("create user failed");}} at this point, I believe you have a deeper understanding of "how to use Rest api to manage Ceph gateways". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.