Total: Today: Yesterday:
노하우/Linux | 2021. 7. 22. 12:10 | Posted by 자수씨

top이라는 명령어만으로는 머신 상태를 확인하기에는 부족함이 있다.

페이스북에서 과거의 오늘이라며 8년 전 글을 보여줬는데 지금 봐도 충격과 공포이다.

 

 

요즘에는 AWS EC2 머신을 주로 사용하므로 해당 머신에 설치하는 방법을 공유하고자 한다.

 

htop

top의 대안으로 나온 프로그램으로 c언어로 된 오픈소스이다. Ncurses를 이용하여 키보드 커서도 이용할 수 있다.

 

 

설치 방법은 간단하다.

 

# 설치
sudo install -y htop

# 실행
htop

 

iotop

프로세스 별 io 통계를 볼 수 있는 프로그램이다.

 

 

이것 또한 설치 방법은 간단하다. 실행 시에는 root 권한이 필요하여 sudo를 이용한다.

 

# 설치
sudo yum install -y iotop

# 실행
sudo iotop

 

iftop

네트워크 연결 목록 및 상태를 보여주는 프로그램이다. 실시간 트래픽 확인에 도움이 된다.

 

 

EC2의 경우 기본적으로 EPEL 리포지토리가 활성화가 되어 있지 않기 때문에 다음과 같은 설정이 필요하다.

 

# 1. EC2 리눅스 버전 확인
cat /etc/-release

# 2-1. Amazon Linux AMI 2018.03 의 경우
sudo yum-config-manager --enable epel

# 2-2. Amazon Linux 2 의 경우
sudo sudo yum-config-manager --enable epel

# 3. epel-release 설치
sudo yum install epel-release

# 4. iftop 설치
sudo yum install iftop

# 실행
sudo iftop

 

iotop 과 마찬가지로 root 권한이 요구되어 실행시 sudo를 이용한다.

노하우/Linux | 2020. 5. 31. 19:36 | Posted by 자수씨

1. yum 을 최신으로 업데이트 한 후에 gcc 와 make 를 설치한다.

$ sudo yum update
$ sudo yum install gcc make

 

2. 레디스 최신 버전 소스를 내려받아 빌드한다.

$ wget http://download.redis.io/releases/redis-6.0.4.tar.gz
$ tar xzf redis-6.0.4.tar.gz
$ cd redis-6.0.4
$ make

 

3. 디렉토리 생성 및 복사

$ sudo mkdir /etc/redis 
$ sudo mkdir /var/lib/redis
$ sudo cp src/redis-server src/redis-cli /usr/local/bin/
$ sudo cp redis.conf /etc/redis/

 

4. /etc/redis/redis.conf 수정

daemonize yes
bind 0.0.0.0
dir /var/lib/redis
logfile "/var/log/redis_6379.log"

 

5. 자동 실행을 위한 설정

$ cd /tmp
$ wget https://raw.github.com/saxenap/install-redis-amazon-linux-centos/master/redis-server
 
$ sudo mv redis-server /etc/init.d
$ sudo chmod 755 /etc/init.d/redis-server

$ sudo chkconfig --add redis-server
$ sudo chkconfig --level 345 redis-server on

 

6. redis 서버 실행

$ sudo service redis-server start
Starting redis-server (via systemctl):                 [  OK  ]

 

참고자료:

1. https://redis.io/download

 

Redis

*Download Redis uses a standard practice for its versioning: major.minor.patchlevel. An even minor marks a stable release, like 1.2, 2.0, 2.2, 2.4, 2.6, 2.8. Odd minors are used for unstable releases, for example 2.9.x releases are the unstable versions of

redis.io

2. https://github.com/saxenap/install-redis-amazon-linux-centos

 

saxenap/install-redis-amazon-linux-centos

his is a installation script to setup Redis 2.6 as a service on Amazon Linux AMI and CentOS distributions. - saxenap/install-redis-amazon-linux-centos

github.com

 

'노하우 > Linux' 카테고리의 다른 글

[EC2] htop, iftop, iotop  (0) 2021.07.22
[scouter] AWS EC2 인스턴스에 scouter-paper 설치하기  (0) 2019.04.23
[AWS] EC2 인스턴스에 nodejs 설치  (0) 2019.04.23
Linux 에 OpenJDK 8 설치  (0) 2019.04.13
포트 우회하기  (0) 2019.04.12

노하우/Linux | 2019. 4. 23. 00:16 | Posted by 자수씨

nvm(노드 버전 관리자)을 설치

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash

nvm 활성화

. ~/.nvm/nvm.sh

npm 설치

2019년 4월 23일 기준 10.15.3 버전이 최신이므로 해당 버전을 설치

[ec2-user@~~]$ nvm install 10.15.3
########################################################################################################################################################################################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v10.15.3 (npm v6.4.1)
Creating default alias: default -> 10.15.3 (-> v10.15.3)

버전 확인

[ec2-user@~~]$ node -e "console.log('Running Node.js ' + process.version)"
Running Node.js v10.15.3

참고자료

노하우/Server | 2019. 4. 19. 22:47 | Posted by 자수씨

스카우터 설치

2019.04.19 기준 2.6.1 버전으로 설치

서버 (collector) 설치

서버만 돌릴 거면 agent 는 제거

$ wget https://github.com/scouter-project/scouter/releases/download/v2.6.1/scouter-all-2.6.1.tar.gz
$ tar xzf scouter-all-2.6.1.tar.gz

$ cd scouter
$ rm -rf agent.*

scouter/server/conf/scouter.conf 설정 (6180 은 api 서버에서 쓸 예정이므로 다른 포트로 변경해준다.)

# Agent Control and Service Port(Default : TCP 6100)
net_tcp_listen_port=6100

# UDP Receive Port(Default : 6100)
net_udp_listen_port=6100

# Http Port for scouter-pulse(Default : 6180)
net_http_port=6101

# DB directory(Default : ./database)
db_dir=/<스토리지경로>/scouter/database

# Log directory(Default : ./logs)
log_dir=/<스토리지경로>/scouter/logs

실행법은 startup.sh 로 한다. (java 가 설치안된 경우에는 별도로 설치)

[ec2-user@~~ server]$ ./startup.sh 
nohup: redirecting stderr to stdout
  ____                  _            
 / ___|  ___ ___  _   _| |_ ___ _ __ 
 \___ \ / __/   \| | | | __/ _ \ '__|
  ___) | (_| (+) | |_| | ||  __/ |   
 |____/ \___\___/ \__,_|\__\___|_|                                      
 Open Source S/W Performance Monitoring  
 Scouter version 2.6.1

[ec2-user@~~ server]$ netstat -na | grep LISTEN    
tcp        0      0 :::6100                     :::*                        LISTEN      
tcp        0      0 :::6101                     :::*                        LISTEN      

client 에서 정상적으로 접근되면 서버는 설치 완료

에이전트 (agent.host) 설치

리눅스 서버에 agent.host 를 설치할 예정이므로 min 버전을 다운 받아 설치한다.
(server 는 필요 없으므로 제거)

$ wget https://github.com/scouter-project/scouter/releases/download/v2.6.1/scouter-min-2.6.1.tar.gz
$ tar xzf scouter-min-2.6.1.tar.gz

$ cd scouter
$ rm -rf server

scouter/agent.host/conf/scouter.conf 설정

obj_name=<agent이름>
net_collector_ip=<collector IP>
net_collector_udp_port=6100
net_collector_tcp_port=6100
#cpu_warning_pct=80
#cpu_fatal_pct=85
#cpu_check_period_ms=60000
#cpu_fatal_history=3
#cpu_alert_interval_ms=300000
#disk_warning_pct=88
#disk_fatal_pct=92

scouter/agent.host 에서 ./host.sh 로 실행시킨다.

[ec2-user@ip~~ agent.host]$ ./host.sh 
nohup: redirecting stderr to stdout
  ____                  _            
 / ___|  ___ ___  _   _| |_ ___ _ __ 
 \___ \ / __/   \| | | | __/ _ \ '__|
  ___) | (_| (+) | |_| | ||  __/ |   
 |____/ \___\___/ \__,_|\__\___|_|                                      
 Open Source S/W Performance Monitoring  
 Scouter version 2.6.1

Configure -Dscouter.config=./conf/scouter.conf
Scouter Host Agent Version 2.6.1 2019-03-17 08:45 GMT
System JRE version : 1.8.0_201

클라이언트에 정상적으로 host 정보가 집계되면 성공

에이전트 (agent.java) 설치

데이터를 집계할 WAS 는 Tomcat 이기 때문에 catalina.sh 에 다음과 같이 추가한다.

$CATALINA_HOME/bin/catalina.sh

# scouter settings
JAVA_OPTS="$JAVA_OPTS -javaagent:/home/ec2-user/scouter/agent.java/scouter.agent.jar"

Tomcat 을 재시작 하면 collector 쪽에 데이터를 전송한다.

참고자료

http://gunsdevlog.blogspot.com/2017/07/scouter-apm-1.html

'노하우 > Server' 카테고리의 다른 글

[nginx] websocket forwarding  (0) 2020.05.31
[MongoDB] CentOS 7에 설치하기  (0) 2019.08.10