Saturday, February 15, 2020

Don’t install Postgres, just PuLL iT



https://hackernoon.com/dont-install-postgres-docker-pull-postgres-bee20e200198
https://hackernoon.com/docker-commands-the-ultimate-cheat-sheet-994ac78e2888
https://www.enterprisedb.com/postgres-tutorials/how-install-postgres-docker
https://github.com/docker-library/postgres
https://www.jrebel.com/blog/docker-commands-cheat-sheethttps://www.jrebel.com/system/files/docker-commands-cheat-sheet.pdf




apt install docker.io

systemctl status docker
docker pull postgres:9.6.17-alpine

docker images
docker ps
docker run
docker exec
docker start
docker stop


root@breaker:/home/learn/docker# docker run --rm   --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data  postgres

Unable to find image 'postgres:latest' locally
latest: Pulling from library/postgres
bc51dd8edc1b: Pull complete 
d2b355dbb6c6: Pull complete 
d237363a1a91: Pull complete 
ff4b9d2fde66: Pull complete 
646492d166e7: Pull complete 
50eeac6fd5fb: Pull complete 
502963de6da8: Pull complete 
d7263f7627b9: Pull complete 
d234d8f1a205: Pull complete 
1b2c24e5275c: Pull complete 
3f7c6dd9a7ae: Pull complete 
d6d6977a74b3: Pull complete 
acf1093f8b78: Pull complete 
77e1ac8c247a: Pull complete 
Digest: sha256:f8ffd650ecc802c8e45d9e72b7ba90829c3d89df3075a23b3f8e966728cfd97c
Status: Downloaded newer image for postgres:latest
aff1e95e8a9ad2ff6b0183785d3515114d28dbc83f17768123293d654cb69be1
root@breaker:/home/learn/docker# 


root@breaker:/home/learn/docker# docker ps

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
aff1e95e8a9a        postgres            "docker-entrypoint.s…"   15 minutes ago      Up 15 minutes       0.0.0.0:5432->5432/tcp   pg-docker

root@breaker:/home/learn/docker# 



root@breaker:/home/learn/docker# docker exec -it pg-docker bash

root@aff1e95e8a9a:/# 
root@aff1e95e8a9a:/# cat /etc/*rele*
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@aff1e95e8a9a:/# 
root@aff1e95e8a9a:/# 
root@aff1e95e8a9a:/# exit
exit
root@breaker:/home/learn/docker# 
root@breaker:/home/learn/docker# cat /etc/*rele*
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"
NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
root@breaker:/home/learn/docker# 


root@breaker:/home/learn/docker# psql -h localhost -U postgres -d postgres

Password for user postgres: 
psql (11.1 (Ubuntu 11.1-1.pgdg16.04+1), server 12.2 (Debian 12.2-1.pgdg100+1))
WARNING: psql major version 11, server major version 12.
         Some psql features might not work.
Type "help" for help.

postgres=# 




root@breaker:/home/learn/docker# docker run  --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5496:5432 -v $HOME/docker/postgres:/var/lib/postgresql/data  postgres:9.6.17-alpine

ea6aa193cdd19bf151601ee27464a08d6934de1704f84bfc3428fe0f7cf566ba
root@breaker:/home/learn/docker# 
root@breaker:/home/learn/docker# psql -h localhost -U postgres -p 5496 -d postgres
Password for user postgres: 
psql (11.1 (Ubuntu 11.1-1.pgdg16.04+1), server 9.6.17)
Type "help" for help.


postgres=# 

postgres=# select version();
                                         version                                         
-----------------------------------------------------------------------------------------
 PostgreSQL 9.6.17 on x86_64-pc-linux-musl, compiled by gcc (Alpine 9.2.0) 9.2.0, 64-bit
(1 row)

postgres=# 


root@breaker:/home/learn/docker# docker ps

CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                    NAMES
ea6aa193cdd1        postgres:9.6.17-alpine   "docker-entrypoint.s…"   4 minutes ago       Up 4 minutes        0.0.0.0:5496->5432/tcp   pg-docker
root@breaker:/home/learn/docker# 


root@breaker:/home/learn/docker# docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                    NAMES
ea6aa193cdd1        postgres:9.6.17-alpine   "docker-entrypoint.s…"   11 minutes ago      Up 17 seconds       0.0.0.0:5496->5432/tcp   pg-docker
root@breaker:/home/learn/docker# 
root@breaker:/home/learn/docker# docker stop pg-docker
pg-docker
root@breaker:/home/learn/docker# 
root@breaker:/home/learn/docker# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
root@breaker:/home/learn/docker# 
root@breaker:/home/learn/docker# docker start pg-docker
pg-docker
root@breaker:/home/learn/docker# 
root@breaker:/home/learn/docker# docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                    NAMES
ea6aa193cdd1        postgres:9.6.17-alpine   "docker-entrypoint.s…"   11 minutes ago      Up 2 seconds        0.0.0.0:5496->5432/tcp   pg-docker

root@breaker:/home/learn/docker# 


root@breaker:/home/learn/docker# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
postgres            9.6.17-alpine       b1adbeb9895f        19 hours ago        38.2MB
postgres            latest              0d2531ee3abd        20 hours ago        397MB

root@breaker:/home/learn/docker# 

Sunday, January 26, 2020

MariaDB Galera Cluster with Arbitrator


https://github.com/auntaru/vagrantfiles.git



[root@garb3 ~]# cat /etc/my.cnf.d/server.cnf
[mariadb]
wsrep_provider='/usr/lib64/galera/libgalera_smm.so'
wsrep_cluster_address=gcomm://192.168.33.11,192.168.33.12,192.168.33.13
wsrep_node_address=192.168.33.13
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
innodb_doublewrite=1
wsrep_on=ON
wsrep_cluster_name="auntaru_mariadb"
log-error = /var/lib/mysql/error.log
[root@garb3 ~]#


starting the cluster , adding one DB node and the arbitrator : 
 - galera_new_cluster
 - systemctl start mariadb.service
 - garbd -a gcomm://192.168.33.11,192.168.33.12,192.168.33.13 -g auntaru_mariadb

https://github.com/auntaru/vagrantfiles/blob/master/provision.sh


The Vagrant script downloads the official centos/7 box from :
https://cloud.centos.org/centos/7/vagrant/x86_64/images/


Friday, January 3, 2020

GiT clone Workspace add Index commit Repository push fetch Remote pull



How to understand Git: an intro to basic commands, tips, and tricks
https://www.freecodecamp.org/news/understanding-git-basics-commands-tips-tricks/






10 insanely useful git commands for common git tasks
https://www.datree.io/resources/git-commands


Git Cheatsheet
https://gist.github.com/hofmannsven/6814451


Git for beginners: 12 commands you need to know
https://blog.prototypr.io/git-for-beginners-12-commands-you-need-to-know-e084cce9cc94

Basic Workflow Commands:

1. git clone
You’ll need to do this just once for each repository you work with. You can use SSH or HTTPS. It makes an exact copy of the entire repository on your local machine.

2. git status
This is the most important Git command for beginners (arguably for all Git users). It can prevent you from getting into a lot of trouble. It will also help you gain a deeper understanding of how Git works, because it allows you to see what is happening behind the scenes.
What does git status do? It shows you everything you need to know about your current branch.


3. git diff
This will show you all the unstaged changes you have made. It’s different from git status which just shows you the names of the unstaged files you have changed.


4. git checkout -b
This is how you make a new branch and switch to that new branch, all in one command. Your branch names should be short but meaningful.
If you made a typo in your branch name, or otherwise just want to rename it, you can do git branch -m and that will rename your current branch.

5. git add and git add .
Warning: use git add . with caution! Never run git add . without looking at your git status first.
How does git add work? It adds your modified file to your staging index. If you have modified more than one file, git add . will add all the files your have edited to your staging index.
With some twisted kind of Git sorcery, I have in the past accidentally added a whole bunch of files, including a whole bunch of changes that I didn’t actually make, to my staging index. This was terrifying. It’s not a huge deal, because you can unstage them with git reset HEAD , but it is avoidable by running git status before adding anything to your staging index.
What the hell is a staging index? It’s where Git stores all your changes that are ready to be committed. If you’re into baseball, you can think of your staging index as being “on deck” and all your unstaged changes as being “in the hole” (if you’re not into baseball, forget I said that).

6. git commit -m ""
After running git add or git add ., you must run git commit -m "" (or you can unstage your changes if you don’t want to commit them, see above). Most likely, you’re going to want to commit your changes.


7. git push
This will push all your changes to the remote repository. You can think of this as uploading your changes.
After you git push, you will probably (depending on your workflow) have to submit a pull request, get approval, and merge your changes to a master branch. This can all be done in a web browser with a program like GitHub or Bitbucket.

8. git pull
If you think of git push as uploading your changes, you can think of git pull as downloading everyone else’s changes. Remember: you always pull down (download) before pushing up (upload).
After you have pushed your changes, it’s probably a good idea to hop on the master branch (you do this by running git checkout master) and doing a quick git pull, so you can develop on the most current version of master.
Tip: you can do both of these in one command by running git checkout master && git pull. This will execute both commands in that order.

Workflow Summary:
You now have everything you need to successfully clone a repository,
create a branch, make changes, and push those changes up to a master branch.






Hibernate in Eclipse with PostgreSQL Example
https://examples.javacodegeeks.com/enterprise-java/hibernate/hibernate-eclipse-postgresql-example/

Spring Boot Microservices , Docker and Kubernetes workshop – part3
https://www.javacodegeeks.com/2019/11/spring-boot-microservices-docker-and-kubernetes-workshop-part3.html

10 Things Java Programmers Should Learn in 2020
https://javarevisited.blogspot.com/2017/12/10-things-java-programmers-should-learn.html


How To Check Disk Space Usage In Linux Using Ncdu
https://www.ostechnix.com/check-disk-space-usage-linux-using-ncdu/

Wednesday, June 8, 2016

CentOS7 ifconfig nmcli nmtui


How to Setup network on centos 7


On CentOS 7 instead of ifconfig , it must be used << ip address >>
or the abbreviated << ip a >> command ...

It seems that ipconfig  is deprecated and superseeded by ip command from iproute2 package

Setup network on CentOS 7 minimal

Type “nmtui” command in your terminal ~ opens Network manager. 

nmtui is an alternative command for nmcli which is based on “Text User Interface”



hostnamectl set-hostname Your-New-Host-Name-Here


Monday, June 6, 2016

JAVA_HOME Variable in Windows

Setting the JAVA_HOME Variable in Windows


The error : 

The registry refers to a nonexistent java runtime enviorement installation or the runtime is currupted.

The system cannot find the path specified.



After you've installed Java in Windows, you must set the  JAVA_HOME environment variable to point to the Java installation directory.


If you installed the Java Development Kit (JDK) you'll be setting the JAVA_HOME environment variable. If you installed the Java Runtime Environment (JRE) you will follow the same steps but set the JRE_HOME environment variable instead. 


Set the JAVA_HOME Variable

To set the JAVA_HOME variable:
  1. Find out where Java is installed. If you didn't change the path during installation, it will be something like this:
    C:\Program Files\Java\jdk1.8.0_65
  2. In Windows 7 right click My Computer and select Properties > Advanced.
    In Windows 8 go to Control Panel > System > Advanced System Settings.
  3. Click the Environment Variables button.
  4. Under System Variables, click New.
  5. In the Variable Name field, enter:
    • JAVA_HOME if you installed the JDK (Java Development Kit)
      or
    • JRE_HOME if you installed the JRE (Java Runtime Environment) 
  6. In the Variable Value field, enter your JDK or JRE installation path.
    If the path contains spaces, use the shortened path name, for example C:\Progra~1\Java\jdk1.8.0_65) 
  7. Click OK and Apply Changes as prompted.


Note for Windows users on 64-bit systems
Progra~1 = 'Program Files'
Progra~2 = 'Program Files(x86)'


JAVA_HOME Variable in Windows

Setting the JAVA_HOME Variable in Windows


The error : 

The registry refers to a nonexistent java runtime enviorement installation or the runtime is currupted.

The system cannot find the path specified.



After you've installed Java in Windows, you must set the  JAVA_HOME environment variable to point to the Java installation directory.


If you installed the Java Development Kit (JDK) you'll be setting the JAVA_HOME environment variable. If you installed the Java Runtime Environment (JRE) you will follow the same steps but set the JRE_HOME environment variable instead. 


Set the JAVA_HOME Variable

To set the JAVA_HOME variable:
  1. Find out where Java is installed. If you didn't change the path during installation, it will be something like this:
    C:\Program Files\Java\jdk1.8.0_65
  2. In Windows 7 right click My Computer and select Properties > Advanced.
    In Windows 8 go to Control Panel > System > Advanced System Settings.
  3. Click the Environment Variables button.
  4. Under System Variables, click New.
  5. In the Variable Name field, enter:
    • JAVA_HOME if you installed the JDK (Java Development Kit)
      or
    • JRE_HOME if you installed the JRE (Java Runtime Environment) 
  6. In the Variable Value field, enter your JDK or JRE installation path.
    If the path contains spaces, use the shortened path name, for example C:\Progra~1\Java\jdk1.8.0_65) 
  7. Click OK and Apply Changes as prompted.


Note for Windows users on 64-bit systems
Progra~1 = 'Program Files'
Progra~2 = 'Program Files(x86)'