[Kafka] Kafka 대용 오픈소스 redpanda 설치 및 설정

Ubuntu 24.04 에 repository 방식으로 설치할 때 다음과 같이 한다.

curl -1sLf \\
  '<https://dl.redpanda.com/public/redpanda/setup.deb.sh>' | sudo -E bash
sudo apt-get install -y redpanda-rpk
sudo apt update
sudo apt install redpanda

broker.dasomoli.org 로 사용한다면, /etc/redpanda/redpanda.yaml 설정 파일 편집. 다음 부분을 고침.

  - address: "broker.dasomoli.org"
    port: 9092

서비스 시작

sudo systemctl enable --now redpanda

서비스 상태 확인

sudo systemctl status redpanda
rpk cluster info --brokers broker.dasomoli.org:9092

사용 중인 토픽 리스트 확인

rpk topic list --brokers broker.dasomoli.org:9092

위의 절차는 인증 없이 사용하게 된다.

[Ethereum] 우분투에 node 설치

execution layer client로 geth를, consensus layer client로 Prysm을 사용한다.

geth 설치

sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt update
sudo apt install -y geth

확인

geth version

부팅 시 자동 실행

sudo vi /etc/systemd/system/geth.service

[Unit]
Description=Ethereum Geth Node
After=network.target

[Service]
Type=simple
User=dasomoli
ExecStart=/usr/bin/geth --mainnet --syncmode "snap" --datadir "/home/dasomoli/geth/data" --http --http.api web3,eth,txpool --http.addr 0.0.0.0
Restart=always
RestartSec=5
LimitNOFILE=8192

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start geth
sudo systemctl enable geth
sudo systemctl status geth

위에서는 “snap” 방식을 사용했다. sync mode로 “full”도 가능.

도메인을 연결한다면 설정에 다음 설정을 포함해야 한다.

	--http.corsdomain "*" \
	--http.vhosts "*"

IPC로 geth console 연결

geth attach ipc:/home/dasomoli/geth/data/geth.ipc

로그 확인

journalctl -u geth -f

Prysm 설치

mkdir prysm
cd prysm/
sudo apt update
sudo apt install -y wget
wget <https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh>
chmod +x prysm.sh

부팅 시 자동 실행

sudo vi /etc/systemd/system/prysm-beacon.service

[Unit]
Description=Prysm Beacon Chain Client
After=network.target

[Service]
Type=simple
User=dasomoli
ExecStart=/home/dasomoli/prysm/prysm.sh beacon-chain \
    --execution-endpoint=http://localhost:8551 \
    --datadir=/home/dasomoli/prysm/data \
    --jwt-secret=/home/dasomoli/geth/data/geth/jwtsecret \
    --accept-terms-of-use \
    --mainnet \
    --checkpoint-sync-url=https://beaconstate.info --genesis-beacon-api-url=https://beaconstate.info
Restart=always
RestartSec=5
LimitNOFILE=8192

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start prysm-beacon
sudo systemctl enable prysm-beacon
sudo systemctl status prysm-beacon

로그 확인

journalctl -u prysm-beacon -f

[Ubuntu] 자동 업데이트 설정

Unattended Upgrade 설치

sudo apt update
sudo apt install unattended-upgrades

자동 업데이트 활성화

sudo dpkg-reconfigure --priority=low unattended-upgrades

설정 파일 편집: sudo vi /etc/apt/apt.conf.d/50unattended-upgrades

Unattended-Upgrade::Allowed-Origins {
    "Ubuntu stable";
    "Ubuntu ${distro_codename}-security";
    "Ubuntu ${distro_codename}-updates";
};

업데이트 주기 설정: sudo vi /etc/apt/apt.conf.d/20auto-upgrades

다음은 패키지 목록 업데이트 간격(1 = 매일), 자동 업데이트 실행 간격 (1 = 매일)

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

로그는 다음에서 확인 가능

less /var/log/unattended-upgrades/unattended-upgrades.log

자동 재부팅 설정: sudo vi /etc/apt/apt.conf.d/50unattended-upgrades

다음은 새벽 2시에 자동 리부팅.

Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "02:00";

Transmission SSL 설정하기

토렌트 머신으로 사용할 때 Transmission을 설치해서 사용한다. 우분투에서도 https://blog.dasomoli.org/raspberrypi-torrent-%eb%a8%b8%ec%8b%a0-%eb%a7%8c%eb%93%a4%ea%b8%b0/ 의 내용을 그대로 설정하면 된다. 이대로 설정하면 http 프로토콜을 이용하게 되는데, 여기서 한 단계 더 나아가서 SSL 설정을 통해 https를 쓰도록 설정하자. letsencrypt 인증서를 사용하는 certbot을 사용하면, 설정은 매우 간단하다.

# certbot --apache

실행 예제 화면은 다음과 같다.

root@bamtol:/etc/letsencrypt# certbot --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: blog.dasomoli.org
2: torrent.dasomoli.org
3: www.dasomoli.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 2

Requesting a certificate for torrent.dasomoli.org

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/torrent.dasomoli.org/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/torrent.dasomoli.org/privkey.pem
This certificate expires on 2023-06-07.
These files will be updated when the certificate renews.

Deploying certificate
Successfully deployed certificate for torrent.dasomoli.org to /etc/apache2/sites-available/torrent.dasomoli.org-le-ssl.conf
Congratulations! You have successfully enabled HTTPS on https://torrent.dasomoli.org

NEXT STEPS:
- The certificate will need to be renewed before it expires. Certbot can automatically renew the certificate in the background, but you may need to take steps to enable that functionality. See https://certbot.org/renewal-setup for instructions.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

그럼 /etc/apache2/sites-enabled/torrent.dasomoli.org-le-ssl.conf 파일이 생성되는데 여기에 SSLProxyEngine on 옵션을 추가해준다. 그럼 이렇게 된다.

<IfModule mod_ssl.c>
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName torrent.dasomoli.org
        ServerAdmin dasomoli@gmail.com

        ProxyPass / http://localhost:9000/
        ProxyPassReverse / http://localhost:9000/

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/torrent.log
        CustomLog ${APACHE_LOG_DIR}/torrent.access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf


SSLCertificateFile /etc/letsencrypt/live/torrent.dasomoli.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/torrent.dasomoli.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLProxyEngine on
</VirtualHost>
</IfModule>

이게 끝. apache2 서비스를 재시작한 후 https로 접근한다.

우분투 24.04도 위와 같은 방식으로 설치 가능한데, workaround가 필요하다. appamor가 Nofity에 대해 잘 작동하지 않는 모양이다.

$ sudo systemctl edit --full transmission-daemon.service

Type=Simple로 바꾼다.

[Unit]
Description=Transmission BitTorrent Daemon
Wants=network-online.target
After=network-online.target

[Service]
User=debian-transmission
Type=Simple
ExecStart=/usr/bin/transmission-daemon -f --log-level=error
ExecReload=/bin/kill -s HUP $MAINPID
NoNewPrivileges=true
MemoryDenyWriteExecute=true
ProtectSystem=true
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Bkouen AK7 Pro Mini PC 사용기

인터넷 커뮤니티를 기웃거리다 전력 사용이 적다는 미니 PC 딜을 발견했습니다. 라즈베리 파이 4를 기존에 개인 NAS 및 블로그 용도로 사용했는데, 이걸 사용하던 주된 이유가 전력을 적게 먹으면서도 필요한 기능을 다 할 수 있었기 때문이었거든요. M1이나 M2 맥 미니로 바꿀까 생각 중이었는데, 이 정도로도 충분하다고 생각하고 질렀습니다! 아마존에서 구입했는데, 배송비 포함 157.29 달러 외 별도 금액은 들지 않았습니다.

모델명은 AK7 Pro이고, 사양은 11th Gen Intel N5105 (Up to 2.9GHz), 램 8GB, SSD 256GB, 그리고 4K@60Hz를 지원하는 HDMI 2개, WIFI와 블루투스 4.2, 기가비트 이더넷, USB 3.0 2개, USB 2.0 2개를 지원합니다. 그리고 윈도우즈 11 Pro 정품이 설치되어 있습니다. 아마존 Q&A에 사용되는 드라이버를 따로 받을 수 있냐는 질문에 안된다고 깔려 있는 거 쓰라고 합니다.

외형을 살펴볼까요? 한 쪽 면에는 전원 스위치와 USB 3.0 포트 두개, USB 2.0 포트 하나가 있습니다.

다른 한쪽 면에는 DC 전원어댑터 구멍, USB 2.0, HDMI 단자 두 개, 이더넷, AUX/MIC 홀이 있습니다.

DC 전원 어댑터는 아래처럼 생겼습니다. 프리볼트긴 합니다만, 11자라 돼지코 필요합니다. 켜져 있을 때는 괜찮은데, 꺼져 있을 때 전원 어댑터를 연결해두면 삐~ 고주파가 들립니다. 저야 24시간 돌아 갈 용도이긴 합니다.

아래 면은 VESA 홀이 있어서 모니터에 붙여서 사용할 수 있습니다. 붙일 수 있는 부속품을 함께 제공합니다.

자, 외형은 다 봤으니 뜯어봅시다.

윗 면에 안테나가 얇은 선으로 연결되어 있으니 조심합시다. 뜯을 때는 https://www.youtube.com/watch?v=YCuRs7jR-ss 를 참고했습니다.

SATA M.2 SSD 256GB 가 달려있습니다. CYX는 어디건지.. 나중에 찾아보니 이 Mini PC 제조사인 것 같습니다. M.2 SSD 옆에 SATA 단자와 2핀짜리 Power도 있어서 확장도 할 수 있다고는 합니다. 그런데 어디로 저 선을 빼야…. 구멍을 뚫어야 하려나요.. 나사가 또 보이니까 더 뜯어봅시다.

방열판에 써멀 발라 붙이고 팬을 돌려서 방열을 하고 있네요. 다시 덮고 전원을 넣어서 켜 봅니다. 윈도우 설치는 영어로 진행할 수 있는데, 언어팩 등을 설치하고 전역 설정을 해주면 한글로도 잘 사용할 수 있습니다. 4K@60Hz도 잘 나오네요. 정보에 프로세서는 2.00 GHz로 나오네요.

SATA SSD 성능을 한번 볼까요?

근데 아까 M.2 슬롯을 보니 NVME도 꽂을 수 있을 거 같던데요? 한번 꽂아봅시다. WD_BLACK SN750 1TB입니다.

인식을 할까요? 오! BIOS에서 잡네요! 그럼 NVME SSD를 하나 사서 달아야겠습니다. 어차피 라즈베리 파이 4에서는 MicroSD 썼었는데 NVME SSD면 차고도 넘칩니다. 같은 용량으로 싼 거 사서 답니다.

다른 PC에서 마이그레이션해서 부팅하니 잘 됩니다. SSD 성능도 잘 나옵니다. 더 좋은 걸 달고 싶지만, 이왕이면, 이왕이면.. 하다 어떻게 되는지 우리는 잘 알고 있습니다.

그럼 다 봤으니.. 우분투를 깝니다. 몇 가지 삽질이 있었습니다만, 잘 뜹니다.

온도도 확인해 봅시다.

8TB짜리 USB 3.0 HDD를 두 개 붙여서 NAS 완성! 제 블로그가 요걸로 계속 돌고 있는 겁니다..

장점은 저전력에 x86_64 PC환경과 같으니 하고 싶은 거 다 해볼 수 있습니다. 가격도 저렴한 편이고, 따로 뭐 살 필요 없이 무선랜, 블루투스도 사용 가능합니다. 전 NAS 용도지만, 윈도우즈 정품도 주니, 업무 용도나 서브 PC로 그냥 써도 될 거 같네요.

단점은 램이 8기가라 좀 아쉬운데 확장 불가, 꺼두었을 때 전원부 고주파음이 있습니다.