[ipfs] ubuntu 16.04 에 IPFS 설치하기

in #kr6 years ago (edited)

blockchainmind_ipfs_intro_1.jpg

1_0kGmNu9xBXUUMRC9BdAJhQ.jpg


  1. 개발 기록을 남기기 위해 쓴 글 입니다.
  2. IPFS 어디다 쓰냐고여 ? 파일 업로드 할 때 쓰면 좋습니다. (feat busy.org) 동영상 스트리밍 할때도 좋고여 ( feat DTube )
  3. 왜 좋냐고여 ? 파일을 분산 해서 가져와 대역폭를 나눠가져와요 속도도 빠르죠+서버 부하가 줄어들죠, 그런데 왜 DTube는 느리냐고요 ? 국내에 서버가 없어요 ㅜㅜ 해외라 느려요 그리고 해당 자료를 다운받아 공유해야 빨라지는데 공유가 거의 없죠(IPFS Daemon 설치 필요)
  4. 기타 궁금한 점이 있음 댓글요

1. go/golang 설치

1.1 의존성 설치

sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt-get update
sudo apt-get install golang-go

1.2 PATH 추가 ( in ~/.profile )

export PATH=$PATH:/usr/local/go/bin
export PATH=$PATH:$GOPATH/bin
  • 경로상에 $GOPATH가 누락된 경우 go env 를 통해 경로정보(GOPATH) 확인 후 PATH에 추가

2. ipfs 설치

2.1 소스 다운로드

$ go get -u -d github.com/ipfs/go-ipfs

2.2 소스 빌드

$ cd $GOPATH/src/github.com/ipfs/go-ipfs<br>
$ make install
  • 이렇게 다운로드 받은 파일은 모두 GOPATH/bin 경로에 파일이 위치하게 된다.

3. ipfs 실행

3.1 초기화

$ ipfs init
initializing IPFS node at /home/wonsama/.ipfs
generating 2048-bit RSA keypair...done
peer identity: QmZVbfF459S3213213NBxxxxxxxxxxxxxxxxxxpCorJggzm6
to get started, enter:

  ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
  • 위와 같이 초기화 된 모습을 볼 수 있다.

3.2 IPFS 파일 보기

$ ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
Hello and Welcome to IPFS!

██╗██████╗ ███████╗███████╗
██║██╔══██╗██╔════╝██╔════╝
██║██████╔╝█████╗  ███████╗
██║██╔═══╝ ██╔══╝  ╚════██║
██║██║     ██║     ███████║
╚═╝╚═╝     ╚═╝     ╚══════╝

If you're seeing this, you have successfully installed
IPFS and are now interfacing with the ipfs merkledag!

 -------------------------------------------------------
| Warning:                                              |
|   This is alpha software. Use at your own discretion! |
|   Much is missing or lacking polish. There are bugs.  |
|   Not yet secure. Read the security notes for more.   |
 -------------------------------------------------------

Check out some of the other files in this directory:

  ./about
  ./help
  ./quick-start     <-- usage examples
  ./readme          <-- this file
  ./security-notes
  • 위와 같이 해당 파일 정보를 확인할 수 있다.
  • ipfs 네트워크 상에 존재하는 파일임 (local ipfs daemon 실행과 관련 없음)

3.3 IPFS 데몬 실행

$ ipfs daemon

3.4 IPFS SERVICE 등록해서 서버 기동 시 자동실행하기

sudo vi /etc/systemd/system/ipfs.service
[Unit]
Description=IPFS Daemon
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
ExecStart=/usr/local/bin/ipfs daemon --enable-namesys-pubsub
User=wonsama

[Install]
WantedBy=multi-user.target
  • ExecStart=/usr/local/bin/ipfs 부분을 GOPATH 를 참조하여 ipfs가 설치된 경로로 변경
  • User=wonsama 이 부분을 초기 서비스 기동 시 실행할 계정명으로 바꿔준다
sudo systemctl daemon-reload
sudo systemctl enable ipfs
sudo systemctl start ipfs
  • 서비스 활성화 및 실행
  • 정지하고 싶은 경우는 ... sudo systemctl stop ipfs
sudo systemctl status ipfs
● ipfs.service - IPFS Daemon
   Loaded: loaded (/etc/systemd/system/ipfs.service; enabled; vendor preset: enabled)
   Active: active (running) since 수 2018-08-22 13:24:24 KST; 3s ago
 Main PID: 17497 (ipfs)
   CGroup: /system.slice/ipfs.service
           └─17497 /home/wonsama/go/bin/ipfs daemon --enable-namesys-pubsub

 8월 22 13:24:26 wonsama ipfs[17497]: Swarm listening on /p2p-circuit/ipfs/QmZVbfF459S72AVxxxxxxxxxxxxxxkUZsJApCorJggzm6
 8월 22 13:24:26 wonsama ipfs[17497]: Swarm announcing /ip4/127.0.0.1/tcp/4001
 8월 22 13:24:26 wonsama ipfs[17497]: Swarm announcing /ip4/127.0.0.1/tcp/41364
 8월 22 13:24:26 wonsama ipfs[17497]: Swarm announcing /ip4/192.168.0.202/tcp/4001
 8월 22 13:24:26 wonsama ipfs[17497]: Swarm announcing /ip4/192.168.0.202/tcp/41364
 8월 22 13:24:26 wonsama ipfs[17497]: Swarm announcing /ip6/::1/tcp/4001
 8월 22 13:24:26 wonsama ipfs[17497]: Swarm announcing /ip6/::1/tcp/46805
 8월 22 13:24:26 wonsama ipfs[17497]: API server listening on /ip4/127.0.0.1/tcp/5001
 8월 22 13:24:26 wonsama ipfs[17497]: Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
 8월 22 13:24:26 wonsama ipfs[17497]: Daemon is ready
  • 서비스 동작상태 확인

3.5 게이트웨이를 공용으로 활성화 하기

$ vi ~/.ipfs/config


"Gateway": "/ip4/127.0.0.1/tcp/8080" 에서 
"Gateway": "/ip4/0.0.0.0/tcp/8080" 으로 변경처리

  • 기본적으로는 로컬에서만 접근이 가능함
    • 127.0.0.1 : 로컬전용
    • 0.0.0.0 : 외부망
    • 192.168.0.xxx : 내부망(공유기로부터 할당 받은 로컬 IP를 넣어준다)

4. 기타

4.1 톰캣 서비스 중지하기

sudo systemctl disable tomcat8
  • 위와 같이 명령어를 넣어주면 됨
  • 포트를 바꿔도 상관이 없지만... 현재 톰캣을 쓰지 않음 !

4.2 설치 시 기본 사용 포트정보

  • 4001 : SWARM, ip4/0.0.0.0
  • 40000+ : 4만번 이상 포트에서 SWARM 관련 포트가 생성됨
  • 5001 : API, ip4/127.0.0.1
  • 8080 : GATEWAY, ip4/127.0.0.1

webui localhost:5001/webui 로 접근하는 경우 로컬에 daemon이 설치 되어 있어야 됨에 유의(API의 ip4/192.168.0.xxx 로 변경해도 실제 로컬 데몬 정보를 참조)

4.2 참조링크

4.3 이전 글

Sort:  

와우.. 멋지네요
IPFS 검색 하다 들어왔습니다. 기대되네요 ^^
좋은 포스팅 감사해요!

At first I thank you for your interest in my articles and I hope to become friends. I am from Jordan, I love Korea, I love your food, I love the customs of the people of the countryside, I love your economic openness ... I hope we always stay friends

처음에는 내 기사에 관심을 가져 주셔서 감사 드리며 나는 친구가되기를 바랍니다. 나는 요르단 출신이고, 나는 한국을 사랑합니다. 나는 음식을 좋아합니다. 나는 시골 사람들의 풍습을 사랑합니다. 나는 경제적 개방성을 사랑합니다 ... 나는 항상 친구가되기를 바랍니다.

이렇게 유익한 글을 올려주셨는데
제가 따라 하기나 할지 걱정입니다.
그래도 리스팀합니다.
감사합니다.

개발관련 글이라 ㅜㅜ 그냥 응원도 감사할 따름이죠 ^^

파일을 분산 해서 가져와 대역폭를 나눠가져와요

파일을 가져올때 멀티세션으로 파일의 조각들을 여러 서버에서 가져오는 건가요?
웹브라우져에서 http로 연결을 하는데, 기본 멀티세션을 지원하나요?
busy.org에서 이미지를 IPFS 쓰는건 알았는데.. 여러서버에서 조각으로 가져오는지는 몰랐네요..

좀더 이야기해보면 ipfs daemon에서 초기에 data를 가져오는 부분에서 그렇게 동작합니다.(청킹(나눠진)된 데이터를 가장 가까운 ipfs 노드에서 수신)

ipfs daemon에서 데이터를 가져온 이후 gateway(비지웹, 디튜브웹)에서 해당 정보를 보여주는 것이죠

게이트웨이 서버측에서는 로컬 ipfs 노드에서 수신된 정보를 웹에 게시하는지라 웹자원(이미지,동영상)을 미리 가지고 있지 않아도 되고 요청 시 수신하여 게시하므로 자원을 아낄 수 있습니다. 특히 영상 같은 경우는 스트리밍을 지원하여 일부만 수신하기 때문에 효율이 더 좋고여

물론 한국같은 경우는 노드가 한국에 있어야 더 빠르겠죠 ㅠㅠ 이해가 되셨나요 ? ㅜㅜ

예.. ipfs daemon에서 각 노드에서 데이터를 가져올때 청킹된 데이터를 멀티세션으로 가져오고, 웹사이트(게이트웨이)에서는 ipfs daemon과 통신해서 보여주는 것이군요.
스트리밍도 지원한다고 하셨는데, ipfs daemon 이 스트리밍 프로토콜을 지원하는 것인가요?
아니면 웹사이트에서 ipfs daemon로 http range request를 하는 건가요?

미리 감사 드립니다.

ps.저도 인터넷 업계에 좀 있어봐서 용어를 대충은 이해합니다. ^^

ipfs daemon에서 스트리밍을 지원 합니다

그래서 ipfs로 mp4가 아니라 avi mkv 등과 같은 포맷을 업로드해도 웹상에서 잘 보여지네여 ^^ (테스트 도 해봄)

좋은 정보 잘보고 갑니다. 팔로잉 할께요~^^

Congratulations @wonsama! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of comments

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:
SteemitBoard and the Veterans on Steemit - The First Community Badge.

Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

pairplay 가 kr-dev 컨텐츠를 응원합니다! :)

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.033
BTC 64386.10
ETH 3142.17
USDT 1.00
SBD 3.98