mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-26 22:35:31 +02:00
added customer related tools
This commit is contained in:
parent
893c47a2e0
commit
100b821c1a
136
tools/joincluster
Executable file
136
tools/joincluster
Executable file
|
@ -0,0 +1,136 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Add the current ejabberd node in a cluster
|
||||
|
||||
# copyright (c) 2010 ProcessOne
|
||||
#
|
||||
# This script is proprietary software and cannot be published or redistribute.
|
||||
|
||||
# Return Code:
|
||||
# 0 : groovy baby
|
||||
# 11 : erl not found
|
||||
# 12 : erlc not found
|
||||
# 20 : database dir doesn't exist
|
||||
# 21 : database dir not writable
|
||||
# 21 : database dir variable not set
|
||||
# 30 : network issue
|
||||
# 31 : node names incompatibility
|
||||
|
||||
function error
|
||||
{
|
||||
echo "Error: $1" >&2
|
||||
exit $2
|
||||
}
|
||||
|
||||
echo "--------------------------------------------------------------------"
|
||||
echo ""
|
||||
echo "ejabberd cluster configuration"
|
||||
echo ""
|
||||
echo "This ejabberd node will be configured for use in an ejabberd cluster."
|
||||
echo "IMPORTANT: all local data from the database will be lost, and"
|
||||
echo "cluster database will be initialized. All data from the master"
|
||||
echo "node will be replicated to this one."
|
||||
echo ""
|
||||
echo "--------------------------------------------------------------------"
|
||||
echo "Press any key to continue, or Ctrl+C to stop now"
|
||||
read foo
|
||||
echo ""
|
||||
|
||||
echo "Make sure you have a running remote master ejabberd node"
|
||||
echo "Before continuing, you must copy the ~/.erlang.cookie file from"
|
||||
echo "remote master node and check ejabberd.cfg compatibility."
|
||||
echo "e.g. hosts definition must match on all nodes"
|
||||
echo ""
|
||||
echo "The remote master node name is defined as ERLANG_NODE into"
|
||||
echo "ejabberdctl.cfg on that remote node."
|
||||
echo ""
|
||||
echo -n "Remote master node name: "
|
||||
read REMOTE
|
||||
echo ""
|
||||
|
||||
cont=Y
|
||||
ping -q -c 1 ${REMOTE#*@} 2>/dev/null >/dev/null
|
||||
[ $? -eq 0 ] || {
|
||||
echo "Cannot ping ${REMOTE#*@}. Are you sure network setup is correct ?"
|
||||
echo -n "Should we continue anyway ? (Y/n) "
|
||||
read cont
|
||||
}
|
||||
cont=`echo $cont | tr a-z A-Z`
|
||||
[ "$cont" == "Y" ] || error "Check your network configuration (dns, firewall, etc...)" 30
|
||||
|
||||
HERE=`which "$0"`
|
||||
BASE=`dirname $HERE`/..
|
||||
ROOTDIR=`cd $BASE; pwd`
|
||||
. $ROOTDIR/bin/ejabberdctl stop 2>/dev/null >/dev/null
|
||||
NAME=-name
|
||||
[ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] && NAME=-sname
|
||||
PA=/tmp/clustersetup_$$
|
||||
CLUSTERSETUP=clustersetup
|
||||
CLUSTERSETUP_ERL=$PA/$CLUSTERSETUP.erl
|
||||
|
||||
REMOTENAME=-name
|
||||
[ "$REMOTE" = "${REMOTE%.*}" ] && REMOTENAME=-sname
|
||||
[ "$REMOTENAME" = "$NAME" ] || {
|
||||
echo "IMPORTANT!: node names are incompatible"
|
||||
echo "Remote node name is $REMOTE"
|
||||
echo "Local node name is $ERLANG_NODE"
|
||||
echo ""
|
||||
echo "Both node names must be short or fqdn names."
|
||||
echo "Using short and fqdn names is impossible."
|
||||
echo ""
|
||||
error "incompatible node names" 31
|
||||
}
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
|
||||
echo "Using commands:"
|
||||
which erl || error "can't find erl" 11
|
||||
which erlc || error "can't find erlc" 12
|
||||
echo ""
|
||||
|
||||
[ -d $EJABBERD_DB ] && rm -Rf $EJABBERD_DB
|
||||
mkdir $EJABBERD_DB || error "$EJABBERD_DB cannot be created" 20
|
||||
[ -w $EJABBERD_DB ] || error "$EJABBERD_DB directory is not writable" 21
|
||||
|
||||
cd $ROOTDIR
|
||||
mkdir -p $PA
|
||||
cat <<EOF > $CLUSTERSETUP_ERL
|
||||
-module($CLUSTERSETUP).
|
||||
|
||||
-export([start/0]).
|
||||
|
||||
set_table_copy(Table, _Node, {badrpc, Reason}) ->
|
||||
io:format("Error: cannot get storage type for table ~p on node $REMOTE:~n ~p~n",[Table, Reason]);
|
||||
set_table_copy(Table, Node, Type) ->
|
||||
io:format("setting table ~p to mode ~p~n",[Table, Type]),
|
||||
case mnesia:add_table_copy(Table, Node, Type) of
|
||||
{aborted, _} ->
|
||||
mnesia:change_table_copy_type(Table, Node, Type);
|
||||
_ ->
|
||||
ok
|
||||
end.
|
||||
|
||||
set_tables({badrpc, Reason}) ->
|
||||
io:format("ERROR: cannot get tables list on $REMOTE : ~p~n",[Reason]);
|
||||
set_tables([]) ->
|
||||
ok;
|
||||
set_tables([schema | Tables]) ->
|
||||
set_tables(Tables);
|
||||
set_tables([Table | Tables]) ->
|
||||
set_table_copy(Table, node(),
|
||||
rpc:call('$REMOTE', mnesia, table_info, [Table, storage_type])),
|
||||
set_tables(Tables).
|
||||
|
||||
start() ->
|
||||
io:format("~n",[]),
|
||||
set_table_copy(schema, node(), disc_copies),
|
||||
set_tables(rpc:call('$REMOTE', mnesia, system_info, [tables])),
|
||||
halt(0).
|
||||
EOF
|
||||
erlc -o $PA $CLUSTERSETUP_ERL
|
||||
erl $NAME $ERLANG_NODE -pa $PA $KERNEL_OPTS -mnesia extra_db_nodes "['$REMOTE']" dir "\"$EJABBERD_DB\"" -s mnesia -s $CLUSTERSETUP start
|
||||
rm -Rf $PA
|
||||
|
||||
echo "End."
|
||||
echo "Check that there is no error in the above messages."
|
93
tools/leavecluster
Executable file
93
tools/leavecluster
Executable file
|
@ -0,0 +1,93 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Remove the current ejabberd node in a cluster
|
||||
|
||||
# Return Code:
|
||||
# 0 : groovy baby
|
||||
# 11 : erl not found
|
||||
# 12 : erlc not found
|
||||
# 20 : database dir doesn't exist
|
||||
# 21 : database dir not writable
|
||||
# 21 : database dir variable not set
|
||||
|
||||
function error
|
||||
{
|
||||
echo "Error: $1" >&2
|
||||
exit $2
|
||||
}
|
||||
|
||||
echo "--------------------------------------------------------------------"
|
||||
echo ""
|
||||
echo "ejabberd cluster configuration"
|
||||
echo ""
|
||||
echo "This ejabberd node will be removed from the cluster."
|
||||
echo "IMPORTANT: this node will be stopped. At least one other clustered"
|
||||
echo "node must be running."
|
||||
echo ""
|
||||
echo "--------------------------------------------------------------------"
|
||||
echo "Press any key to continue, or Ctrl+C to stop now"
|
||||
read foo
|
||||
echo ""
|
||||
|
||||
HERE=`which "$0"`
|
||||
BASE=`dirname $HERE`/..
|
||||
ROOTDIR=`cd $BASE; pwd`
|
||||
. $ROOTDIR/bin/ejabberdctl stop 2>/dev/null >/dev/null
|
||||
$ROOTDIR/bin/ejabberdctl stopped
|
||||
PA=/tmp/clustersetup_$$
|
||||
CLUSTERSETUP=clustersetup
|
||||
CLUSTERSETUP_ERL=$PA/$CLUSTERSETUP.erl
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
|
||||
echo "Using commands:"
|
||||
which erl || error "can't find erl" 11
|
||||
which erlc || error "can't find erlc" 12
|
||||
echo ""
|
||||
|
||||
cd $ROOTDIR
|
||||
mkdir -p $PA
|
||||
cat <<EOF > $CLUSTERSETUP_ERL
|
||||
-module($CLUSTERSETUP).
|
||||
|
||||
-export([start/0]).
|
||||
|
||||
del_table_copy(Table, Node) ->
|
||||
case mnesia:del_table_copy(Table, Node) of
|
||||
{aborted, Reason} -> io:format("Error: can not remove ~p table: ~p~n", [Table, Reason]);
|
||||
_ -> io:format("table ~p removed from cluster~n", [Table])
|
||||
end.
|
||||
|
||||
del_tables([],_) ->
|
||||
ok;
|
||||
del_tables([schema | Tables], Node) ->
|
||||
del_tables(Tables, Node);
|
||||
del_tables([Table | Tables], Node) ->
|
||||
del_table_copy(Table, Node),
|
||||
del_tables(Tables, Node).
|
||||
|
||||
start() ->
|
||||
io:format("~n",[]),
|
||||
Removed = node(),
|
||||
case mnesia:system_info(running_db_nodes)--[Removed] of
|
||||
[] -> io:format("Error: no other node running in the cluster~n");
|
||||
Nodes ->
|
||||
del_tables(mnesia:system_info(local_tables), Removed),
|
||||
mnesia:stop(),
|
||||
case rpc:call(hd(Nodes), mnesia, del_table_copy, [schema, Removed]) of
|
||||
{badrpc,Reason} -> io:format("Error: can not unregister node ~p from cluster: ~p~n", [Removed, Reason]);
|
||||
{aborted,Reason} -> io:format("Error: can not unregister node ~p from cluster: ~p~n", [Removed, Reason]);
|
||||
{atomic, ok} ->
|
||||
mnesia:delete_schema([Removed]),
|
||||
io:format("node ~p removed from cluster~n", [Removed])
|
||||
end
|
||||
end,
|
||||
halt(0).
|
||||
EOF
|
||||
erlc -o $PA $CLUSTERSETUP_ERL
|
||||
erl $NAME $ERLANG_NODE -pa $PA $KERNEL_OPTS -mnesia dir "\"$EJABBERD_DB\"" -s mnesia -s $CLUSTERSETUP start
|
||||
rm -Rf $PA
|
||||
|
||||
echo "End."
|
||||
echo "Check that there is no error in the above messages."
|
38
tools/tcp-tuning.sh
Executable file
38
tools/tcp-tuning.sh
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
ulimit -n 562524
|
||||
# /etc/security/limits.conf
|
||||
#@ejabberd soft nofile 562000
|
||||
#@ejabberd hard nofile 562000
|
||||
# 4KB send buffer, 20,480 connections max at worst case
|
||||
#echo 83886080 > /proc/sys/net/core/wmem_max
|
||||
#echo 83886080 > /proc/sys/net/core/wmem_default
|
||||
echo 327680000 > /proc/sys/net/core/wmem_max
|
||||
echo 327680000 > /proc/sys/net/core/wmem_default
|
||||
# 16KB receive buffer, 20,480 connections max at worst case
|
||||
#echo 335544320 > /proc/sys/net/core/rmem_max
|
||||
#echo 335544320 > /proc/sys/net/core/rmem_default
|
||||
echo 1310720000 > /proc/sys/net/core/rmem_max
|
||||
echo 1310720000 > /proc/sys/net/core/rmem_default
|
||||
# Max open files
|
||||
echo 562524 > /proc/sys/fs/file-max
|
||||
# Fast port recycling (TIME_WAIT)
|
||||
echo 1 >/proc/sys/net/ipv4/tcp_tw_recycle
|
||||
echo 1 >/proc/sys/net/ipv4/tcp_tw_reuse
|
||||
# TIME_WAIT buckets increased
|
||||
echo 360000 > /proc/sys/net/ipv4/tcp_max_tw_buckets
|
||||
# FIN timeout decreased
|
||||
echo 15 > /proc/sys/net/ipv4/tcp_fin_timeout
|
||||
# SYN backlog increased
|
||||
echo 65536 > /proc/sys/net/ipv4/tcp_max_syn_backlog
|
||||
# SYN cookies enabled
|
||||
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
|
||||
# Local port range maximized
|
||||
echo "1024 65535" > /proc/sys/net/ipv4/ip_local_port_range
|
||||
# Netdev backlog increased
|
||||
echo 100000 > /proc/sys/net/core/netdev_max_backlog
|
||||
# Do no save route metrics
|
||||
echo 1 > /proc/sys/net/ipv4/route/flush
|
||||
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
|
||||
# Interface transmit queuelen increased
|
||||
ifconfig eth0 txqueuelen 10000
|
||||
|
Loading…
Reference in New Issue
Block a user