Java Dump creation script

DevOps 2020. 1. 15. 18:01

#!/bin/sh
if [[ $# -ne 1 ]]
then
echo 'Usage: th_info.sh '
echo "-------------------------------------------------------------------"
jps
exit
fi




export jpid=$1
export top_cpu_count=20
export thread_info=${jpid}_thread_info_`date +%Y%m%d_%H%M%S`.txt


export tmp_dex_thread_id=tmp_dex_thread_id.tmp
export tmp_hex_thread_id=tmp_hex_thread_id.tmp


echo "-------------------------------------------------------------------" >> ${thread_info}
echo " CPU usage per thread in JVM ${jpid}   "`date +%Y/%m/%d_%H:%M:%S`    >> ${thread_info}
echo "-------------------------------------------------------------------" >> ${thread_info}
echo " ThreadID(HEX)  ThreadID(DEC)  Usage"                                >> ${thread_info}


ps -mo pcpu,lwp -p ${jpid}| awk '{if ($2 ~/[0-9]/) {print $2 " " $1""}}'  | sort -k 2 -r  | head -n ${top_cpu_count}  > ./${tmp_dex_thread_id}
cat ./${tmp_dex_thread_id} | awk '{print $1}' | xargs printf "%x\n"  > ./${tmp_hex_thread_id}
paste  ./${tmp_hex_thread_id}  ./${tmp_dex_thread_id}                      >> ./${thread_info}


echo "-------------------------------------------------------------------" >> ${thread_info}
echo " Full thread dump                                                  " >> ${thread_info}
echo "-------------------------------------------------------------------" >> ${thread_info}


jstack ${jpid} >> ${thread_info}


rm ./${tmp_dex_thread_id}  ./${tmp_hex_thread_id}

'DevOps' 카테고리의 다른 글

Ping Test for Tomcat AJP connector  (0) 2020.01.15
GitLab with Docker Image official guide (GitLab)  (0) 2020.01.15
docker cli #01  (0) 2020.01.15
Ansible quick start  (0) 2020.01.15
Git cheat sheet #02  (0) 2020.01.15
블로그 이미지

Melting

,

#!/usr/bin/perl

# AJPING - pings a servlet engine with AJP protocol

# Sends:   \x12\x34\x00\x01\x0a

# Expects: \0x41\0x42\0x00\0x01\0x09

#

use strict;

use Socket;             # Part of perl

use Time::HiRes 'time'; # http://search.cpan.org/~jhi/Time-HiRes-1.9721/HiRes.pm

 

sub xdie;

sub usage;

 

my ($host, $port);

 

if (@ARGV == 2) {

  $host = $ARGV[0];

  $port = $ARGV[1];

} else {

  ($host, $port) = split (/:/, shift @ARGV, 2);

}

 

if (!$host || !$port) {

  usage();

}

 

for (my $i = 0; $i < 10; $i++) {

  my $start = time();

  my $iaddr = inet_aton($host) || xdie("Unknown host ($host)");

  my $paddr = sockaddr_in($port, $iaddr) || xdie ("Unable to establish a socket address");

  my $proto = getprotobyname('tcp');

  socket(my $sock, PF_INET, SOCK_STREAM, $proto) || xdie "Unable to create a socket.";

  connect($sock, $paddr)  || xdie "Unable to connect to server";

  syswrite $sock, "\x12\x34\x00\x01\x0a";

  sysread $sock, my $recv, 5 || die "read: $!, stopped";

  my @vals = unpack 'C5', $recv;

  my @acks = qw (65 66 0 1 9);

  my %vals = map {$_, 1} @vals;

  my @diff = grep {!$vals {$_}} @acks;

 

  if (@diff == 0) {

    use POSIX qw(strftime);

    my ($datestring) = strftime "%a %b %e %H:%M:%S %Y", localtime;

    printf "[$datestring] Reply from $host: %d bytes in %3.3f seconds\n", (length("@vals") - $#vals), (time() - $start);

  } else {

    print "Protocol error: unable to verify AJP host $host:$port\n";

    exit 1;

  }

  close($sock);

  sleep(1);

}

 

exit;

 

sub usage {

  print "ajping - pings a server via AJP protocol\n";

  print "usage: ajping host:port\n";

  print "       ajping host port\n";

  exit;

}

 

sub xdie {

  my $msg = shift;

  printf STDERR "ERROR: $msg\n";

  exit 1;

}

 

'DevOps' 카테고리의 다른 글

Java Dump creation script  (0) 2020.01.15
GitLab with Docker Image official guide (GitLab)  (0) 2020.01.15
docker cli #01  (0) 2020.01.15
Ansible quick start  (0) 2020.01.15
Git cheat sheet #02  (0) 2020.01.15
블로그 이미지

Melting

,

https://docs.gitlab.com/omnibus/docker/

 

 

--------------------------------------------------------------------

sudo docker run --detach \

  --hostname gitlab.example.com \

  --publish 3443:443 --publish 3080:80 --publish 3022:22 \

  --name gitlab \

  --restart always \

  --volume /opt/dev/gitlab/config:/etc/gitlab \

  --volume /opt/dev/gitlab/logs:/var/log/gitlab \

  --volume /opt/dev/gitlab/data:/var/opt/gitlab \

  gitlab/gitlab-ce:latest

--------------------------------------------------------------------

 

--------------------------------------------------------------------

docker-compose.yml

--------------------------------------------------------------------

web:

  image: 'gitlab/gitlab-ce:latest'

  restart: always

  hostname: 'gitlab.example.com'

  environment:

    GITLAB_OMNIBUS_CONFIG: |

      external_url 'https://gitlab.example.com'

      # Add any other gitlab.rb configuration here, each on its own line

  ports:

    - '3080:80'

    - '3443:443'

    - '3022:22'

  volumes:

    - '/opt/dev/gitlab/config:/etc/gitlab'

    - '/opt/dev/gitlab/logs:/var/log/gitlab'

    - '/opt/dev/gitlab/data:/var/opt/gitlab'

--------------------------------------------------------------------

 

 

-  https://blog.sonatype.com/maxences-technical-corner

    >> Using a Dockerized Nexus as a Docker Registry

 

--------------------------------------------------------------------

  nexus-data fold link #01 - bind local directory to nexus

--------------------------------------------------------------------

$ mkdir -p /opt/dev/dockerized_env/nexus/data

$ sudo chown -R 200 /opt/dev/dockerized_env/nexus/data

$ docker run -d --name nexus --restart always -p 3081:8081 -p 3082:8082 -v /opt/dev/dockerized_env/nexus/data:/nexus-data sonatype/nexus3

 

--------------------------------------------------------------------

  nexus-data fold link #02 - using docker volume

--------------------------------------------------------------------

$ docker volume create --name nexus-data  

$ docker volume ls

$ docker run -d --name nexus --restart always -p 3081:8081 -p 3082:8082 -v nexus-data:/nexus-data sonatype/nexus3

 

 

 

 

 

 

'DevOps' 카테고리의 다른 글

Java Dump creation script  (0) 2020.01.15
Ping Test for Tomcat AJP connector  (0) 2020.01.15
docker cli #01  (0) 2020.01.15
Ansible quick start  (0) 2020.01.15
Git cheat sheet #02  (0) 2020.01.15
블로그 이미지

Melting

,

docker cli #01

DevOps 2020. 1. 15. 17:55

$ docker search "ubuntu"

$ docker pull ubuntu:16.04

$ docker pull ubuntu:latest

$ docker images

$ docker run -it -d --name ubuntu16 ubuntu:16.04 /bin/bash        

$ docker run –it -p 8080:80 –v ~/shared_src:/mnt/shared_src --name ubuntu16 ubuntu:16.04 /bin/bash

$ docker start ubuntu16 (sudo docker restart/stop ubuntu16)

$ docker attach ubuntu16

    [docker shell] <Ctrl> + p , <Ctrl> + q

$ docker start ubuntu16

$ docker exec ubuntu16 echo "HelloWorld"

$ docker exec -it ubuntu16 /bin/bash

$ docker rm ubuntu16

$ docker ps -a

 

 

+. Docker logs

$ docker logs ${container id}

$ docker logs --tail 10 ${container id}

$ docker logs -f ${container id}

 

 

+. Commit to image

$ docker tag ${image_id} ${docker_hub_id}/${image_name}:{tag}         -> for docker hub

$ docker tag ${image_id} ${registry_host_ip:port}/${image_name}:{tag} -> for private registry

 

 

 

+. Docker Hub Login & Push

$ docker login –u${user_id}

$ docker push ${docker_hub_id}/${image_name}:{tag}

 

 

 

+. Dockerfile

$ vi Dockerfile

    FROM ubuntu:16.04

    MAINTAINER Foo Bar foo@bar.com

    RUN apt-get update

    RUN apt-get install -y nginx

    RUN echo "daemon off;" >> /etc/nginx/nginx.conf

    RUN chown -R www-data:www-data /var/lib/nginx

    VOLUME ["/opt/docker/src", "/opt/docker/log", "/opt/docker/lib"]

    WORKDIR /etc/nginx

    CMD ["nginx"]

    EXPOSE 80

    EXPOSE 443

$ docker build --tag ubuntu:16.04 .

 

 

 

+. Docker Compose

a. Create empty directory & create 'docker-compose.yml'  

-----------------------------------------------------------------------------------------

    version: '2'

 

    services:

       db:

         image: mysql:5.7

         volumes:

           - db_data:/var/lib/mysql

         restart: always

         environment:

           MYSQL_ROOT_PASSWORD: wordpress

           MYSQL_DATABASE: wordpress

           MYSQL_USER: wordpress

           MYSQL_PASSWORD: wordpress

 

       wordpress:

         depends_on:

           - db

         image: wordpress:latest

         volumes:

           - wp_data:/var/www/html

         ports:

           - "8000:80"

         restart: always

         environment:

           WORDPRESS_DB_HOST: db:3306

           WORDPRESS_DB_PASSWORD: wordpress

    volumes:

        db_data:

        wp_data:

-----------------------------------------------------------------------------------------

 

b. docker-compose up

 

 

 

+. .dockerignore

-----------------------------------------------------------------------------------------

# git

.git

.gitignore

.svn

 

# os-related

.DS_Store

.ipynb_checkpoints

pids

*.pid

*.seed

 

# javascripts

.grunt

.lock-wscript

node_modules

 

# Spring Boot

/src

.pom.xml

/.settings

.classpath

.project

.springBeans

-----------------------------------------------------------------------------------------

 

 

 

+. remove unused volume

docker volume ls -qf "dangling=true" | xargs docker volume rm

 

 

 

+. Runtime Options - docker resource control

$ docker run -it -d --cpus=".5" --memory="256m" --name  ubuntu16_8 ubuntu:16.04 /bin/bash

 

 

+. Docker resource usage monitoring -> glances

 

 

 

 

 

 

 

 

'DevOps' 카테고리의 다른 글

Ping Test for Tomcat AJP connector  (0) 2020.01.15
GitLab with Docker Image official guide (GitLab)  (0) 2020.01.15
Ansible quick start  (0) 2020.01.15
Git cheat sheet #02  (0) 2020.01.15
Git cheat sheet #01  (0) 2020.01.15
블로그 이미지

Melting

,

# sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config

     ==> enable 'sshd password authentication'

# service ssh restart

# apt-get install nodejs npm

# npm install -g wetty    (or)   yarn global add wetty

# curl https://gist.githubusercontent.com/subicura/9058671c16e2abd36533fea2798886b0/raw/e5d249612711b14c9c8f44798dea1368395e86a9/wetty.service -o /lib/systemd/system/wetty.service

    => vi /lib/systemd/system/wetty.service

            ----------------------------------------

[Unit]

Description=wetty service

After=network.target

StartLimitIntervalSec=0

 

[Service]

Type=simple

Restart=always

RestartSec=1

User=root

ExecStart=/usr/local/bin/wetty -p 4200 --base=/

 

[Install]

WantedBy=multi-user.target

            ----------------------------------------

 

# systemctl start wetty

# systemctl enable wetty

 

<connect with web browser 'http://ip-addr:4200'

 

블로그 이미지

Melting

,

# apt-mark hold <package-name>                                  --> register as 'hold upgrade'

# apt-mark unhold <package-name>                             --> re-enable auto upgrade

# apt-mark showhold                                                             --> show list of 'disabled packages'

 

 

# apt list --installed | grep postgres                                --> check installed package name & version ...

 

블로그 이미지

Melting

,

Ansible quick start

DevOps 2020. 1. 15. 17:50

====================================================================================

+. SSH Setup 

====================================================================================

$ sudo vi /etc/ssh/sshd_config

 ------------------------------------------

PermitRootLogin yes

PasswordAuthentication yes

 ------------------------------------------

$ sudo service ssh restart

$ ssh-keygen 

          --> /home/tomcat/.ssh/ansible/id_rsa

$ ssh-copy-id -i ~/.ssh/ansible/id_rsa root@130.210.105.28      (managed node user & host)

          --> copying 'public key' to remote server's 'authorized_keys

$ ssh 'root@130.210.105.28'  

$ ssh-copy-id -i ~/.ssh/ansible/id_rsa tomcat@130.210.105.28    (managed node user & host)

 

 >> https://code-maven.com/enable-ansible-passwordless-sudo

 

 

====================================================================================

+. SSH Setup - using different key files for each server

====================================================================================

$ ssh-keygen

   -> /home/tomcat/.ssh/ansible/id_rsa

$ ssh-copy-id -i ~/.ssh/ansible/id_rsa root@ssh.sever.com

$ ssh root@ssh.server.com

 

 

====================================================================================

+. Inventory file - simple example #01

====================================================================================

 ------------------------------------------

[dev]

localhost

 

[dev:vars]

ansible_ssh_private_key_file=~/.ssh/id_rsa

 

[all:vars]

ansible_python_interpreter=/usr/bin/python3

 ------------------------------------------

 

 

 

====================================================================================

+. Ansible ping

====================================================================================

$ ansible all -m ping -i ./e-hosts

   => SSH password error : set 'host_key_checking' to 'false'

     

      $ sudo vi /etc/ansible/ansible.cfg

      $ host_key_checking = False

 

 

====================================================================================

+. 'Missing sudo password' error

====================================================================================

 

$ sudo visudo

    %sudo   ALL=(ALL:ALL) NOPASSWD: ALL

 

 

 

 

 

 

====================================================================================

+. Playbook example #01 (ansible-playbook -i ../inv/local-hosts ../playbook/os-setup.yml)

====================================================================================

### ************************************************************************************* ###

---

#- hosts: all

- hosts: localhost

  become: true

#  vars_files:

#    - vars/default.yml

#

#   --- default.yml ---

#   ---

#   create_user: sammy

#   copy_local_key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"

#   sys_packages: [ 'curl', 'vim', 'git', 'ufw']

#   --------------------

 

  tasks:

    - name: Install Prerequisites

      apt: name=aptitude update_cache=yes state=latest force_apt_get=yes

 

  # Sudo Group Setup

    - name: Make sure we have a 'wheel' group (create if not exists)

      group:

        name: wheel

        state: present

 

    - name: Allow 'wheel' group to have passwordless sudo

      lineinfile:

        path: /etc/sudoers

        state: present

        regexp: '^%wheel'

        line: '%wheel ALL=(ALL) NOPASSWD: ALL'

        validate: '/usr/sbin/visudo -cf %s'

        

  # User + Key Setup

    - name: Create a new regular user with sudo privileges

      user:

        name: "ansible01"

        state: present

        groups: wheel,tomcat

        append: true

        create_home: true

        shell: /bin/bash

        

#    - name: Set authorized key for remote user

#      authorized_key:

#        user: "ansible01"

#        state: present

#        key: "{{ copy_local_key }}"

 

    - name: Disable password authentication for root

      lineinfile:

        path: /etc/ssh/sshd_config

        state: present

        regexp: '^#?PermitRootLogin'

        line: 'PermitRootLogin prohibit-password'

 

#    - name: Add apt repository for Chrome

    - apt_repository:

        repo: deb http://dl.google.com/linux/chrome/deb/ stable main

        state: present

        filename: google-chrome

 

 

  # Install Packages

    - name: Update apt

      apt: update_cache=yes

 

    - name: Install required system packages

      apt: name=nmon,htop state=latest

 

# # UFW Setup

#    - name: UFW - Allow SSH connections

#      ufw:

#        rule: allow

#        name: OpenSSH

#

#    - name: UFW - Deny all other incoming traffic by default

#      ufw:

#        state: enabled

#        policy: deny

#        direction: incoming

 

 

# Remote shell execution

# # https://docs.ansible.com/ansible/latest/modules/shell_module.html

    - name: Create script test directory

      become: true

      become_user: root

      file:

         path: /opt/dev/ansible/tmp_work/ansible_filetest_01

         state: directory

         mode: "u=rwx,g=rwx,o=rwx"

 

    - name: Change to target directory & generate shell script.

      become: true

      become_user: tomcat

      shell:

         cmd: echo "echo \"Exec by Ansible\"" > ansible_test_script01.sh ; echo "date" >> ansible_test_script01.sh ; chmod u+x ansible_test_script01.sh  ; sleep 1

         chdir: /opt/dev/ansible/tmp_work/ansible_filetest_01

 

    - name: Execute shell script.

      become: true

      become_user: tomcat

      shell: /opt/dev/ansible/tmp_work/ansible_filetest_01/ansible_test_script01.sh >> ansible_test_log01.txt

      args:

         chdir: /opt/dev/ansible/tmp_work/ansible_filetest_01

 

# # SCP file copy from master to remote : define remote server to 'host' & defile source-master- to 'delegate_to' -> 'delegate_to' executes transfer process.

    - name: SCP file copy from master to remote.

      become: true

      become_user: root

      synchronize:

         src: /opt/dev/ansible/tmp_work/transfer_files

         dest: /opt/dev/ansible/tmp_work/ansible_filetest_01

      delegate_to: localhost

 

    - name: Copy local file

      become: true

      become_user: tomcat

      copy:

        src: /opt/dev/ansible/tmp_work/transfer_files/src.txt

        dest: /opt/dev/ansible/tmp_work/transfer_files/src_copied.txt

 

#     - name: Remove script test file

#       become: true

#       become_user: root

#       file:

#          path: /opt/dev/ansible/tmp_work/ansible_filetest_01

#          state: absent

 

 

 

# # Disabling warnings

# - name: Using curl to connect to a host via SOCKS proxy (unsupported in uri). Ordinarily this would throw a warning.

#   shell: curl --socks5 localhost:9000 http://www.ansible.com

#   args:

#     warn: no

### ************************************************************************************* ###

 

 

====================================================================================

+. Playbook example #02 (ansible-playbook -i ../inv/local-hosts ../playbook/docker-ops.yml)

====================================================================================

### ************************************************************************************* ###

# # https://docs.ansible.com/ansible/latest/modules/docker_container_module.html !!!

---

#- hosts: all

- hosts: localhost

  become: true

 

  tasks:

#     - name: Remove container from all networks

#       docker_container:

#         name: ansible-docker-test

#         state: absent

#         purge_networks: yes

  

    - name: Create Docker container

      docker_container:

        name: ansible-docker-test

        image: ubuntu:18.04

        recreate: yes

        command: bash

        detach: true

        interactive: true

        tty: true

 

    - name: add docker container to inventory

      add_host:

        name: ansible-docker-test

        ansible_connection: docker

 

- hosts: ansible-docker-test

  gather_facts: false

  tasks:

 

    - name: update apt cache

      delegate_to: ansible-docker-test

      raw: apt -y update

 

    - name: install python

      delegate_to: ansible-docker-test

      raw: apt -y install python-minimal

 

#     - name: demonstrate that normal ansible modules work

#       file:

#         path: /etc/testdir

#         state: directory

 

    - name: Install python on docker

      delegate_to: ansible-docker-test

      raw: apt -y update && apt install -y python-minimal

### ************************************************************************************* ###

 

 

 

====================================================================================

+. Playbook example #03 ( https://docs.ansible.com/ansible/latest/modules/docker_container_module.html)

====================================================================================

### ************************************************************************************* ###

- name: Create a data container

  docker_container:

    name: mydata

    image: busybox

    volumes:

      - /data

 

- name: Re-create a redis container

  docker_container:

    name: myredis

    image: redis

    command: redis-server --appendonly yes

    state: present

    recreate: yes

    exposed_ports:

      - 6379

    volumes_from:

      - mydata

 

- name: Restart a container

  docker_container:

    name: myapplication

    image: someuser/appimage

    state: started

    restart: yes

    links:

     - "myredis:aliasedredis"

    devices:

     - "/dev/sda:/dev/xvda:rwm"

    ports:

     - "8080:9000"

     - "127.0.0.1:8081:9001/udp"

    env:

        SECRET_KEY: "ssssh"

        # Values which might be parsed as numbers, booleans or other types by the YAML parser need to be quoted

        BOOLEAN_KEY: "yes"

 

- name: Container present

  docker_container:

    name: mycontainer

    state: present

    image: ubuntu:14.04

    command: sleep infinity

 

- name: Stop a container

  docker_container:

    name: mycontainer

    state: stopped

 

- name: Start 4 load-balanced containers

  docker_container:

    name: "container{{ item }}"

    recreate: yes

    image: someuser/anotherappimage

    command: sleep 1d

  with_sequence: count=4

 

- name: remove container

  docker_container:

    name: ohno

    state: absent

 

- name: Syslogging output

  docker_container:

    name: myservice

    image: busybox

    log_driver: syslog

    log_options:

      syslog-address: tcp://my-syslog-server:514

      syslog-facility: daemon

      # NOTE: in Docker 1.13+ the "syslog-tag" option was renamed to "tag" for

      # older docker installs, use "syslog-tag" instead

      tag: myservice

 

- name: Create db container and connect to network

  docker_container:

    name: db_test

    image: "postgres:latest"

    networks:

      - name: "{{ docker_network_name }}"

 

- name: Start container, connect to network and link

  docker_container:

    name: sleeper

    image: ubuntu:14.04

    networks:

      - name: TestingNet

        ipv4_address: "172.1.1.100"

        aliases:

          - sleepyzz

        links:

          - db_test:db

      - name: TestingNet2

 

- name: Start a container with a command

  docker_container:

    name: sleepy

    image: ubuntu:14.04

    command: ["sleep", "infinity"]

 

- name: Add container to networks

  docker_container:

    name: sleepy

    networks:

      - name: TestingNet

        ipv4_address: 172.1.1.18

        links:

          - sleeper

      - name: TestingNet2

        ipv4_address: 172.1.10.20

 

- name: Update network with aliases

  docker_container:

    name: sleepy

    networks:

      - name: TestingNet

        aliases:

          - sleepyz

          - zzzz

 

- name: Remove container from one network

  docker_container:

    name: sleepy

    networks:

      - name: TestingNet2

    purge_networks: yes

 

- name: Remove container from all networks

  docker_container:

    name: sleepy

    purge_networks: yes

 

- name: Start a container and use an env file

  docker_container:

    name: agent

    image: jenkinsci/ssh-slave

    env_file: /var/tmp/jenkins/agent.env

 

- name: Create a container with limited capabilities

  docker_container:

    name: sleepy

    image: ubuntu:16.04

    command: sleep infinity

    capabilities:

      - sys_time

    cap_drop:

      - all

 

- name: Finer container restart/update control

  docker_container:

    name: test

    image: ubuntu:18.04

    env:

      arg1: "true"

      arg2: "whatever"

    volumes:

      - /tmp:/tmp

    comparisons:

      image: ignore   # don't restart containers with older versions of the image

      env: strict   # we want precisely this environment

      volumes: allow_more_present   # if there are more volumes, that's ok, as long as `/tmp:/tmp` is there

 

- name: Finer container restart/update control II

  docker_container:

    name: test

    image: ubuntu:18.04

    env:

      arg1: "true"

      arg2: "whatever"

    comparisons:

      '*': ignore  # by default, ignore *all* options (including image)

      env: strict   # except for environment variables; there, we want to be strict

 

- name: Start container with healthstatus

  docker_container:

    name: nginx-proxy

    image: nginx:1.13

    state: started

    healthcheck:

      # Check if nginx server is healthy by curl'ing the server.

      # If this fails or timeouts, the healthcheck fails.

      test: ["CMD", "curl", "--fail", "http://nginx.host.com"]

      interval: 1m30s

      timeout: 10s

      retries: 3

      start_period: 30s

 

- name: Remove healthcheck from container

  docker_container:

    name: nginx-proxy

    image: nginx:1.13

    state: started

    healthcheck:

      # The "NONE" check needs to be specified

      test: ["NONE"]

 

- name: start container with block device read limit

  docker_container:

    name: test

    image: ubuntu:18.04

    state: started

    device_read_bps:

      # Limit read rate for /dev/sda to 20 mebibytes per second

      - path: /dev/sda

        rate: 20M

    device_read_iops:

      # Limit read rate for /dev/sdb to 300 IO per second

      - path: /dev/sdb

        rate: 300

### ************************************************************************************* ###

 

 

'DevOps' 카테고리의 다른 글

Ping Test for Tomcat AJP connector  (0) 2020.01.15
GitLab with Docker Image official guide (GitLab)  (0) 2020.01.15
docker cli #01  (0) 2020.01.15
Git cheat sheet #02  (0) 2020.01.15
Git cheat sheet #01  (0) 2020.01.15
블로그 이미지

Melting

,

Git cheat sheet #02

DevOps 2020. 1. 15. 17:48

+. git stash

    tomcat@dev ~/forked/gitrepo01 (dev) $ echo "Temp item for stash" > tmp_task01.txt

    tomcat@dev ~/forked/gitrepo01 (dev) $ git add .

    tomcat@dev ~/forked/gitrepo01 (dev) $ git stash save tmp_task01

    tomcat@dev ~/forked/gitrepo01 (dev) $ echo "Temp item for stash v2" > tmp_task02.txt

    tomcat@dev ~/forked/gitrepo01 (dev) $ git add . ; git stash save tmp_task02

    tomcat@dev ~/forked/gitrepo01 (dev) $ echo "Temp item for stash v3" > tmp_task03.txt

    tomcat@dev ~/forked/gitrepo01 (dev) $ git add . ; git stash save tmp_task03

    tomcat@dev ~/forked/gitrepo01 (dev) $ git stash list

        stash@{0}: On dev: tmp_task03

        stash@{1}: On dev: tmp_task02

        stash@{2}: On dev: tmp_task01

    tomcat@dev ~/forked/gitrepo01 (dev) $ git stash show stash@{0}

    tomcat@dev ~/forked/gitrepo01 (dev) $ git stash apply stash@{1}

    tomcat@dev ~/forked/gitrepo01 (dev) $ git stash drop stash@{1}

    tomcat@dev ~/forked/gitrepo01 (dev) $

    tomcat@dev ~/forked/gitrepo01 (dev) $ git stash push -m "comments for stashed files" ./conf_dev01.txt ./conf/conf_dev02.txt           <- stash for multiple files

    tomcat@dev ~/forked/gitrepo01 (dev) $ git stash list

    tomcat@dev ~/forked/gitrepo01 (dev) $ git stash show stash@{0}

    tomcat@dev ~/forked/gitrepo01 (dev) $ git stash apply stash@{0}

 

 

+. Git tag   (Lightweight tag / Annotated tag)  

$ git init ;

$ date > 1.txt ; git add . ; git commit -m "v1"

$ date > 2.txt ; git add . ; git commit -m "v2"

$ git checkout -b "dev01" ;  date > 3.txt ; git add . ; git commit -m "d1-v3"

$ git checkout master ; date > 4.txt ; git add . ; git commit -m "v4"

 

$ git tag v1.0.1

$ git tag -a 'myApp01' -m 'Main stream before merge'    

$ git lg1 -n 10

$ git tag -l

$ git tag -l -n

$ git merge develop

$ git tag -a "myApp02" -m "Main stream with new feature"

$ git lg1 -n 10

    *   10a0646 - (55 seconds ago) Merge branch 'dev01' - jjung (HEAD -> master, tag: myApp02)

    |\  

    | * 63dd5cd - (6 minutes ago) d1-v3 - jjung (dev01)

    * | c56d570 - (6 minutes ago) v4 - jjung (tag: v1.0.1, tag: myApp01)

    |/  

    * e5a381f - (7 minutes ago) v2 - jjung

    * 7fa7018 - (7 minutes ago) v1 - jjung

$ git tag -l -n

    myApp01         Main stream before merge

    myApp02         Main stream with new feature

    v1.0.1          v4

$ git checkout v1.0.1 ; git checkout master ; git checkout myApp02 ; git checkout master

$ git show v1.0.1

$ git show myApp01

 

$ git tag -d v1.0.1

$ git tag -l -n

    myApp01         Main stream before merge

    myApp02         Main stream with new feature

$ git tag -d 'myApp01'

 

$ git push origin v1.0.2

$ git push origin --tag      >> push all tag to remote

$ git tag -d v1.0.2

$ git push tag :v1.0.2       >> delete remote tag

 

 

+. cleanup old/out-dated remote branches

git remote prune origin

  > https://railsware.com/blog/2014/08/11/git-housekeeping-tutorial-clean-up-outdated-branches-in-local-and-remote-repositories/

 

 

+. git alias

 > git history log view

    $ git config --global alias.lg1 "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"

    $ git config --global alias.lg1 "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%aI)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"

    $ git config --global alias.lg1 "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(white)%s%C(reset) %C(green)(%ad)%C(reset) %C(dim white)<%an>%C(reset)%C(auto)%d%C(reset)' --date=format:'%Y-%m-%d %H:%M:%S' --all"

 

    $ git config --global alias.lg2 "log --oneline"

    $ git config --global alias.lg3 "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n%C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all"

    $ git lg1

    $ git lg1 -n 5

    $ git lg2

    $ git lg2 -n 5

 

 > using meld for git diff

    git config --global alias.meld "difftool -t meld --dir-diff"

    git config --global alias.melds "difftool -t meld --dir-diff --staged"

    git config --global alias.meldh "difftool -t meld --dir-diff HEAD"

    (or)

    meld = difftool -t meld --dir-diff

    meldh = difftool -t meld --dir-diff HEAD

    melds = difftool -t meld --dir-diff --staged

    

 

 > git amend (add to last commit with  staged files)

    git config --global alias.add2last "commit -a --amend -C HEAD"

 

 > git show alias

    aliases =  "!git config -l | grep ^alias" (to be added directly to .gitconfig)

 

+. bash alias for git 

    $ alias tar-src='tar --exclude={.DS_Store,.git,.svn,node_modules,target,*.iml,*.ipr,*.iws,.idea,.settings,.project,.classpath} -cvf '

    $ cat ~/.bashrc | grep tar-src

alias tar-src='tar --exclude={.DS_Store,.git,.svn,node_modules,target,*.iml,*.ipr,*.iws,.idea,.settings,.project,.classpath} -cvf '

    $ tar-src tar-src-test.tar ./tar-src-folder/

 

 

+. bash with git branch name

     > https://coderwall.com/p/fasnya/add-git-branch-name-to-bash-prompt

    $ vi .bashrc

        parse_git_branch() {

             git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'

        }

        export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

 

 

+. install git meld for windows

  > install  meld for windows

  > git config --global difftool.meld.path "C:\dev\Meld\Meld.exe"

  > git config --global diff.tool meld

  > git config --global difftool.prompt false

  > git config --global mergetool.meld.path "C:\dev\Meld\Meld.exe"

  > git config --global merge.tool meld

  > git config --global mergetool.prompt true

  > git config --global alias.meld "difftool -t meld --dir-diff"

 

 

+. git search

 > Search by author

   $ git log --author="Donohue" --oneline

 > Search by message

   $ git log --grep='SASS' --oneline

 > Search by file

   $ git log -- "src/main/lincense.txt"

 

 

+. git log graph with single line

 $ git log --graph --oneline

 

 

 

+. gitconfig

        [user]

            name = jjung

            email = jjung@waikato.ac.nz

        [core]

            editor = vi

        [push]

            default = matching

        [alias]

            lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(white)%s%C(reset) %C(green)(%ad)%C(reset) %C(dim white)<%an>%C(reset)%C(auto)%d%C(reset)' --date=format:'%Y-%m-%d %H:%M:%S' --all

            lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n%C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all

            meld = difftool -t meld --dir-diff

            melds = difftool -t meld --dir-diff --staged

            meldh = difftool -t meld --dir-diff HEAD

       [core]

            autocrlf = true            => windows environment (change cr+lf to lf before store)

            autocrlf = input           => linux/unix/mac environment (use lf as line ending)

 

 

+. handling line break : need to define global configuration

   $ git config --global core.autocrlf true   => windows environment (change cr+lf to lf before store)

   $ git config --global core.autocrlf input  => linux/unix/mac environment (use lf as line ending)

   $ git config --global core.autocrlf false  => default option, doesn't convert line-break && not recommended

 

+. dos2unix for converting CR+LF to LF (commit changes first - or will lose your code!)

    $ find . -type f -not -path "./.git/*" -exec grep -Il '.' {} \; | grep -v "./.project" | grep -v "./.classpath" | grep -v "./.mule/"| grep -v "./target/" | xargs dos2unix

      > dos2unix : utility changes CR+LF to LF

      > find ... -type f : find only file type

      > find ... -not path : exclude following path

      > find ... -exec grep -Il '.' {} \;   : exclude binary file

      > | grep -v ... : exclude following results

 

 

+. clean-up cached changes when .gitignore is not working (commit changes first - or will lose your code!)

    $  git rm -r --cached .

    $  git add .

    $  git commit -m "fixed untracked files"

 

 

+. ignore file permission changes (not recommended)

          > git records only two file mode 644 & 755

    $ git config --global core.fileMode false

    $ git -c core.fileMode=false diff     --> one-off commands    

     cf.    

      # update all directory permission to '755'

       find . -type d -not -perm 0755 | grep -v ".git" | grep -v "target"  | xargs chmod 755

      # update all normal files permission to '644'

       find ./ -type f -not -perm 0644 | grep -v ".git" | grep -v "target" | grep -v ".sh" | xargs chmod 644

      # update all script files permission to '755'

        find ./ -type f -not -perm 0755 | grep -v ".git" | grep -v "target" |  grep ".sh" | xargs chmod 755

      # update <cr>+<lf> to <lf>

        find . -type f  | grep -v ".git" | grep -v "target" | xargs dos2unix

 

+. gitignore list

 

 

+. Useful links

 > http://devpools.kr/2017/02/05/%EC%B4%88%EB%B3%B4%EC%9A%A9-git-%EB%90%98%EB%8F%8C%EB%A6%AC%EA%B8%B0-reset-revert/

 

 

 

+. bash with git branch name & git status

----------------------------------------------------------------------------------------------------------------------------

##### git bash prompt ######################

PS_COLOR_RED="\033[31m\\"

PS_COLOR_YELLOW="\033[33m\\"

PS_COLOR_GREEN="\033[32m"

PS_COLOR_OCHRE="\033[95m\\"

PS_COLOR_BLUE="\033[34m\\"

PS_COLOR_WHITE="\033[37m\\"

PS_COLOR_RESET="\e[0m"

# get current branch in git repo

function parse_git_branch() {

    BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`

    if [ ! "${BRANCH}" == "" ]

    then

        STAT=`parse_git_dirty`

        echo " (${BRANCH}${STAT})"

    else

        echo ""

    fi

}

# get current status of git repo

function parse_git_dirty {

    status=`git status 2>&1 | tee`

    dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`

    untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"`

    ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"`

    newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"`

    renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"`

    deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"`

    bits=''

    if [ "${renamed}" == "0" ]; then

        bits=">${bits}"

    fi

    if [ "${ahead}" == "0" ]; then

        bits="*${bits}"

    fi

    if [ "${newfile}" == "0" ]; then

        bits="+${bits}"

    fi

    if [ "${untracked}" == "0" ]; then

        bits="?${bits}"

    fi

    if [ "${deleted}" == "0" ]; then

        bits="x${bits}"

    fi

    if [ "${dirty}" == "0" ]; then

        bits="!${bits}"

    fi

    if [ ! "${bits}" == "" ]; then

        echo " ${bits}"

    else

        echo ""

    fi

}

 

export PS1="\u@\h \[\033[32m\]\w\[\e[96m\]\$(parse_git_branch)\[\033[00m\] $ "

----------------------------------------------------------------------------------------------------------------------------

 

 

+. git alias advanced configuration - interactive mode using fzf & pygments

----------------------------------------------------------------------------------------------------------------------------

a. install prerequisite applications

    # git clone "https://github.com/junegunn/fzf.git"

    # mv fzf /usr/share/

    # cd /usr/share/fzf ; ./install

      --> check ~/.bashrc && ~/.zshrc  

      --> logout & login (or reload bash/zsh)

        ==> this configuration should be copied to each user

          # cp ./.fzf.* ~tomcat/

          # chown tomcat:tomcat ~tomcat/.fzf.*

          # cp ~tomcat/.bashrc ~tomcat/.bashrc_bak

          # echo "[ -f ~/.fzf.bash ] && source ~/.fzf.bash" >> ~tomcat/.bashrc

          # cp ~tomcat/.zshrc ~tomcat/.zshrc_bak

          # echo "[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh" >> ~tomcat/.zshrc

 

    +. run with cli

       find ./ -name "*" | fzf > selected.txt      -> single selection

       find ./ -name "*" | fzf -m > selected.txt   -> multiple selection (with tab)

 

    # apt install python3-pip

    # apt install python-pygments

       ==> python3-pip & python-pygments are used to preview screen

 

b. ~/.gitconfig

    al = "!# Prints all aliases.;\n\

        git config --list \

        | egrep '^alias.+' \

        | sed -e 's/^alias\\.//' \

        | column -t -s'=' \

        | sed 's/!#* *//; s/;$//' \

        | cut -c1-85"

    st = status

     sts = status -s

    b0 = "!git branch | awk '/^\\*/{print $2}'"

    backup = "!git branch backup-`git b0`"

    lp = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit

    ch = "!git checkout $(git bselect)"

    bselect = "! # select branch with preview; \n\

        f() { \

            _height=$(stty size | awk '{print $1}');\

            git branch | fzf --preview \"git lp {1} | head -n $_height\"; \

        }; f"

    af = "!git diff-select | xargs git add"

    diff-select = "! # add files with fzf preview diffs; \n\

        f() { \

            _height=$(stty size | awk '{print $1}');\

            git diff-info \

            | fzf -m --header \"$(git diff --shortstat)\" --preview \

                \"if [[ {1} == '??' ]]; then cat {3}; else git diff {3}; fi \

                | head -n $_height \

                | pygmentize\" \

            | awk '{print $3}'; \

        }; f"

    diff-info = "! # get diff info;\n\

        fileA=/tmp/git-s-$(uuidgen); \

        fileB=/tmp/git-diff-$(uuidgen); \

        git sts | awk '{print $2,$1}' > $fileA; \

        git diff --numstat | awk '{print $3,$1,$2}' > $fileB; \

        join -t' ' -a 1 $fileA $fileB | awk '{print $2, \"(+\"$3 \",-\"$4\")\", $1}' | sed 's/(+,-)/./' | column -t -s' ' ; \

        rm -f $fileA $fileB; \

    "

 

 

'DevOps' 카테고리의 다른 글

Ping Test for Tomcat AJP connector  (0) 2020.01.15
GitLab with Docker Image official guide (GitLab)  (0) 2020.01.15
docker cli #01  (0) 2020.01.15
Ansible quick start  (0) 2020.01.15
Git cheat sheet #01  (0) 2020.01.15
블로그 이미지

Melting

,

Git cheat sheet #01

DevOps 2020. 1. 15. 17:45

+. reset vs revert ?

    reset  :  make clear commit history but, should clear whole commits before reset point 

    revert : delete only one commit between already committed items && good for remotely pushed commit (reset can be done by --force option but it is not desirable)

 

 

+. git commit --amend : add to last commit

 

+. git reset : change previous commit & restore old version

    --soft  : changes only commit history, commit history is deleted but, every changes are remained status -> can commit again

    --mixed : default option, changes only staged files & commit history  

    --hard  : changes all working directory, staged files, repository => most clear & popular way

    

    cf. git reset HEAD <file>   -> unstage specific file

    cf. git checkout -- <file>  -> changes file to original status of working directory (like just cloned status)

            (or) git checkout -- .

 

+. git reset : merge commit history using 'git reset --soft HEAD~n' 

      >>>  delete commit  history & keep changes 

 tomcat@dev ~/workspace (master) $ ls

    v1.txt    v2.txt    v3.txt    v4.txt

 tomcat@dev ~/workspace (master) $ git lg1

    * 3adf76e - (4 seconds ago) v4.txt - jjung (HEAD -> master)

    * ec6e89e - (12 seconds ago) v3.txt - jjung

    * 7cbd268 - (20 seconds ago) v2.txt - jjung

    * 467315b - (27 seconds ago) v1.txt - jjung

 tomcat@dev ~/workspace (master) $ git reset --soft HEAD~3

 tomcat@dev ~/workspace (master) $ git lg1

    * 467315b - (2 minutes ago) v1.txt - jjung (HEAD -> master)

 tomcat@dev ~/workspace (master) $ ls

    v1.txt    v2.txt    v3.txt    v4.txt 

 

 

+. git reset : merge commit history using 'git reset --hard HEAD~n'   

      >>>  delete commit  history & remove changes

tomcat@mint ~/_gt[master] $ git lg1 -n 10

* 22a20d3 - (4 seconds ago) v3 - jjung (HEAD -> master)

* 713afad - (26 seconds ago) v2 - jjung

* 3b0bfea - (47 seconds ago) v1 - jjung

tomcat@mint ~/_gt[master] $ ls

1.txt  2.txt  3.txt

tomcat@mint ~/_gt[master] $ git reset --hard HEAD~1

HEAD is now at 713afad v2

tomcat@mint ~/_gt[master] $ ls

1.txt  2.txt

tomcat@mint ~/_gt[master] $ git lg1 -n 10

* 713afad - (58 seconds ago) v2 - jjung (HEAD -> master)

* 3b0bfea - (79 seconds ago) v1 - jjung

 

 

 

 

+. git revert : make new commit (after current version) & restore old version

 

 

 

+. git revert usage #01 : delete only one commit between already committed items

    tomcat@dev ~/forked/gitrepo01 (dev) $ git lg1

        * ae027e0 - (2 seconds ago) F-v3.txt - jjung (HEAD -> dev)

        * 9d116e1 - (2 minutes ago) F-v2.txt - jjung

        * 9f31110 - (74 minutes ago) Fork & Branch v1 - jjung (origin/dev)

        * c600480 - (76 minutes ago) Main Stream update v1 - jjung (upstream/master)

        * 2054426 - (83 minutes ago) first commit - jjung (origin/master, origin/HEAD, master)

    tomcat@dev ~/forked/gitrepo01 (dev) $ ls

        F-v1.txt  F-v2.txt  F-v3.txt  M-v1.txt    README.md

    tomcat@dev ~/forked/gitrepo01 (dev) $ git revert 9d116e1

        [dev 6cf7c7a] Revert "F-v2.txt"

         1 file changed, 0 insertions(+), 0 deletions(-)

         delete mode 100644 F-v2.txt

    tomcat@dev ~/forked/gitrepo01 (dev) $ git lg1

        * 6cf7c7a - (6 seconds ago) Revert "F-v2.txt" - jjung (HEAD -> dev)

        * ae027e0 - (30 seconds ago) F-v3.txt - jjung

        * 9d116e1 - (2 minutes ago) F-v2.txt - jjung

        * 9f31110 - (74 minutes ago) Fork & Branch v1 - jjung (origin/dev)

        * c600480 - (76 minutes ago) Main Stream update v1 - jjung (upstream/master)

        * 2054426 - (84 minutes ago) first commit - jjung (origin/master, origin/HEAD, master)

    tomcat@dev ~/forked/gitrepo01 (dev) $ ls

        F-v1.txt  F-v3.txt  M-v1.txt  README.md

 

 

+. git rebase

    <<< Type #01 >>>

    tomcat@serena ~/_git01 (master) $ git lg1

        * c9f223d - (5 minutes ago) Revert "d1-v5" - jjung (dev)

        * 33dff97 - (7 minutes ago) d1-v6 - jjung

        * 8e28bcb - (8 minutes ago) d1-v5 - jjung

        | * 237ffb3 - (7 minutes ago) m1-v6 - jjung (HEAD -> master)

        | * 71522bd - (7 minutes ago) m1-v4 - jjung

        | * 2849938 - (36 minutes ago) v5 - jjung

        |/  

        * 9a7b911 - (36 minutes ago) v4 - jjung

        * ee470e1 - (39 minutes ago) v2 - jjung

        * 4c84853 - (39 minutes ago) v1 - jjung

    tomcat@serena ~/_git01 (master) $ git rebase c9f223d

        First, rewinding head to replay your work on top of it...

        Applying: v5

        Applying: m1-v4

        Applying: m1-v6

    tomcat@serena ~/_git01 (master) $ git lg1

        * 8dbc9e8 - (7 minutes ago) m1-v6 - jjung (HEAD -> master)

        * 4e4a048- (7 minutes ago) m1-v4 - jjung

        * 449d995- (37 minutes ago) v5 - jjung

        * c9f223d - (6 minutes ago) Revert "d1-v5" - jjung (dev)

        * 33dff97 - (8 minutes ago) d1-v6 - jjung

        * 8e28bcb - (8 minutes ago) d1-v5 - jjung

        * 9a7b911 - (37 minutes ago) v4 - jjung

        * ee470e1 - (40 minutes ago) v2 - jjung

        * 4c84853 - (40 minutes ago) v1 - jjung

    

    <<< Type #02 >>>    

    tomcat@serena ~/_git01 (master) $ git lg1

        * 9272161 - (2 seconds ago) m-r-2 - jjung (HEAD -> master)

        * 88f8d6d - (11 seconds ago) m-r-1 - jjung

        * 4e4a048 - (10 minutes ago) m1-v4 - jjung

        * 449d995 - (39 minutes ago) v5 - jjung

        | * 99b6d07 - (46 seconds ago) d-r-2 - jjung (dev)

        | * b3d357f - (54 seconds ago) d-r-1 - jjung

        |/  

        * c9f223d - (8 minutes ago) Revert "d1-v5" - jjung

        * 33dff97 - (11 minutes ago) d1-v6 - jjung

        * 8e28bcb - (11 minutes ago) d1-v5 - jjung

        * 9a7b911 - (40 minutes ago) v4 - jjung

        * ee470e1 - (42 minutes ago) v2 - jjung

        * 4c84853 - (43 minutes ago) v1 - jjung

    tomcat@serena ~/_git01 (master) $ git rebase dev

        First, rewinding head to replay your work on top of it...

        Applying: v5

        Applying: m1-v4

        Applying: m-r-1

        Applying: m-r-2

    tomcat@serena ~/_git01 (master) $ git lg1

        * 299b6e1 - (31 seconds ago) m-r-2 - jjung (HEAD -> master)

        * 08322c9 - (40 seconds ago) m-r-1 - jjung

        * e987916 - (11 minutes ago) m1-v4 - jjung

        * 5e77ffc - (40 minutes ago) v5 - jjung

        * 99b6d07 - (75 seconds ago) d-r-2 - jjung (dev)

        * b3d357f - (83 seconds ago) d-r-1 - jjung

        * c9f223d - (9 minutes ago) Revert "d1-v5" - jjung

        * 33dff97 - (11 minutes ago) d1-v6 - jjung

        * 8e28bcb - (11 minutes ago) d1-v5 - jjung

        * 9a7b911 - (40 minutes ago) v4 - jjung

        * ee470e1 - (43 minutes ago) v2 - jjung

        * 4c84853 - (43 minutes ago) v1 - jjung

 

        <<< Type #03 >>>    

    tomcat@mint ~/_gt[master] $ git lg1 -n 10

    * db6bdf1 - (4 seconds ago) v4 - jjung (HEAD -> master)

    * 9ec6ca0 - (14 seconds ago) v3 - jjung

    * 713afad - (80 minutes ago) v2 - jjung

    * 3b0bfea - (80 minutes ago) v1 - jjung

    tomcat@mint ~/_gt[master] $ ls

        1.txt  2.txt  3.txt  4.txt

    tomcat@mint ~/_gt[master] $ git rebase -i HEAD~3

    ---------------------------------------

    pick 713afad v2

    pick 342adf3 v3              --> delete this line (commit v3)

    pick 2e86b18 v4

    # Rebase 3b0bfea..2e86b18 onto 3b0bfea (2 commands)

    ---------------------------------------

    Successfully rebased and updated refs/heads/master.

    tomcat@mint ~/_gt[master] $ ls

        1.txt  2.txt  4.txt

    tomcat@mint ~/_gt[master] $ git lg1 -n 10

    * 2e86b18 - (63 seconds ago) v4 - jjung (HEAD -> master)

    * 713afad - (81 minutes ago) v2 - jjung

    * 3b0bfea - (81 minutes ago) v1 - jjung

 

    

+. git rebase & upstream

 

+. using rebase for cherry-picking multiple commits     

    (Scenario: need to merge 'some of required commits' from 'develop branch' to 'master branch')

    tomcat@serena ~/_git01 (master) $ git lg1

        * 8c889a6 - (4 minutes ago) dev01-3 - jjung (HEAD -> dev01)

        * e1c88dc - (6 minutes ago) dev01-2 - jjung

        * ed4a439 - (7 minutes ago) dev01-1 - jjung

        | * ff9ee46 - (5 minutes ago) m-3 - jjung (master)

        | * 2489da9 - (6 minutes ago) m-2 - jjung

        |/

        * 3ac7d31 - (9 minutes ago) v1 - jjung

    tomcat@serena ~/_git01 (master) $ git checkout -b dev01_rebase

        Switched to a new branch 'dev01_rebase'

    tomcat@serena ~/_git01 (dev01_rebase) $ git lg1

        * 8c889a6 - (4 minutes ago) dev01-3 - jjung (HEAD -> dev01_rebase, dev01)

        * e1c88dc - (6 minutes ago) dev01-2 - jjung

        * ed4a439 - (7 minutes ago) dev01-1 - jjung

        | * ff9ee46 - (5 minutes ago) m-3 - jjung (master)

        | * 2489da9 - (6 minutes ago) m-2 - jjung

        |/

        * 3ac7d31 - (9 minutes ago) v1 - jjung

    tomcat@serena ~/_git01 (dev01_rebase) $ git rebase --interactive master

         (select only required commit)

        Successfully rebased and updated refs/heads/dev01_rebase.

    tomcat@serena ~/_git01 (dev01_rebase) $ git lg1

        * d3d2882 - (4 minutes ago) dev01-2 - jjung (HEAD -> dev01_rebase)

        * 358474d - (4 minutes ago) dev01-1 - jjung

        * ff9ee46 - (3 minutes ago) m-3 - jjung (master)

        * 2489da9 - (3 minutes ago) m-2 - jjung

        | * 8c889a6 - (2 minutes ago) dev01-3 - jjung (dev01)

        | * e1c88dc - (4 minutes ago) dev01-2 - jjung

        | * ed4a439 - (4 minutes ago) dev01-1 - jjung

        |/

        * 3ac7d31 - (7 minutes ago) v1 - jjung

    tomcat@serena ~/_git01 (dev01_rebase) $ git checkout master 

        Switched to branch 'master'

    tomcat@serena ~/_git01 (master) $ git merge dev01_rebase 

        Updating ff9ee46..d3d2882

        Fast-forward

         dev01-1.txt | 1 +

         dev01-2.txt | 1 +

         2 files changed, 2 insertions(+)

         create mode 100644 dev01-1.txt

         create mode 100644 dev01-2.txt

    tomcat@serena ~/_git01 (master) $ git lg1 

        * d3d2882 - (5 minutes ago) dev01-2 - jjung (HEAD -> master, dev01_rebase)

        * 358474d - (5 minutes ago) dev01-1 - jjung

        * ff9ee46 - (4 minutes ago) m-3 - jjung

        * 2489da9 - (4 minutes ago) m-2 - jjung

        | * 8c889a6 - (3 minutes ago) dev01-3 - jjung (dev01)

        | * e1c88dc - (5 minutes ago) dev01-2- jjung

        | * ed4a439 - (5 minutes ago) dev01-1 - jjung

        |/

        * 3ac7d31 - (8 minutes ago) v1 - jjung

    tomcat@serena ~/_git01 (master) $ git branch -D dev01_rebase 

 

+. git cherry-pick (merge for only required commit) 

    tomcat@serena ~/_gt2 (master) $ git lg1

        * 4b5b440 - (45 seconds ago) m-3 - jjung (HEAD -> master)

        * 4f6f33a - (53 seconds ago) m-2 - jjung

        | * 3722f30 - (84 seconds ago) dev01-3 - jjung (dev01)

        | * fef466f - (2 minutes ago) dev01-2 - jjung

        | * 27e9013 - (2 minutes ago) dev01-1 - jjung

        |/  

        * 98141d5 - (2 minutes ago) v1 - jjung

    tomcat@serena ~/_gt2 (master) $ git cherry-pick fef466f

        [master 1d2c11a] dev01-2

         Date: Thu Mar 8 14:36:37 2018 +1300

         1 file changed, 1 insertion(+)

         create mode 100644 dev01-2.txt

    tomcat@serena ~/_gt2 (master) $ git lg1

        * 1d2c11a - (2 minutes ago) dev01-2 - jjung (HEAD -> master)

        * 4b5b440 - (60 seconds ago) m-3 - jjung

        * 4f6f33a - (68 seconds ago) m-2 - jjung

        | * 3722f30 - (2 minutes ago) dev01-3 - jjung (dev01)

        | * fef466f - (2 minutes ago) dev01-2 - jjung

        | * 27e9013 - (2 minutes ago) dev01-1 - jjung

        |/  

        * 98141d5 - (3 minutes ago) v1 - jjung

 

 

 

'DevOps' 카테고리의 다른 글

Ping Test for Tomcat AJP connector  (0) 2020.01.15
GitLab with Docker Image official guide (GitLab)  (0) 2020.01.15
docker cli #01  (0) 2020.01.15
Ansible quick start  (0) 2020.01.15
Git cheat sheet #02  (0) 2020.01.15
블로그 이미지

Melting

,

1. check software raid status

# cat /proc/mdstat

Personalities : [raid1] 

md0 : active raid1 sdc1[1] sdb1[2](F)

  346242536 blocks [2/1] [_U]

 

unused devices: <none>



2. remove failed disk from raid

# mdadm --manage /dev/md0 --remove /dev/sdb1 

mdadm: hot removed /dev/sdb1



3. re-add failed disk to raid

# mdadm --manage /dev/md0 --add /dev/sdb1 

mdadm: re-added /dev/sdb1



4. check rebuilding status

# cat /proc/mdstat 

Personalities : [raid1] 

md0 : active raid1 sdb1[2] sdc1[1]

      346242536 blocks [2/1] [_U]

      [>....................]  recovery =  0.0% (13434/346242536) finish=145.6min speed=42192K/sec


블로그 이미지

Melting

,