2
1

Mountpoint for Amazon S3 に RDS for Oracle からデータエクスポートしてみた

Posted at

はじめに

最初に断っておくと、現時点では RDS for OracleからMountpoint for Amazon S3を直接マウントすることはできないため、外部のEC2インスタンスにS3をマウントして、そこに従来型のexpでデータを出力する、というあまり実用的ではない形の紹介となる。

image.png

将来的にはRDS for OracleからそのままS3をマウントすることができるようになると拝察され、その場合には以下のような構成をとることができる。この構成はexpdp/impdpだけではなく、外部表としてのS3の利用も可能となると想定され、RDS for Oracleの利用方法を大きく変える可能性があると考えている。

image.png

Mountpoint for Amazon S3って?

Mountpoint for Amazon S3は2023/8/9に Mountpoint for Amazon S3 の一般提供を開始 としてGAされた機能で、EC2からS3を直接マウントしてファイルの読み書きができる、という機能となる。(現時点でファイル更新とかはできない)

本機能については「 [アップデート] Mountpoint for Amazon S3 が GA されました。 」等で解説されているので、確認してほしい。

Mountpoint for Amazon S3 に RDS for Oracleからデータエクスポートしてみた

Mountpoint for Amazon S3のインストール

EC2(Amazon Linux2)にmount-s3.rpmをインストールする。

mount-s3.rpm インストールログ
インストールログ
$ wget https://s3.amazonaws.com/mountpoint-s3-release/latest/x86_64/mount-s3.rpm
--2023-09-17 00:55:06--  https://s3.amazonaws.com/mountpoint-s3-release/latest/x86_64/mount-s3.rpm
Resolving s3.amazonaws.com (s3.amazonaws.com)... 52.217.120.16, 52.216.34.16, 52.217.228.24, ...
Connecting to s3.amazonaws.com (s3.amazonaws.com)|52.217.120.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10443024 (10.0M) [binary/octet-stream]
Saving to: ‘mount-s3.rpm’

100%[========================================================================================================================================================================>] 10,443,024  4.70MB/s   in 2.1s

2023-09-17 00:55:09 (4.70 MB/s) - ‘mount-s3.rpm’ saved [10443024/10443024]

$ sudo yum install ./mount-s3.rpm
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Examining ./mount-s3.rpm: mount-s3-1.0.1-1.x86_64
Marking ./mount-s3.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mount-s3.x86_64 0:1.0.1-1 will be installed
--> Processing Dependency: fuse for package: mount-s3-1.0.1-1.x86_64
akopytov_sysbench/x86_64/signature                                                                                                                                                         |  833 B  00:00:00
akopytov_sysbench/x86_64/signature                                                                                                                                                         | 1.0 kB  00:00:00 !!!
akopytov_sysbench-source/signature                                                                                                                                                         |  833 B  00:00:00
akopytov_sysbench-source/signature                                                                                                                                                         | 1.0 kB  00:00:00 !!!
amzn2-core                                                                                                                                                                                 | 3.7 kB  00:00:00
https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
322 packages excluded due to repository priority protections
--> Running transaction check
---> Package fuse.x86_64 0:2.9.2-11.amzn2 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================
 Package                                          Arch                                           Version                                                 Repository                                          Size
==================================================================================================================================================================================================================Installing:
 mount-s3                                         x86_64                                         1.0.1-1                                                 /mount-s3                                           53 M
Installing for dependencies:
 fuse                                             x86_64                                         2.9.2-11.amzn2                                          amzn2-core                                          86 k

Transaction Summary
==================================================================================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total size: 53 M
Total download size: 86 k
Installed size: 53 M
Is this ok [y/d/N]: y
Downloading packages:
fuse-2.9.2-11.amzn2.x86_64.rpm                                                                                                                                                             |  86 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
pgdg-redhat-repo-42.0-24.noarch has missing requires of /etc/redhat-release
  Installing : fuse-2.9.2-11.amzn2.x86_64                                                                                                                                                                     1/2
  Installing : mount-s3-1.0.1-1.x86_64                                                                                                                                                                        2/2
  Verifying  : fuse-2.9.2-11.amzn2.x86_64                                                                                                                                                                     1/2
  Verifying  : mount-s3-1.0.1-1.x86_64                                                                                                                                                                        2/2

Installed:
  mount-s3.x86_64 0:1.0.1-1

Dependency Installed:
  fuse.x86_64 0:2.9.2-11.amzn2

Complete!

S3のマウント

S3(バケット名:asahide-test-s3)をマウントポイント /mnt/s3-mount にマウントする。
root:root 755 になってしまうので、変更しようとしたができず。。

S3のマウント
$ sudo mount-s3 asahide-test-s3 /mnt/s3-mount
bucket asahide-test-s3 is mounted at /mnt/s3-mount

$ sudo ls -l /mnt
total 0
drwxr-xr-x 2 root root 0 Sep 17 00:57 s3-mount

$ sudo chmod 777 /mnt/s3-mount
chmod: changing permissions of ‘/mnt/s3-mount’: Operation not permitted

試しにそのままexpを実行してみたが、やはり書き込みできず失敗。

expの実行
$ exp admin/xxxxxxxx@testdb01.xxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com:1521/testdb01 tables=testusr.testtbl file=/mnt/s3-mount/testexp.dmp log=/mnt/s3-mount/testexp.log
Export: Release 21.0.0.0.0 - Production on Sun Sep 17 01:01:23 2023
Version 21.8.0.0.0

Copyright (c) 1982, 2022, Oracle and/or its affiliates.  All rights reserved.

EXP-00028: failed to open /mnt/s3-mount/testexp.log for write
EXP-00000: Export terminated unsuccessfully

S3再マウント&再exp

expを実行するec2-userで再マウントを行う。

再マウント
$ sudo umount /mnt/s3-mount
$ sudo -u ec2-user mount-s3 asahide-test-s3 /mnt/s3-mount
bucket asahide-test-s3 is mounted at /mnt/s3-mount
$ mount | grep s3
mountpoint-s3 on /mnt/s3-mount type fuse (rw,nosuid,nodev,noatime,user_id=1000,group_id=1000,default_permissions)
$ ls -l /mnt
total 0
drwxr-xr-x 2 ec2-user ec2-user 0 Sep 17 01:10 s3-mount

無事ec2-userでマウントできたので、expを実行。

exp実行
$ exp admin/xxxxxxxx@testdb01.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com:1521/testdb01 tables=testusr.testtbl file=/mnt/s3-mount/testexp-s3.dmp log=/mnt/s3-mount/testexp-s3.log

Export: Release 21.0.0.0.0 - Production on Sun Sep 17 01:12:59 2023
Version 21.8.0.0.0

Copyright (c) 1982, 2022, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.19.0.0.0
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses JA16SJISTILDE character set (possible charset conversion)

About to export specified tables via Conventional Path ...
Current user changed to TESTUSR
. . exporting table                        TESTTBL          1 rows exported
EXP-00091: Exporting questionable statistics.
Export terminated successfully with warnings.

無事expが完了。

exp結果
$ ll /mnt/s3-mount/ | grep testexp
-rw-r--r-- 1 ec2-user ec2-user      16384 Sep 17 01:13 testexp-s3.dmp
-rw-r--r-- 1 ec2-user ec2-user        508 Sep 17 01:13 testexp-s3.log

image.png

まとめ

最初にも記載したが、RDS for OracleそのものからS3と直接やり取りできるようになると、外部表としての利用等でローカル以外のIOリソースが利用できるようになり、新たな利用ができるようになると考えている。
現状環境がなく確認できないが、RDS Custrom for Oracleで既に利用可能であれば幅広い活用ができると拝察している。

おまけ

出力したexpダンプファイルのimpでの取り込みを実施した。
当然ながら特に問題なくimpできることが確認できた。

impの結果
$ imp admin/xxxxxxxx@testdb01.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com:1521/testdb01 tables=testtbl fromuser=testusr touser=testusr ignore=y file=/mnt/s3-mount/testexp-s3.dmplog=/mnt/s3-mount/testimp-s3-4.log

Import: Release 21.0.0.0.0 - Production on Sun Sep 17 01:17:31 2023
Version 21.8.0.0.0

Copyright (c) 1982, 2022, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.19.0.0.0

Export file created by EXPORT:V21.00.00 via conventional path
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses JA16SJISTILDE character set (possible charset conversion)
IMP-00403:

Warning: This import generated a separate SQL file "/mnt/s3-mount/testimp-s3-4_sys.sql" which contains DDL that failed due to a privilege issue.

. importing TESTUSRs objects into TESTUSR
. . importing table                      "TESTTBL"          1 rows imported
Import terminated successfully with warnings.

$ sqlplus admin/xxxxxxxx@testdb01.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com:1521/testdb01
SQL*Plus: Release 21.0.0.0.0 - Production on Sun Sep 17 01:17:35 2023
Version 21.8.0.0.0

Copyright (c) 1982, 2022, Oracle.  All rights reserved.

Last Successful login time: Sun Sep 17 2023 01:17:31 +00:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.19.0.0.0

SQL> select * from testusr.testtbl;

        ID VAL
---------- ----------
         1 hogehoge

Elapsed: 00:00:00.00
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1