Monday, September 10, 2018

How To Move Docker Images OS Files From Default To Different OS Location

Requirement:

    By default docker ce is installed on /var/lib/docker which may have limited space. As more and more images are coming and easy for moving images, we better put images on mounted Filesystem

Solution:

   Scope: it is tested on Docker 18.06.1-ce  on Linux

  • As root
  • systemctl stop docker
  • mv /var/lib/docker   /bigdisk/apps/docker
  • ln -s /bigdisk/apps/docker  /var/lib/docker
  • systemctl start docker
It will work fine after restart


Wednesday, September 05, 2018

Proxy Settings For Docker Daemon and Docker Containers

Proxy Settings For Docker Daemon

 Scope: Oracle Linux 7  +  Docker 18.06.0-ce
  • refer docker doc link
  • Create a systemd drop-in directory for the docker service
  • mkdir -p /etc/systemd/system/docker.service.d
  • Create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"
  • systemctl daemon-reload
  • systemctl  restart docker
  • Docker daemon can access internet via proxy

Proxy Settings For Docker Containers

 Scope: Oracle Linux 7  +  Docker 18.06.0-ce
  • refer docker doc link
  • create or edit the file ~/.docker/config.json
  • In our case, we run docker as root, it is /root/.docker/config.json
add below into the file
{
 "proxies":
 {
   "default":
   {
     "httpProxy": "http://127.0.0.1:3001",
     "noProxy": "*.test.example.com,.example2.com"
   }
 }
}
  • save the file. 
  • Next time when we start a new container, it will add this proxy automatically

Monday, September 03, 2018

Python3 File Open() and Print() Tips

Sample File Content

$ cat xmen_base.txt
Storm
Wolverine
test

#type and boolean attr of  file

>>> xmen_file = open('xmen_base.txt','r')
>>> xmen_file
<_io.TextIOWrapper name='xmen_base.txt' mode='r' encoding='cp1252'>
>>> type(xmen_file)
<class '_io.TextIOWrapper'>
>>> bool(xmen_file)
True

#print() add a newline at each end

>>> for a in xmen_file:
...     print(a)
...
Storm

Wolverine

test

>>> xmen_file.seek(0)
0

#tell print() not to add newline at each end

>>> for a in xmen_file:
...     print(a,end='')
...
Storm
Wolverine
test

#tell print() to add ; at end of each end

>>> xmen_file.seek(0)
0
>>> for a in xmen_file:
...     print(a.strip() + ';')
...
Storm;
Wolverine;
test;
>>> xmen_file.close()

Python open file mode detailed explaination .Quote from link

The argument mode points to a string beginning with one of the following
 sequences (Additional characters may follow these sequences.):

 ``r''   Open text file for reading.  The stream is positioned at the
         beginning of the file.

 ``r+''  Open for reading and writing.  The stream is positioned at the
         beginning of the file.

 ``w''   Truncate file to zero length or create text file for writing.
         The stream is positioned at the beginning of the file.

 ``w+''  Open for reading and writing.  The file is created if it does not
         exist, otherwise it is truncated.  The stream is positioned at
         the beginning of the file.

 ``a''   Open for writing.  The file is created if it does not exist.  The
         stream is positioned at the end of the file.  Subsequent writes
         to the file will always end up at the then current end of file,
         irrespective of any intervening fseek(3) or similar.

 ``a+''  Open for reading and writing.  The file is created if it does not
         exist.  The stream is positioned at the end of the file.  Subse-
         quent writes to the file will always end up at the then current
         end of file, irrespective of any intervening fseek(3) or similar.

Saturday, September 01, 2018

Some Python Logic Operations Tips

Python or and logic Operations Meaning: 

Boolean on functions

All print( ) boolean is false is because print() does not return anything. it returns None. If a function returns a none-zero value, boolean is True

>>> bool(print('aa'))
aa
False
>>> bool(print(''))

False

>>> def add_two(num):
...    return num + 2
...
>>> add_two(3)
5
>>> '' or "" or None or add_two(4) or print('gg')
6
>>> '' or "" or None or add_two(-2) or print('gg')
gg

OR

It  find&return first true or return last expression
examples:
>>> 100 or 33 or 55
100
>>> 100 or 0 or 55

100
>>> '' or "" or None or print('ddd') or print('gg')
ddd
gg
>>> '' or "" or None or print('ddd') or 'aa' or print('gg')
ddd
'aa'
>>> '' or "" or None or print('ddd')
ddd

AND

It find&return first false or return last expression
examples:

>>> 100 and 33 and 55
55
>>> 100 and 0 and 55

0
>>> print('aaa') and print('bbb') and ''

aaa
>>> '' and  "" and None and  print('ddd')
''
>>> 'aa' and '' and print('dddd')
''

Sunday, August 26, 2018

ORA-65028 When Creating Pluggable Database Via DBLINK


Symptom:

    We try to take whole data refresh from PROD DB to Stage DB to have more accurate env for developers.  We use dblink to create a pluggable DB from read only PROD DB

SQL>CREATE PLUGGABLE DATABASE TESTPDB FROM NON$CDB@PROD_DBLINK;
ERROR at line 1:
ORA-65028: Unable to open plugin data file at path
ORA-27036: translation error, unable to expand file name
Additional information: 7202
Additional information: 2

In the alert logs, only see
**************************************************************
Undo Create of Pluggable Database TESTPDB with pdb id - 3.
**************************************************************
Deleted Oracle managed file +DATAC1/CASCDBTEST/7000B69622B37FE2E053A27D4598FB7A/DATAFILE/system.552.980410169
ORA-65028 signalled during: CREATE PLUGGABLE DATABASE TESTPDBFROM NON$CDB@PROD_DBLINK...

When you check trace directory of alert log. You will find there are other trace files like diag trc..... which give you more helpful information
There are such error in the diag trc
Chains most likely to have caused the hang:
 [a] Chain 1 Signature: 'remote db file read'<='PX Deq: Execute Reply'
     Chain 1 Signature Hash: 0x5c57b818
 [b] Chain 2 Signature: 'PX Deq: Execution Msg'
     Chain 2 Signature Hash: 0x6319d684
 [c] Chain 3 Signature: 'remote db file read'
     Chain 3 Signature Hash: 0x2e6fafb0

So the error is related to DB hang and DB hang is related to parallel execution of creating pdb and remote db file read.

Solution:

     Double check tnsnames.ora are in sync between the rac nodes.
     Shutdown 2nd node and parallel execution as workaround