'알아둘일'에 해당하는 글 200건

예전에 우분투에서 autossh 를 설정하는 법을 정리했었다.( blog.1day1.org/615 )

맥미니 도 같이 쓰고 있는데, 맥미니도 설정해보고자 한다.(그동안 딱히 사용할 일은 없었다.)

맥에서는 brew 로 autossh 를 설치한다.

brew install autossh

이제 자동으로 실행되도록 설정한다. 우분투의 systemd 와 비슷한 launchctl 을 사용한다.

다음과 같은 설정.( ooo.plist 파일은 임의로 만들면 된다. )

$ cat Library/LaunchAgents/org.1day1.macmini.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    	<string>1day1 org macmini</string>
    <key>KeepAlive</key>
    	<true/>
    <key>RunAtLoad</key>
    	<true/>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/autossh</string>
	<!-- autossh switches -->
        <string>-M</string>
        <string>0</string>
	<!-- ssh switches -->
        <string>-N</string>
        <string>-T</string>
	<string>-o</string>
	        <string>ControlMaster no</string>
	<string>-o</string>
        	<string>ServerAliveInterval 60</string>
	<string>-o</string>
        	<string>ServerAliveCountMax 3</string>
	<string>-p</string>
        	<string>2222</string>
	<string>-l</string>
        	<string>root</string>
	<string>-i</string>
        	<string>/Users/your-mac-user-name/.ssh/id_rsa</string>
	<string>-R</string>
        	<string>9191:127.0.0.1:5900</string>
	<string>-R</string>
        	<string>9122:127.0.0.1:22</string>
	<string>your-externel-server</string>
    </array>
</dict>
</plist>

-p 2222 -l root -i 비밀키 , your-externel-server  => 이 부분들은 본인에 맞게 수정해서 사용한다.

다음처럼 실행.

launchctl load -S Aqua Library/LaunchAgents/org.1day1.macmini.plist 

실행되어 있는지 확인.

$ launchctl list |grep 1day1
23391	0	1day1 org macmini

터널링 서버에 접속이 되어 있는지 확인한다.

이제 임의의 곳에서 맥미니에 접속할 수 있게 된다.

 

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

맥os 의 기본메일앱을 사용하고 있다. imap 으로 연결해서 사용중인데, 몇몇 메일이 올때 한글 파일명이 ????? 등으로 깨져서 보일때가 있다.

utf-8 / euc-kr 등 인코딩 문제인데, utf-8 으로 기본 세팅이 되어 있지 않은 듯 싶다.

관리자로 권한
sudo -s

defaults write com.apple.mail NSPreferredMailCharset "UTF-8"

명령을 해주고, 메일앱을 CMD+Q 로 완전종료했다가 다시 실행해주면 정상적으로 보일 것이다.

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

공유기 등 내부망에 있어서 외부 접속이 어려운 환경에서 접속할 수 있게 할 수 있다.

터널링을 통해 가능하다. ssh 로 접속해 있을 수 있는 호스팅 환경이 있으면 된다.

apt install autossh

설치는 쉽다.

systemd / upstart 방식에 따라 자동 실행 설정이 조금 다르다.

# systemd 방식 (최근 배포판)

# vi /etc/systemd/system/autossh.service
[Unit]
Description=AutoSSH service for a reverse tunnel 
After=network-online.target

[Service]
ExecStart=/usr/bin/autossh -M 0 -q -N \
-i /root/.ssh/id_rsa \
-o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" your-externel-server \
-R 5991:127.0.0.1:5901 \
-R 5922:127.0.0.1:22 \
-R 5989:192.168.11.19:5900

[Install]
WantedBy=multi-user.target

위 설정처럼 하면 된다. 자신의 맞는 환경에 따라 수정해서 사용하면 된다.
내부 서비스(5901 , 22) 로 접속가능하고, 또는 동일네트워크 다른 서버로도 접속가능하다.

위 파일 생성 후 다음 명령으로 실행해준다.

systemctl enable autossh
systemctl start autossh

 

# upstart 방식 (예전 방식)

# vi /etc/init/autossh.conf 
description "autossh daemon for ssh tunnel"

start on net-device-up IFACE=eth0
stop on runlevel [01S6]

#setuid autossh

respawn
respawn limit 5 60

script
export AUTOSSH_FIRST_POLL=30
export AUTOSSH_GATETIME=0
export AUTOSSH_POLL=60
/usr/bin/autossh -M 0 -q -N \
-i /root/.ssh/id_rsa \
-o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" your-externel-server \
-R 5991:127.0.0.1:5901 \
-R 5922:127.0.0.1:22 \
-R 5989:192.168.11.19:5900
end script

설정 방식만 조금 다를 뿐 사용법은 동일하다.

 

그럼, 제 3의 위치에서 터널링으로 뚫어 놓은 내부서버에 접속해본다.
당연히 바로 접속 할 수는 없다.

다음의 ssh 명령으로  {로컬PC} => 외부 서버 => 내부망(터널링)  으로 접속한다.

ssh your-externel-server -L 5991:127.0.0.1:5991 -L 5922:127.0.0.1:5922 

위 설정은 로컬PC 의 포트로 터널링한 내부망의 서비스 포트와 연결하는 것이다.

ssh root@localhost -p 5922

내부에서 다음 처럼 접속하면 된다. (위 예시는 내부망의 22번 ssh 포트로 접속하는 명령)

조금 복잡해 보일 수 있지만, 흐름을 이해하면 크게 어렵지는 않다.

내부망에 포트포워딩으로 접근할 수 없는 경우, 보안접속이 필요한 서비스 등에 사용할 수 있다.
기본적으로 ssh 를 이용한 것이라 vpn 처럼 보안접속이 필요한 경우등에 유용할 듯 싶다.

 

[추가]

systemd 방식 설정 후 재부팅했는데, autossh 가 실행이 안되는 경우

다음과 같은 에러가 날때 (systemctl status autossh 로 확인)

ssh exited prematurely with status 255; autossh exiting

구글링 해보니, After=network-online.target 대신에

After=network.target
After=NetworkManager-wait-online.service

등등 여러개로 바꿔가며 해봐도 안된다. 네트워크가 정상 접속되는 시점이 차이가 있는 듯 하다.

 

# vi /etc/systemd/system/autossh.service 에 다음 항목을 추가해준다.

[Service]
ExecStartPre=/bin/sh -c 'until ping -c1 google.com; do sleep 1; done;'

 

위 처럼 네트워크가 동작하는지 체크 후에 실행하도록 한다. ( 완료 후 systemctl daemon-reload 로 설정을 재로딩 해준다)

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

맥os 를 쓰다보면, 한글의 자소가 분리되는 현상을 경험하게 된다.

윈도우 / 리눅스 / 맥os 등을 같이 쓰다보면, 프로그램 처리시 조치해줘야 할 부분이 있다.

php 에서는 다음 방법으로 조치해준다.

패키지는 php-intl 를 설치해줘야 한다.

코드 처리는 다음처럼 해준다.

if (!\Normalizer::isNormalized($file_location)) { // mac type - utf8
  $file_location = \Normalizer::normalize($file_location);
}

요점은 맥os 방식을 윈도우/리눅스 방식으로 바꿔준다 라고 이해하면 된다.

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

우분투 로그인이 안된다.

.xsession-error 파일을 확인해 본다.(계정 폴더에 있다.)

/etc/X11/Xsession.d/99x11-common_start: line 5: /sbin/upstart: No such file or directory

다음과 같은 에러가 보인다.

우분투는 부팅 스크립트 방식을 바꿔왔다. 

system-v 방식 : /etc/init.d , rcX.d 형태의 관리

upstart 방식 : /etc/init/ 안에 부팅 관련 스크립트 관리  ( service OOO restart 형태 관리 )

systemd 방식 : 가장 최근 방식 ( systemctl restart OOO )

 

설치된 운영체제는 18.04 버전인데, systemd 을 쓰기에 upstart 는 쓰지 않는다.
(16.04 => 18.04 로 업그레이드해서 남아있었던듯 하다)

해결 방법은 upstart 를 제거해준다.

apt purge upstart

다시 GUI 로그인 해보면 될 것이다.

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

vuejs 를 사용시 vue-router 를 사용하여, 경로를 지정할 수 있다.
그러면 about / price / 등 필요한 페이지를 분리할 수 있어 작업하기 편하다.
그런데, SPA 웹페이지이기 때문에 index.html 내에서 처리가 된다.

즉, 해당 경로로 직접 들어가면 404 페이지가 표시된다.
그렇다면 404 페이지를 모두 index.html 으로 보내면 된다. ( 참조 : https://router.vuejs.org/kr/guide/essentials/history-mode.html )

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

아파치 apache 설정시 다음과 같은 에러가 발생할 수 있다.

RewriteBase: only valid in per-directory config files
Action 'configtest' failed.
The Apache error log may have more information.

그런경우는 해당 설정이 <Directory > </Directory> 설정내에 넣어준다.

<Directory {{vue앱-디렉토리패스}}>

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

</Directory>

이런식으로 넣어준다. vue 앱과 서버측 (node / go / php 등) 어플과 조합을 해서 사용가능하다.

php 같은 경우 laravel 등의 프레임웍(modern php)을 써도 되고, 그냥 날코딩(legacy php)으로 만들어서 조합해도 상관없다.

{{vue-app-path}}/api/[php app file].php

형태로 php 어플을 실행해도 된다.

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

모니터 연결이 안된 서버에 vnc 접속시 해상도가 1024x768 등 낮게 설정이 된다.

가상의 모니터로 접속할 수 있게 설정해준다.

더미 모니터 패키지를 설치한다.

apt install xserver-xorg-video-dummy

xorg 설정을 해준다. ( /usr/share/X11/xorg.conf.d/xorg.conf )

Section "Device"
    Identifier "DummyDevice"
    Driver "dummy"
    VideoRam 256000
EndSection

Section "Screen"
    Identifier "DummyScreen"
    Device "DummyDevice"
    Monitor "DummyMonitor"
    DefaultDepth 24
    SubSection "Display"
        Depth 24
        Modes "1920x1080_60.0"
    EndSubSection
EndSection

Section "Monitor"
    Identifier "DummyMonitor"
    HorizSync 30-70
    VertRefresh 50-75
    ModeLine "1920x1080" 148.50 1920 2448 2492 2640 1080 1084 1089 1125 +Hsync +Vsync
EndSection

재부팅하면 원하는 해상도로 접속이 된다.

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

몽고db 데이터를 이전하기 위해 mongodump / mongorestore 로 백업 / 복구 하였다.

그런데, 원래 그런지, 어떤 설정이 있는 것인지 인덱스 가 생성되지 않았다.
> ( 기본은 인덱스가 재 생성 되는 듯 한데, --noIndexRestore 을 주면 인덱스 미생성 )

dump / restore 중에 뭔가 이상이 있는 것인가?  또는 --gzip / --archive 옵션으로 하면 생성이 안되는 것일까?

정확한 이유는 체크해봐야 할 듯 하다.

암튼 그래서 createIndex 로 생성하려하는데, 다음과 같은 에러가 발생하였다.

2020-04-18T06:14:45.987+0000 I  NETWORK  [js] DBClientConnection failed to receive message from 127.0.0.1:27017 - HostUnreachable: Connection closed by peer
command terminated with exit code 137

몽고db - POD 에 접속을 못하는 듯 하다. 좀더 체크해보니 인덱스 생성도중에 mongod POD 가 중지 Down 되어 버린다.

해당 이슈에 대한 검색으로는 특별한 원인을 찾지 못했다. 몽고db 리플리카 셋은 kubernetes(microk8s) 로 세팅하였다.

예상되는 부분은  restore 과정중에 뭔가 데이터가 깨진것이 아닌가 예상이 된다.
그래서 pvc 를 삭제하면, 리플리카 셋이 자동으로 재생성(초기화) 되면서 pod 가 재실행되도록 하였다.

위 조치로 해결이 되었다. (일단 예상은 맞는 듯 하다)

그런데, 근본적인 작업이었던  백업 / 복구 방식이 문제였을까? ( mongodump => mongorestore )

그냥 데이터 디렉토리를 그대로 복사하는 방법으로 해야할까? 좀더 테스트를 해봐야 겠다.

[추가]

좀더 체크해보니, mongorestore 메시지에 이상이 있었다. (몽고db - pod 가 이상이 있어서 인덱스 생성 실패 케이스)

[정상]

2020-04-20T00:16:08.550+0900	restoring indexes for collection test.product from metadata
2020-04-20T00:19:35.655+0900	finished restoring test.product (5522171 documents, 0 failures)
2020-04-20T00:19:35.655+0900	restoring users from archive '/restore/restore/restore-archive.gz'
2020-04-20T00:19:35.881+0900	5522171 document(s) restored successfully. 0 document(s) failed to restore.

[이상있는 경우]
2020-04-18T07:11:49.926+0900	restoring indexes for collection test.product from metadata
2020-04-18T07:12:44.169+0900	finished restoring test.product (5522171 documents, 0 failures)
2020-04-18T07:12:44.170+0900	Failed: test.product: error creating indexes for test.product: createIndex error: connection(mongod-2.mongodb-service:27017[-11]) incomplete read of message header: EOF
2020-04-18T07:12:44.170+0900	5522171 document(s) restored successfully. 0 document(s) failed to restore.

 

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

우분투에서 윈도우의 공유폴더를 연결해 사용하고 있다.
그동안 별 이슈 없이 사용했던것 같다.

그런데, 윈도우 업데이트 후에 다음과 같은 에러가 발생하면서 연결이 안된다.

mount error(127): Key has expired

"키가 만료되었습니다" / NT_STATUS_ACCOUNT_DISABLED 등의 메시지가 보일 수도 있다.

mount 할때 guest 계정으로 연결하는데, 윈도우 업데이트 후에 해당 계정설정이 바뀐 듯 하다.

위 그림은 조치한 후에 화면이다.   활성계정 부분이 "예" 로 되어 있어야 하는데, "아니오" 로 되어 있었다.

net user guest /active:yes

로 활성화 해준다.

 

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

간단한 golang 어플을 도커 이미지를 사용해서 배포하려 한다.(배포는 kubernetes 를 사용한다)

docker hub 등 온라인 방식으로 해도 되지만, microk8s 의 registry 서비스를 이용한다.
방법은 그리 어렵지 않다.  https://microk8s.io/docs/registry-built-in 를 참조 한다.

일종의 registry 서비스를 로컬에 가동하여 도커 이미지를 등록 하는 것이다.

1. 이미지 빌드

$ sudo docker build . -t localhost:32000/prod-api:registry

Sending build context to Docker daemon  4.608kB
Step 1/6 : FROM golang:latest
latest: Pulling from library/golang
dc65f448a2e2: Pull complete 
346ffb2b67d7: Pull complete 
dea4ecac934f: Pull complete 
8ac92ddf84b3: Pull complete 
7ca605383307: Pull complete 
f47e6cebc512: Pull complete 
530350156010: Pull complete 
Digest: sha256:fe6b1742d48c4d6d360c6fac1e289e8529aaab924fa0e49a330868be50c0f2f4
Status: Downloaded newer image for golang:latest
 ---> 297e5bf50f50
Step 2/6 : RUN mkdir /app
 ---> Running in 2a6795d86353
Removing intermediate container 2a6795d86353
 ---> 541dbb10344e
Step 3/6 : ADD . /app/
 ---> c60e6e741cb4
Step 4/6 : WORKDIR /app
 ---> Running in 5de0b590c65d
Removing intermediate container 5de0b590c65d
 ---> 24c7788d1b8e
Step 5/6 : RUN go build -o main .
 ---> Running in 5e44a7f53909
Removing intermediate container 5e44a7f53909
 ---> 56462a496eac
Step 6/6 : CMD ["/app/main"]
 ---> Running in bdde4584ff89
Removing intermediate container bdde4584ff89
 ---> dbba71be4f83
Successfully built dbba71be4f83
Successfully tagged localhost:32000/prod-api:registry

등록체크 

$ sudo docker images

REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
localhost:32000/prod-api   registry            dbba71be4f83        5 minutes ago       810MB

 

2. 이미지 registry 등록

$ sudo docker push localhost:32000/prod-api

The push refers to repository [localhost:32000/prod-api]
44006ff06569: Pushed 
203febf79d4f: Pushed 
2ec821486852: Pushed 
cae11887bc90: Pushed 
729c3ac48990: Pushed 
8378cd889737: Pushed 
5c813a85f7f0: Pushed 
bdca38f94ff0: Pushed 
faac394a1ad3: Pushed 
ce8168f12337: Pushed 
registry: digest: sha256:7c8fe99287f680f23e611c4113834c5c8343aa102a49a3584a65888205604609 size: 2420

 

3. kubernetes 로 배포

배포코드는 https://github.com/yusufkaratoprak/kubernetes-gosample 를 참조

$ vi config/deploy.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: prod-api-dep
spec:
  replicas: 1
  selector:
    matchLabels:
      app: prod-api
  template:
    metadata:
      name: prod-api
      labels:
        app: prod-api
    spec:
      containers:
      - name: prod-api-dep
        image: localhost:32000/prod-api:registry
        ports:
        - containerPort: 8090

$ vi config/service.yaml

apiVersion: v1
kind: Service
metadata:
  name: prod-api-service
spec:
  selector:
    app: prod-api
  ports:
    - name: http
      protocol: TCP
      port: 8070
      targetPort: 8090
  externalIPs:
    - 192.168.0.111

배포/가동 : kubectl apply -f config/

$ curl 192.168.0.111:8070  으로 체크

추후 LoadBalance 로 설정 - golang 파드는  replicas 로 여러대로 동작

 

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

쿠버네티스를 세팅하면서 최종 하려는 목적은  mongodb + golang API 앱 이다.

몽고디비 replica set + golang 도 pod 를 5개 이상 띄워서 REST API 를 서비스하려는 것이다.

현재는 쿠버네티스 로컬에 microk8s 로 간단하게 세팅해서 구성중이다.
다른 언어로 해도 되는데, go 로 굳이 하려는 이유는 딱히 없지만, 이유를 찾아보자면
go 가 클라우드 친화적(?)이라고 느껴서 이다. (쿠버네티스 도 아마 go 로 많이 작성되어 있는 것으로 알고 있다)

작성하려는 것은 대단한 앱은 아니지만, 개발환경을 구성해야 한다. 간단히 정리해본다

1. golang 설치 - 우분투(kubernetes) / MacOS (개발환경)
https://golang.org/doc/install 를 참조하면 된다.
특이한점은 GOPATH 라는 특이한 규칙(?)이 있다.
gopath 를 설정하고 ( work / workspace 등 - 본인이 편한대로 ) , 소스 src , bin 등의 규칙이 있다.
개인 소스를 src/github.com/{깃헙아이디}/프로젝트명  형태로 작업한다.
src/github.com/1day1/hello 같은식

git run github.com/1day1/hello 

형태로 실행할 수 있다.

2. vscode 설치 - MacOS (생략)
https://code.visualstudio.com/download

3. vscode 에서 확장/플러그인 extension 설치 (go 로 검색)
https://code.visualstudio.com/docs/languages/go

4. 추후 vscode 에서 필요한 설정 ( 아마도 sftp 연결 / git 세팅 등이 될 듯 하다)

keyboard shortcut 설정

  • reveal in Side bar : cmd + shift + R 
  •  

go 확장 - gopath 설정 ( setting.json )

  • "go.gopath": "/Users/onedayone/go-apps"

 

[필요하면 계속 추가]

 

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

지난번 kubernetes 에서 mongodb replica set 세팅 하는 방법을 정리했다. ( https://blog.1day1.org/598 )

그런데, 이제 mongo db 내부에서 replica set 을 설정한다.

(kube => pod 접속)
$ kubectl exec -ti mongod-0 -c mongod-container bash
   or
$ kubectl exec -ti mongod-0 -- bash

(pod 내에서 mongo console 실행)
# mongo

처음에는 다음처럼 나온다.

rs.status()
{
	"ok" : 0,
	"errmsg" : "no replset config has been received",
	"code" : 94,
	"codeName" : "NotYetInitialized"
}

리플리카 셋을 설정한다.

config = {_id: "MainRepSet", version: 1, members: [
       { _id: 0, host : "mongod-0.mongodb-service:27017" },
       { _id: 1, host : "mongod-1.mongodb-service:27017" },
       { _id: 2, host : "mongod-2.mongodb-service:27017" },
       { _id: 3, host : "mongod-3.mongodb-service:27017" }
 ]}
 rs.initiate(config)

초기 설정 후 관리계정을 만들어 준다.

use admin
db.createUser({user:"admin",pwd:passwordPrompt(),roles:[{role:"root",db:"admin"}]})

(사용은)
db.getSiblingDB('admin').auth("admin", passwordPrompt())

(수정)
db.updateUser("admin", {pwd:passwordPrompt()})

정상 세팅은 다음 처럼 나온다.

더보기

MainRepSet:PRIMARY> rs.status()
{
"set" : "MainRepSet",
"date" : ISODate("2020-02-20T08:39:06.434Z"),
"myState" : 1,
"term" : NumberLong(1),
"syncingTo" : "",
"syncSourceHost" : "",
"syncSourceId" : -1,
"heartbeatIntervalMillis" : NumberLong(2000),
"majorityVoteCount" : 3,
"writeMajorityCount" : 3,
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1582187942, 1),
"t" : NumberLong(1)
},
"lastCommittedWallTime" : ISODate("2020-02-20T08:39:02.691Z"),
"readConcernMajorityOpTime" : {
"ts" : Timestamp(1582187942, 1),
"t" : NumberLong(1)
},
"readConcernMajorityWallTime" : ISODate("2020-02-20T08:39:02.691Z"),
"appliedOpTime" : {
"ts" : Timestamp(1582187942, 1),
"t" : NumberLong(1)
},
"durableOpTime" : {
"ts" : Timestamp(1582187942, 1),
"t" : NumberLong(1)
},
"lastAppliedWallTime" : ISODate("2020-02-20T08:39:02.691Z"),
"lastDurableWallTime" : ISODate("2020-02-20T08:39:02.691Z")
},
"lastStableRecoveryTimestamp" : Timestamp(1582187912, 3),
"lastStableCheckpointTimestamp" : Timestamp(1582187912, 3),
"electionCandidateMetrics" : {
"lastElectionReason" : "electionTimeout",
"lastElectionDate" : ISODate("2020-02-20T08:38:32.108Z"),
"electionTerm" : NumberLong(1),
"lastCommittedOpTimeAtElection" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"lastSeenOpTimeAtElection" : {
"ts" : Timestamp(1582187901, 1),
"t" : NumberLong(-1)
},
"numVotesNeeded" : 3,
"priorityAtElection" : 1,
"electionTimeoutMillis" : NumberLong(10000),
"numCatchUpOps" : NumberLong(0),
"newTermStartDate" : ISODate("2020-02-20T08:38:32.690Z"),
"wMajorityWriteAvailabilityDate" : ISODate("2020-02-20T08:38:33.290Z")
},
"members" : [
{
"_id" : 0,
"name" : "mongod-0.mongodb-service:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 805,
"optime" : {
"ts" : Timestamp(1582187942, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2020-02-20T08:39:02Z"),
"syncingTo" : "",
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "could not find member to sync from",
"electionTime" : Timestamp(1582187912, 1),
"electionDate" : ISODate("2020-02-20T08:38:32Z"),
"configVersion" : 1,
"self" : true,
"lastHeartbeatMessage" : ""
},
{
"_id" : 1,
"name" : "mongod-1.mongodb-service:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 44,
"optime" : {
"ts" : Timestamp(1582187942, 1),
"t" : NumberLong(1)
},
"optimeDurable" : {
"ts" : Timestamp(1582187942, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2020-02-20T08:39:02Z"),
"optimeDurableDate" : ISODate("2020-02-20T08:39:02Z"),
"lastHeartbeat" : ISODate("2020-02-20T08:39:06.193Z"),
"lastHeartbeatRecv" : ISODate("2020-02-20T08:39:05.256Z"),
"pingMs" : NumberLong(1),
"lastHeartbeatMessage" : "",
"syncingTo" : "mongod-0.mongodb-service:27017",
"syncSourceHost" : "mongod-0.mongodb-service:27017",
"syncSourceId" : 0,
"infoMessage" : "",
"configVersion" : 1
},
{
"_id" : 2,
"name" : "mongod-2.mongodb-service:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 44,
"optime" : {
"ts" : Timestamp(1582187942, 1),
"t" : NumberLong(1)
},
"optimeDurable" : {
"ts" : Timestamp(1582187942, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2020-02-20T08:39:02Z"),
"optimeDurableDate" : ISODate("2020-02-20T08:39:02Z"),
"lastHeartbeat" : ISODate("2020-02-20T08:39:06.187Z"),
"lastHeartbeatRecv" : ISODate("2020-02-20T08:39:05.581Z"),
"pingMs" : NumberLong(0),
"lastHeartbeatMessage" : "",
"syncingTo" : "mongod-0.mongodb-service:27017",
"syncSourceHost" : "mongod-0.mongodb-service:27017",
"syncSourceId" : 0,
"infoMessage" : "",
"configVersion" : 1
},
{
"_id" : 3,
"name" : "mongod-3.mongodb-service:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 44,
"optime" : {
"ts" : Timestamp(1582187942, 1),
"t" : NumberLong(1)
},
"optimeDurable" : {
"ts" : Timestamp(1582187942, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2020-02-20T08:39:02Z"),
"optimeDurableDate" : ISODate("2020-02-20T08:39:02Z"),
"lastHeartbeat" : ISODate("2020-02-20T08:39:06.201Z"),
"lastHeartbeatRecv" : ISODate("2020-02-20T08:39:05.256Z"),
"pingMs" : NumberLong(1),
"lastHeartbeatMessage" : "",
"syncingTo" : "mongod-0.mongodb-service:27017",
"syncSourceHost" : "mongod-0.mongodb-service:27017",
"syncSourceId" : 0,
"infoMessage" : "",
"configVersion" : 1
}
],
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1582187942, 1),
"signature" : {
"hash" : BinData(0,"pHhOTNJaI3y8hvPOpgcOs9zJ7I8="),
"keyId" : NumberLong("6795445338166525955")
}
},
"operationTime" : Timestamp(1582187942, 1)
}


이후에 primary 에서 데이터를 등록하면 secondary 에 반영된다.

kubernetes 에서  delete / apply 등으로 새로 세팅하거나 했을때 기존 설정이 정상 동작 하지 않는 경우.
Primary 가 없거나 하는 경우.

Our replica set config is invalid or we are not a member of it

설정을 재등록(?) 해준다. 

conf = rs.conf()
rs.reconfig(conf, {force:true})

 

[추가] 몇몇 주요 명령

1. replica set 추가

rs.add("mongod-3.mongodb-service:27017")

2. sync 상태 보기

PRIMARY> rs.printSlaveReplicationInfo()

source: mongod-1.mongodb-service:27017
	syncedTo: Fri Feb 28 2020 02:56:26 GMT+0000 (UTC)
	0 secs (0 hrs) behind the primary 
source: mongod-2.mongodb-service:27017
	syncedTo: Fri Feb 28 2020 02:56:26 GMT+0000 (UTC)
	0 secs (0 hrs) behind the primary 
source: mongod-3.mongodb-service:27017
	syncedTo: Fri Feb 28 2020 02:56:26 GMT+0000 (UTC)
	0 secs (0 hrs) behind the primary 

3. 특정노드 에러메시지 (해결책 - 찾는 중)

PRIMARY> rs.status()
..
"stateStr" : "(not reachable/healthy)",
..
"lastHeartbeatMessage" : "Our replica set configuration is invalid or does not include us",
..

PRIMARY> rs.printSlaveReplicationInfo()
...
...
source: mongod-0.mongodb-service:27017
	syncedTo: Thu Jan 01 1970 00:00:00 GMT+0000 (UTC)
	1584736418 secs (440204.56 hrs) behind the primary 

원인이 뭘까? 특별히 비정상 종료 같은 것은 없던 것 같은데. config 서버를 따로 두지 않는 문제일까?

  해결책 1) 해당 pvc / pod 를 삭제한다 => 쿠버네티스 가 알아서 재가동 하면서 정상 처리 된다. (옳은 방법인지는 의문)

kubectl delete pvc mongodb-persistent-storage-claim-mongod-0
kubectl delete pod/mongod-0

 

 

 

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

몽고디비를 서비스에 도입해보려고 테스트 중이다.

여러가지 설치 방법이 있지만, 쿠버네티스 를 활용해서 하려한다.

1. microk8s 를 설치한다.
https://microk8s.io/docs/ 설치방법은 너무 쉽다.
몇몇 서비스를 활성화 시킨다.

microk8s.enable dns storage ingress registry

 

microk8s.kubectl 은 링크걸어두면 편하다.

sudo ln -s microk8s.kubectl /snap/bin/kubectl

or

sudo snap alias microk8s.kubectl kubectl

 

2. 몽고디비 replica set 설정을 사용한다.
https://maruftuhin.com/blog/mongodb-replica-set-on-kubernetes/ 의 설정을 참조

$ openssl rand -base64 741 > ./replica-set-key.txt
$ kubectl create secret generic shared-bootstrap-data \
  --from-file=internal-auth-mongodb-keyfile=./replica-set-key.txt

3. 설정을 사용해 몽고디비를 가동한다.

kubectl apply -f replica-sets/mongodb-rc.yaml

다음과 같은 명령으로 상황을 모니터링 하면 좋다.

kubectl get all -o wide
kubectl get pvc -o wide
kubectl get nodes -o wide

정상적으로 실행되지 않고, pending 으로 시간이 걸린다면, 삭제했다가 다시 실행해본다.

(전체 삭제)
kubectl delete -f replica-sets/mongodb-rc.yaml

(pvc 삭제)
kubectl delete pvc mongodb-persistent-storage-claim-mongod-0

 

정상적이라면 다음처럼 나온다.

kubectl get pods -o wide

NAME       READY   STATUS    RESTARTS   AGE     IP            NODE            
mongod-0   1/1     Running   0          6m45s   10.1.32.109   192.168.77.20   
mongod-1   1/1     Running   0          6m43s   10.1.70.10    kube-mk8s       
mongod-2   1/1     Running   0          6m42s   10.1.32.110   192.168.77.20   
mongod-3   1/1     Running   0          6m41s   10.1.70.11    kube-mk8s       

 

4. mongo 접속하여 replica set 설정한다. (세부 설정은 별도로 정리 예정)

(kube => pod 접속)
kubectl exec -ti mongod-0 -c mongod-container bash

(pod 내에서 mongo console 실행)
mongo

 

해당 replica set 의 몽고 서버에 접속하기 위해 dns 설정이 잘 되었는지 확인해본다.

kubectl apply -f https://k8s.io/examples/admin/dns/busybox.yaml
kubectl exec -ti busybox -- nslookup mongod-0.mongodb-service

설정을 확인해서 정상적으로 pod IP 가 나와야 한다.

이런식으로 나오면 실패.

Server:    127.0.0.53
Address 1: 127.0.0.53

nslookup: can't resolve 'mongod-0.mongodb-service'

아래처럼 나와야 정상.

Server:    10.152.183.10
Address 1: 10.152.183.10 kube-dns.kube-system.svc.cluster.local

Name:      mongod-0.mongodb-service
Address 1: 10.1.32.109 mongod-0.mongodb-service.default.svc.cluster.local

 

 

[추가]

혹시 microk8s 설치시 다음과 같은 메시지나 나오고 진행이 안된다면.

error: too early for operation, device not yet seeded or device model not acknowledged

snapd 를 삭제했다가 다시 설치해본다.

sudo apt purge snapd
sudo apt install snapd
반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

쿠버네티스 를 사용하기 위해 알아보고 있다. (이미 대세가 된지 오래)

단순 개발환경에 적용하기 보다. 실무에 적용하기 위해 연습/학습 단계 부터 단계적으로 해본다.

현재로서는 다음 단계로 진행예정.

1. microk8s (우분투 기반) - 로컬
2. kubeadm , kubespray 등을 이용한 세팅 - (클라우드 or 실서버)
3. helm 등의 패키지(?) 개념의 설치/세팅

아직 용어도 익숙치 않아서 시간이 걸리겠지만, 하나씩 해보면서 목표를 이뤄나간다.

장비도 노트북(그램) , 서버(PC) , 클라우드(D.O , GCP) 등 여러환경에서 해본다.

 

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

예전 부터 가상서버를 써왔다. 국내/해외. 본격적으로 써온지도 5년이 넘었다.
(특히 해외업체들의 서비스가 괜찮아 많이 쓰고 있다. https://blog.1day1.org/564 에 소개를 하기도 했다)

국내업체들은 아직 불편한 부분이 많다.
그 사이 AWS 도 국내 서비스도 하고 있다.

이미 AWS 쪽은 대세가 된 kubernetes , 위 업체중 디지털오션 만 공식(?) 지원하고 있다. 서비스로서 지원.

디지털오션 - 쿠버네티스 서비스

벌쳐 / 리노드는 아직 공식 지원하지는 않는다. 별개로 kubernetes 설치해서 사용할 수는 있다.

디지털오션은 서비스로 지원해서, 쿠버네티스 클러스터를 구성하기 쉽도록 했다.(마스터는 별도 비용을 받지 않는 듯 하다)
노드 비용만 계산이 되는 듯 하다.(10$ 플랜부터 사용가능)

런칭한지는 좀 되었지만, 아직 실 사용은 해보지 않아 언급하진 않았다.
조만간 서비스를 쿠버네티스 기반으로 옮길것을 검토중이라 정리 차원에서 글을 쓴다.

도입하면서 나오는 이슈들을 정리할 생각이다.

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

사용중인 시스템에 HDD 관련 커널에러가 발생하였다.

보통 여러가지 이유가 많지만, 이런 에러가 생기면 그냥 AS 보낸다.

그런데, 이번에는 디스크 관리를 보니 배드섹터 1 개 라고 나온다. 애매하네...
당장 시스템 교체할 하드가 마땅치 않아, AS 보내기전 잠시라도 계속 사용해야 하는 상황.

배드섹터를 기록(?)해서 에러가 발생하지 않도록 하고자 한다.

커널 에러 메세지는 이런식이다. (에러 종류에 따라 , 메시지가 다르다 )

[348303.307873] ata4: EH complete
[348305.814497] ata4.00: exception Emask 0x0 SAct 0x1000000 SErr 0x0 action 0x0
[348305.814503] ata4.00: irq_stat 0x40000008
[348305.814508] ata4.00: failed command: READ FPDMA QUEUED
[348305.814517] ata4.00: cmd 60/08:c0:78:3b:76/00:00:31:01:00/40 tag 24 ncq 4096 in
                         res 41/40:00:78:3b:76/00:00:31:01:00/40 Emask 0x409 (media error) <F>
[348305.814521] ata4.00: status: { DRDY ERR }
[348305.814524] ata4.00: error: { UNC }
[348305.815611] ata4.00: configured for UDMA/133
[348305.815625] sd 3:0:0:0: [sdc] tag#24 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
[348305.815630] sd 3:0:0:0: [sdc] tag#24 Sense Key : Medium Error [current] [descriptor] 
[348305.815635] sd 3:0:0:0: [sdc] tag#24 Add. Sense: Unrecovered read error - auto reallocate failed
[348305.815639] sd 3:0:0:0: [sdc] tag#24 CDB: Read(16) 88 00 00 00 00 01 31 76 3b 78 00 00 00 08 00 00
[348305.815643] blk_update_request: I/O error, dev sdc, sector 5124799352

눈에 띄는 부분은 마지막줄.

blk_update_request: I/O error, dev sdc, sector 5124799352

배드 섹터가 생긴 것으로 보인다(다른 에러로 인해 나오는 경우도 있을 수 있을 듯 하다 - 입출력시 에러이니 다양한 원인이 있을 수 있음)


보통의 절차는 badblocks 로 배드섹터 위치를 찾고, fsck 로 배드섹터 표시를 해서 디스크사용시 해당 섹터를 건드리지 않도록 한다.

badblocks -v /dev/sdc1 > badsectors.txt

위 처럼 배드섹터 위치를 찾는다 ( /dev/sdc1 등은 본인의 HDD 명칭으로 쓰면 된다)
오래걸린다 (디스크 크기가 크면 클수록)
검색 범위를 정할 수 있는지 모르겠다. 2930265542

그 다음은 배드섹터를 파일시스템에 기록(?) 한다.

fsck.ext4 -l badsectors.txt  /dev/sdc1

fsck 명령은 본인의 파일시스템에 맞게 적절하게 바꿔준다. (fsck.ext2 , fsck.ext3 등)

끝.

이게 영구적인 해결방법은 아닐 듯 하다. 배드섹터가 계속 생길 수 있으니, AS 보내기 전까지 버텨보자.


추가

badblocks 가 너무 오래 걸린다. (거의 2시간 넘게 했는데, 반도 못했다. 6시간 넘게 걸릴 듯 하다 - 하드디스크 속도에 따라 차이가 있을 듯 함. 해당 HDD 는 7200 rpm )

badblocks -v /dev/sdc1 > badsectors.txt
Checking blocks 0 to 2930265542
Checking for bad blocks (read-only test): ^C

Interrupted at block 1102688832

block 범위를 정해서 다시 해본다. ( 전체가 5860533168 이다. 대략 배드섹터 위치는 5124799352 )

Disk /dev/sdc: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt

위 처럼 한 블럭이 512 byte ( badblocks 의 기본값은 1024 - 그래서 0 to 2930265542 으로 나옴)
그런데, 512 로 하면 다음과 같은 메시지가 나온다.

badblocks: 정의한 자료형으로 쓰기엔 너무 큰 값 invalid end block (5860531087): must be 32-bit value

기본값 1024 로 해야겠다. 대신 뒤의 블럭을 반으로 나눠서 범위를 정해야 겠다. ( 2562399676 가 된다)
그러고 보니 기본값을 fsck 쪽과도 맞춰야 할까? 파일시스템마다 다를려나? ( 4096 이 기본값인가? 5124799352 x 0.125 = 640599919 이 된다.)

# badblocks -b 4096 -v /dev/sdc1 640600000 640590000 > badsectors.txt
Checking blocks 640590000 to 640600000
Checking for bad blocks (read-only test): done                                                 
Pass completed, 1 bad blocks found. (1/0/0 errors)
# cat badsectors.4096.txt 
640599663

뒤의 숫자는 640599919 의 대략 범위 위치를 {last block} {first block} ( 끝 / 시작 값을 약간 여유 잡고 지정한다 )
실제 블록 위치는 640599663 로 확인된다.

fsck 를 해보니.

# fsck.ext4 -l badsectors.4096.txt /dev/sdc1
e2fsck 1.42.13 (17-May-2015)
/dev/sdc1: Updating bad block inode.
Pass 1: Checking inodes, blocks, and sizes

Running additional passes to resolve blocks claimed by more than one inode...
Pass 1B: Rescanning for multiply-claimed blocks
Multiply-claimed block(s) in inode 110625949: 640599663
Pass 1C: Scanning directories for inodes with multiply-claimed blocks
Pass 1D: Reconciling multiply-claimed blocks
(There are 1 inodes containing multiply-claimed blocks.)

File { ================== 에러난 파일 =================== } (inode #110625949, mod time Wed Jun 26 16:35:07 2019) 
  has 1 multiply-claimed block(s), shared with 1 file(s):
    <The bad blocks inode> (inode #1, mod time Sat Jul 27 21:54:33 2019)
Clone multiply-claimed blocks<y>? yes
Error reading block 640599663 (Attempt to read block from filesystem resulted in short read).  에러 무시<y>? yes
강제로 덮어쓰기<y>? no
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found.  Create<y>? no
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong for group #0 (23517, counted=23516).
Fix<y>? yes
Free blocks count wrong for group #19549 (65535, counted=0).
Fix<y>? yes

/dev/sdc1: ***** FILE SYSTEM WAS MODIFIED *****

/dev/sdc1: ********** WARNING: Filesystem still has errors **********

/dev/sdc1: 36792/183148544 files (0.0% non-contiguous), 632810807/732566385 blocks

위에서 Clone multiply-claimed blocks? yes => 이 부분을 그냥 n 로 건너뛰는게 좋다. 어차피 에러로 복사(clone) 실패 하는 듯 함.

일단 위와 같이 조치했는데, 잘 된 것인지는 좀더 체크해봐야 겠다. ( 특히 block 의 위치가 맞게 처리된 것인지... )

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

기존에 vmware 로 세팅되어 사용중이던 windows xp 를 다른 호스트머신 으로 옮기려고 한다.

그런데, vmware player 가 설치가 안된다. (windows 10 의 문제인지?)
계속 알아볼까 하다가, 그냥 virtualbox 로 옮기기로 해본다. (요즘 PC 성능이 좋아져 vm 의 성능차이가 없을 듯 하여)

예전(몇년전)에 virtualbox 를 vmware 로 해봤을때는 잘 안되었는데, 그 반대를 해보려는것.

결론은 잘 이전 된다.

그 설명을 정리해본다.

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

우분투 업그레이드를 했다. (간만에)

버전은 4.4.0-143-generic

Virtualbox 가  커널이 바뀌어서 모듈을 재 컴파일 해야 한다.

# sudo /sbin/rcvboxdrv setup

Stopping VirtualBox kernel modules ...done.

Uninstalling old VirtualBox DKMS kernel modules ...done.

Trying to register the VirtualBox kernel modules using DKMSERROR: Cannot create report: [Errno 17] File exists: '/var/crash/virtualbox-5.0.0.crash'

Error! Bad return status for module build on kernel: 4.4.0-143-generic (x86_64)

Consult /var/lib/dkms/vboxhost/5.0.40/build/make.log for more information.

 ...failed!

  (Failed, trying without DKMS)

Recompiling VirtualBox kernel modules ...failed!

  (Look at /var/log/vbox-install.log to find out what went wrong)

에러가 난다.  Virtualbox 특정 버전만 그런것인가? ( 5.0.40 )


일단 커널 버전을 내렸다. 4.4.0-143 은 걸러야 겠다.


ps. 다른 서버 4.4.0-142 버전은 괜찮은 것 같다.

필요하면 설치

apt-get install linux-image-4.4.0-142-generic


[추가 - 03/21]

새버전 4.4.0-144 버전이 올라와서 해보니, 동일 이슈.


[추가-04/11]

새버전 4.4.0-146 까지도 나왔는데, 동일

virtualbox-5.2 / virtualbox-6.0 도 해봐도 에러.

https://askubuntu.com/questions/1126721/4-4-0-143-generic-upgrade-16-04-vmware-no-loger-working/1126950

=> 모듈 소스를 수정해서 조치를 해야할 듯 하다. (아직 안 해봄)  => 이건 vmware 기준 소스 수정


[추가-04/16]

virtualbox 의 vboxdrv 쪽의 소스를 수정하는 방법

virtualbox 6.0.4 를 기준으로 설명 ( 커널 버전은 4.4.0-146 으로 설명)

참조 - /usr/src/linux-headers-4.4.0-146-generic/include/linux/mm.h 의 get_user_pages 의 인수가 다른 문제

vboxdrv 의 소스를 수정해준다.

/usr/src/vboxhost-6.0.4/vboxdrv/r0drv/linux/memobj-r0drv-linux.c 에서 get_users_pages 부분을 수정해주면 된다.

1122                                 /*fWrite,*/                 /* Write to memory. */

virtualbox 버전에 따라 소스 라인 위치는 다를 수 있다.


수정 후  /sbin/vboxconfig  로 다시 모듈을 만들어 준다.

정상 동작까지는 확인 했는데, 이 방법은 위험성이 있으니, 사용하면서 이상현상이 있으면 추가로 글을 남기도록 한다.


반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

ubuntu 에서 squid3 설정.

- 설정은 간단하다.

- curl 을 이용해 해당 proxy 서버를 사용할때 주의점.

 

# 설치

apt-get install squid3 
또는
apt install squid

끝. 쉽다.

 

# 설정

/etc/squid3/squid.conf 을 설정 (다른 위치 : /etc/squid/squid.conf )

(원래 파일은 복사하고, 새로 생성한다)
  => 원래 파일을 주석제거하고 복사하고 싶을때

mv squid.conf squid.conf.old     # backup
cat squid.conf.old | egrep -v '^[[:space:]]*(#.*)?$' > squid.conf

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT

 

# digest

auth_param digest program /usr/lib/squid3/digest_file_auth /etc/squid3/squid3.digest.passwd

auth_param digest realm proxy

acl sq_digest proxy_auth REQUIRED

http_access allow sq_digest

 

# basic

auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/squid3.basic.passwd

auth_param basic realm proxy

acl sq_basic proxy_auth REQUIRED

http_access allow sq_basic

 

cache deny all

 

http_port 4128

 

#http_port 3128

coredump_dir /var/spool/squid3

 

refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern (Release|Packages(.gz)*)$      0       20%     2880
refresh_pattern .               0       20%     4320

 

진한 부분이 추가한 부분이다. 기본파일에는 http_access 관련 설정이 있는데 삭제했다.

 

# 포트 변경

그리고 추천하는 부분은 기본포트인 3128 을 다른 포트로 바꾸길 권장한다.
언제나 그렇듯이 공격 대상이 될 수 있다. (ssh 도 필수로 바꾸는 것이 좋다. 22 -> 다른 포트)

 

# 캐시 비활성화

cache deny all 

캐시를 비활성화 했는데, 필요하면 삭제 또는 주석처리한다.

 

# 인증 모드

인증 모드는 digest 와 basic 이 있는데 설정은 위와 같다. 동시에 써도 되는지는 모르겠다.

암호파일 생성은 htpasswd / htdigest 를 사용한다.

사용법은

htpasswd -c /etc/squid3/squid3.basic.passwd {username}

htdigest -c /etc/squid3/squid3.digest.passwd proxy {username}

암호화는 digest 방식을 추천한다.

 

모두 설정이 완료되었으면 재시작해서 바뀐 설정을 적용한다.

service squid3 restart

 

 

 

# curl 에서는 다음처럼 사용한다. ( php 기준 설명 )

php curl 은 아쉽게도 digest 모드를 아직 지원안하는 듯 하다.

$proxyserv = '123.123.123.123:4128' ;
$proxyauth = 'username:password';

 

curl_setopt($ch, CURLOPT_PROXY, $proxyserv );

curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth );
 

위와 같이 써준다.

curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_DIGEST ); 

위 옵션이 되면 좋겠는데, 아쉽게도 현재는 안된다.( 현재는 CURLAUTH_BASIC , CURLAUTH_NTLM 만 지원)

 

 

 

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

mysql 에서 mariadb 로 바꾼뒤 신규설치는 모두 mariadb 를 사용하고 있다.

내부 호스팅용으로 서버를 구축하는데, mariadb 를 설치하려 한다.

https://downloads.mariadb.org/mariadb/repositories/#mirror=kaist

를 사용.

기존에 하던 방식대로 하는데, 이번에는 뭔가 이상하다.

# apt-get install mariadb-server
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다      
상태 정보를 읽는 중입니다... 완료
몇몇 패키지를 설치할 수 없습니다. 요청한 상황이 불가능할 수도 있고,
불안정 배포판을 사용해서 일부 필요한 패키지를 아직 만들지 않았거나,
아직 Incoming에서 나오지 않은 경우일 수도 있습니다.
이 상황을 해결하는데 다음 정보가 도움이 될 수도 있습니다:

다음 패키지의 의존성이 맞지 않습니다:
 mariadb-server : 의존: mariadb-server-5.5 (= 5.5.42+maria-1~trusty) 하지만 %s 패키지를 설치하지 않을 것입니다
E: 문제를 바로잡을 수 없습니다. 망가진 고정 패키지가 있습니다.

이런식의 에러가 난다.

# apt-cache policy mariadb-server-5.5
mariadb-server-5.5:
  설치: (없음)
  후보: 5.5.42+maria-1~trusty
  버전 테이블:
     5.5.42+maria-1~trusty 0
        500 http://ftp.kaist.ac.kr/mariadb/repo/5.5/ubuntu/ trusty/main amd64 Packages
     5.5.41-1ubuntu0.14.04.1 0
        500 http://ftp.daumkakao.com/ubuntu/ trusty-updates/universe amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ trusty-security/universe amd64 Packages
     5.5.36-1 0
        500 http://ftp.daumkakao.com/ubuntu/ trusty/universe amd64 Packages

기본 패키지와 충돌이 나는 것일까?

그냥 5.5.36 으로 설치하면 괜찮을까?


기본 패키지로 깔아보니 잘 된다. 버전은 다음과 같다.

mysql  Ver 15.1 Distrib 5.5.41-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2



반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

서버를 변경하게 되었다. 

DNS 도 바꾸었는데, 해당 서버에 접속하는 외부의 특정서버에서 계속 구서버로 접속하는 문제가 있었다.

처음에는 /etc/hosts 등에 고정이 되었나 했는데, 아니다.

그리고 apache 가 그런 설정이 있나 체크해봤다. 아니다.

접속 부분이 php 의 curl 을 사용하고 있다.

curl 에서 혹시 DNS 캐시를 사용하나? 관련 부분을 찾아봤다.

아마도 관련된 옵션은 다음인 듯 하다. 

    curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false);

    curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, 2);


해당 옵션을 넣어주니 해결이 되었다.(아마도 첫번째 옵션일 듯 하다)


특정서버의 설정에서 문제가 있는지, 다른 외부 서버들은 이상이 없었다.



반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

그동안 Digital Ocean 과 Linode 를 사용하고 있다.
내부 서비스에 작은 클라우드가 많이 필요해서 현재 수십대를 사용하고 있다.

둘다 별다른 불만은 없다.

좀더 다양한 지역분산 위해 VPS호스팅이 눈에 띄면 테스트 해보고 있다.


2016-07 월 특별 프로모션 중 

http://www.vultr.com/?ref=6923034-3B



몇개중에 vultr 이 눈에 띈다. http://www.vultr.com/?ref=6822762

vulture 의 줄임말인가? 뭐라 읽어야 하지? 벌쳐?

5$ 부터 시작한다. DO 보다 램이 조금 높다. 가격 우위에서 앞선다.


배포도 편하다. 일본지역이 있어서 좋다.
느낌은 DO 와 비슷하다. ssh key 등록도 되어 편하다.

성능은 배포해서 써보고 있는데, 무난한 것 같다.(뭐 기술적으로 비슷할테니...)

paypal 도 있고, 신용카드 결제도 가능핟.

bitcoin 으로도 결제 가능한 것이 특이하다.


프로모션 코드로 'SSDVPS' 를 입력하면 $20 credit 을 준다.(단, 1개월내에 소진해야 한다.)
언제까지 적용가능한지는 모르겠다.
신청하기 : http://www.vultr.com/?ref=6822762

5$ / 15$ plan 을 신청하고 1달써보고 테스트 해볼 예정이다.

검증해보고, 서비스로 쓸 만하다 싶으면, 서비스에 적용해야 겠다.



[기타 관련글]

가상서버들 간단한 사용기 - 스마일서브 / 디지털오션 / 벌쳐(vultr) 등

테스트 중인 가상서버 업체(USA)




반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

우분투의 기본설정으로 모니터 자동끄기를 사용하고 있었다.

그런데, 어떤 이유인지 모니터를 2개연결하니 작동이 이상해졌다.

그래서 그냥 스크립트로 만들었다.(외국의 스크립트를 내 입맛에 맞게 부분 변경함)


시스템설정 > 키보드 > 단축키 에서 사용자 설정으로 다음 실행파일을 실행시키는 방법으로 한다.

#!/bin/bash
screenOffLockFile=/tmp/screen-off-lock
systemLockFile=/tmp/system-lock

if [ -f $screenOffLockFile ];
then
        rm $screenOffLockFile
        rm $systemLockFile
        notify-send "Screen on." -i /usr/share/icons/gnome/48x48/devices/display.png
else
        touch $screenOffLockFile
        sleep .5
        notify-send "Screen off now." -i /usr/share/icons/gnome/48x48/devices/display.png
        touch $systemLockFile
        sleep 1
        gnome-screensaver-command -l
        while [ -f  $screenOffLockFile ]
        do
                xset dpms force off
                if [ -f $systemLockFile ];
                then
                        sleep 30
                else
                        sleep 10
                fi
        done
        xset dpms force on
fi

난 안쓰는 Pause / Break 키를 단축키로 매핑시켰다. (본인 취향에 따라 )


gnome-screensaver-command -l  => 이 부분은 모니터를 끄면서 잠금모드로 변경하도록 했다.

30초단위로 모니터가 꺼진다.(시간단위도 본인에 맞게 조정)

계속 꺼지게 되므로 켜짐모드로 하려면 단축키를 다시 눌러준다.



반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

목적은 다음과 같다. A 서버가 SXX 서버들에 API 데이터를 전송을 하는데, 서버호스팅의 트래픽이 몰리는 문제가 있다. 그래서 트래픽을 분산하고자 한다.가능한 코드를 적게 고쳐서 분산을 하고 싶다.

A -> SXX 로 바로 보내는 것이 아니라,  A -> B(proxy) -> SXX 로 보내게 된다.
그래서 트래픽을 A / B 가 나누어서 나오게 된다.

SXX.domain.co.kr 으로 원래 가던 트래픽이 SXX.domain.kr 으로 쏴주면 proxy 를 거쳐 원래주소로 가게된다.(SXX.domain.kr 은 B 서버로 설정해준다)

B서버의 nginx 설정은 다음과 같다.

server {
        listen 80;
        server_name ~^(?<subserv>.+)\.domain\.kr$ ;
        location / {
                resolver 168.126.63.1 ;
                proxy_pass http://${subserv}.domain.co.kr ;
                proxy_set_header Host $subserv.domain.co.kr ;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

위와 같은 방식으로 해준다.


위 진한 부분의 resolver 를 주지 않으면 proxy_pass 의 ${subserv} 부분때문에 다음과 같은 에러가 난다.

2014/10/17 13:38:11 [error] 9577#0: *1 no resolver defined to resolve s13.domain.co.kr, client: 11.22.33.44, server: s13.domain.kr, request: "GET /aaa HTTP/1.1", host: "s13.domain.kr"
2014/10/17 13:40:44 [error] 15697#0: *1 no resolver defined to resolve s13.domain.co.kr, client: 11.22.33.44, server: ~^(?<subserv>.+)\.domain\.kr$, request: "GET /aaa HTTP/1.1", host: "s13.domain.kr"
2014/10/17 13:47:20 [error] 19726#0: *3 no resolver defined to resolve s13.domain.co.kr, client: 11.22.33.44, server: ~^(?<subserv>.+).domain.kr$, request: "GET /aaa HTTP/1.1", host: "s13.domain.kr"
2014/10/17 13:50:41 [error] 26918#0: *1 no resolver defined to resolve domain.co.kr, client: 11.22.33.44, server: ~^(?<subserv>.+)\.domain\.kr$, request: "GET /aaa HTTP/1.1", host: "s13.domain.kr"
2014/10/17 13:52:07 [error] 27502#0: *1 no resolver defined to resolve domain.co.kr, client: 11.22.33.44, server: ~^(?<subserv>.+)\.domain\.kr$, request: "GET /aaa HTTP/1.1", host: "s13.domain.kr"





반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

목적은 다음과 같다.

우분투 14.04 vino-server <==> ssh 터널링(putty) <==> 윈도우 vnc

이와 같은 목적으로 세팅을 했다. putty 에서 ssh 터널링 설정은 많으니 패스.

그런데, 윈도우에서 vnc 로 접속시 다음과 같은 메시지가 나온다.

Error in TightVNC Viewer: No security types supported. Server sent security types, but we do not support any of their.

tightvnc 먼저 테스트.

Unable to connect to VNC Server using your chosen security setting.
Either upgrade VNC Server to a more recent version from RealVNC, or select a weaker level of encryption.
혹시나 해서 realvnc. 둘다 마찬가지.


ssh 를 통과해서 security 관련 문제가 나타나는 듯 하다.

결국은 vino-server 대신 x11vnc 를 사용하기로 했다.

설치/설정 방법은 http://blog.1day1.org/561 를 참조한다.


x11vnc 로 바꾸고, 접속해보니 정상적으로 접속한다.



반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

우분투에서 vino-server 보다 x11vnc 가 나은듯 하다.

x11vnc 를 설치해보자

apt-get install x11vnc xinetd

로 설치해준다.

그리고, xinetd 는 x11vnc 를 자동실행시켜주기 위해 사용한다(취향에 따라 gdm 로그인시 자동실행시켜도 된다.)

/etc/xinetd.d/x11vnc 로 다음 내용을 저장한다.

service x11vnc
{
   port = 5901
   type = UNLISTED
   socket_type = stream
   protocol = tcp
   wait = no
   user = root
   server = /usr/bin/x11vnc
   server_args = -inetd -o /var/log/x11vnc.log -display :0 -auth /var/lib/gdm/:0.Xauth -xkb -repeat -many -bg -noxdamage -rfbauth /etc/x11vnc.passwd
   disable = no
}


여기서 조심할 항목은 /etc/x11vnc.passwd 의 암호를 지정하는 것이다.

x11vnc -storepasswd /etc/x11vnc.passwd


로 하면 암호를 물어보고, 해당 파일로 저장이 된다.

server_args 부분설명
  -noxdamage :  compiz 상에서 화면갱신등의 성능이 좋지 않는데, 저 옵션을 주면 좋아진다.

  -xkb -repeat  : shift 키가 안먹을때 넣어 준다.

  -auth {xauth} : ps aux | grep auth  명령으로 위치를 찾아준다.

/usr/bin/X -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch

ubuntu 14.04 에서는 위와 같다. lightdm 부분 /var/run/lightdm/root/:0 을 -auth 옵션뒤에 넣어준다.

 

설정 완료 후에는 xinetd 를 재시작 해준다.

service xinetd restart

 

[추가-2020-03-31]

우분투 18.04 에서는 lightdm 대신에 gdm 을 사용한다.(auth 부분이 /run/user/121/gdm/Xauthority 이다 )
특정 시스템의 문제인지 모르겠지만, 로그인 하면 검정화면이 된다.

해결 방법이 있을듯 하지만, 그냥 lightdm 을 설치해서 해결했다.

apt install lightdm

 

반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

btrfs 를 사용하고 있는데, 아직 익숙하지 않은지, 뭔가 이상한 부분들이 있다.

virtualbox 가상머신을 사용하던중 프리징 되는 현상이 발생했다. 그냥 강제종료를 하니 이제 뜨지 않는다.ㅜㅜ


커널에러가 발생하는 듯 싶다. 커널호환이 안되는 것인가?

다음과 같은 커널에러가 발생한다.

# cat kern.log-btrfs-panic
[  115.018518] ------------[ cut here ]------------
[  115.018540] kernel BUG at /build/buildd/linux-3.13.0/fs/btrfs/ctree.c:3166!
[  115.018563] invalid opcode: 0000 [#1] SMP
[  115.018578] Modules linked in: pci_stub vboxpci(OF) vboxnetadp(OF) vboxnetflt(OF) vboxdrv(OF) snd_hda_codec_hdmi snd_hda_codec_realtek x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm crct10dif_pclmul crc32_pclmul ghash_clmulni_intel dm_multipath scsi_dh aesni_intel aes_x86_64 lrw gf128mul glue_helper snd_hda_intel snd_hda_codec ablk_helper snd_hwdep cryptd rts5139(C) snd_pcm arc4 btusb snd_page_alloc rtl8723ae rtl8723_common rtl_pci rtlwifi snd_seq_midi snd_seq_midi_event mac80211 joydev snd_rawmidi serio_raw snd_seq cfg80211 snd_seq_device lpc_ich nouveau i915 snd_timer ttm mei_me drm_kms_helper mei drm snd i2c_algo_bit soundcore bnep rfcomm bluetooth mxm_wmi msi_wmi sparse_keymap binfmt_misc wmi parport_pc video mac_hid ppdev lp parport hid_generic hid_logitech_dj usbhid hid btrfs libcrc32c raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor psmouse ahci raid6_pq libahci raid1 raid0 alx mdio multipath linear dm_mirror dm_region_hash dm_log
[  115.018939] CPU: 1 PID: 732 Comm: btrfs-endio-wri Tainted: GF        C O 3.13.0-35-generic #62-Ubuntu
[  115.018966] Hardware name: Micro-Star International Co., Ltd. CR42 2M/GE40 2OC/MS-1492, BIOS E1492IMS.30O 01/29/2014
[  115.018996] task: ffff880222c8e000 ti: ffff8800b9a04000 task.ti: ffff8800b9a04000
[  115.019018] RIP: 0010:[<ffffffffa00f1a31>]  [<ffffffffa00f1a31>] btrfs_set_item_key_safe+0x161/0x170 [btrfs]
[  115.019063] RSP: 0018:ffff8800b9a05b70  EFLAGS: 00010246
[  115.019079] RAX: 0000000000000000 RBX: 0000000000000004 RCX: 00000005e87b0000
[  115.019099] RDX: 0000000000000000 RSI: ffff8800b9a05c76 RDI: ffff8800b9a05b8f
[  115.019119] RBP: ffff8800b9a05bc8 R08: 0000000000000001 R09: ffff8800b9a05b90
[  115.019139] R10: 00000005e87b8000 R11: 00000000ffffffff R12: ffff8800b9a05b7e
[  115.019160] R13: ffff88003612a7e0 R14: ffff8800b9a05c76 R15: ffff880114d79680
[  115.019181] FS:  0000000000000000(0000) GS:ffff88022fa80000(0000) knlGS:0000000000000000
[  115.019204] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  115.019221] CR2: 00007f5d0c011088 CR3: 000000018e42b000 CR4: 00000000001427e0
[  115.019242] Stack:
[  115.019249]  ffff880035e61000 0118ffffa012a959 006c000000000000 1800000005e87b00
[  115.019274]  6c00000000000001 00000005e87b0000 ffff880114d79680 00000005e87b0000
[  115.019298]  0000000000000000 0000000000000ef7 ffff88003612a7e0 ffff8800b9a05cc0
[  115.019323] Call Trace:
[  115.019349]  [<ffffffffa0127ae1>] __btrfs_drop_extents+0x421/0xad0 [btrfs]
[  115.019374]  [<ffffffff810aafe2>] ? autoremove_wake_function+0x12/0x40
[  115.019406]  [<ffffffffa0128d10>] btrfs_drop_extents+0x60/0x90 [btrfs]
[  115.019435]  [<ffffffffa01188cc>] insert_reserved_file_extent.constprop.53+0x6c/0x290 [btrfs]
[  115.019467]  [<ffffffffa011e375>] btrfs_finish_ordered_io+0x2e5/0x570 [btrfs]
[  115.019495]  [<ffffffffa011e885>] finish_ordered_fn+0x15/0x20 [btrfs]
[  115.019523]  [<ffffffffa014219a>] worker_loop+0x15a/0x5c0 [btrfs]
[  115.019550]  [<ffffffffa0142040>] ? btrfs_queue_worker+0x310/0x310 [btrfs]
[  115.019572]  [<ffffffff8108b4a2>] kthread+0xd2/0xf0
[  115.019588]  [<ffffffff8108b3d0>] ? kthread_create_on_node+0x1c0/0x1c0
[  115.019608]  [<ffffffff8172ecbc>] ret_from_fork+0x7c/0xb0
[  115.019625]  [<ffffffff8108b3d0>] ? kthread_create_on_node+0x1c0/0x1c0
[  115.019644] Code: 48 8b 45 bf 48 8d 7d c7 4c 89 f6 48 89 45 d0 0f b6 45 be 88 45 cf 48 8b 45 b6 48 89 45 c7 e8 97 f2 ff ff 85 c0 0f 8f 48 ff ff ff <0f> 0b 0f 0b 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55
[  115.019750] RIP  [<ffffffffa00f1a31>] btrfs_set_item_key_safe+0x161/0x170 [btrfs]
[  115.019779]  RSP <ffff8800b9a05b70>
[  115.029262] ---[ end trace 642f12bbe4eff1cc ]---


일단 마운트 해제하고, btrfsck 를 해본다.

# btrfsck --repair /dev/vg_data/lv_data
enabling repair mode
Checking filesystem on /dev/vg_data/lv_data
UUID: c5cd286a-980e-414e-b10a-aacbf5c5e449
checking extents
checking free space cache
cache and super generation don't match, space cache will be invalidated
checking fs roots
root 5 inode 280 errors 180, file extent overlap, file extent discount
found 18378234624 bytes used err is 1
total csum bytes: 58871948
total tree bytes: 193949696
total fs tree bytes: 48832512
total extent tree bytes: 58753024
btree space waste bytes: 45925595
file data blocks allocated: 3653029335040
 referenced 52821159936
Btrfs v3.12

뭔가 고치긴 한것 같다.


그런데, virtualbox 를 다시 실행해도 같은 에러가 발생한다.

커널버전을 낮춰볼까?



다시 체크를 해보니

# btrfsck /dev/vg_data/lv_data
Checking filesystem on /dev/vg_data/lv_data
UUID: c5cd286a-980e-414e-b10a-aacbf5c5e449
checking extents
checking free space cache
free space inode generation (0) did not match free space cache generation (57150)
free space inode generation (0) did not match free space cache generation (57150)
free space inode generation (0) did not match free space cache generation (57151)
free space inode generation (0) did not match free space cache generation (57150)
free space inode generation (0) did not match free space cache generation (57147)
free space inode generation (0) did not match free space cache generation (57134)
free space inode generation (0) did not match free space cache generation (56404)
free space inode generation (0) did not match free space cache generation (57135)
free space inode generation (0) did not match free space cache generation (26053)
free space inode generation (0) did not match free space cache generation (56713)
free space inode generation (0) did not match free space cache generation (57137)
free space inode generation (0) did not match free space cache generation (57139)
free space inode generation (0) did not match free space cache generation (57148)
free space inode generation (0) did not match free space cache generation (57097)
free space inode generation (0) did not match free space cache generation (56684)
free space inode generation (0) did not match free space cache generation (57124)
free space inode generation (0) did not match free space cache generation (56680)
free space inode generation (0) did not match free space cache generation (56646)
free space inode generation (0) did not match free space cache generation (57050)
free space inode generation (0) did not match free space cache generation (56697)
free space inode generation (0) did not match free space cache generation (56681)
free space inode generation (0) did not match free space cache generation (57078)
free space inode generation (0) did not match free space cache generation (57087)
free space inode generation (0) did not match free space cache generation (57118)
free space inode generation (0) did not match free space cache generation (57078)
free space inode generation (0) did not match free space cache generation (57107)
free space inode generation (0) did not match free space cache generation (57147)
free space inode generation (0) did not match free space cache generation (57097)
free space inode generation (0) did not match free space cache generation (57097)
free space inode generation (0) did not match free space cache generation (57140)
free space inode generation (0) did not match free space cache generation (57147)
free space inode generation (0) did not match free space cache generation (57083)
free space inode generation (0) did not match free space cache generation (52539)
free space inode generation (0) did not match free space cache generation (56699)
free space inode generation (0) did not match free space cache generation (57141)
free space inode generation (0) did not match free space cache generation (57088)
free space inode generation (0) did not match free space cache generation (57097)
free space inode generation (0) did not match free space cache generation (57055)
free space inode generation (0) did not match free space cache generation (57087)
free space inode generation (0) did not match free space cache generation (57097)
free space inode generation (0) did not match free space cache generation (56527)
free space inode generation (0) did not match free space cache generation (57097)
free space inode generation (0) did not match free space cache generation (47463)
free space inode generation (0) did not match free space cache generation (57081)
free space inode generation (0) did not match free space cache generation (57097)
free space inode generation (0) did not match free space cache generation (57097)
free space inode generation (0) did not match free space cache generation (57056)
free space inode generation (0) did not match free space cache generation (57141)
free space inode generation (0) did not match free space cache generation (57150)
free space inode generation (0) did not match free space cache generation (57150)
free space inode generation (0) did not match free space cache generation (57147)
free space inode generation (0) did not match free space cache generation (57147)
free space inode generation (0) did not match free space cache generation (57147)
free space inode generation (0) did not match free space cache generation (57147)

free space inode generation (0) did not match free space cache generation (57147)
free space inode generation (0) did not match free space cache generation (57070)
free space inode generation (0) did not match free space cache generation (57090)
free space inode generation (0) did not match free space cache generation (57148)
free space inode generation (0) did not match free space cache generation (57147)
free space inode generation (0) did not match free space cache generation (57147)
free space inode generation (0) did not match free space cache generation (57122)
free space inode generation (0) did not match free space cache generation (57147)
free space inode generation (0) did not match free space cache generation (57118)
free space inode generation (0) did not match free space cache generation (57147)
free space inode generation (0) did not match free space cache generation (57097)
checking fs roots
root 5 inode 280 errors 180, file extent overlap, file extent discount
found 45291307607 bytes used err is 1
total csum bytes: 58871948
total tree bytes: 193966080
total fs tree bytes: 48832512
total extent tree bytes: 58769408
btree space waste bytes: 45951279
file data blocks allocated: 3653012492288
 referenced 52804317184
Btrfs v3.12

이런 엄청난 메시지가..

btrfsck 로는 해결이 안되는 것 같다.

그냥 btrfs 를 버리고 ext4 로 해야겠다.
btrfs 의 데이터를 다른곳으로 옮기고, mkfs.ext4 로 다시 생성, 다시 복사. 끝.

ext4 로 바꾸고 다시 해보니 일단은 정상적인 듯 하다.

btrfs 는 문제해결능력을 더 키운후에 다시 도전해야 겠다.

data 는 그냥 바꾸면 되는데, root 는 어떻게 할지 고민해봐야겠다.
btrfs => ext4 로 바로 바꿔주는 방법을 찾아야 겠다.


반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

nginx 로 사이트를 운영중이다. 그런데 다음과 같은 에러가 나온다.

400 Bad Request

Request Header Or Cookie Too Large

nginx/1.6.1

무슨 문제일까?

설정값으로 바꿀 수 있을 것 같은데.


찾았다.

관련글 : http://wiki.nginx.org/HttpCoreModule#large_client_header_buffers

/etc/nginx/nginx.conf 등에 추가한다. http 또는 server 쪽에 넣어준다.

기본값은 4 8k

    large_client_header_buffers 4 16k;

16k 로 늘려줬다. 너무 늘리는 것은 좋지 않겠지.



반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

microSD 를 써보려고 하는데, exfat 으로 포맷되어 있다.

기본으로 설치된 ubuntu 에서 인식을 못한다.

우분투 14.04 에서는 공식패키지로 있다.(이전에는 PPA 를 사용했다)

# apt-get install exfat-utils
패키지 목록을 읽는 중입니다... 완료
의존성 트리를 만드는 중입니다      
상태 정보를 읽는 중입니다... 완료
다음 패키지를 더 설치할 것입니다:
  exfat-fuse
다음 새 패키지를 설치할 것입니다:
  exfat-fuse exfat-utils
0개 업그레이드, 2개 새로 설치, 0개 제거 및 3개 업그레이드 안 함.
112 k바이트 아카이브를 받아야 합니다.
이 작업 후 304 k바이트의 디스크 공간을 더 사용하게 됩니다.
계속 하시겠습니까? [Y/n]
받기:1 http://ftp.daum.net/ubuntu/ trusty/universe exfat-fuse amd64 1.0.1-1 [26.0 kB]
받기:2 http://ftp.daum.net/ubuntu/ trusty/universe exfat-utils amd64 1.0.1-1 [85.7 kB]
내려받기 112 k바이트, 소요시간 0초 (161 k바이트/초)
Selecting previously unselected package exfat-fuse.
(데이터베이스 읽는중 ...현재 353015개의 파일과 디렉터리가 설치되어 있습니다.)
Preparing to unpack .../exfat-fuse_1.0.1-1_amd64.deb ...
Unpacking exfat-fuse (1.0.1-1) ...
Selecting previously unselected package exfat-utils.
Preparing to unpack .../exfat-utils_1.0.1-1_amd64.deb ...
Unpacking exfat-utils (1.0.1-1) ...
Processing triggers for man-db (2.6.7.1-1) ...
exfat-fuse (1.0.1-1) 설정하는 중입니다 ...
exfat-utils (1.0.1-1) 설정하는 중입니다 ...

exfat-utils / exfat-fuse 를 설치하면 된다.

재부팅 안해도 바로 인식한다.



반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,

모바일에서 ssh 터널링을 해보자.

지난번에 icinga 모니터링(http://blog.1day1.org/547)을 세팅한후에 웹화면을 모바일에서도 보려고 한다.

그냥 공유기/서버에 포트포워딩을 할까 하다가 ssh 터널링으로 해보기로 한다.
PC 에서는 putty 등으로 터널링을 하면 된다.

모바일에서는 ConnectBot 이라는 앱을 이용한다.


# 서버 접속 설정(포트포워딩)

1) 하단 부분에 접속할 서버를 세팅한다 (계정@서버주소:포트 형식)


2) 생성된 리스트의 항목을 누르고 있으면 아래처럼 포트 포워딩을 할 수 있다.


3) 처음에는 비어있을 것인데 폰의 메뉴탭(또는 윈도우탭을 오래누르면 된다)을 누르면 포트를 추가할 수 있다.


4) Source Port 는 폰에서 접속할 포트. Destination 은 서버측의 IP:포트 가 된다.(ssh 터널링을 해봤으면 익숙 할 것이다)

위와 같이 설정후에 접속해보면 ssh 터널링이 연결되어 있을 것이다.

폰에서 모니터링 서버에 접속해서 볼 수 있게 된다. 그런데, 패스워드를 입력해야 한다.
공개키를 사용해서 바로 접속하도록 해본다.

# 공개키 사용하기

1) 공개키 관리 접속 및 설정.(폰의 메뉴키를 누르면 나온다.)


2) 서버키를 생성한다.(역시 메뉴키를 누른다) - Generate 는 새로생성.
  이미 키가 있다면 import 로 한다.


3) 아래 처럼 입력할 부분을 넣어준다.(난 암호를 비워놨다.)
   Generate 를 누르면 공개키를 생성하게 된다.


4) 아래처럼 나오면 파란 부분을 문질러주면 된다.


5) 생성이 된후에 공개키를 복사해서 메일같은 것으로 보낸후 서버에 추가해주면 된다.
  서버의 .ssh/authorized_keys 에 넣어주면 된다.


6) 설정후에 이 공개키를 서버접속시 사용하도록 한다.(서버 설정에서 Edit host 로 들어간다)
   Use pubkey authentication 를 누르면 설정했던 키가 나온다. 해당 키를 선택한다.

서버에 접속을 하면 바로 접속이 될 것이다.

접속한 후에 모니터링화면을 접속해본다.
localhost:8833 포트가 ssh 터널링을 통해 원격지 서버의 모니터링 포트로 접속해서 보여주게 된다.

공개적인 것이 아닌 경우 이런식으로 ssh 터널링을 하면 좋은 것 같다.
성능도 그렇게 나쁘지는 않은 것 같다.


반응형

WRITTEN BY
1day1
하루하루 즐거운일 하나씩, 행복한일 하나씩 만들어 가요.

,