요약
1. Why IPFS ?
왜 IPFS를 써야 되는가 ?
- Blockchain + DIDs (Distribution Identifications) 인증 + IPFS 파일공유 를 통한 콜라보레이션(협업) !!
- 스팀잇 글쓰기 블록사이즈 (65k) 등의 한계를 넘을 수 있음. ( 예시 > d.Tube 등 )
- URL로 손쉽게 파일 공유가 가능
[그림] IPFS로 올려 본 IPFS 로고
주소 : https://ipfs.io/ipfs/QmTDfwTbTkq8k36wPcpAaJWKgUkdmfUFWotWEmKJscHFxE[그림] IPFS로 올려 본 IPFS 로고
주소 : https://ipfs.io/ipfs/QmZ5GPnQMiAdfKcG6YfxizAavYx7qv7oKJe9u2Vx6G5z9G커맨드 : curl -F 'image=@/Users/wonsama/Desktop/guidedog.jpg' http://192.168.0.101:5001/api/v0/add2. 설치 및 사용법
- https://ipfs.io/docs/install/ 다운로드 ( windows, mac, linux 가능 )
- daemon을 기동 => http://localhost:5001:webui - file 탭을 통해 파일 업로드 가능 ( 일반적으로는 cli로 처리 )
3. 맺음말
- 향후에는 IPFS를 통해 다양한 컨텐츠가 공유 될 것이라고 생각 됩니다. 그래서 공부중 ...
- 잘 이해 안되시면 아래쪽 참조글 부터 읽어 보시길 권해 드립니다. ( 케블리
최고 !! )
본문시작 !!
IPFS 란 ?
IPFS (InterPlanetary File System)는 모든 컴퓨팅 장치를 동일한 파일 시스템으로 연결하려고 하는 P2P 분산 파일 시스템입니다.

설치
- ( ubuntu 16.04 기준으로 작성 )
- https://dist.ipfs.io/go-ipfs/ 에 접속하여 최신 버전 정보 확인
sudo apt-get update
sudo apt-get install golang-go -y
wget https://dist.ipfs.io/go-ipfs/v0.4.15/go-ipfs_v0.4.15_linux-386.tar.gz
tar xvfz go-ipfs_v0.4.15_linux-386.tar.gz
sudo mv go-ipfs/ipfs /usr/local/bin/ipfs
설치 스크립트 / 위와 같이 설치 이후, 기존 tar와 폴더는 제거해도 무관
설치경로 설정
- 기본적으로는 저장소가 ~/.ipfs 에 기록된다.
- 변경하기 위해서는 환경 변수값(
IPFS_PATH)을 추가 설정하면 됨.
echo 'export IPFS_PATH=/blockchain/.ipfs' >> ~/.profile
source ~/.profile
ipfs 설치 관련 환경변수 설정
설치 초기화
ipfs init을 하면 위에서 설정한IPFS_PATH폴더에 관련 파일이 생성된다.
ipfs init
[결과]
initializing IPFS node at /home/bc/dev/.ipfs
generating 2048-bit RSA keypair...done
peer identity: QmUGWEmvqir1NGWm2QiokuurbBRG6CksXFhPrD87SS3Zz2
to get started, enter:
ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme
설치 결과
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 cat ...명령어를 입력하면 ipfs에 존재하는 readme 파일 정보를 읽어 볼 수 있다.
ipfs cat /ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/quick-start
예시) quick-start 파일 보기
ipfs 파일 추가
$ ipfs add sample
[결과]
added QmeomffUNfmQy76CQGy9NdmqEnnHU9soCexBnGU3ezPHVH sample
샘플 파일 추가
참고로 파일은 1일이 지나면 ipfs 네트워크 상에서 지워집니다(가비지컬렉팅), 그래서 파일을 영속적으로 유지하고자 하려면 파일 추가 시 -pin 옵션을 로 설정된 파일(add 시 기본적으로 true임)이 네트워크 상에 존재해야 됩니다.(즉 파일이 pinned되어진 채로 daemon이 기동되어 있어야 파일이 유지됨)
ipfs 파일 감싸기
$ ipfs add wow.txt
added QmTppEckQeay4RZ5meNCSsUYbNDwVdYtd1FNz5vqRb3pap wow.txt
[web] 파일명 및 확장자 확인 불가
https://ipfs.io/ipfs/QmTppEckQeay4RZ5meNCSsUYbNDwVdYtd1FNz5vqRb3pap
$ ipfs add wow.txt -w
added QmTppEckQeay4RZ5meNCSsUYbNDwVdYtd1FNz5vqRb3pap wow.txt
added QmXKfsf2UKnLTnmaf87zerTeTT4DUrL6ZYg9pFeE6BvNPY
[web] 폴더로 감싸줘서 확인 가능
https://ipfs.io/ipfs/QmXKfsf2UKnLTnmaf87zerTeTT4DUrL6ZYg9pFeE6BvNPY/wow.txt
-w 옵션으로 파일을 감싸주면 손쉽게 파일의 정보를 확인할 수 있다.
ipfs 데몬 시작
- 데몬 등록 이후
http://localhost:5001/webui페이지를 통해 webui를 통해 손쉽게 작업 수행 가능 - 본인의 PC IP주소가 192.168.0.xxx 등과 같은 내부망인 경우 반드시 port forwarding (4001) 또는 dmz 설정을 해야 외부망으로 등록이 가능해 진다. 그래야지만 https://ipfs.io 사이트 등에서 정상적으로 파일 다운로드가 가능해짐. (
Swarm announcing정보 참조)
$ ipfs daemon
Initializing daemon...
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.0.11/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmdBS7g6pKF4S3pcrq8fm4e4NYNTBn6WaPAjTMxJmo7Ag5
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/192.168.0.11/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/127.0.0.1/tcp/5001
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready
ipfs에 파일 등록을 위한 데몬 기동
참조) 일반적으로
$ nohup ipfs daemon &과 같이 background로 기동함.
ipfs 파일보기
http://localhost:8080/ipfs/[HASH_VALUE]
L 로컬에서만 됨 !! (빠름)
http://localhost:5001/webui
L 업로드 된 파일 목록 정보를 손쉽게 조회 할 수 있음
https://ipfs.io/ipfs/[HASH_VALUE]
L 웹에서 볼 수도 있음 !! (느림)
ipfs 데몬 종료
$ ipfs shutdown
기동중인 ipfs daemon을 종료 시킬 때 사용한다
관련링크
MAIN
참조 한글
[케블리] #8. IPFS(InterPlanetary File System)이해하기 1부 : HTTP Web을 넘어서, IPFS Web으로
[케블리]#27. IPFS(InterPlanetary File System)이해하기 2부 / IPFS와 블록체인, 그리고 파일코인(Filecoin)
[케블리]#36. IPFS(InterPlanetary File System)이해하기 3부 / IPFS와 SWARM
REFRENCE
버그 (ipfs version 0.4.15)
ipfs-update동작하지 않음ipfs mount이상동작 : /ipns 정상마운팅 /ipfs 비정상 마운팅 => 파일을 볼 수 없음 -_-;