Import Oracle dump tables to Oracle Database in docker - oracle

OS is Ubuntu 20.04. I have a Oracle Database 19c which is in docker. In details, In /opt, I create oracle folder with subfolders and give them grant. You see them in following:
sudo chmod 777 /opt/oracle/admin/
sudo chown -R root /opt/oracle/admin/
sudo chmod 777 /opt/oracle/oradata/
sudo chown -R root /opt/oracle/oradata/
sudo chmod 777 /opt/oracle/scripts/startup/
sudo chown -R root /opt/oracle/scripts/startup/
sudo chmod 777 /opt/oracle/scripts/setup/
sudo chown -R root /opt/oracle/scripts/setup/
Then I run the Oracle Docker image with this command:
sudo docker run --name oracledb --shm-size=4g -p 1521:1521 -p 5500:5500 -e ORACLE_SID=testdb -e ORACLE_PDB=testpdb -e ORACLE_PWD=Oracle123 -v /opt/oracle/oradata:/opt/oracle/oradata -v /opt/oracle/admin:/opt/oracle/admin -v /opt/oracle/scripts/startup:/opt/oracle/scripts/startup -v /opt/oracle/scripts/setup:/opt/oracle/scripts/setup oracle:19.3.0
After running Oracle, I open sqlnet.ora in /opt/oracle/oradata/dbconfig/TESTDB of the host and change its content. After making change, it is like this:
SQLNET.AUTHENTICATION_SERVICES=(ALL)
NAMES.DIRECTORY_PATH= (EZCONNECT, TNSNAMES, HOSTNAME)
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
SQLNET.ALLOWED_LOGON_VERSION_SERVER=8
SQLNET.ALLOWED_LOGON_VERSION=8
Other two file are like this:
listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
)
)
tnsnames.ora
TESTDB=localhost:1521/TESTDB
TESTPDB=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = TESTPDB)
)
)
DEDICATED_THROUGH_BROKER_LISTENER=ON
DIAG_ADR_ENABLED = off
It is run without problem. I install Bbvis and create a User, but I cannot import any ".dmp" table.
Even though I can create user in Dbvis, UI Oracle does not work. I cannot see any thing in localhost:5500/em. It is strange for me.
Also, I install Sql developer to import the tables, but I cannot connect to database at all. I receive this error:
Status : Failure -Test failed: IO Error: Got minus one from a read call
I try to use impdp in docker like this:
docker exec -it id_container impdp user/password DUMPFILE=cst.dmp
but I receive this error:
ORA-27101: shared memory realm does not exist
Moreover, when I run this command:
sudo docker exec -ti 6e277a00b558 sqlplus system/Pass#TESTPDB
It wants me to enter user-name and password. I enter "system" and its password. But it is not accepted and I receive this error:
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Additional information: 4376
Additional information: -179270649
Process ID: 0
Session ID: 0 Serial number: 0
I search a lot and test every way to import the dump files into Oracle Docker in Ubuntu. Even, I install squirrelsql, but It can import CSV files which I do not have.
Any help is really appreciated.

Related

Docker MinIO entrypoint

I have this project which was initially set up on Mac, I'm on Windows, it's a Docker project which runs Node, Kafka and a few other containers, one of them being MinIO. Everything works as intended except MinIO, I get the following error:
createbuckets_1 | /bin/sh: nc: command not found
Docker-compose code:
createbuckets:
image: minio/mc
networks:
- localnet
depends_on:
- minio
entrypoint: >
/bin/sh -c "
while ! nc -zv minio 9000; do echo 'Wait minio to startup...' && sleep 0.1; done; sleep 5;
/usr/bin/mc config host add myminio http://minio:9000 X X;
/usr/bin/mc rm -r --force myminio/cronify/details;
/usr/bin/mc mb myminio/cronify/details;
/usr/bin/mc policy set download myminio/cronify/details;
exit 0;"
Where X is, credentials are supposed to be.
I have been trying to find a fix for weeks.
I have also tried to change the entrypoint from /bin/sh -c to /bin/bash -c or #!/bin/bash -c or #!/bin/sh -c, I get the same error except ".../bin/bash: nc: command not found".
Dockerfile contains:
FROM confluentinc/cp-kafka-connect
I am not entirely sure what you are asking here, but if you are asking about the error message itself, it is telling you that nc is not installed (because it won't be in a container). I am also not clear on which container minio is running in. Assuming the container is being pulled from minio/minio, then it will have curl installed, and you can just use the health check endpoint instead of trying to use nc - https://docs.min.io/minio/baremetal/monitoring/healthcheck-probe.html#minio-healthcheck-api. If it is not a minio container, you would just need to make sure it has curl installed (or nc if for some reason you were set on using that).

Running oracle queries through azure databricks

Hi I created a notebook in azure databricks to extract a table from an oracle database. I get the error DPI-1047 cannot locate a 64 bit oracle client library. I guess I have to have an oracle client library running on my cluster. I tried to research the issue and found many posts where people said I needed an init script for the oracle client. I couldnt find how to make that init script however. I also found on this website
https://medium.com/#srijansahay/connecting-sql-server-oracle-mysql-and-postgresql-from-azure-services-using-python-789e93d879b4
the following code:
%sh
mkdir -p /opt/oracle
cd /opt/oracle
wget https://download.oracle.com/otn_software/linux/instantclient/193000/instantclient-basic-linux.x64-19.3.0.0.0dbru.zip
unzip instantclient-basic-linux.x64–19.3.0.0.0dbru.zip
sudo sh -c “echo /opt/oracle/instantclient_19_3 > /etc/ld.so.conf.d/oracle-instantclient.conf”
sudo ldconfig
export LD_LIBRARY_PATH=/opt/oracle/instantclient_19_3:$LD_LIBRARY_PATH
This code is however for Linux. How do I modify it for windows? Here is what I have so far:
%sh
mkdir -p /opt/oracle
cd /opt/oracle
wget https://download.oracle.com/otn_software/nt/instantclient/19800/instantclient-basic-windows.x64-19.8.0.0.0dbru.zip
unzip instantclient-basic-windows.x64-19.8.0.0.0dbru.zip
sudo sh -c “echo /opt/oracle/instantclient_19_8 > /etc/ld.so.conf.d/oracle-instantclient.conf”
sudo ldconfig
export LD_LIBRARY_PATH=/opt/oracle/instantclient_19_8:$LD_LIBRARY_PATH
I think everything past the unzip is incorrect. Thanks for the help in advance I'm very new to databricks.
Since there are no library path and path Separation in Windows we need to use PATH for both instead. At the end of the script you place the python stuff.
Rem ic.cmd
C:
Set ORABAS = "\opt\oracle"
cd %ORABAS%
wget https://download.oracle.com/otn_software/nt/instantclient/19600/instantclient-basic-windows.x64-19.6.0.0.0dbru.zip
unzip instantclient-basic-windows.x64-19.6.0.0.0dbru.zip
set ORACLE_HOME=%ORABAS%\instantclient_19_3
set TNS_ADMIN=%ORACLE_HOME%
set PATH=%ORACLE_HOME%;%PATH%

How to specify the local directory in INTO OUTFILE-clause?

SELECT *
FROM tabname
INTO OUTFILE '~/results.csv'
FORMAT CSV
How to specify the outfile directory as the local workstation?
It needs to run this command from the client side (local workstation) and define the path to local file:
clickhouse-client --host ch_server --user test_user --password 12345 \
--query="select * from db_name.table_name INTO OUTFILE '/tmp/result.csv' FORMAT CSV"
To install clickhouse-client use command:
sudo apt-get install clickhouse-client

chown: changing ownership of '/u01/app/oracle': Operation not permitted

I am using Docker (Community edition, Version 17.09.1-ce-mac42 (21090), 3176a6af01). For webapp development, I need Oracle 12c (and I need saving my works (database table, view, data, etc.) after close Docker application), therefore I use https://github.com/MaksymBilenko/docker-oracle-12c
I do these steps
sudo docker pull sath89/oracle-12c
sudo mkdir -p /Users/donhuvy/Documents/oracle12c_data
sudo docker run -d -p 8080:8080 -p 1521:1521 -v /Users/donhuvy/Documents/oracle12c_data:/u01/app/oracle -e DBCA_TOTAL_MEMORY=2048 sath89/oracle-12c
Result
eccdc90353d36e85f08597dea894da332a29024d88c3e80d20894540029667d4
then
docker logs -f eccdc90353d36e85f08597dea894da332a29024d88c3e80d20894540029667d4
I see this error:
chown: changing ownership of '/u01/app/oracle': Operation not permitted
What is the cause and how to avoid the error?
On macOS 10.13.1 High Sierra with Docker Community Edition version 17.09.1-ce-mac42 (21090) 3176a6af01, do these steps:
sudo docker pull sath89/oracle-12c
sudo mkdir -p /Users/donhuvy/Documents/oracle12c_data
sudo mkdir -p /u01/app/oracle
To avoid error
chown: changing ownership of '/u01/app/oracle': Operation not
permitted
Use Finder, go to directory /Users/donhuvy/Documents/oracle12c_data, Right click, choose context menu Get info, see at the bottom right corner, you will see a lock icon, click the icon, enter your administration password. Then set permission Read & Write for everyone
Do the same thing with directory /u01/app/oracle
Then run
sudo docker run -d -p 8080:8080 -p 1521:1521 -v /Users/donhuvy/Documents/oracle12c_data:/u01/app/oracle -e DBCA_TOTAL_MEMORY=2048 sath89/oracle-12c
After you worked, if you want pause/stop your work, turn off Docker. When you turn on Docker, return previous works, all things are still exist.

SMB mount fails with execl()

To mount CIFS presently I use system() call in source, this works. If I try to run command manually on shell it works too.
$ mount -t cifs //IP/dir /mnt -o user=name,pass=PASS,domain=mydomain,nounix
$ mount.cifs //IP/dir /mnt -o user=name,pass=PASS,domain=mydomain,nounix
But if i replace the same command with exec() family i see errors.
if(fork() == 0)
{
if (execl("/bin/mount", "/bin/mount", "-t", "cifs", "//IP/dir", "/mnt",
"-o user=name,pass=PASS,domain=mydomain,nounix", (char*) NULL) < 0)
...
}
else
...
Error: mount: mounting cifs on //IP/dir /mnt failed: No such file or directory. It looks like mount directory "/mnt" is not recognized or not seen by mount process.
Tried below things but no luck:
as suggested in forums tried using sec=ntlmv2 and other options
with mount.cifs
combined arguments "//IP/dir" and "/mnt" as "//ipaddr/dir /mnt"
What would be the cause here? How to see the command line parameters of the exec()'ed program ?
Version of mount:
mount.cifs version: 1.14-x
Regards, - AK
Used strace() to find the arguments passed to execl(). Solved my issue by using system calls mount() and umount().
Presuming you have installed samba
sudo apt-get install samba
In the Global section of the file /etc/samba/smb.conf you should have this :-
workgroup = WORKGROUP
netbios name = PCNAME
name resolve order = bcast host
Change WORKGROUP and PCNAME accordingly. Set the name resolve order as shown in order to browse windows shares using Nautilus.

Resources