[ssh] config 파일에 IP와 Hostname을 함께 지정

~/.ssh/config 파일 안에 hostname을 지정한다면, 그 뒤에 IP 주소를 함께 지정하면 hostname이나 IP 둘 중 어느 하나로 접속해도 같은 설정이 적용된다. 항목을 여러개 만들 필요 없다. 공백으로 구분하면 다 같이 적용된다. 예를 들면 다음과 같다.

Host nas.dasomoli.org 112.145.250.152 192.168.0.204
    HostName nas.dasomoli.org
    User dasomoli
    Port 2048
    IdentityFile ~/.ssh/id_rsa_dasomoli_nas

[AWS] ALB 설정 백업

AWS CLI를 이용해서 ALB 관련 설정을 백업하고 삭제하자.

Config

aws elbv2 describe-load-balancers [--region <Region>] --load-balancer-arns <ALB ARN>

Listener

aws elbv2 describe-listeners [--region <Region>] --load-balancer-arn <ALB ARN>

Listener Rules

위의 Listner를 얻은 정보에서 각 Lisner 별로 각각 실행한다.

aws elbv2 describe-rules [--region <Region>] --listener-arn <Listener ARN>

나중에 필요하면 위의 정보로 다시 ALB를 추가한다.

[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";

[matplotlib] 한글 폰트 설정

apt-get install -y fonts-nanum
fc-cache -fv
rm ~/.cache/matplotlib -rf

혹은 Windows에서는

from matplotlib import font_manager, rc
font_path = 'C:/Windows/Fonts/NGULIM.TTF'
font = font_manager.FontProperties(fname=font_path).get_name()
rc('font', family=font)

[WordPress] json 파일을 업로드하고 싶을 때

아래 플러그인을 설치하면 된다.

설치 후 “설정” 메뉴에 보면, “MIME 유형 설정”이 생긴다.

그 후 아래처럼 “json = application/json”을 추가한 후 “저장” 하면 된다. “보안 옵션”도 켰다.

[Linux] logrotate 설정

로그 남길 때 그냥 주구장창 남기면 디스크가 꽉 찬다.

/var/log 아래 남는 log 들처럼 주기적으로 gzip으로 압축하고, 오래된 로그는 저절로 지워지도록 하고 싶을 때 logrotate를 쓴다.

logrotate를 설정해서 주기마다 압축해서 남기고, 때 되면 지우도록 만들자.

아래 명령은 도움말인 man page를 보여 준다.

# man logrotate

 

logrotate의 설정 파일들은 아래에서 찾을 수 있다.

/etc/logrotate.conf : logrotate의 기본 설정 파일. 여기서 /etc/logrotate.d/ 아래의 파일들을 include 하도록 되어 있다.
/etc/logrotate.d/ : logrotate를 사용해서 로그를 남기고 싶은 유틸리티들이 여기다 설정 파일을 둔다.

 

예제를 보자.

# vi /etc/logrotate.d/mysqlmon
/var/log/mysqlmon/mysqlmon.log /var/log/mysqlmon/mysqlmon.err {
        daily
        missingok
        rotate 7
        compress
        notifempty
}

위의 예제의 각 옵션은 다음과 같다.

daily: 하루 주기

missingok: 로그 파일이 없어도 에러 메시지를 쓰지 않는다.

rotate 7: 오래된 로그를 7개 남긴다.

compress: gzip으로 압축한다.

notifempty: 로그 파일이 비어 있으면 rotate하지 않는다.

다른 자세한 옵션은 man page를 참고하자.

[Raspbian] ibus-hangul로 한글 입력 설정

Raspbian 설치하고 언어를 바로 Korean으로 설정하고 하라는대로 재부팅하면 폰트가 설치되어 있지 않아서 메뉴가 다 깨져보여서 보기 힘들다. 난 그냥 English를 사용하도록 한 후, 필요한 걸 설치했다.

입력기가 요즘 또 새로운게 생겨서 fcitx를 쓸 수도 있는 것 같던데, ibus-hangul을 설치했다.

sudo apt-get install ibus-hangul

 

재부팅하면 트레이에 ibus 아이콘이 보인다. 기본은 English다.

우클릭 / “Preferences” / “Input Method” / “Add” / “…” / “Korean” 을 하면 태극 무늬의 “Korean” 이 추가된다.

English는 제거하자.

한영키는 별도 설정없이 기본으로 한영키를 쓰면 한글과 영문이 토글된다.

Shift + space도 된다.

 

[Raspberry Pi] 라즈베리파이에 미디어위키(MediaWiki) 설치

라즈베리파이의 OS, Raspbian에서는 패키지를 제공하므로 매우 간단하다.

sudo apt-get install mediawiki

 

설치하면 apache2의 available configuration에 mediawiki라는 새로운 configuration(/etc/apache2/conf-available/mediawiki.conf)이 생긴다.

아래의 Alias를 풀어서 /mediawiki 로 접근해도 된다.

#Alias /mediawiki /var/lib/mediawiki

 

난 VirtualHost를 이용한다.

/etc/apache2/sites-available/wiki.dasomoli.org.conf

<VirtualHost *:80>
        # 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 wiki.dasomoli.org

        ServerAdmin dasomoli@gmail.com
        DocumentRoot /var/lib/mediawiki

        # 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}/wiki_error.log
        CustomLog ${APACHE_LOG_DIR}/wiki.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
</VirtualHost>

 

이제 mediawiki configuration을 enable 하자

sudo a2enconf mediawiki

wiki.dasomoli.org site도 enable하자

sudo a2ensite wiki.dasomoli.org.conf

apache2도 reload하자

sudo service apache2 reload

 

이제 wiki.dasomoli.org에 접속해서 mediawiki 설치를 시작한다.

설치가 끝나면 LocalSettings.php 파일을 저장할 수 있는데, 이 파일을 /etc/mediawiki/LocalSettings.php 로 저장한다.

다시 wiki.dasomoli.org로 접속해보면. 설치된 위키를 볼 수 있다!