Skip to content

Instantly share code, notes, and snippets.

View TyeolRik's full-sized avatar

TyeolRik TyeolRik

View GitHub Profile
@TyeolRik
TyeolRik / gfs2_install_guide.txt
Created October 1, 2024 23:07
GFS2 설치가이드
현재: ProLinux 8.6
/dev/sdc 가 공유볼륨이라는 사실은
1. DB1 에서 dd if=/dev/urandom of=/dev/sdc bs=4K count=1 날림.
2. DB1, DB2 에서 hexdump /dev/sdc -C 로 같은 값이 나오는지 확인.
3. 공유볼륨 확인 완료.
모든 노드에 대해
1. dnf install lvm2-lockd gfs2-utils dlm-lib -y
2. /etc/hosts 에 10.0.2.22 GFS-DB1 / 10.0.2.21 GFS-DB2 추가
@TyeolRik
TyeolRik / CheatSheet.sh
Created June 13, 2024 07:12
Shell Script Cheat Sheet
#!/bin/bash
# 관련한 모든 rpm 들 설치 (with dependencies)
dnf download --resolve --alldeps <package_name_1> ...
@TyeolRik
TyeolRik / remove_osd.sh
Last active June 24, 2024 00:43
Remove Ceph OSD forcefully
#!/bin/bash
# This is really dangerous command.
# Please be CAREFUL
TARGET_OSD_ID="$1" # 6
TARGET_HOST_NAME=$(ceph orch ps --daemon_type osd --format json| jq -r '.[] | select(.daemon_id == '\""$TARGET_OSD_ID"\"') | .hostname')
TARGET_DAEMON_NAME=$(ceph orch ps --daemon_type osd --format json | jq -r '.[] | select(.daemon_id == '\""$TARGET_OSD_ID"\"') | .daemon_name')
TARGET_OSD_DEV_PATH=$(ceph device ls-by-host "${TARGET_HOST_NAME}" --format json | jq -r '.[] | select(.daemons[] | contains('\""${TARGET_DAEMON_NAME}"\"')) | .location[] | .dev')
# ceph orch ls --service_type osd --format json | jq -c '.[] | select(.spec.data_devices.paths != null) | select(.spec.data_devices.paths[] | contains('\"${TARGET_OSD_DEV_PATH}\"')) | select(.placement.hosts != null) | select(.placement.hosts[] | contains('\"${TARGET_HOST_NAME}\"'))'
@TyeolRik
TyeolRik / replace.sh
Created October 5, 2023 02:00
Replace whole line which matches.
#!/bin/bash
version=$(git rev-parse HEAD | cut -c1-8)
version="0.1.7-nightly-$version"
sed -i "/EXTCTRL_VERSION = \"/c\ EXTCTRL_VERSION = \"$version\";" ./main.cpp
@TyeolRik
TyeolRik / add_osd.yaml
Created September 26, 2023 02:45
Ceph adding osd
# ceph orch apply -i add_osd.yaml
service_type: osd
service_id: osd_localhost
placement:
hosts:
- node1
data_devices:
paths:
- /dev/sdb
- /dev/sdc
#!/bin/bash
function snakecase_to_camelCase() {
local ret
ret=$(echo $1 | sed -E 's/_(.)/\U\1/g')
echo "$ret"
}
SomeString="snakecase_looks_very_bad"
camelCase=$(snakecase_to_camelCase "$SomeString")
function camelcase_to_snakecase() {
local ret
ret=$(echo "$1" | sed -r 's/([A-Z])/_\L\1/g' | sed 's/^_//')
echo "$ret"
}
SomeString="helloWorldMyFriend"
snake_case=$(camelcase_to_snakecase "${SomeString}")
echo $snake_case
@TyeolRik
TyeolRik / ConvertUpperCase.sh
Last active May 24, 2023 01:08
Function return values in Shell Script
#!/bin/bash
function all_uppercase() {
local ret=${1^^} # Make input parameter Upper case. Should be declared in local variable.
echo "$ret" # This is like return.
}
SomeString="HelloWorld"
UpperCase=$(all_uppercase "${SomeString}")
echo $UpperCase
@TyeolRik
TyeolRik / test.sql
Last active December 29, 2022 14:52
[Oracle] Use list using VARRAY data type.
CREATE TYPE SUBUSER AS OBJECT (
ID VARCHAR2(200),
PERMISSIONS VARCHAR2(12)
);
CREATE TYPE SUBUSERS AS VARRAY(1000) OF SUBUSER; -- Nested Table type.
CREATE TABLE USER (
UID VARCHAR2(50),
SUBUSERS_COLUMN SUBUSERS -- An Instance of Nested Table
@TyeolRik
TyeolRik / CEPH_Install_For_Admin_at_closed_networks.sh
Last active July 12, 2022 03:49
CEPH Installation in Closed Network Nodes with maintaining firewalld and selinux. OS: CentOS 8 Stream, CEPH Version: Pacific (v16.2.9)
#!/bin/bash
###########################
# Information
# Host 1 (node1): 172.22.4.101 - admin
# host 2 (node2): 172.22.4.102
# host 3 (node3): 172.22.4.103
# host 4 (node4): 172.22.4.104
# host 5 (node5): 172.22.4.105
###########################