Tuesday 11 October 2016

STEPS TO INSTALL JAVA ON LINUX x64 AND SETTING JAVA PATH

step1: download the javaSE jdk-8u11-linux-x64.tar.gz step2: open the terminal and unzip the tar file $ tar -zxvf jdk-8u101-linux-x64.tar.gz step3: copy the unzip folder to usr/lib/java, $ cd /usr/lib $ sudo mkdir java $ cd ~/home/user/Downloads $ sudo mv jdk1.8.0_101/ /usr/lib/java $ cd /usr/java/java1.8.0_101/bin step4: Run the below commands sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/java/jdk1.8.0_101/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/java/jdk1.8.0_101/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/java/jdk1.8.0_101/bin/javaws" 1 step5: update the JAVA_HOME in your ~/.bashrc #JAVA HOME directory setup export JAVA_HOME=/usr/lib/java/jdk1.8.0_101 export PATH="$PATH:$JAVA_HOME/bin" VERIFY: $ java -version jdk1.8.0_101 version $ echo $JAVA_HOME /usr/lib/java/jdk1.8.0_101

Saturday 24 September 2016

Demonstrate Dockerswarm to create, add, deploy and inspect the service

Create a swarm

(Make sure the Docker Engine daemon is started on the host machines) Step1:Open a terminal and ssh into the machine where you want to run your manager node. Step2:$docker swarm init --advertise-addr 192.168.99.100 To add a worker to this swarm, run the following command: docker swarm join \ --token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx\ 192.168.99.100:2377 To add a manager to this swarm, run "docker swarm join-token manager" and follow the instructions. Step3:Run docker info to view the current state of the swarm:$ docker info Step4:Run the docker node ls command to view information about nodes: $ docker node ls

Add nodes to the swarm

(Once you've created a swarm with a manager node, you're ready to add worker nodes) Step5: Open a terminal and ssh into the machine where you want to run a worker node Step6: create a worker node joined to the existing swarm $ docker swarm join\ --token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx\ 192.168.99.100:2377 If you don't have the command available, you can run the following command on a manager node to retrieve the join command for a worker: $ docker swarm join-token worker Step7: Open a terminal and ssh into the machine where you want to run a second worker node[worker2] Step8: $ docker swarm join\ --token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0\ 192.168.99.100:2377 Step9:Open a terminal and ssh into the machine where the manager node runs. $ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER 03g1y59jwfg7 worker2 Ready Active 9j68exjopxe7 worker1 Ready Active dxn1zf6l61qs * manager1 Ready Active Leader

Deploy a service to the swarm

(After you create a swarm, you can deploy a service to the swarm. For this tutorial, you also added worker nodes, but that is not a requirement to deploy a service) Step1:Open a terminal and ssh into the machine where you run your manager node Step2:$ docker service create --replicas 1 --name helloworld alpine ping docker.com Step3:$ docker service ls //shows the list of running services

Inspect a service on the swarm

(When you have deployed a service to your swarm, you can use the Docker CLI to see details about the service running in the swarm) Step1:If you haven't already, open a terminal and ssh into the machine where you run your manager node Step2:$docker service inspect --pretty helloworld //display the details about a service Step3:Run docker service ps <SERVICE-ID> to see which nodes are running the service: $docker service ps helloworld Step4:$ docker ps

Scale the service in the swarm

(Once you have deployed a service to a swarm, you are ready to use the Docker CLI to scale the number of service ps in the swarm) Step1: If you haven't already, open a terminal and ssh into the machine where you run your manager node $docker service scale <SERVICE-ID>=<NUMBER-OF-TASKS> $docker service scale helloworld=5 Step2: Run docker service ps <SERVICE-ID> to see the updated task list: $ docker service ps helloworld Step3: Run docker ps to see the containers running on the node.

Delete the service running on the swarm

Step1: If you havent already, open a terminal and ssh into the machine where you run your manager node $docker service rm helloworld Step2: Run docker service inspect <SERVICE-ID> to verify that the swarm manager removed the service: $docker service inspect helloworld

Installing Docker (OperatingSystem : CentOs 7)

There are two method to Install Docker in CentOS 7

[Method1]: Install with yum

$ cd /etc/yum.repos.d yum.repos.d]$ ls -la CentOs-Base.repo,CentOs-CR.repo,CentOs-Debuginfo.repo, CentOs-fasttrack.repo,CentOs-Media.repo,CentOs-Soureces.repo CentOs-Vault.repo,epel.repo, epel-testing.repo $ sudo vim docker.repo [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/7/ enable=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg $sudo yum update $sudo yum install docker-engine $sudo systemctl enable docker //To enable our docker service $sudo systemctl start docker //start the docker $sudo systemctl status docker //check the status of the docker By default the docker create a file in "/var/run" directory that own by the docker group called docker.sock, if you are not the member of that group or you are not root by default you dont have access to the docker daemon. $ sudo usermod -aG docker your_username //add your user to docker group $ docker images $ docker run hello-world // pull the image and create a Container

[Method2]: Install with script

$ sudo yum update //make sure your existing yum packages are up-to-date $ curl -fsSL https://get.docker.com/| sh //run the docker installation script This Script adds the docker.repo repository and installs Docker. $ sudo service docker start

Uninstall Docker:

$ yum list installed |grep docker //list the package you have installed $ sudo yum -y remove docker-engine.x86_64 //remove the package This command does not remove images, containers, volumes or user-created configuration files on host. $ rm -rf /var/lib/docker //delete all your images,containers,volumes