I installed oracle db version 19c in my docker environment with the following command:
docker run --name oracle19c --network host -p 1521:1521 -p 5500:5500
-v /opt/oracle:/u01/oracle oracle/database:19.3.0-ee
Then I connect to it with:
docker exec -ti oracle19c sqlplus system/oracle#orclpdb1
SQL>
Then I setup my database. Afterwards I want to import dummy data from a tbl file so I exit sqlplus and I use the command:
sqlldr userid=system control=/home/userhere/sql_loader/control.ctl log=sf1customer.log
and get sqlldr: not found
I don't have much experience with Docker, but my research leads to me to believe that SQL *Loader does not come with the docker image. However, I do not know how to extend the image or where exactly I would call SQL *Loader even if I did. I am on a Ubuntu server and any help would be appreciated.
SQL*Loader is in the image - but the docker container is separate from your host OS, so ubuntu doesn't know any of the files or commands inside it exist. Any commands inside the container should be run as docker commands. If you try this, it should connect to your running container and print the help page:
docker exec -ti oracle19c sqlldr
Since you're running this command on the docker container, sqlldr doesn't have access to any of your host OS's files unless you specifically granted them to the container. But good news - when you started the database with docker run, that's what the -v /opt/oracle:/u01/oracle part of the command did - it mapped /opt/oracle on your Ubuntu filesystem to /u01/oracle in the docker container. So any files that you put in /opt/oracle will be available in the container under /u01/oracle.
So you'll need to do a couple things:
Your control.ctl file, log file, and whatever data file you're using need to be accessible to the container. Either move them to /opt/oracle or shutdown your database container and restart it with something like -v /home/userhere/sql_loader:/u01/oracle in the command.
You might also need to edit your control.ctl file to make sure that it doesn't reference any file paths on your host OS. Either use relative paths (./myfile.csv) or absolute paths with the container's filesystem (/u01/oracle/myfile.csv)
Now you should be able to run sqlldr on the container, and it should be able to access your data files.
docker exec -ti oracle19c sqlldr userid=system control=/u01/oracle/control.ctl log=/u01/oracle/sf1customer.log
Edit: Oh, I should mention - as an alternative, if you download and install the Oracle Instant Client in Ubuntu, you could run sqlldr locally in Ubuntu, and connect to the docker container over the network as a "remote" database:
sqlldr system#localhost:1521/orclpdb1 control=/home/userhere/sql_loader/control.ctl log=sf1customer.log
That way you don't have to move your files anywhere.
Related
Sometimes the Docker container where Memgraph is running just stops working or says that the process was aborted with exit code 137. How can I fix this?
You should check the Memgraph logs, where you'll probably find the reason why the process was aborted.
Since you said that you're using Memgraph with Docker, there are two options:
If you run Memgraph with Docker using the volume for logs, that is with
-v mg_log:/var/log/memgraph, then mg_log folder usually can be found at \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\ (Windows) or /var/lib/docker/volumes/ (Linux and macOS).
If you run Memgraph without using the volume for logs, then you need to enter the Docker container. In order to do that, first you have to find out the container ID by running docker ps. Then you have to copy the container ID and run docker exec -it <containerID> bash. For example, if container ID is 83d76fe4df5a, then you run docker exec -it 83d76fe4df5a bash. Next, you need find the folder where logs are located. You can do that by running cd /var/log/memgraph. To read the logs, run cat <memgraph_date>.log, that is, if you have log file memgraph_2022-03-02.log located inside the log folder, then run cat memgraph_2022-03-02.log.
Hopefully, when you read the logs, you'll be able to fix your problem.
I migrated from Linux to Windows and tried to setup a postgres container with a mounted directory (copied from my Linux install) containing the database.
This does not work.
Windows mounts are always owned by root
Postgres does not run under root
How to get this unholy combination to work?
You don't provide much details so it is difficult to tell what actually went wrong. However there is a known issue with Postgres setup on Windows Docker using a windows mount for database data files. In that case, running docker logs will show something along the following lines
waiting for server to start....FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
HINT: The server must be started by the user that owns the data directory.
stopped waiting
pg_ctl: could not start server
Unfortunately there is no way to overcome this issue so you cannot use Windows mount, see Postgres Data has wrong ownership. You may use docker volumes in order to make database data indipendent from docker postgres container, using the following commands
docker create -v /var/lib/postgresql/data --name PostgresData alpine
docker run -p 5432:5432 --name yourPostgres -e POSTGRES_PASSWORD=yourPassword -d --volumes-from PostgresData postgres
You may find a more thoroughful explanation at Setup Postgresql on Windows with Docker
I run Oracle Database 12.2.0.1 from official dockerfile. As far as I see, if I do
docker stop <container_id>
the current state of the database is lost and next time it will do some clean start.
How to shutdown the database correctly and stop the container, but save the current state?
If I do
./sqlplus sys as sysdba
SHUTDOWN IMMEDIATE
the container remains running and still consumes 11GB of 16GB of RAM, so as far as I guess, to stop the container I should probably kill some process, but it is not clear when should I do
docker commit <container_id>
so ideally I need something like shutdown_oracle_and_commit_container.sh.
Inside the docker container the oracle instance is started with runOracle.sh, but there is no stopOracle.sh
You should use a docker volume to store the data from your database outside your container. Therefore use the -v option and mount any path you like to store your data to /opt/oracle/oradata inside the container.
From the docs:
-v /opt/oracle/oradata
The data volume to use for the database.
Has to be writable by the Unix "oracle" (uid: 54321) user inside the container!
If omitted the database will not be persisted over container recreation.
So according to that run:
docker run -v /path/to/your/datastore/:/opt/oracle/oradata oracle/database
The data from your database are now stored outside the container. If you use docker stop <container_id> or even docker rm <container_id> and you recreate a container again your data will be the same. For more information and configuration parameters see the docs.
To shutdown the DB inside docker container, first
get into container in interactive mode, by executing:
docker exec -it <name> /bin/bash
if you made it with default name, <name> = myxedb
start sqlplus and login to your DB (as sysdba)
sqlplus /nolog
conn sys/***#<db> as sysdba
in my case, <db> = //localhost:1521/XE
issue the shutdown process
shutdown immediate
That's it.
I am using docker on windows. With the use of kitematic, I have created an ubuntu container. This ubuntu image has postgresql installed on it.
Wondering if there is any possibility to access the postgres configuration files available in the container from the host (windows machine)?
Where exactly does the container store its file system on the host machine?
I hope it would be part of image file with format VMDK.
Please correct me if I'm wrong.
Wondering if there is any possibility to access the postgres configuration files available in the container from the host (windows machine)
That is not how Docker would allow you to modify a file in a container.
For that, you should mount a host (Windows) folder when starting (docker run -v) your container.
See "Mount a host directory as a data volume"
docker run -d -P --name web -v /c/Users/<myACcount>/src/webapp:/opt/webapp training/webapp python app.py
Issue 247 mentions ~/Library/Application Support/Kitematic for App data, and ~/Kitematic "for easy access to volume data".
Can I have multiple databases on oracle express edition? Please let me know what are steps to setup?
No. You can only have one XE database per server. You can have as many schemas in that database as you'd like. If you are coming from a background in other databases, what most databases refer to as a database is most equivalent to what Oracle refers to as a schema.
We were using separate virtual machine instances with Windows XP installed to create multiple oracle xe databases. However virtual machines consume too much memory for that simple task.
Now I'm using docker. Below you can find the docker image I'm currently using:
https://github.com/MaksymBilenko/docker-oracle-xe-11g
After you install docker to your computer, you can use the following commands to create the database:
# Create a folder for data in your home folder or somewhere else
mkdir /home/sedran/mydb1
# Download the docker image
docker pull sath89/oracle-xe-11g
# Create and start a new container with oracle-xe running on it
docker run --name oracle11g_mydb1 -d -p 1522:1521 -p 49163:8080 -v /home/sedran/mydb1:/u01/app/oracle sath89/oracle-xe-11g
Then you can connect to this DB from localhost:1522/XE
To create a second database, execute the following commands:
mkdir /home/sedran/mydb2
docker run --name oracle11g_mydb2 -d -p 1523:1521 -p 49164:8080 -v /home/sedran/mydb2:/u01/app/oracle sath89/oracle-xe-11g
The new DB will listen to port 1523 on localhost.
Do not forget to assign different ports, names and data folders (volumes) to every container.