{"id":1043,"date":"2021-12-03T16:34:28","date_gmt":"2021-12-03T08:34:28","guid":{"rendered":"https:\/\/www.yinyubo.com\/?p=1043"},"modified":"2023-04-14T11:12:54","modified_gmt":"2023-04-14T03:12:54","slug":"docker","status":"publish","type":"post","link":"https:\/\/www.yinyubo.com\/?p=1043","title":{"rendered":"docker\u7248Minio\u63a5\u5165LDAP"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"\u80cc\u666f\">\u80cc\u666f<\/h2>\n\n\n\n<p>\u56e0\u4e3a\u5b98\u7f51\u7684LDAP\u6587\u6863\u63a5\u5165\u5199\u7684\u8fc7\u4e8e\u5206\u6563\uff0c\u5b9e\u5728\u4e0d\u5229\u4e8e\u65b0\u624b\u90e8\u7f72\uff0c\u6240\u4ee5\u91cd\u65b0\u6574\u7406\u4e86\u4e00\u7248\uff0c\u65b9\u4fbf\u7528\u6237\u80fd\u4e00\u6b21\u90e8\u7f72\u5b8c\u6210<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"docker-\u8fd0\u884c\u4e00\u4e2aminio-\u670d\u52a1\u7aef\">docker \u8fd0\u884c\u4e00\u4e2aminio \u670d\u52a1\u7aef<\/h2>\n\n\n\n<p>1.\u9996\u5148\u6211\u4eec\u4f7f\u7528docker\u8fd0\u884c\u4e00\u4e2a\u65b0\u7248\u672c\u7684minio\u3002\u4e3b\u8981\u662f\u8bbe\u7f6eminio\u7684root\u7528\u6237\u540d\u5bc6\u7801(\u4ee5\u524d\u53ebAccessKey\u548csecrestKey)\uff0cLDAP\u670d\u52a1\u7aef\u4fe1\u606f<\/p>\n\n\n\n<p>2.\u6ce8\u610f\u4e0b\u9762\u8fd0\u884c\u547d\u4ee4\u4e2d${}\u7684\u66ff\u6362\u6210\u4f60\u81ea\u5df1\u7684LDAP\u670d\u52a1\u4fe1\u606f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run --rm -p 7000:9000 -p 7001:7001 --name minio1 \\\n  -e \"MINIO_ROOT_USER=minio\" \\\n  -e \"MINIO_ROOT_PASSWORD=minio123\" \\\n  -e \"MINIO_IDENTITY_LDAP_TLS_SKIP_VERIFY=on\" \\\n  -e \"MINIO_IDENTITY_LDAP_SERVER_INSECURE=on\" \\\n  -e \"MINIO_IDENTITY_LDAP_STS_EXPIRY=24h\" \\\n  -e \"MINIO_IDENTITY_LDAP_SERVER_ADDR=${LDAP\u57df\u540d}\" \\\n  -e \"MINIO_IDENTITY_LDAP_LOOKUP_BIND_DN=${LDAP\u53ea\u8bfb\u8d26\u6237}\" \\\n  -e \"MINIO_IDENTITY_LDAP_LOOKUP_BIND_PASSWORD=${LDAP\u53ea\u8bfb\u8d26\u6237\u7684\u5bc6\u7801}\" \\\n  -e \"MINIO_IDENTITY_LDAP_USER_DN_SEARCH_BASE_DN=${LDAP\u7528\u6237\u641c\u7d22\u57df}\" \\\n  -e \"MINIO_IDENTITY_LDAP_USER_DN_SEARCH_FILTER=(&amp;(objectClass=inetOrgPerson)(uid=%s))\" \\\n  -e \"MINIO_IDENTITY_LDAP_GROUP_SEARCH_BASE_DN=${LDAP\u7ec4\u641c\u7d22\u57df}\" \\\n  -e \"MINIO_IDENTITY_LDAP_GROUP_SEARCH_FILTER=(&amp;(objectclass=groupOfUniqueNames)(uniquemember=%d))\" \\\n  minio\/minio:RELEASE.2021-11-24T23-19-33Z server \/data --console-address \":7001\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"docker-\u8fd0\u884c\u4e00\u4e2aminio-\u5ba2\u6237\u7aef\">docker \u8fd0\u884c\u4e00\u4e2aminio \u5ba2\u6237\u7aef<\/h2>\n\n\n\n<p>1.\u8fd0\u884cminio\u5ba2\u6237\u7aef\uff0c\u5e76\u8fdb\u5165\u5bb9\u5668\u5185<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -it --entrypoint=\/bin\/sh minio\/mc<\/code><\/pre>\n\n\n\n<p>2.\u8bbe\u7f6e\u5ba2\u6237\u7aef\u5230\u670d\u52a1\u7aef\u7684\u8fde\u63a5\u4fe1\u606f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mc config host add minio http:\/\/${\u670d\u52a1\u5668IP}:7000 minio minio123 --api S3v4<\/code><\/pre>\n\n\n\n<p>3.\u68c0\u67e5minio\u670d\u52a1\u7aef\u7684\u6743\u9650\u5217\u8868<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mc config host add minio http:\/\/${\u670d\u52a1\u5668IP}:7000 minio minio123 --api S3v4<\/code><\/pre>\n\n\n\n<p>4.\u8bbe\u7f6e\u7528\u6237\u6743\u9650\u6216\u8005\u7ec4\u6743\u9650<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mc admin policy set minio consoleAdmin user=cn=\u674e\u9547\u4f1f,ou=XXX,ou=XXX,ou=XXX,dc=XXX\nmc admin policy set minio consoleAdmin group=cn=\u5357\u4eac\u6d4b\u8bd5\u90e8,dc=XXX<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u6253\u5f00\u6d4f\u89c8\u5668-\u4f7f\u7528ldap\u8d26\u6237\u767b\u5f55\">\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u4f7f\u7528ldap\u8d26\u6237\u767b\u5f55<\/h2>\n\n\n\n<p>\u8fd9\u91cc\u6211\u8bbe\u7f6e\u7684\u662f\u8d85\u7ba1\u7528\u6237\uff0c\u6240\u4ee5\u53ef\u4ee5\u770b\u5230\u6240\u6709\u7684\u529f\u80fd<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"509\" src=\"https:\/\/www.yinyubo.com\/wp-content\/uploads\/2021\/12\/image-1024x509.png\" alt=\"\" class=\"wp-image-1044\" srcset=\"https:\/\/www.yinyubo.com\/wp-content\/uploads\/2021\/12\/image-1024x509.png 1024w, https:\/\/www.yinyubo.com\/wp-content\/uploads\/2021\/12\/image-300x149.png 300w, https:\/\/www.yinyubo.com\/wp-content\/uploads\/2021\/12\/image-768x381.png 768w, https:\/\/www.yinyubo.com\/wp-content\/uploads\/2021\/12\/image.png 1057w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"788\" src=\"https:\/\/www.yinyubo.com\/wp-content\/uploads\/2021\/12\/image-1-1024x788.png\" alt=\"\" class=\"wp-image-1045\" srcset=\"https:\/\/www.yinyubo.com\/wp-content\/uploads\/2021\/12\/image-1-1024x788.png 1024w, https:\/\/www.yinyubo.com\/wp-content\/uploads\/2021\/12\/image-1-300x231.png 300w, https:\/\/www.yinyubo.com\/wp-content\/uploads\/2021\/12\/image-1-768x591.png 768w, https:\/\/www.yinyubo.com\/wp-content\/uploads\/2021\/12\/image-1.png 1100w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">python\u4f7f\u7528ldap\u8d26\u6237\u63a5\u5165minio\uff0c\u4e0b\u8f7d\u6587\u4ef6<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>from progress.bar import Bar\nimport threading\nfrom minio import Minio\nimport zipfile\nimport os\nimport time\nfrom minio.credentials import LdapIdentityProvider\n\n# STS endpoint \u4e00\u822c\u6765\u8bf4\u5c31\u662f MinIO server\u7684\u5730\u5740\nsts_endpoint = \"minio.lzw.local\"\n\n# LDAP username.\nldap_username = \"ldap\u7528\u6237\u540d\"\n\n# LDAP password.\nldap_password = \"ldap\u5bc6\u7801\"\n\nprovider = LdapIdentityProvider(sts_endpoint, ldap_username, ldap_password)\n\n# \u5982\u679c\u662fhttp\u7684\u6ce8\u610fsecure=False\uff0c\u4f7f\u7528\u4e0a\u9762\u7684ldap\u4fe1\u606f\nclient = Minio(sts_endpoint,secure=False, credentials=provider)\n\n# \u6d4b\u8bd5\u4e0b\u8f7d\u4e00\u4e2a\u6587\u4ef6\u73a9\u73a9\uff0c\u52a0\u4e00\u4e2a\u8fdb\u5ea6\u6761\nbucket_name=\"bucket\u540d\u5b57\"\n\nobject_name=\"object\u540d\u5b57\"\n\nget_object_with_progress(client, bucket_name, object_name)\n\ndef get_object_with_progress(client, bucket_name, object_name):\n    try:\n        data = client.get_object(bucket_name, object_name)\n        total_length = int(data.headers.get('content-length'))\n        bar = Bar(object_name, max=total_length \/ 1024 \/ 1024, fill='*', check_tty=False,\n                  suffix='%(percent).1f%% - %(eta_td)s')\n        with open('.\/' + object_name, 'wb') as file_data:\n            for d in data.stream(1024 * 1024):\n                bar.next(1)\n                file_data.write(d)\n        bar.finish()\n    except Exception as err:\n        print(err)\n\n\nclass ProgressThread(threading.Thread):\n    def __init__(self, name):\n        threading.Thread.__init__(self)\n        self.name = name\n\n    def run(self):\n        print(\"\u5f00\u59cb\u4e0b\u8f7d\u6587\u4ef6:\" + self.name)\n        global download_flag\n        max_number = 100\n        bar = Bar(self.name, max=max_number, check_tty=False)\n        for i in range(max_number):\n            # Do some work\n            if download_flag is False:\n                bar.next(max_number - i)\n                bar.finish()\n                break\n            else:\n                time.sleep(2)\n                bar.next()\n        print(\"\\n\u6587\u4ef6\u4e0b\u8f7d\u5b8c\u6210:\" + self.name)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f \u56e0\u4e3a\u5b98\u7f51\u7684LDAP\u6587\u6863\u63a5\u5165\u5199\u7684\u8fc7\u4e8e\u5206\u6563\uff0c\u5b9e\u5728\u4e0d\u5229\u4e8e\u65b0\u624b\u90e8\u7f72\uff0c\u6240\u4ee5\u91cd\u65b0\u6574\u7406\u4e86\u4e00\u7248\uff0c\u65b9\u4fbf\u7528\u6237\u80fd\u4e00\u6b21\u90e8\u7f72\u5b8c\u6210  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1043","post","type-post","status-publish","format-standard","hentry","category-influxdb"],"_links":{"self":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts\/1043","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1043"}],"version-history":[{"count":5,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts\/1043\/revisions"}],"predecessor-version":[{"id":1234,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=\/wp\/v2\/posts\/1043\/revisions\/1234"}],"wp:attachment":[{"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yinyubo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}