How does Fabric cli get ip of peer/orderer in the example of byfn? - hyperledger-fabric

Could any body tell me how the cli knows the IPs of other peers and orders just according to the Host in the configtx.yaml?
When does the DNS information generated?
Can anybody also tell me some more information about the configuration below "CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock"?

When you run fabric example, it always refer default credentials or already confirugred fabric configuration.
For example, if you use basic fabric example, you will run [your directory]/fabric-dev-servers/startFabric.sh
this file refer already configured information. One of them is connection profile. If you look at createPeerAdmin.sh file, you can find DevServer_connection.json. This file contains connection information for the fabric network.
As you are using byfn.sh, you can add the host ip address using "extra_hosts" in docker-compose.yaml file.
As there is no definition about this, it will use localhost as default.
https://medium.com/1950labs/setup-hyperledger-fabric-in-multiple-physical-machines-d8f3710ed9b4
like this,
extra_hosts:
- "peer0.org1.example.com:192.168.1.10"
- "ca.org1.example.com:192.168.1.15"
- "peer0.org2.example.com:192.168.1.20"
- "ca.org2.example.com:192.168.1.25"

Related

Azure Service Fabric application - hostname and host IP address

From Azure service fabric application how to get the hostname and host IP address of the node which is serving the current request? please suggest.
These environment variables are made available by SF:
Fabric_NodeIPOrFQDN - The IP or FQDN of the node, as specified in the cluster manifest file. (e.g. localhost or 10.0.0.1)
Fabric_NodeName - The node name of the node running the process (e.g. _Node_0)
Assuming that you're using C#, you can get an environment variable by using Environment.GetEnvironmentVariable
Other then using environment variables you can use the StatelessServiceContext class. It has a NodeContext property containing several interesting properties. In your service you can get the fqdn/ip address like this:
var address = Context.NodeContext.IPAddressOrFQDN;
Afaik the Node Name isn't tied to a machine name, it is a logical name. Node name can be user defined name. I'd say Environment.MachineName or Context.NodeContext.IPAddressOrFQDN is the most accurate.

Minifabric problem with apiserver and fabric 2.2.1 error join on the channel in multihost configuration

I had created a custom network with my organizations and my peers running 100% on a host with which I was interfacing via an ApiServer based on this: https://kctheservant.medium.com/rework-an-implementation-of-api-server-for-hyperledger-fabric-network-fabric-v2-2-a747884ce3dc The problem is when I switched to using networking on 2 hosts using docker swarm. When I join the channel from the second host I get the error: "unable to contact the endpoint". So I switched to using "minifabri" which promises easy use, and in fact the network is customized in a short time, even there it gave me an error when joining the channel of the second host, solved by setting the variable EXPOSE_ENDPOINT = true. The problem is that now nmon I can no longer get my apiserver to work, what I did is (as indicated in the Readme) replace the contents of the "main.js" file with my server code and run the "apprun" command. This gives me an error if I leave the server listening on a port, while it is successful if I comment out the last 2 lines of the code. The problem is that I don't have how to query the server if I don't have a listening port. Summarizing my questions are:
how can I create an api server done like that on minifabric?
alternatively how can I solve the problem on the Fabric base (I can't find an EXPOSE_ENDPOINT variable to set), probably the problem will be the same as the one I had on minifabric. Thanks to those who will help me.

Not able to create hyperledger fabric network using cello

I started cello and i am able to open user dashboard on 8081 but not the operator dashboard (I checked the port and found docker-proxy named service is running). Now on user dashboard i am trying to create a new network. But it's throwing error Apply Chain myorg fail. I have attached the screenshot. . I checked the post request reponse and it shows {"success":false,"message":"System maintenance, please try again later!"}
The Cello system is suggested to be deployed on multiple servers, at least 1 Master Node + 1 Worker Node.
Make sure that you have done installation of worker
http://hyperledger-cello.readthedocs.io/en/latest/installation_worker_docker/
Then make sure you added worker hosts in operator dashboard and chains are active.
http://localhost:8080/view/hosts (Add hosts)
http://localhost:8080/view/clusters?type=active (Check chains active or not)
For more information on cello installation refer: Hyperledger Cello Installation

Confluence in Docker can't see PostgreSQL in Docker

I'm trying to set up both Confluence and PostgreSQL in Docker. I've got them both up and running on my fully up to date CentOS 6 machine, with volume-mapping to the host file system so I can back them up easily. I can connect to PostgreSQL using pgAdmin from another machine just fine, and I can get into Confluence from a browser from that same machine. So, basically, both apps seem to be running as expected inside their respective containers and are accessible to the outside world, which of course eliminates a whole bunch of possibilities for my issue.
And that issue is that Confluence can't talk to PostgreSQL during initial setup, which is necessary for it to function. I'm getting connection failed errors (to be specific: "Can't reach database server or port : SQLState - 08001 org.postgresql.util.PSQLException: The connection attempt failed").
PostgreSQL is using the default 5432 port, which of course is exposed, otherwise I wouldn't be able to connect to it via pgAdmin, and of course I know the ID/password I'm trying is correct for the same reason (and besides, if it was an auth problem I wouldn't expect to see this error message). When I try to configure the database connection during Confluence's initial setup, I specify the IP address of the host machine, just like from pgAdmin on the other machine, but that doesn't work. I also tried some things that I basically knew wouldn't work (0.0.0.0, 127.0.0.1 and localhost).
I'm not sure what I need to do to make this work. Is there maybe some special method to specify the IP to a container from the same host machine, some nomenclature I'm not aware of?
At this point, I'm "okay" with Docker in terms of basic operations, but I'm far from an expert, so I'm a bit lost. I'm also not a big-time *nix user generally, though I can usually fumble my way through most things... but any hints would be greatly appreciated because I'm at a loss right now otherwise.
Thanks,
Frank
EDIT 1: As requested by someone below, here's my pg_hba.conf file, minus comments:
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
host all all all md5
try changing the second line of the pg_hba.conf file to the following:
host all all 0.0.0.0/32 trust
this will cause PostgreSQL to start accepting calls from any source address. Since a docker container is technically not operating on localhost but on its own ip, the current configuration causes PostgreSQL to block any connections to it.
Also check if confluence is searching for the database on localhost. If that is the case change that to the ip of the hostmachine within the docker network.
Success! The solution was to create a custom network and then use the image name in the connection string to PostreSQL container from Confluence container. In other words, I ran this:
docker network create -d bridge docker-net
Then, on both of the docker run commands for the PostgreSQL and Confluence containers, I added:
--network=docker-net
That way, when I ran through the Confluence configuration wizard, when it asked for the hostname for the PostgreSQL server, I used postgres (the name I gave the container) rather than an IP address or actual hostname. Docker makes that work thanks to the custom network. This also leaves the containers available via the IP of the host machine, so for example I can still connect to PostgreSQL via 192.168.123.12:5432, and of course I can launch Confluence in the browser via 192.168.123.12:8080.
FYI, I didn't even have to alter the pg_hba.conf file, I just used the official PostgreSQL image (latest) as it was, which is ideal.
Thanks very much to RSloeserwij for the suggestions... while none of them proved to be the solution I needed, they did put me on the right track in the Docker docs, which, after some reading, led me to understand a few things I didn't before and figure out the config magic I needed.

What is purpose of "CORE_PEER_CHAINCODELISTENADDRESS" environment variable?

In core.yaml
for peer we can define env. variable as chaincodelistenaddress (CORE_PEER_CHAINCODELISTENADDRESS).
what is purpose of this environment variable ?
Can we use this variable for instead of DEV mode ?
Currently I am trying to deploy network on Openshift platform. In this case when I set variable as CORE_PEER_CHAINCODELISTENADDRESS : peer01.local.com:7051 as same as CORE_PEER_ADDRESS :peer01.local.com:7051
it gives me error as address already bind while starting peer container.
If i assign different port CORE_PEER_CHAINCODELISTENADDRESS : peer01.local.com:7052
it gives me error as can not assign address peer01.local.com:7052.
This refers to the endpoint that the peer would listen to with regarding for the chaincode service.
Yes, you can use the variable when using dev-mode.
With regarding the errors - please specify your fabric version as things have changed slightly in the master branch.
In v1.0.0 (release branch), you can make your chaincode bind to the same port as the peer.
Also - please upload your core.yaml and the peer log for further information.
Alternatively you can seek advice in the fabric channel in https://chat.hyperledger.org/channel/fabric

Resources