anchor.diff:          Username = proplists:get_value(username, Args),
           Password = proplists:get_value(password, Args),
   
  -        {StartOk, StartError} = onepanel_utils:apply_on_hosts(Dbs, ?MODULE, local_start, [Username, Password, hd(Dbs)], ?RPC_TIMEOUT),
  +        {StartOk, StartError} = onepanel_utils:apply_on_hosts(Dbs, ?MODULE, local_start, [Username, Password], ?RPC_TIMEOUT),
   
           case StartError of
               [] ->
  -                case dao:update_record(?GLOBAL_CONFIG_TABLE, ?CONFIG_ID, [{dbs, Dbs}]) of
  -                    ok -> ok;
  -                    Other ->
  -                        ?error("Cannot update database nodes configuration: ~p", [Other]),
  -                        onepanel_utils:apply_on_hosts(Dbs, ?MODULE, local_stop, [], ?RPC_TIMEOUT),
  -                        {error, {hosts, Dbs}}
  +                {_, JoinError} = onepanel_utils:apply_on_hosts(Dbs, ?MODULE, join_cluster, [Username, Password, hd(Dbs)], ?RPC_TIMEOUT),
  +                case JoinError of
  +                    [] ->
  +                        case dao:update_record(?GLOBAL_CONFIG_TABLE, ?CONFIG_ID, [{dbs, Dbs}]) of
  +                            ok -> ok;
  +                            Other ->
  +                                ?error("Cannot update database nodes configuration: ~p", [Other]),
  +                                onepanel_utils:apply_on_hosts(Dbs, ?MODULE, local_stop, [], ?RPC_TIMEOUT),
  +                                {error, {hosts, Dbs}}
  +                        end;
  +                    _ ->
  +                        ?error("Cannot add following hosts: ~p to database cluster", [JoinError]),
  +                        {error, {hosts, JoinError}}
                   end;
               _ ->
                   ?error("Cannot start database nodes on following hosts: ~p", [StartError]),
  
positive.code:     end.
  
  
  %% join_cluster/4
  %% ====================================================================
  %% @doc Adds database host to cluster. ClusterHost is one of current
  %% database cluster hosts and Host is supposed to join database cluster.
  %% @end
  -spec join_cluster(Username :: binary(), Password :: binary(), Host :: string(), ClusterHost :: string()) -> Result when
      Result :: ok | {error, Reason :: term()}.
  %% ====================================================================
  join_cluster(_, _, Host, Host) ->
      ok;
  
  join_cluster(Username, Password, Host, ClusterHost) ->
      try
          URL = "http://" ++ ClusterHost ++ ":" ++ ?DEFAULT_PORT ++ "/nodes/" ++ ?DEFAULT_DB_NAME ++ "@" ++ Host,
  
          {ok, "201", _, ResponseBody} = request(Username, Password, URL, put, []),
          true = proplists:get_value(<<"ok">>, mochijson2:decode(ResponseBody, [{format, proplist}])),
  
          ok
      catch
          _:Reason ->
              ?error("Cannot join database cluster: ~p", [Reason]),
              {error, Reason}
      end.
  
  
  %% request/3
  %% ====================================================================
  %% @doc Sends request to database node with default headers and options
  
negative.code: -export([install/1, uninstall/1, start/1, stop/1, restart/1]).
  
  %% API
  -export([local_install/0, local_uninstall/0, local_start/2, local_stop/0, join_cluster/3]).
  -export([change_username/3, local_change_username/3, change_password/4, local_change_password/3]).
  
  %% Defines how many times onepanel will try to verify database node start
  