You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by David Leangen <ap...@leangen.net> on 2020/04/26 10:48:45 UTC
Re: Problems connecting to Cassandra using Docker
Hi,
Several months later, I want to give JAMES another try.
In the meantime, I have familiarized myself a little bit with Docker, and have started moving all of my infrastructure to Kubernetes. I am now interested in going directly to Kubernetes (bypassing Docker and Docker Compose). I am more than happy to submit PRs as well as I figure it out.
However, for me to start working with JAMES, I am not even able to build the project via Maven. Worse, I am unable to understand from the documentation what needs to be done.
Since this is now off topic for this thread, I will open another thread.
Thanks,
=David
> On Nov 4, 2019, at 16:36, David Leangen <ap...@leangen.net> wrote:
>
>
> Hi Benoit,
>
> Sure, would be happy to.
>
> I am still a Docker novice, but I am learning. If my learnings can be of any help to others, that would be nice.
>
>
> Cheers,
> =David
>
>
>
>> On Nov 4, 2019, at 16:17, Tellier Benoit <bt...@apache.org> wrote:
>>
>> Hi David,
>>
>> We currently have an open ticket for documenting network usage:
>>
>> - JAMES-2333 Docker links concidered legacy [1]
>>
>> [1] https://issues.apache.org/jira/browse/JAMES-2333
>>
>> Would you like to contribute some documentation on the topic?
>>
>> Benoit Tellier
>>
>>
>>
>> On 02/11/2019 19:59, David Leangen wrote:
>>>
>>> Hi,
>>>
>>> Just for anybody who ever somehow stumbles across this thread, I wanted to provide some closure.
>>>
>>> I did not know that there was a difference between a named network in Docker, and the default bridge network. (I am currently using v19.) The differences are described here:
>>>
>>> https://docs.docker.com/network/bridge/##differences-between-user-defined-bridges-and-the-default-bridge <https://docs.docker.com/network/bridge/##differences-between-user-defined-bridges-and-the-default-bridge>
>>>
>>>
>>> Connecting to Cassandra is a piece of cake if you use a named network. Note that all containers need to belong to the same network. Docker will handle all the networking automatically.
>>>
>>>
>>> That’s all there was to it. For some reason it took me a very long time to actually find that information.
>>>
>>>
>>> Cheers,
>>> =David
>>>
>>>
>>>
>>>> On Oct 29, 2019, at 19:14, David Leangen <ap...@leangen.net> wrote:
>>>>
>>>>
>>>> Hi Benoit,
>>>>
>>>> Thank you very much for your hints. That gives me some ideas of a few more things I can investigate.
>>>>
>>>> Cheers,
>>>> =David
>>>>
>>>>
>>>>
>>>>
>>>>> On Oct 29, 2019, at 12:58, Tellier Benoit <bt...@apache.org> wrote:
>>>>>
>>>>> Hello David,
>>>>>
>>>>> - 1. Does the `cassandra` DNS entry within the James container resolves
>>>>> to Cassandra? (this can be achieved with links or network).
>>>>>
>>>>> - 2. A restarting Cassandra (with many data in the commitlog) might
>>>>> reject clients. Monitor Cassandra logs to check if this happens.
>>>>>
>>>>> I also noticed you used an unoffical image for Cassandra. Could this be
>>>>> a cause for your issue? Are you sure cassandra is well started after
>>>>> your configuration modifications?
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Benoit
>>>>>
>>>>> On 28/10/2019 13:07, David Leangen wrote:
>>>>>>
>>>>>> Hi!
>>>>>>
>>>>>> I am sure the problem is due to my inexperience with Docker and Cassandra, and even more so networking between multiple Docker containers… but I have tried everything I can think of and would like to ask for some help. 😅
>>>>>>
>>>>>> I am getting this error:
>>>>>>
>>>>>> [root@e5cc3846b51c apache-james-3.3.0]# java -Dworking.directory=/opt/apache-james-3.3.0 -jar server/container/guice/cassandra-guice/target/james-server-cassandra-guice.jar
>>>>>> 2019-10-28 05:51:54,981 WARN [main] - [org.apache.james.modules.mailbox.ResilientClusterProvider]- Error establishing Cassandra connection. Next retry scheduled in PT5S ms
>>>>>> com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /172.17.0.2:9042 (com.datastax.driver.core.exceptions.TransportException: [/172.17.0.2:9042] Cannot connect))
>>>>>>
>>>>>>
>>>>>> The error is shown when I try to run JAMES from within a Docker container.
>>>>>>
>>>>>> Cassandra is up and running, and ought to be available via the IP address 172.17.0.2, on port 9042.
>>>>>>
>>>>>> [root@james ~]# ip addr
>>>>>> 1: lo: <SNIP>
>>>>>> 2: eth0: <SNIP>
>>>>>> 3: eth1: <SNIP>
>>>>>> 4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
>>>>>> link/ether 02:42:76:5f:17:bb brd ff:ff:ff:ff:ff:ff
>>>>>> inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
>>>>>> valid_lft forever preferred_lft forever
>>>>>> inet6 fe80::42:76ff:fe5f:17bb/64 scope link
>>>>>> valid_lft forever preferred_lft forever
>>>>>> 10: veth81426b0@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
>>>>>> link/ether 1a:70:e2:f3:7e:70 brd ff:ff:ff:ff:ff:ff link-netnsid 0
>>>>>> inet6 fe80::1870:e2ff:fef3:7e70/64 scope link
>>>>>> valid_lft forever preferred_lft forever
>>>>>> 12: vethc13d660@if11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
>>>>>> link/ether 5a:fd:2d:ad:df:12 brd ff:ff:ff:ff:ff:ff link-netnsid 1
>>>>>> inet6 fe80::58fd:2dff:fead:df12/64 scope link
>>>>>> valid_lft forever preferred_lft forever
>>>>>>
>>>>>> The two virtual ethernet ports are for the james and cassandra containers.
>>>>>>
>>>>>> Here is the run command for cassandra:
>>>>>>
>>>>>> docker run \
>>>>>> -dit \
>>>>>> -v /home/cassandra/conf:/opt/cassandra/latest/conf \
>>>>>> -v /home/cassandra/data:/data \
>>>>>> -v /home/cassandra/commitlog:/commitlog \
>>>>>> -v /home/cassandra/saved_caches:/saved_caches \
>>>>>> -v /home/cassandra/hints:/hints \
>>>>>> -p 7000:7000 \
>>>>>> -p 7001:7001 \
>>>>>> -p 7199:7199 \
>>>>>> -p 9042:9042 \
>>>>>> -p 9160:9160 \
>>>>>> --ulimit memlock=-1:-1 \
>>>>>> --memory='1g' \
>>>>>> --name=cassandra \
>>>>>> dleangen/cassandra:3.11.4
>>>>>>
>>>>>>
>>>>>> Here is docker ps from the host:
>>>>>>
>>>>>> [root@james ~]# docker ps
>>>>>> CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
>>>>>> e5cc3846b51c dleangen/james:3.3.0 "/bin/bash" 7 minutes ago Up 7 minutes youthful_pascal
>>>>>> 1fefe86df493 dleangen/cassandra:3.11.4 "cassandra -f" 9 minutes ago Up 9 minutes 0.0.0.0:7000-7001->7000-7001/tcp, 0.0.0.0:7199->7199/tcp, 0.0.0.0:9042->9042/tcp, 0.0.0.0:9160->9160/tcp cassandra
>>>>>>
>>>>>> Here is the /etc/hosts file in the Cassandra container:
>>>>>>
>>>>>> bash-4.2$ more /etc/hosts
>>>>>> 127.0.0.1 localhost
>>>>>> ::1 localhost ip6-localhost ip6-loopback
>>>>>> fe00::0 ip6-localnet
>>>>>> ff00::0 ip6-mcastprefix
>>>>>> ff02::1 ip6-allnodes
>>>>>> ff02::2 ip6-allrouters
>>>>>> 172.17.0.2 1fefe86df493
>>>>>>
>>>>>>
>>>>>> Cassandra is up. I tested that it is indeed available from within the Docker container over 127.0.0.1.
>>>>>>
>>>>>> So how the heck do I get my james container to be able to connect to it??
>>>>>>
>>>>>> (I plan to use Docker Compose later… right now I’m trying to just connect my containers directly.)
>>>>>>
>>>>>>
>>>>>> Thank you in advance for your help!!! 😇
>>>>>>
>>>>>> Cheers,
>>>>>> =David
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>>>>> For additional commands, e-mail: server-user-help@james.apache.org
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>>>> For additional commands, e-mail: server-user-help@james.apache.org
>>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>> For additional commands, e-mail: server-user-help@james.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org