If you have some memcached servers and want to transition to couchbase, you'll get into trouble because moxi, the couchbase memcached proxy will try to bind port 11211. I didn't find any way to change this port in the official documentation.
ps tells us moxi is spawned by an erlang process, the main couchbase one, ns_server.
998 3510 7.4 7.3 339884 300480 ? SLl Apr29 48:19 /opt/couchbase/lib/erlang/erts-5.8.5/bin/beam.smp -A 16 -sbt u -P 327680 -K true -MMmcs 30 -- -root /opt/couchbase/lib/erlang -progname erl -- -home /opt/couchbase -- -smp enable -setcookie nocookie -kernel inet_dist_listen_min 21100 inet_dist_listen_max 21299 error_logger false -sasl sasl_error_logger false -noshell -noinput -noshell -noinput -run ns_bootstrap -- -couch_ini /opt/couchbase/etc/couchdb/default.ini /opt/couchbase/etc/couchdb/default.d/capi.ini /opt/couchbase/etc/couchdb/default.d/geocouch.ini /opt/couchbase/etc/couchdb/local.ini -ns_server config_path "/opt/couchbase/etc/couchbase/static_config" -ns_server pidfile "/opt/couchbase/var/lib/couchbase/couchbase-server.pid" -ns_server nodefile "/opt/couchbase/var/lib/couchbase/couchbase-server.node" -ns_server cookiefile "/opt/couchbase/var/lib/couchbase/couchbase-server.cookie" -ns_server enable_mlockall true [....] 998 3601 0.0 0.0 80580 2488 ? Ssl Apr29 0:06 \_ /opt/couchbase/bin/moxi -Z port_listen=11211,default_bucket_name=default,downstream_max=1024,downstream_conn_max=4,connect_max_errors=5,connect_retry_interval=30000,connect_timeout=400,auth_timeout=100,cycle=200,downstream_conn_queue_timeout=200,downstream_timeout=5000,wait_queue_timeout=200 -z url=http://127.0.0.1:8091/pools/default/saslBucketsStreaming -p 0 -Y y -O stderr
Then you can dive into ns_server source; and find out in src/ns_config_default.erl :
{{node, node(), moxi}, [{port, misc:get_env_default(moxi_port, 11211)},
{verbosity, ""}
]},
% Note that we currently assume the ports are available
% across all servers in the cluster.
%
% This is a classic "should" key, where ns_port_sup needs
% to try to start child processes. If it fails, it should ns_log errors.
{{node, node(), port_servers},
[{moxi, path_config:component_path(bin, "moxi"),
["-Z", {"port_listen=~B,default_bucket_name=default,downstream_max=1024,downstream_conn_max=4,"
"connect_max_errors=5,connect_retry_interval=30000,"
"connect_timeout=400,"
"auth_timeout=100,cycle=200,"
"downstream_conn_queue_timeout=200,"
"downstream_timeout=5000,wait_queue_timeout=200",
[port]},
"-z", {"url=http://127.0.0.1:~B/pools/default/saslBucketsStreaming",
[{misc, this_node_rest_port, []}]},
"-p", "0",
"-Y", "y",
"-O", "stderr",
{"~s", [verbosity]}
],
[{env, [{"EVENT_NOSELECT", "1"},
{"MOXI_SASL_PLAIN_USR", {"~s", [{ns_moxi_sup, rest_user, []}]}},
{"MOXI_SASL_PLAIN_PWD", {"~s", [{ns_moxi_sup, rest_pass, []}]}}
]},
use_stdio, exit_status,
port_server_send_eol,
stderr_to_stdout,
stream]
},
So the function misc:get_env_default/2 (hello erlang folks) is responsible for setting this value
% Get an application environment variable, or a defualt value.
get_env_default(Var, Def) ->
case application:get_env(Var) of
{ok, Value} -> Value;
undefined -> Def
end.
That "environment" should not be mistaken with the "shell" environment. This call a standard erlang function : http://www.erlang.org/doc/apps/kernel/application.html#get_env-1
digging out in the couchbase config, you find /opt/couchbase/etc/couchbase/static_config that contains erlang code.
Add to this file
{moxi_port, 21112}.
and then rm /opt/couchbase/var/lib/couchbase/config/config.dat, restart daemon and you'll have moxi running on port 21112
this is a great post!