Oracle 12c database on docker container, status: unhealthy - database

I’m trying to install a oracle database on my mac machine, but my container status is unhealthy. after i run this command:
docker run -d -it --name store/oracle/database-enterprise:12.2.0.1
and check the status by docker ps
it shows that it's unhealthy.
and when i run docker exec -it bash -c "source /home/oracle/.bashrc; sqlplus /nolog"
I get sqlplus command not found.
this is the logs:
Oracle Database 12.2.0.1 Setup
Mon Feb 17 13:46:41 UTC 2020
Check parameters ......
log file is : /home/oracle/setup/log/paramChk.log
paramChk.sh is done at 0 sec
untar DB bits ......
log file is : /home/oracle/setup/log/untarDB.log
untarDB.sh is done at 38 sec
config DB ......
log file is : /home/oracle/setup/log/configDB.log
mkdir: cannot create directory '/u02/app': No space left on device
mkdir: cannot create directory '/u03/app': No space left on device
mkdir: cannot create directory '/u04/app': No space left on device
mkdir: cannot create directory '/u01/app/oracle/product/12.2.0/dbhome_1/admin': No space left on device
ln: failed to create symbolic link '/u02/app/oracle/audit': No such file or directory
ln: failed to create symbolic link '/u02/app/oracle/oradata': No such file or directory
ln: failed to create symbolic link '/u03/app/oracle/fast_recovery_area': No such file or directory
ln: failed to create symbolic link '/u04/app/oracle/redo': No such file or directory
/home/oracle/setup/configDBora.sh: line 137: orapwd: command not found
/home/oracle/setup/configDBora.sh: line 171: /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/sqlnet.ora: No such file or directory
/home/oracle/setup/configDBora.sh: line 172: /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/sqlnet.ora: No such file or directory
/home/oracle/setup/configDBora.sh: line 173: /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/sqlnet.ora: No such file or directory
/home/oracle/setup/configDBora.sh: line 184: /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora: No such file or directory
/home/oracle/setup/configDBora.sh: line 185: /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora: No such file or directory
/home/oracle/setup/configDBora.sh: line 186: /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora: No such file or directory
/home/oracle/setup/configDBora.sh: line 197: /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/tnsnames.ora: No such file or directory
/home/oracle/setup/configDBora.sh: line 206: /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/tnsnames.ora: No such file or directory
/home/oracle/setup/configDBora.sh: line 209: lsnrctl: command not found
Mon Feb 17 13:47:19 UTC 2020
Start Docker DB configuration
Call configDBora.sh to configure database
Configure DB as oracle user
Setup Database directories ...
/home/oracle/setup/configDBora.sh: line 123: sqlplus: command not found
update password
create pdb : ORCLPDB1
/home/oracle/setup/configDBora.sh: line 141: sqlplus: command not found
Reset Database parameters
/home/oracle/setup/configDBora.sh: line 155: sqlplus: command not found
DONE!
Remove password info
Docker DB configuration is complete !
configDB.sh is done at 38 sec
Done ! The database is ready for use .
# ===========================================================================
# == Add below entries to your tnsnames.ora to access this database server ==
# ====================== from external host =================================
ORCLCDB=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<ip-address>)(PORT=<port>))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCLCDB.localdomain)))
ORCLPDB1=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<ip-address>)(PORT=<port>))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCLPDB1.localdomain)))
#
#ip-address : IP address of the host where the container is running.
#port : Host Port that is mapped to the port 1521 of the container.
# The mapped port can be obtained from running "docker port <container-id>"
JIT: pid 5408 requesting stop
2017-08-08T17:41:41.417556+00:00
ARCH: Archival disabled due to shutdown: 1090
Shutting down archive processes
Archiving is disabled
2017-08-08T17:41:41.436309+00:00
Stopping background process VKTM
2017-08-08T17:41:47.017665+00:00
Instance shutdown complete (OS id: 5408)
Mon Feb 17 14:05:05 UTC 2020
shutdown database
/home/oracle/setup/shutDB.sh: line 53: sqlplus: command not found
stop listener
/home/oracle/setup/shutDB.sh: line 61: lsnrctl: command not found
Start up Oracle Database
Mon Feb 17 14:05:07 UTC 2020
start database
/home/oracle/setup/startupDB.sh: line 53: sqlplus: command not found
start listener
/home/oracle/setup/startupDB.sh: line 61: lsnrctl: command not found
The database is ready for use

Prune your volumes and then make sure your mount volume is under the docker desktop (OSX)> Docker Dashboard> Resources> File sharing
More about mounting
Starting an Oracle database server instance: Example
docker run --name TEST-DB -p 9999:1521 -p 9991:5500 -v /Users/yourusername/data/oracle:/opt/oracle/oradata store/oracle/database-enterprise:12.2.0.1
The default user credentials from dockerhub:
user:sys password:Oradoc_db1.

Related

How to bind a host directory to docker container via docker CLI?

I'm trying to bind a host directory to a mssql docker container and have the following [bash] script:
#!/bin/sh
IMPORTDIR=$(cd $(dirname $0); pwd)
DATADIR=${DATADIR:-/tmp/db/}
set -xe
docker run --detach \
-e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=Passw0rd" -e "MSSQL_PID=Express" \
-v ${DATADIR}:/mnt/db \
-v ${IMPORTDIR}:/mnt/importing \
-p 127.0.0.1:1433:1433 \
--name mssql-db \
mcr.microsoft.com/mssql/server:latest
sleep 30
docker exec mssql-db /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P Passw0rd -Q "
RESTORE FILELISTONLY FROM DISK = '/mnt/db/mssql_db.bak'"
For which I receive the following error message when I run the script:
RESTORE FILELISTONLY FROM DISK = '\''/mnt/db/mssql_db.bak'\'''
Msg 3201, Level 16, State 2, Server cd17fd41ce82, Line 2
Cannot open backup device '/mnt/db/mssql_db.bak'. Operating system error 2(The system cannot find the file specified.).
Msg 3013, Level 16, State 1, Server cd17fd41ce82, Line 2
RESTORE FILELIST is terminating abnormally.
When I log into the container I see that indeed the file, which is in the host directory, isn't present is in the container's directory.
The following is my setup info:
Operating System: Mac Os 10.13.6
Docker Version:
File perms (on the host): -rw-r--r--#
I solved this because by adding the real path to /tmp to the file sharing resource path in docker.
In my OS version (can't comment on the later versions), the /tmp is a symlink to it's real path /private/tmp once I added that to the FILE SHARING resources, it worked.
I had just recently upgraded to docker as this wasn't an issue I previously experienced pre-upgrade

Zeppelin cannot start

I am trying to install Zeppelin, I did setup SPARK, JAVA home in /conf/. I also changed the port to not be conflict with Spark's port. But when I start zeppelin-daemon here what I got:
Log dir doesn't exist, create /opt/zeppelin-0.8.2/zeppelin-0.8.2-bin-all/logs
mkdir: cannot create directory ‘/opt/zeppelin-0.8.2/zeppelin-0.8.2-bin-all/logs’: Permission denied
Pid dir doesn't exist, create /opt/zeppelin-0.8.2/zeppelin-0.8.2-bin-all/run
mkdir: cannot create directory ‘/opt/zeppelin-0.8.2/zeppelin-0.8.2-bin-all/run’: Permission denied
/opt/zeppelin-0.8.2/zeppelin-0.8.2-bin-all/bin/zeppelin-daemon.sh: line 187: /opt/zeppelin-0.8.2/zeppelin-0.8.2-bin-all/logs/zeppelin-harry-Harry-SNS.out: No such file or directory
Zeppelin start [ OK ]
/opt/zeppelin-0.8.2/zeppelin-0.8.2-bin-all/bin/zeppelin-daemon.sh: line 196: /opt/zeppelin-0.8.2/zeppelin-0.8.2-bin-all/run/zeppelin-harry-Harry-SNS.pid: No such file or directory
/opt/zeppelin-0.8.2/zeppelin-0.8.2-bin-all/bin/zeppelin-daemon.sh: line 189: /opt/zeppelin-0.8.2/zeppelin-0.8.2-bin-all/logs/zeppelin-harry-Harry-SNS.out: No such file or directory
cat: /opt/zeppelin-0.8.2/zeppelin-0.8.2-bin-all/run/zeppelin-harry-Harry-SNS.pid: No such file or directory
Zeppelin process died [FAILED]
as I understand, its missing pid directory which idk how can I create one.

postgresql error connecting after moving data directory

EDIT-2
I found out that the database doesn't even start after making the file location change.
This is with the default file location:
$pg_isready
/var/run/postgresql:5432 - accepting connections
$pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
9.5 main 5432 online postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
pg_lsclusters output is green.
After the file location has changed on postgresql.conf:
$pg_isready
/var/run/postgresql:5432 - no response
$pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
9.5 main 5432 down root /mnt/Data/postgresdb/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
Here the output is red.
Following this post here, I tried to start the cluster manually:
$pg_ctlcluster 9.5 main start
Warning: the cluster will not be running as a systemd service. Consider using systemctl:
sudo systemctl start postgresql#9.5-main
Error: You must run this program as the cluster owner (root) or root
I tried the same command with sudo:
Error: Config owner (postgres:124) and data owner (root:0) do not match, and config owner is not root
Which again makes me think the problem might lie with permissions of the directory. The directory is owned by root whose ownership I am unable to change.
EDIT-1
I've been working on this and I'd like to distill this post further to give more specifics. This is my current situation:
I installed postgres: sudo apt-get install postgresql and postgresql-contrib
I used sudo -U postgres psql to get into the postgres shell (I'm not sure if this is what I need to do)
show data_directory returns: /var/lib/postgresql/9.5/main
The data directory is located in Ubuntu ext4 formatted hard drive. I also have a 1 TB NTFS formatted hard disk mounted on /mnt/Data (which is mounted automatically on boot). What I tried:
Stop the postgres service: sudo systemctl stop postgresql
Create a new directory /mnt/Data/postgresdb and copy contents of the previous main to this which gives me a full path of /mnt/Data/postgresdb/postgresql/9.5/main using: sudo rsync -av /var/lib/postgresql/ /mnt/Data/postgresdb/postgresql/
Edit /etc/postgresql/9.5/main/postgresql.conf to change data_directory from the path mentioned above to /mnt/Data/postgresdb/postgresql/9.5/main
Start the postgres service: sudo systemctl start postgresl
Run sudo -U postgres psql but get the error that was mentioned in the original post.
These are the permissions on the respective main directories:
ls -l /var/lib/postgresql/9.5/
total 4.0K drwx------ 19 postgres postgres 4.0K Jan 16 12:40 main
ls -l /mnt/Data/postgresdb/postgresql/9.5/
total 4.0K drwxrwxrwx 1 root root 4.0K Jan 16 12:13 main
From the looks of it, the default directory is owned by "postgres" and the new directory is owned by root. However, when I try to change ownership to postgres: chown -R postgres main, it doesn't output any error, but the ownership doesn't change. I'm curious whether this is because this drive is NTFS formatted and is mounted.
Here is my /etc/fstab:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda5 during installation
UUID=3f5a9875-89a3-4ce5-b778-9d7aaf148ed6 / ext4 errors=remount-ro 0 1
# swap was on /dev/sda6 during installation
UUID=85c3f4d4-e450-435b-8dd6-cf1b2cbd8fc2 none swap sw 0 0
/dev/disk/by-label/Data /mnt/Data auto nosuid,nodev,nofail,x-gvfs-show 0 0
Any ideas on how I can go about fixing this?
ORIGINAL POST
Recently, I installed Postgresql for storing some data for my research. The dataset came with instructions on how to setup the data on a Postgresql database (if interested, more info on that here and here). I installed Postgresql and set up a "role" and used the script that was provided for loading the database. It worked but I underestimated the size of the dataset and the script quit saying there was no more space.
I have two drives on my computer a 250G SSD drive with Windows and Ubuntu installed (125G each). And a 1TB HDD NTFS formatted where I store my data. So I thought moving the database to a folder on the other drive would be helpful. I purged all the data and the database to start afresh and followed the instructions here to move the database directory. However, after moving the directory, when I try to connect using psql I get the following error:
~ psql -U username -d postgres 14:48:33
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
How can I fix this? I am running 64-bit Ubuntu 16.04 with Postgresql-9.5. As mentioned earlier, I moved the DB directory a NTFS formatted filesystem (not sure if that cause any problems).
Thanks.
As mentioned in the comments the NTFS was the problem. I ended up resizing my bigger hard drive with 100GB formatted as ext4 and was able to launch postgres with the new data directory without any problems.

OSError: [Errno 13] Permission denied: '/var/lib/pgadmin'

Ubuntu 16.04.3
I'd like to install pgAdmin:
I hvae created a virtualenv with python 2.
Then install pgAdmin 4 v2.0:
pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v2.0/pip/pgadmin4-2.0-py2.py3-none-any.whl
It's time to run pgAdmin:
(pgadmin4) michael#michael-desktop:~/PycharmProjects/venv$ python pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
Traceback (most recent call last):
File "pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py", line 55, in <module>
exec(open(file_quote(setupfile), 'r').read())
File "<string>", line 46, in <module>
File "/home/michael/PycharmProjects/venv/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 23, in create_app_data_directory
_create_directory_if_not_exists(os.path.dirname(config.SQLITE_PATH))
File "/home/michael/PycharmProjects/venv/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 15, in _create_directory_if_not_exists
os.mkdir(_path)
OSError: [Errno 13] Permission denied: '/var/lib/pgadmin'
Could you give me a kick here?
If you do not want to change the permission of anything, you can always override default paths in pgAdmin4.
Create a file named config_local.py (if not already present) at your installation location ../pgadmin4/web/
File location in my case:
/usr/local/lib/python2.7/dist-packages/pgadmin4/config_local.py
and add following code in your config_local.py,
import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgadmin/'))
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
Restart pgAdmin4 and check.
Permission error means the user 'michael' (/var/lib has drwxr-xr-x) has the permission to execute but doesn't have the permission to write on the folder (according to your comment of the folder info below).
One of the solutions you can use to be able to access freely the folder would be something like:
chown -R michael:root /path/to/the/directory
The second part of the answer, you've figured it out #Michael.
downloading pgadmin by using the command:
wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.5/pip/pgadmin4-1.5-py2.py3-none-any.whl
and then execute command:
pip install pgadmin4*.whl.
create the folders manually (or add to your pgAdmin installation script, if there is one), and assign the permissions:
sudo mkdir "/var/log/pgadmin"
sudo chmod a+wrx "/var/log/pgadmin"
sudo mkdir "/var/lib/pgadmin"
sudo chmod a+wrx "/var/lib/pgadmin"
this would not assign permissions to the entire /var/log but just for the /var/log/pgadmin only.
solved issue with several steps
1. create empty folders on host vm
mkdir /private/var/lib/pgadmin
chmod 777 /private/var/lib/pgadmin
start pgadmin docker image
docker pull dpage/pgadmin4
docker run -p 80:80\
-v /private/var/lib/pgadmin:/var/lib/pgadmin \
...
you will see newly created file structure like this
/private/var/lib/pgadmin
-rw-------. 1 5050 5050 757760 Jan 13 23:11 pgadmin4.db
drwx------. 2 5050 5050 50 Jan 13 23:00 sessions
drwxr-xr-x. 3 5050 5050 31 Jan 13 23:17 storage
thus UID 5050 is our target one
4. copy your pgadmin4.db into target dir and apply proper UID [5050 in my case]
As a result application will work, user settings will be saved.
I installed pgadmin4 v2.1 on Ubuntu 16.04 and had this problem. See the last line of code. (I run this in a script file, lazy.) I also installed 2.0 this way as a test to see if it really is a fix. I did not have to use config_local.py.
cd ..
cd home/vagrant
sudo apt-get install build-essential libssl-dev libffi-dev libgmp3-dev virtualenv python-pip libpq-dev python-dev
virtualenv .pgadmin4
cd .pgadmin4
source bin/activate
wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v2.1/pip/pgadmin4-2.1-py2.py3-none-any.whl
pip install pgadmin4-2.1-py2.py3-none-any.whl
# For this either use your remote host panel to edit the file or:
nano lib/python2.7/site-packages/pgadmin4/config.py
# Change:
# DEFAULT_SERVER = '0.0.0.0'
# Here is the trick. Run this boot up file with sudo. This fixed it for me.
sudo python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
I had the same problem with pgAdmin4 v3.1, I just write sudo python pgAdmin4.py and it worked!.

Restore postgresql 9.4 database from files

I have a tar.gz which is supposed to contain a complete Postgres 9.4 database backup.
I attemped to restore the database using pg_restore, but I realised (after I unpacked the file) that it has the same structure as the /var/lib/postgresql/9.4/main directory running on my localhost.
So I stopped the postgresql service running on localhost, I replaced my main directory with the one from the archive as described here: Restore postgresql from files.
Moreover I've set owner and permissions in a recursive manner like this:
chown -R postgres:postgres /var/lib/postgresql/9.4/main/
chmod -R 700 /var/lib/postgresql/9.4/main/.
I've restarted the service:
root#EED-015-LIN:~# service postgresql status
9.3/main (port 5433): online
9.4/main (port 3007): online,recovery
...But when I try to connect using psql
postgres#EED-015-LIN:~$ psql -p 3007
psql: FATAL: the database system is starting up
What am I missing?

Resources