Hello 👋

🧑🏻‍💻 A Developers who create code that changes the world

Infrastructure/Linux

[Linux] 인프라 설치 스크립트 및 오류 해결

Potato_H 2024. 8. 14. 17:29
# ------------------------------
# 버전 정의 (참고용)
# ------------------------------
PYTHON_VERSION=3.12.8
INFLUXDB_VERSION=1.11.8
TELEGRAF_VERSION=1.34.1
GRAFANA_VERSION=11.6.0
REDIS_VERSION=7.0.11
REDIS_CMD_VERSION=0.8.0
FLUENTD_VERSION=1.18.0
POETRY_VERSION=2.1.2
MONGO_VERSION=5.0.31
PG_VERSION=14
KONG_VERSION=3.9.0
KONG_REPO_URL="https://download.konghq.com/gateway-3.x-rhel"
KONGA_VERSION=0.1.3


# ================================================
# 0. 네트워크 설정 (Wi-Fi, 유선 동시 연결 필요 시)
# ================================================

# 유선(enp3s0) 네트워크 우선순위 낮춤
sudo nmcli connection modify enp3s0 ipv4.route-metric 1000
sudo nmcli connection down enp3s0 && sudo nmcli connection up enp3s0

# Wi-Fi(apgn) 우선순위 높임 (선택사항)
sudo nmcli connection modify apgn ipv4.route-metric 100
sudo nmcli connection down apgn && sudo nmcli connection up apgn


# ================================================
# 1. 필수 패키지 설치
# ================================================

sudo dnf install -y epel-release dnf-plugins-core wget curl git gcc make unzip \
    python3 python3-devel python3-pip nodejs \
    openssl-devel bzip2-devel libffi-devel zlib-devel xz-devel readline-devel sqlite-devel \
    ruby ruby-devel gcc-c++


# ================================================
# 2. Python 3.12.8 설치 (컴파일)
# ================================================

cd /usr/src
wget https://www.python.org/ftp/python/3.12.8/Python-3.12.8.tgz
sudo tar xzf Python-3.12.8.tgz
cd Python-3.12.8
./configure --enable-optimizations --with-ensurepip=install
make -j$(nproc)
sudo make altinstall

python3.12 --version


# ================================================
# 3. Poetry 설치 및 설정
# ================================================

export POETRY_HOME=/opt/poetry
curl -sSL https://install.python-poetry.org | /usr/local/bin/python3.12 -
ln -sf $POETRY_HOME/bin/poetry /usr/local/bin/poetry
poetry --version

poetry config virtualenvs.in-project true
poetry config --list


# ================================================
# 4. MongoDB 5.0.31 설치
# ================================================

sudo tee /etc/yum.repos.d/mongodb-org-5.0.repo > /dev/null <<EOF
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc
EOF

sudo dnf install -y mongodb-org-5.0.31 mongodb-org-server-5.0.31 \
    mongodb-org-shell-5.0.31 mongodb-org-mongos-5.0.31 mongodb-org-tools-5.0.31

mongod --version


# ================================================
# 5. InfluxDB 1.11.8, Telegraf 1.34.1 설치
# ================================================

sudo tee /etc/yum.repos.d/influxdata.repo > /dev/null <<EOF
[influxdata]
name=InfluxData Repository
baseurl=https://repos.influxdata.com/rhel/\${releasever}/\${basearch}/stable
enabled=1
gpgcheck=0
EOF

sudo dnf clean metadata
sudo dnf install -y --allowerasing influxdb-1.11.8 telegraf-1.34.1

influxd version
telegraf --version


# ================================================
# 6. Grafana 11.6.0 설치
# ================================================

sudo tee /etc/yum.repos.d/grafana.repo > /dev/null <<EOF
[grafana]
name=Grafana OSS
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
EOF

sudo dnf install -y grafana-11.6.0

grafana-server -v


# ================================================
# 7. Redis 7.4.2 설치 (소스 컴파일)
# ================================================

https://github.com/redis/redis/releases 여기서 파일 가져오기
cd /usr/local/src
sudo tar xzf redis-7.4.2.tar.gz
cd redis-7.4.2

sudo make && sudo make install

redis-cli --version


# ================================================
# 8. Redis Commander 0.8.0 설치
# ================================================

sudo dnf remove -y nodejs npm
curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo dnf install -y nodejs --allowerasing

node -v
npm -v

sudo npm install -g redis-commander@0.8.0
redis-commander --version


# ================================================
# 9. Fluentd 1.18.0 설치 (Ruby 3.0)
# ================================================

sudo dnf remove -y ruby ruby-devel
sudo dnf module reset -y ruby
sudo dnf module enable -y ruby:3.0
sudo dnf install -y ruby ruby-devel

ruby -v

sudo gem install fluentd -v 1.18.0
sudo mkdir -p /etc/fluent

fluentd --version


# ================================================
# 10. PostgreSQL 14 설치
# ================================================

sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf -qy module disable postgresql
sudo dnf install -y postgresql14-server postgresql14

sudo /usr/pgsql-14/bin/postgresql-14-setup initdb

psql --version

sudo systemctl start postgresql-14
sudo systemctl enable postgresql-14

#위의 내용으로 안되면 아래와 같이 다시 설치
# sudo dnf reinstall -y postgresql14-server
# sudo chown -R postgres:postgres /var/lib/pgsql/14



# ================================================
# 11. Kong Gateway 3.9.0 설치
# ================================================

sudo rm -f /etc/yum.repos.d/kong*.repo
curl -sL https://packages.konghq.com/public/gateway-39/setup.rpm.sh | sudo bash
sudo dnf install -y kong

sudo systemctl start kong
sudo systemctl enable kong

kong version


# ================================================
# 12. Konga 0.1.3 설치
# ================================================

git clone https://github.com/pantsel/konga.git
cd konga

sudo dnf install -y python2
export PYTHON=/usr/bin/python2
export CXXFLAGS="-std=gnu++14"

npm install --legacy-peer-deps
npm install

nohup /usr/bin/node bin/konga.js play --no-prompt > konga.log 2>&1 &

cat package.json | grep '"version"'


# ================================================
# 13. Nginx 1.14 설치
# ================================================

sudo dnf install -y nginx
sudo systemctl enable --now nginx

nginx -v


# ================================================
# 14. Nomad 설치
# ================================================

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum install -y nomad

sudo systemctl start nomad
sudo systemctl enable nomad

nomad version


# ================================================
# 15. 방화벽 비활성화
# ================================================

sudo systemctl stop firewalld
sudo systemctl disable firewalld


# ================================================
# 설치 완료
# ================================================

설치 중 에러 사항

1. InfluxData 레포지토리 GPG 검증 실패

dnf install -y influxdb-1.11.8 telegraf-1.34.1 … 오류: GPG 확인 실패
dnf clean metadata && dnf install 로 캐시 초기화 후 재설치

 

 

2. Telegraf 서비스 “no outputs found” 오류

2025-04-17T08:25:17Z I! Loading config: /etc/telegraf/telegraf.conf 2025-04-17T08:25:17Z E! [telegraf] Error running agent: no outputs found, probably invalid config file provided
config 파일에서 [[outputs.influxdb]] 블록 및 urls·database 필드를 주석 해제

 


3. Redis Commander – Node.js 엔진 불일치 경고

npm WARN notsup Unsupported engine for yargs@17.4.1: wanted: {"node":">=12"} (current: {"node":"10.24.0","npm":"6.14.11"})
NodeSource 모듈을 최신 v16으로 활성화
curl -sL https://rpm.nodesource.com/setup_16.x | bash - dnf install -y nodejs

 


4. Fluentd 설치 오류 (drb gem – Ruby 버전 문제)

ERROR: Error installing fluentd: drb requires Ruby version >= 2.7.0. The current ruby version is 2.5.0.

 

Rocky 8 기본 모듈 Ruby 2.5.9. Fluentd 1.18의 drb 의존성이 Ruby >=2.7 필요
기존 Ruby 모듈 비활성화, Ruby 3.x 모듈 활성화
dnf module disable -y ruby
dnf module enable -y ruby:3.0
dnf install -y ruby ruby-devel
gem install fluentd -v ${FLUENTD_VERSION}

 

 

5. Poetry 설치 오류 (poetry-core>=2.0 의존성)

ERROR: Could not find a version that satisfies the requirement poetry-core>=2.0 (from versions: 1.0.x…)
python 3.6 버전에서 안되는 오류
Python 3.12.8을 소스 컴파일로 설치
dnf install -y openssl-devel bzip2-devel libffi-devel zlib-devel xz-devel readline-devel sqlite-devel
cd /usr/src
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz
tar xzf Python-${PYTHON_VERSION}.tgz
cd Python-${PYTHON_VERSION}
./configure --enable-optimizations --with-ensurepip=install
make altinstall