Skip to content

Commit 43dbb2a

Browse files
committed
oac * postgresql
1 parent 602a296 commit 43dbb2a

File tree

11 files changed

+147
-0
lines changed

11 files changed

+147
-0
lines changed

data-platform/open-source-data-platforms/oci-postgresql/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ OCI Database with PostgreSQL is designed for high availability by offering durab
2424
- [Terraform to deploy OCI PostgreSQL database](https://blogs.oracle.com/cloud-infrastructure/post/deploy-managed-oci-database-with-postgresql-service-with-terraform)
2525
- [Backup and Restore an OCI Database with PostgreSQL](https://docs.oracle.com/en/learn/backup-and-restore-db-with-postgresql/index.html#introduction)
2626

27+
# Reusable Assets
28+
29+
- [Create a connection between OCI PostgreSQL and Oracle Analytics Cloud](https://github.com/oracle-devrel/technology-engineering/tree/main/data-platform/open-source-data-platforms/oci-postgresql/code-examples/connect-to-oac)
30+
When you are looking to establish an OCI PostgreSQL instance, connect to it, and connect to Oracle Analytics Cloud, use these steps to guide you. The steps include using DBeaver to create a new table and load data, create an OCI PostgreSQL instance, connect to it, and connect the instance as source to Oracle Analytics Cloud.
31+
32+
2733
# License
2834

2935
Copyright (c) 2024 Oracle and/or its affiliates.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2024 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Connect OCI PostgreSQL to Oracle Analytics Cloud
2+
3+
Reviewed: 29.07.2024
4+
5+
# When to use this asset?
6+
7+
When you are looking to establish an OCI PostgreSQL instance, connect to it, and connect to Oracle Analytics Cloud
8+
9+
# How to use this asset?
10+
11+
Open the connect-to-oac.md file and follow the steps carefully.
12+
13+
# Pre-requisites:
14+
15+
- Create a VCN with public and private subnet
16+
- Create an OCI PostgreSQL database instance in the private subnet
17+
- Create a Linux instance in public subnet, same VCN
18+
- Add port 5432 to the private subnet security list
19+
20+
# License
21+
22+
Copyright (c) 2024 Oracle and/or its affiliates.
23+
24+
Licensed under the Universal Permissive License (UPL), Version 1.0.
25+
26+
See [LICENSE](https://github.com/oracle-devrel/technology-engineering/blob/main/LICENSE) for more details.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Connect to OCI PostgreSQL, load data using DBeaver and connect to Oracle Analytics Cloud
2+
3+
Prerequisites
4+
- Create a VCN with public and private subnet
5+
- Create an OCI PostgreSQL database instance in the private subnet
6+
- Create a Linux instance in public subnet, same VCN
7+
- Add port 5432 to the private subnet security list
8+
9+
For more details on using Linux instance to connect to PostgreSQL, [see documentation here](https://www.postgresql.org/download/linux/redhat/).
10+
11+
# Create and access an OCI PostgreSQL database
12+
13+
1. SSH into the Linux instance, make sure the instance is in the public subnet of the same VCN you provisioned the OCI PostgreSQL instance. Run the below command. This will install the client for PostgreSQL version 14.
14+
```
15+
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
16+
sudo dnf -qy module disable postgresql
17+
sudo dnf install -y postgresql14-server
18+
sudo /usr/pgsql-14/bin/postgresql-14-setup initdb
19+
sudo systemctl enable postgresql-14
20+
sudo systemctl start postgresql-14
21+
```
22+
23+
2. Following, run the below command.
24+
```rm -rf ~/.pgpass```
25+
26+
3. Go to your OCI PostgreSQL overview page, click on **Copy** in the CA Certificate or download the certificate. Run the below command in the terminal.
27+
```
28+
sudo nano ./dbsystem.pub
29+
```
30+
31+
4. Copy and paste the full certificate int he dbsystem.pub file. Save and close the file.
32+
33+
5. Test the connection using the following command. Change the private IP and user name.
34+
```psql -h [DB Private IP] -U [user name] -d postgres```
35+
36+
Example of statement: *psql -h 10.0.1.81 -U admin -d postgres*
37+
38+
6. Run the below statement as test to review the connection.
39+
```select version();```
40+
41+
7. Connect as user. Change the below command and run in the terminal.
42+
```psql "sslmode=verify-full sslrootcert=./dbsystem.pub host=<endpoint_fqdn> hostaddr=[DB private IP] dbname=postgres user=<user_name>"```
43+
44+
Example of fulll statement: *psql "sslmode=verify-full sslrootcert=./dbsystem.pub host=e43jihot7lyhlnh6kat3io357iy43a-primary.postgresql.us-ashburn-1.oc1.oraclecloud.com hostaddr=10.0.1.81 dbname=postgres user=admin"*
45+
46+
8. Run something as test the connection is working.
47+
```select version();```
48+
49+
50+
# Connect using DBeaver
51+
52+
9. Install DBeaver locally
53+
54+
10. Add the credentials to connect to the OCI PostgreSQL. See the screenshots. DBeaver will use the same instance in the public subnet (using SSH) to be able to access the OCI PostgreSQL database.
55+
56+
![1](images/img_1.png)
57+
![2](images/img_2.png)
58+
59+
11. Create a new table and load some data using DBeaver. See an example of loading .csv file [here](https://dbeaver.com/docs/dbeaver/Data-transfer/).
60+
61+
62+
# Connect using Oracle Analytis Cloud (OAC).
63+
64+
12. Create on OAC instance. See documentation here to [create an OAC instance](https://docs.oracle.com/en/cloud/paas/analytics-cloud/acoci/create-services.html#ACOCI-GUID-47022452-65CC-4345-8F7F-A447BB24A48A).
65+
66+
13. Create a new Private Zone in DNS management. See the below screen or review the [documentation](https://docs.oracle.com/en-us/iaas/Content/DNS/Tasks/privatedns.htm#:~:text=Use%20private%20DNS%20to%20create,premises%20or%20other%20private%20networks.).
67+
68+
14. Add a new record in the new private zone, pointing to the private ip/endpoint of the OCI PostgreSQL database instance.
69+
70+
![4](images/img_4.png)
71+
![3](images/img_3.png)
72+
73+
15. Create a PAC for the OAC instance. Use the zone just created (not the record). Select the private subnet. Review the steps in this [documentation](https://blogs.oracle.com/analytics/post/create-a-private-access-channel-in-oracle-analytics).
74+
75+
![5](images/img_5.png)
76+
77+
16. Open OAC and create the connection to the OCI PostgreSQL instance. Add the correct details: use the just created private zone and record as host. Add the correct username and password.
78+
79+
![5](images/img_6.png)
80+
![6](images/img_7.png)
38.3 KB
Loading
27.1 KB
Loading
47.3 KB
Loading
321 KB
Loading
38.6 KB
Loading
34.4 KB
Loading

0 commit comments

Comments
 (0)