Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose clouseau example #182

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rkleine
Copy link

@rkleine rkleine commented Jun 3, 2020

Overview

Docker compose example with clouseau plugin

GitHub issue number

Fixed #8

@kocolosk
Copy link
Member

kocolosk commented Jun 3, 2020

Nice! That’s a very welcome contribution. Will take a closer look later today.

@wohali
Copy link
Member

wohali commented Jun 3, 2020

We might also want to put this into the CouchDB docs, @kocolosk .

@kocolosk
Copy link
Member

kocolosk commented Jun 4, 2020

Yes that's a good idea @wohali.

@rkleine, I'd like to pull a version of these instructions into the main README of the repo for greater visibility. I'm mulling over simplifying them by pointing to a pre-built Clouseau image instead of including all of the configuration files and instructions to assemble a working container from a vanilla OpenJDK image. Of course we don't have any official or semi-official image for Clouseau, so that complicates matters a bit. Will give it some thought. Just wanted to keep you posted.

@wohali
Copy link
Member

wohali commented Jun 4, 2020

@kocolosk I'd only suggested a subdir because I assumed the files mentioned in here would go in there, separate to the README.

We can def. put this in the README here as well as ensure they end up in the Docker official docs if you like, as well as the main CouchDB docs.

@rkleine
Copy link
Author

rkleine commented Jun 9, 2020

Hi @kocolosk, Im using a local docker clouseau image. Maybe this save you some time

; ./etc/clouseau.ini
[clouseau]
name=clouseau@127.0.0.1
cookie=monster
dir=/var/lib/clouseau
max_indexes_open=500
# ./etc/log4j.properties
log4j.rootLogger=debug, CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %c [%p] %m%n
# Dockerfile
FROM openjdk:8-alpine

RUN apk add --update unzip

RUN wget -q -O clouseau-2.17.0-dist.zip https://github.com/cloudant-labs/clouseau/releases/download/2.17.0/clouseau-2.17.0-dist.zip
RUN unzip clouseau-2.17.0-dist.zip
RUN rm -rf clouseau-2.17.0-dist.zip

RUN mkdir -p /opt/clouseau/etc
COPY etc /opt/clouseau/etc

CMD java -server \
      -classpath '/clouseau-2.17.0/*' \
      -Xmx2G -Dsun.net.inetaddr.ttl=30 \
      -Dsun.net.inetaddr.negative.ttl=30 \
      -Dlog4j.configuration=file:/opt/clouseau/etc/log4j.properties \
      -XX:OnOutOfMemoryError="kill -9 %p" \
      -XX:+UseConcMarkSweepGC \
      -XX:+CMSParallelRemarkEnabled com.cloudant.clouseau.Main /opt/clouseau/etc/clouseau.ini
# build
docker build --tag clouseau:2.17.0 --tag clouseau:latest .

With docker run

# start couchdb
docker run --rm -p "5984:5984" --name couchdb -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=admin -e NODENAME=127.0.0.1 -e ERL_FLAGS="-setcookie monster" couchdb:3.1.0

# start cluseau
docker run --rm --network=container:couchdb --name clouseau clouseau:2.17.0

Or with docker-compose up

version: '3.8'
services:
  couchdb1:
    image: couchdb:3.1.0
    restart: always
    ports:
      - 5984:5984
    environment:
      - COUCHDB_USER=admin
      - COUCHDB_PASSWORD=admin
      - NODENAME=127.0.0.1
      - ERL_FLAGS=-setcookie monster

  clouseau1:
    image: clouseau:2.17.0
    restart: always
    depends_on:
      - couchdb1
    network_mode: service:couchdb1
docker-compose up
# test
curl -sSL http://localhost:5984 | grep "search"

@kocolosk kocolosk changed the base branch from master to main November 11, 2020 16:47
@wohali
Copy link
Member

wohali commented Mar 16, 2021

@rkleine Would love to merge this. Can you unify this with the changes proposed in #186 - if needed?

Alternately if you'd like to just put this directly in our documentation, I'd be happy to merge a PR in our repo there, https://github.com/apache/couchdb-documentation/pulls

@klaemo
Copy link
Contributor

klaemo commented Mar 23, 2021

I tried to get it running the way @rkleine described. Definitely got much further than I did on my own :D
Unfortunately clouseau crashes the instant I curl http://localhost:5984, though 🤔

clouseau1_1          | 2021-03-23 08:59:14,788 clouseau.main [INFO] Clouseau running as clouseau@127.0.0.1
clouseau1_1          | 2021-03-23 08:59:14,796 scalang.ErlangNode [DEBUG] deliverMonitor Pid('clouseau@127.0.0.1,2,1,2) -> Pid('clouseau@127.0.0.1,3,1,2) (Reference('clouseau@127.0.0.1,WrappedArray(0, 0, 0),2))
clouseau1_1          | 2021-03-23 08:59:14,799 scalang.ErlangNode [DEBUG] deliverMonitor Pid('clouseau@127.0.0.1,2,1,2) -> Pid('clouseau@127.0.0.1,4,1,2) (Reference('clouseau@127.0.0.1,WrappedArray(1, 0, 0),2))
clouseau1_1          | 2021-03-23 08:59:14,801 scalang.ErlangNode [DEBUG] deliverMonitor Pid('clouseau@127.0.0.1,2,1,2) -> Pid('clouseau@127.0.0.1,5,1,2) (Reference('clouseau@127.0.0.1,WrappedArray(2, 0, 0),2))
clouseau1_1          | 2021-03-23 08:59:43,372 scalang.node.ErlangHandler [DEBUG] handler message HandshakeSucceeded('couchdb@127.0.0.1,[id: 0x0f3eed1a, /127.0.0.1:45801 => /127.0.0.1:36147])
clouseau1_1          | 2021-03-23 08:59:43,380 scalang.node.ErlangHandler [DEBUG] handler message MonitorMessage(Pid('couchdb@1,4876,0,2),'net_k,Reference('couchdb@1,Vector(80488, 1221066753, 1159136377),2))
clouseau1_1          | 2021-03-23 08:59:43,381 scalang.ErlangNode [DEBUG] monitor Pid('couchdb@1,4876,0,2) -> 'net_k (Reference('couchdb@1,Vector(80488, 1221066753, 1159136377),2))
clouseau1_1          | 2021-03-23 08:59:43,382 scalang.ErlangNode [DEBUG] pids List(Pid('clouseau@127.0.0.1,1,1,2), Pid('clouseau@127.0.0.1,2,1,2), Pid('clouseau@127.0.0.1,3,1,2), Pid('clouseau@127.0.0.1,5,1,2), Pid('clouseau@127.0.0.1,0,0,2), Pid('clouseau@127.0.0.1,4,1,2))
clouseau1_1          | 2021-03-23 08:59:43,382 scalang.ErlangNode [WARN] Try to monitor non-live process: Pid('couchdb@1,4876,0,2) -> 'net_k (Reference('couchdb@1,Vector(80488, 1221066753, 1159136377),2))
clouseau1_1          | 2021-03-23 08:59:43,382 scalang.ErlangNode [DEBUG] handling monitor exit for Monitor(Pid('couchdb@1,4876,0,2),'net_k,Reference('couchdb@1,Vector(80488, 1221066753, 1159136377),2))
clouseau1_1          | 2021-03-23 08:59:43,383 scalang.ErlangNode [DEBUG] node scalang.ErlangNode@2e775cbc sending MonitorExitMessage('net_k,Pid('couchdb@1,4876,0,2),Reference('couchdb@1,Vector(80488, 1221066753, 1159136377),2),'noproc)
clouseau1_1          | 2021-03-23 08:59:43,385 scalang.epmd.EpmdHandler [DEBUG] Oh snap channel closed.
clouseau1_1          | 2021-03-23 08:59:43,385 scalang.epmd.EpmdHandler [DEBUG] Oh snap channel closed.
clouseau1_1          | 2021-03-23 08:59:43,387 scalang.node.ErlangHandler [DEBUG] handler message RegSend(Pid('couchdb@1,4876,0,2),'net_k,('$gen_,(Pid('couchdb@1,4876,0,2),Reference('couchdb@1,Vector(80488, 1221066753, 1159136377),2)),('is_a,'couchdb@1)))
clouseau1_1          | 2021-03-23 08:59:43,388 scalang.node.ErlangHandler [ERROR] error caught in erlang handler 'couchdb@127.0.0.1
[...] java stacktrace
clouseau1_1          | 2021-03-23 08:59:43,389 scalang.node.ErlangHandler [INFO] channel disconnected org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext@3f55b189 [id: 0x0f3eed1a, /127.0.0.1:45801 :> /127.0.0.1:36147] DISCONNECTED. peer: 'couchdb@127.0.0.1

I'm not sure what's going on. It looks like it can indeed reach epmd, but then it exits?

CouchDB is running fine in its container and I can successfully reach couch on localhost from within the clouseau container:

[info] 2021-03-23T08:50:58.630473Z couchdb@127.0.0.1 <0.11.0> -------- Application couch started on node 'couchdb@127.0.0.1'
[...]
[notice] 2021-03-23T08:54:50.455952Z couchdb@127.0.0.1 <0.2199.0> a6c58336d7 finish_cluster: ok
[...]
[notice] 2021-03-23T08:55:53.487534Z couchdb@127.0.0.1 <0.3014.0> 6488627f8b localhost:5984 172.24.0.1 undefined GET / 200 ok 84

Any ideas?

Update: Played around with https://hub.docker.com/r/kocolosk/couchdb-search which gives me the following errors:

In the CouchDB container:

[error] 2021-03-26T14:07:20.458212Z couchdb@127.0.0.1 <0.1148.0> -------- ** 'couchdb@127.0.0.1': Connection attempt to node 'clouseau@127.0.0.1' aborted since it cannot handle ["UTF8_ATOMS"].**

In the couchdb-search container:

couchdb-search_1     | 2021-03-26 14:07:20,467 scalang.node.ServerHandshakeHandler [ERROR] Channel closed during handshake
couchdb-search_1     | 2021-03-26 14:07:20,471 scalang.node.ErlangHandler [DEBUG] handler message HandshakeFailed('couchdb@127.0.0.1)
couchdb-search_1     | 2021-03-26 14:09:07,923 scalang.node.ErlangHandler [INFO] channel disconnected org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext@5de467e4 [id: 0x7785090e, /127.0.0.1:50937 :> /127.0.0.1:41465] DISCONNECTED. peer: null

@paolosanchi
Copy link

paolosanchi commented Nov 8, 2023

Hi @kocolosk, Im using a local docker clouseau image. Maybe this save you some time

; ./etc/clouseau.ini
[clouseau]
name=clouseau@127.0.0.1
cookie=monster
dir=/var/lib/clouseau
max_indexes_open=500
# ./etc/log4j.properties
log4j.rootLogger=debug, CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %c [%p] %m%n
# Dockerfile
FROM openjdk:8-alpine

RUN apk add --update unzip

RUN wget -q -O clouseau-2.17.0-dist.zip https://github.com/cloudant-labs/clouseau/releases/download/2.17.0/clouseau-2.17.0-dist.zip
RUN unzip clouseau-2.17.0-dist.zip
RUN rm -rf clouseau-2.17.0-dist.zip

RUN mkdir -p /opt/clouseau/etc
COPY etc /opt/clouseau/etc

CMD java -server \
      -classpath '/clouseau-2.17.0/*' \
      -Xmx2G -Dsun.net.inetaddr.ttl=30 \
      -Dsun.net.inetaddr.negative.ttl=30 \
      -Dlog4j.configuration=file:/opt/clouseau/etc/log4j.properties \
      -XX:OnOutOfMemoryError="kill -9 %p" \
      -XX:+UseConcMarkSweepGC \
      -XX:+CMSParallelRemarkEnabled com.cloudant.clouseau.Main /opt/clouseau/etc/clouseau.ini
# build
docker build --tag clouseau:2.17.0 --tag clouseau:latest .

With docker run

# start couchdb
docker run --rm -p "5984:5984" --name couchdb -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=admin -e NODENAME=127.0.0.1 -e ERL_FLAGS="-setcookie monster" couchdb:3.1.0

# start cluseau
docker run --rm --network=container:couchdb --name clouseau clouseau:2.17.0

Or with docker-compose up

version: '3.8'
services:
  couchdb1:
    image: couchdb:3.1.0
    restart: always
    ports:
      - 5984:5984
    environment:
      - COUCHDB_USER=admin
      - COUCHDB_PASSWORD=admin
      - NODENAME=127.0.0.1
      - ERL_FLAGS=-setcookie monster

  clouseau1:
    image: clouseau:2.17.0
    restart: always
    depends_on:
      - couchdb1
    network_mode: service:couchdb1
docker-compose up
# test
curl -sSL http://localhost:5984 | grep "search"

This 100% worked with couchdb version 3.1.0, but if I bump to 3.3.2 I get this error:

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   Monster detected ohno!, aborting startup.
   Please change the Erlang cookie in vm.args to the same
   securely generated random value on all nodes of this cluster.
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I've removed the ERL_FLAGS=-setcookie monster and couchdb starts, but when I query the index I get this error:

Could not connect to the Clouseau Java service at clouseau@127.0.0.1

@big-r81
Copy link

big-r81 commented Nov 8, 2023

Bring back the setcookie line. You need to set a cookie value other than "monster".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Provide Image with Clouseau / Fulltext Search
6 participants