스테이징 호스트 장비, 스토리지망 인터페이스 설정 : MTU 9000
root@brighforest:~# ifconfig br2
br2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9000
...





스토리지 서버 Ping 테스트


1. MTU 1500 테스트 - 정상 응답
root@brighforest:~# ping -M do -s 1472 xxx.xxx.xxx.96
PING xxx.xxx.xxx.96 (xxx.xxx.xxx.96) 1472(1500) bytes of data.
1480 bytes from xxx.xxx.xxx.96: icmp_seq=1 ttl=64 time=0.163 ms
1480 bytes from xxx.xxx.xxx.96: icmp_seq=2 ttl=64 time=0.213 ms
1480 bytes from xxx.xxx.xxx.96: icmp_seq=3 ttl=64 time=0.229 ms




2. MTU 1600 테스트 - 정상 응답 안 함
root@brighforest:~# ping -M do -s 1600 xxx.xxx.xxx.96
PING xxx.xxx.xxx.96 (xxx.xxx.xxx.96) 1600(1628) bytes of data.
...



3. MTU 9000 테스트 - 정상 응답 안 함
root@brighforest:~# ping -M do -s 8972 xxx.xxx.xxx.96
PING xxx.xxx.xxx.96 (xxx.xxx.xxx.96) 8972(9000) bytes of data.
...
 
 
참고)
https://blog.naver.com/PostView.naver?blogId=jesstter&logNo=222077975245
 

 

테스트 환경

Ubuntu 20.04.4 LTS

 

 

1. 서버 디스크 현황

brightforest-ubuntu 서버

/dev/vda - 루트 디스크 50GB

/dev/vdb - 추가 디스크 50GB

/dev/vdc - 추가 디스크 60GB

/dev/vdd - 추가 디스크 70GB

*물리 디스크가 아니라 가상 디스크이기 때문에 sda가 아닌 vda 형태로 표시

 

root@brightforest-ubuntu:~# fdisk -l

...

Disk /dev/vdb: 50 GiB, 53687091200 bytes, 104857600 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/vdc: 60 GiB, 64424509440 bytes, 125829120 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/vdd: 70 GiB, 75161927680 bytes, 146800640 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes

 

 

LVM 생성 순서

물리볼륨 (PV, Physical Volume)

 - 실제로 나눈 파티션 (/dev/sda1, /dev/vdb1 등)

 

볼륨그룹(VG, Volume Group)

 - 물리적 볼륨이 모여서 하나의 볼륨그룹을 이룬다.

 

논리적볼륨(LV, Logical Volume)

 - 서버에 마운트하여 사용하는 파티션 형태

 

 

 

1. 추가 디스크 LVM 타입으로 파티션 생성

(1) fdisk /dev/vdb ~ vdd까지 수행

root@brightforest-ubuntu:~# fdisk /dev/vdb

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x7558c0e3.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-104857599, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-104857599, default 104857599):

Created a new partition 1 of type 'Linux' and of size 50 GiB.

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden or  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi ea  Rufus alignment
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         eb  BeOS fs
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ee  GPT
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        ef  EFI (FAT-12/16/
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f0  Linux/PA-RISC b
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f1  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f4  SpeedStor
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      f2  DOS secondary
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fb  VMware VMFS
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fc  VMware VMKCORE
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fd  Linux raid auto
1c  Hidden W95 FAT3 75  PC/IX           bc  Acronis FAT32 L fe  LANstep
1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot    ff  BBT
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

 

 

(2) 파티션 확인

root@brightforest-ubuntu:~# fdisk -l
...
Disk /dev/vdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7558c0e3

Device     Boot Start       End   Sectors Size Id Type
/dev/vdb1        2048 104857599 104855552  50G 8e Linux LVM


Disk /dev/vdc: 60 GiB, 64424509440 bytes, 125829120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0fa7eae4

Device     Boot Start       End   Sectors Size Id Type
/dev/vdc1        2048 125829119 125827072  60G 8e Linux LVM


Disk /dev/vdd: 70 GiB, 75161927680 bytes, 146800640 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xce0b4588

Device     Boot Start       End   Sectors Size Id Type
/dev/vdd1        2048 146800639 146798592  70G 8e Linux LVM

 

 

 

 

2. 물리볼륨 생성

root@brightforest-ubuntu:~# pvcreate /dev/vdb1
  Physical volume "/dev/vdb1" successfully created.

root@brightforest-ubuntu:~# pvcreate /dev/vdc1
  Physical volume "/dev/vdc1" successfully created.

root@brightforest-ubuntu:~# pvcreate /dev/vdd1
  Physical volume "/dev/vdd1" successfully created.


root@brightforest-ubuntu:~# pvdisplay
  "/dev/vdb1" is a new physical volume of "<50.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/vdb1
  VG Name
  PV Size               <50.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               wP5pKr-2kNV-aXIb-5E2F-Wv8w-3aHc-Vns37O

  "/dev/vdc1" is a new physical volume of "<60.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/vdc1
  VG Name
  PV Size               <60.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               r01RIY-mPPb-850G-DyYX-go5j-VjlQ-4C2vJU

  "/dev/vdd1" is a new physical volume of "<70.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/vdd1
  VG Name
  PV Size               <70.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               DXuL0f-apwh-BLPP-4wvG-jIjc-J3dX-ieNgsi

 

 

 

3. 볼륨그룹 생성

root@brightforest-ubuntu:~# vgcreate brightforest-vg /dev/vdb1 /dev/vdc1 /dev/vdd1
  Volume group "brightforest-vg" successfully created


root@brightforest-ubuntu:~# vgdisplay
  --- Volume group ---
  VG Name               brightforest-vg
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               <179.99 GiB
  PE Size               4.00 MiB
  Total PE              46077
  Alloc PE / Size       0 / 0
  Free  PE / Size       46077 / <179.99 GiB
  VG UUID               Es9ha0-Vc1M-xspN-WVcn-JBco-3nor-BgzRdZ

 

 

 

4. 논리볼륨 생성

 - 100GB, 80GB(나머지) Logical Volume 생성

root@brightforest-ubuntu:~# lvcreate -n bf-lv01 -L 100GB brightforest-vg
  Logical volume "bf-lv01" created.

root@brightforest-ubuntu:~# lvcreate -n bf-lv02 -l 100%FREE brightforest-vg
  Logical volume "bf-lv02" created.


root@brightforest-ubuntu:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/brightforest-vg/bf-lv01
  LV Name                bf-lv01
  VG Name                brightforest-vg
  LV UUID                NpQpoL-8wKY-KbXB-Tqo8-5pUq-Kur4-sefnw0
  LV Write Access        read/write
  LV Creation host, time brightforest-ubuntu, 2022-10-13 06:45:37 +0000
  LV Status              available
  # open                 0
  LV Size                100.00 GiB
  Current LE             25600
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/brightforest-vg/bf-lv02
  LV Name                bf-lv02
  VG Name                brightforest-vg
  LV UUID                5Zc6zq-EkD4-U78O-4AcT-Sz0T-24jm-d2wo8U
  LV Write Access        read/write
  LV Creation host, time brightforest-ubuntu, 2022-10-13 06:46:32 +0000
  LV Status              available
  # open                 0
  LV Size                <79.99 GiB
  Current LE             20477
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

 

 

 

5. 파일시스템 포맷 및 마운트

(1) ext3 타입으로 포맷

root@brightforest-ubuntu:~# mkfs.ext3 /dev/brightforest-vg/bf-lv01
mke2fs 1.45.5 (07-Jan-2020)
Discarding device blocks: done
Creating filesystem with 26214400 4k blocks and 6553600 inodes
Filesystem UUID: 1030fa17-c484-4251-bda0-d1c20dcc8835
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done
Writing inode tables: done
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done


root@brightforest-ubuntu:~# mkfs.ext3 /dev/brightforest-vg/bf-lv02
mke2fs 1.45.5 (07-Jan-2020)
Discarding device blocks: done
Creating filesystem with 20968448 4k blocks and 5242880 inodes
Filesystem UUID: 6e6cb512-9602-4dde-8293-3c84ae688ec6
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000

Allocating group tables: done
Writing inode tables: done
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done

 

(2) 마운트

#마운트 할 폴더 생성
root@brightforest-ubuntu:~# mkdir -p /mnt/bf01
root@brightforest-ubuntu:~# mkdir -p /mnt/bf02


#마운트
root@brightforest-ubuntu:~# mount -t ext3 /dev/brightforest-vg/bf-lv01 /mnt/bf01
root@brightforest-ubuntu:~# mount -t ext3 /dev/brightforest-vg/bf-lv02 /mnt/bf02


#확인
root@brightforest-ubuntu:~# df -h
Filesystem                                                Size  Used Avail Use% Mounted on
...
/dev/mapper/brightforest--vg-bf--lv01   98G   61M   93G   1% /mnt/bf01
/dev/mapper/brightforest--vg-bf--lv02   79G   57M   75G   1% /mnt/bf02

 

(3) /etc/fstab 등록

...
/dev/brightforest-vg/bf-lv01    /mnt/bf01       ext3    defaults        0 0
/dev/brightforest-vg/bf-lv02    /mnt/bf02       ext3    defaults        0 0

 

 

6. 결론

 - 50G, 60G, 70G 디스크를 하나의 180G VG으로 묶은 후 각각 100G, 80G LV로 생성

 - 마운트 후에는 각각 93G, 75G로 실사용 용량이 7% 감소.

 

돌려줘..

 

 

참고사이트)

https://jangpd007.tistory.com/235

스크립트로 파일 내 문자열 수정 할 경우. 유용한 예제.

 

 

정규식

. -> 모든 문자

* -> 0개 이상

? -> 1개 또는 0개

 

예제 1

sed -i "s/\(# \)\?registry_host:.*/registry_host: \"${PRIVATE_REGISTRY}\"/" offline.yml

sed -i 's/\(# \)\?docker_insecure_registries:/docker_insecure_registries:/' offline.yml

-> 변수를 받을 경우 쌍따옴표(") 사용.

-> 변수가 있는데 따옴표(')를 사용한다면 문자 그대로 출력 ex) ${PRIVATE_REGISTRY}

->  \(# \)\? 원래 형태는 (# )? 이며, 특수문자이기 때문에 역슬래시(\)로 체크

->  (# )?registry_host 의미는 registry_host 또는 # registry_host를 의미 함

 

 

예제 2

sed -i "/docker_insecure_registries:/a\  - ${PRIVATE_REGISTRY}" docker.yml

sed -i '/docker_insecure_registries:/a\  - brightforest.com' docker.yml

-> a 옵션은 docker_insecure_registries: 다음라인에   - ${PRIVATE_REGISTRY} 를 추가

-> i 옵션은 이전 라인에 추가

 

 

예제 3

sed -i "s/container_manager: .*/container_manager: ${CLUSTER_RUNTIME/" k8s-cluster.yml

sed -i "s|kube_service_addresses: .*|kube_service_addresses: ${SERVICE_NETWORK}|" k8s-cluster.yml

-> 구분자로 /와 | 모두 사용 가능

-> path가 들어갈 경우 역슬래시를 써야해서 구분자 /를 쓰면 귀찮아짐

-> path가 있을 경우 구분자 |를 사용하면 역슬래시를 안써도 되서 편함.

 

 

예제 4

sed -i "s/\(# \)\?http_proxy: .*/http_proxy: /"http:/\/\${PROXY_SERVER}\"/" all.yml

sed -i "s/127\.0\.0\.1:6443/${MASTER0_IP}:6443/g" kube-admin.conf

-> 점(.) 앞에도 역슬래시(\)를 써야 함

 

 

 

옵션 참고

https://jhnyang.tistory.com/m/287

1. tee 명령어

 - standard input에서 문자열을 읽어서 standard output과 파일에 문자열을 씀

 

 

2. 사용법

(1) echo 명령어와 사용

 - test.txt에 기존 내용이 있다면 모두 삭제되고 "hello"만 저장

$ echo "hello" | tee test.txt

 

(2) cat 명령어와 사용

  - 파일을 읽어서 새로운 파일로 내용 저장

$ cat test.txt | tee test2.txt

 

(3) echo 명령어로 기존 파일 뒤에 내용 추가

$ echo "world" | tee -a test.txt

 

(4)  /dev/null을 이용하여 터미널에는 표기되지 않게 사용

$ echo "hello" | tee -a test.txt /dev/null

 

 

3. 심화

$ echo "hello" >> test.txt

$ echo "hello" | tee -a test.txt

 - 위 두 명령어는 같은 결과를 보임

 - 일반사용자 계정일 경우 sudo echo와 같이 사용할 경우 root 권한 파일에는 Permission denied로 정상동작하지 않음

 - 위와 같은 경우 echo를 sudo tee로 받아서 실행하면 정상적으로 작동

 - 쉘 스크립트에서 root 권한으로 특정파일을 쓰거나 append 할 때 주로 사용한다고 함.

 

 

 

참고) https://www.lesstif.com/lpt/linux-tee-89556049.html

 

 

1. 특정 경로의 txt 파일 내 문자열 치환

red -> green

$ find ./ -name "*.txt" -exec sed -i 's/red/green/g' {} \;

 

 

 

 

2. 스크립트 내 변수 사용

bright.sh 스크립트 내에서 변수를 사용하여 green으로 변경

*변수를 사용할 경우 작은따옴표(')가 아닌 큰따옴표(")를 사용해야 함

*작은따옴표를 사용 할 경우 green이 아닌, $COLOR로 변경

#!/bin/bash

COLOR=green
find ./ -name "*.txt" -exec sed -i "s/red/$COLOR/g" {} \;

 

쌍따옴표인줄 알았는데 큰따옴표라니..

1. default gateway

 - default gateway를 잘 못 설정하면 네트워크가 안 될 수 있음

 - 확인 방법

    # netstat -rn

    # route

    # ip route

 

 

2. 임시적용

# route add default gw [게이트웨이주소] [장치명]

 -> route add default gw 192.168.56.1 eth1

 

 

3. 영구적용

# echo 'GATEWAY=게이트웨이주소' >> /etc/sysconfig/network

# service network restart

 

 

* 설정이 안 먹을 경우 ~/ifcfg-eth0 등에 METRIC 설정을 해주면 된다고 함

http://initium2017.blogspot.com/2017/03/centos-default-gateway.html

'Linux' 카테고리의 다른 글

[Linux] CentOS repository 설정  (0) 2020.05.21
[Linux] CentOS NTP 설정  (0) 2020.04.21
[Linux] CentOS7 ssh 포트 변경  (0) 2020.03.17
[Linux] shutdown, reboot 명령어  (0) 2020.03.16
[Linux] CentOS 부팅시 데몬 시작하기, chkconfig  (0) 2020.03.14

1. CPU 코어 전체 개수 확인

grep -c processor /proc/cpuinfo

 

2. 물리 CPU 개수 확인

grep ^processor /proc/cpuinfo | wc -l

 

3. CPU당 물리 코어 수 확인

grep 'cpu cores' /proc/cpuinfo | tail -l

1. 설치

$ yum -y install cronie

$ systemctl start crond

$ ps -ef | grep crond

 

 

2. CentOS 시작 시 Crontab이 자동으로 실행되도록 설정

$ systemctl enable crond (설정)

$ systemctl list-unit-files (확인)

 

 

3. 설정 방법

crontab 명령어를 사용하며 작성하는 cron은 개별 사용자용 크론. /var/spool/cron 아래에 저장

 

crontab 명령어

crontab -e : 예약된 작업리스트

crontab -l : 예약된 작업 수정

crontab -r : 예약된 작업 삭제

crontab -u 사용자명 : 루트관리자는 해당 사용자의 crontab 파일 read, delete, modify 가능

 

 

4. crontab 항목 의미

1 minute (0 - 59)

2 hour (0 - 23)

3 day of month(1-31)

4 month(1-12) or jan, feb,mar...

5 요일(0-7) 일요일 0 or 7, 월 1, 화 2, 수 3, 목 4, 금 5, 토 6

6 사용자명, /etc/crontab, /etc/cron.d에 저장될 경우 필요

7 작업명령, 실행할 명령을 한 줄로 기입

 

 

5. 예제

(1) 매일 5:10분 100일 지난 로그 삭제, 5시 20분 전일 로그 압축

10 5 * * * find /app/logs/ -type f -daystart -mtime +100 -exec rm {} \;
20 5 * * * find /app/logs/ -name "*$(date +\%Y-\%m-\%d --date '-1 days')" -exec gzip {} \;  

 

(2) 월~금 매월 매일 10시5분, 10시45에 루트 권한으로 시간동기화 명령어 실행

45,5 10 * * 1-5 root /usr/bin/rdate -s time.bora.net && clock -w

 

(3) 반복적으로 30분마다 run.sh 실행

*/30 * * * * /script/run.sh

 

(4) 매주 토요일 오전 1시 30분에 run.sh 를 실행

30 1 * * 6 /script/run.sh

 

(5) 로그 남기기

* * * * * /script/run.sh >> /script/log/run.sh.log 2>&1

 

(6) 로그 압축 후 백업 디렉토리로 복사, 오래된 로그 삭제

10 5 * * * find /app/jboss/logs/ -type f -daystart -mtime +190 -exec rm {} \;
20 5 * * * find /app/jboss/logs/ -type f -name "*$(date +\%Y-\%m-\%d --date '-1 days')" -exec gzip {} \;

 

30 5 * * * rsync -avz /app/jboss/logs /log_backup/app1 --include=\*.gz --exclude=*.*
40 5 * * * find /app/jboss/logs/ -type f -name "*.gz" -exec rm {} \;
50 5 * * * find /log_backup/app? -type f -daystart -mtime +190 -exec rm {} \;

 

*/log_backup/app? : app1~3 폴더 등이 있을 경우 모두 적용.

+ Recent posts