For testing, I want to be able to run several IPFS nodes on a single machine.
This is the scenario: I am building small services on top of IPFS core library, following the Making your own IPFS service guide. When I try to put client and server on the same machine (note that each of them will create their own IPFS node), I will get the following:
panic: cannot acquire lock: Lock FcntlFlock of /Users/long/.ipfs/repo.lock failed: resource temporarily unavailable
Install IPFS on a server, create a new repo with ipfs init . Start a background IPFS node daemon process with: ipfs daemon & , add the files to the network with ipfs add -r <your-files> and pin the hash that you want to keep online forever with ipfs pin add -r <your-ipfs-hash/> .
IPFS is a peer-to-peer decentralized network that lets users back up files and websites by hosting them across numerous nodes. This ensures that content is resistant to censorship and centralized points of failure, such as server issues or coordinated attacks.
Nodes are an IPFS program that you run on your local computer to store files and connect to the IPFS network. They're the most crucial aspect of IPFS. Without nodes running the IPFS daemon (explained below), there would be no IPFS Network.
Usually, when you start with IPFS, you will use ipfs init
, which will create a new node. The default data and config stored for that particular node are located at ~/.ipfs
. Here is how you can create a new node and config it so it can run besides your default node.
For a new node you have to use ipfs init
again. Use for instance the following:
IPFS_PATH=~/.ipfs2 ipfs init
This will create a new node at ~/.ipfs2 (not using the default path).
As both of your nodes now bind to the same ports, you need to change the port configuration, so both nodes can run side by side. For this, open ~/.ipfs2/configand find
Addresses`:
"Addresses": {
"API": "/ip4/127.0.0.1/tcp/5001",
"Gateway": "/ip4/127.0.0.1/tcp/8080",
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001"
]
}
To for example the following:
"Addresses": {
"API": "/ip4/127.0.0.1/tcp/5002",
"Gateway": "/ip4/127.0.0.1/tcp/8081",
"Swarm": [
"/ip4/0.0.0.0/tcp/4002",
"/ip6/::/tcp/4002"
]
}
With this, you should be able to run both node .ipfs and .ipfs2 on a single machine.
Notes:
IPFS_PATH=~/.ipfs2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With