Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
9d0c5428
Commit
9d0c5428
authored
May 06, 2005
by
joreland@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ndb - autotest
update make-config script
parent
749a1f9a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
444 deletions
+63
-444
ndb/test/run-test/make-config.sh
ndb/test/run-test/make-config.sh
+63
-444
No files found.
ndb/test/run-test/make-config.sh
View file @
9d0c5428
#!/bin/sh
#!/bin/sh
# NAME
# make-config.sh - Makes a config file for mgm server
#
# SYNOPSIS
# make-config.sh [ -t <template> ] [-s] [ -m <machine conf> [ -d <directory> ]
#
# DESCRIPTION
#
# OPTIONS
#
# EXAMPLES
#
#
# ENVIRONMENT
# NDB_PROJ_HOME Home dir for ndb
#
# FILES
# $NDB_PROJ_HOME/lib/funcs.sh general shell script functions
#
#
# SEE ALSO
#
# DIAGNOSTICTS
#
# VERSION
# 1.0
# 1.1 021112 epesson: Adapted for new mgmt server in NDB 2.00
#
# AUTHOR
# Jonas Oreland
#
# CHANGES
# also generate ndbnet config
#
progname
=
`
basename
$0
`
baseport
=
""
synopsis
=
"make-config.sh [ -t template ] [ -m <machine conf> ] [ -d <dst directory> ][-s] [<mgm host>]"
basedir
=
""
proc_no
=
1
node_id
=
1
#: ${NDB_PROJ_HOME:?} # If undefined, exit with error message
dir_file
=
/tmp/dirs.
$$
config_file
=
/tmp/config.
$$
#: ${NDB_LOCAL_BUILD_OPTIONS:=--} # If undef, set to --. Keeps getopts happy.
add_procs
(){
# You may have to experiment a bit
# to get quoting right (if you need it).
#. $NDB_PROJ_HOME/lib/funcs.sh # Load some good stuff
trace
()
{
echo
$*
1>&2
}
syndie
()
{
trace
$*
exit
1
}
# defaults for options related variables
#
mgm_nodes
=
0
ndb_nodes
=
0
api_nodes
=
0
uniq_id
=
$$
.
$$
own_host
=
`
hostname
`
dst_dir
=
""
template
=
/dev/null
machines
=
/dev/null
verbose
=
yes
# used if error when parsing the options environment variable
#
env_opterr
=
"options environment variable: <<
$options
>>"
# Option parsing, for the options variable as well as the command line.
#
# We want to be able to set options in an environment variable,
# as well as on the command line. In order not to have to repeat
# the same getopts information twice, we loop two times over the
# getopts while loop. The first time, we process options from
# the options environment variable, the second time we process
# options from the command line.
#
# The things to change are the actual options and what they do.
#
add_node
(){
no
=
$1
;
shift
type
=
$1
;
shift
type
=
$1
;
shift
echo
$*
|
awk
'BEGIN{FS=":";}{h=$1; if(h=="localhost") h="'
$own_host
'";
while
[
$#
-ne
0
]
printf("%s_%d_host=%s\n", "'
$type
'", "'
$no
'", h);
do
if(NF>1 && $2!="") printf("%s_%d_port=%d\n",
add_proc
$type
$1
"'
$type
'", "'
$no
'", $2);
shift
if(NF>2 && $3!="") printf("%s_%d_dir=%s\n",
done
"'
$type
'", "'
$no
'", $3);
}'
}
add_mgm_node
(){
mgm_nodes
=
`
cat
/tmp/mgm_nodes.
$uniq_id
|
grep
"_host="
|
wc
-l
`
mgm_nodes
=
`
expr
$mgm_nodes
+ 1
`
while
[
$#
-gt
0
]
do
add_node
${
mgm_nodes
}
mgm_node
$1
>>
/tmp/mgm_nodes.
$uniq_id
shift
mgm_nodes
=
`
expr
$mgm_nodes
+ 1
`
done
}
add_ndb_node
(){
ndb_nodes
=
`
cat
/tmp/ndb_nodes.
$uniq_id
|
grep
"_host="
|
wc
-l
`
ndb_nodes
=
`
expr
$ndb_nodes
+ 1
`
while
[
$#
-gt
0
]
do
add_node
${
ndb_nodes
}
ndb_node
$1
>>
/tmp/ndb_nodes.
$uniq_id
shift
ndb_nodes
=
`
expr
$ndb_nodes
+ 1
`
done
}
add_api_node
(){
api_nodes
=
`
cat
/tmp/api_nodes.
$uniq_id
|
grep
"_host="
|wc
-l
`
api_nodes
=
`
expr
$api_nodes
+ 1
`
while
[
$#
-gt
0
]
do
add_node
${
api_nodes
}
api_node
$1
>>
/tmp/api_nodes.
$uniq_id
shift
api_nodes
=
`
expr
$api_nodes
+ 1
`
done
}
}
rm
-rf
/tmp/mgm_nodes.
$uniq_id
;
touch
/tmp/mgm_nodes.
$uniq_id
add_proc
(){
rm
-rf
/tmp/ndb_nodes.
$uniq_id
;
touch
/tmp/ndb_nodes.
$uniq_id
dir
=
""
rm
-rf
/tmp/api_nodes.
$uniq_id
;
touch
/tmp/api_nodes.
$uniq_id
conf
=
""
case
$type
in
for
optstring
in
"
$options
"
""
# 1. options variable 2. cmd line
mgm
)
do
dir
=
"ndb_mgmd"
conf
=
"[ndb_mgmd]
\n
Id:
$node_id
\n
HostName:
$2
\n
"
while
getopts
d:m:t:n:o:a:b:p:s i
$optstring
# optstring empty => no arg => cmd line
node_id
=
`
expr
$node_id
+ 1
`
do
;;
case
$i
in
api
)
dir
=
"ndb_api"
q
)
verbose
=
""
;;
# echo important things
conf
=
"[api]
\n
Id:
$node_id
\n
HostName:
$2
\n
"
t
)
template
=
$OPTARG
;;
# Template
node_id
=
`
expr
$node_id
+ 1
`
d
)
dst_dir
=
$OPTARG
;;
# Destination directory
;;
m
)
machines
=
$OPTARG
;;
# Machine configuration
ndb
)
s
)
mgm_start
=
yes
;;
# Make mgm start script
dir
=
"ndb"
\?
)
syndie
$env_opterr
;;
# print synopsis and exit
conf
=
"[ndbd]
\n
Id:
$node_id
\n
HostName:
$2
\n
"
node_id
=
`
expr
$node_id
+ 1
`
;;
mysqld
)
dir
=
"mysqld"
conf
=
"[mysqld]
\n
Id:
$node_id
\n
HostName:
$2
\n
"
node_id
=
`
expr
$node_id
+ 1
`
;;
mysql
)
dir
=
"mysql"
;;
esac
esac
done
dir
=
"
$proc_no
.
$dir
"
proc_no
=
`
expr
$proc_no
+ 1
`
[
-n
"
$optstring
"
]
&&
OPTIND
=
1
# Reset for round 2, cmdline options
echo
-e
$dir
>>
$dir_file
if
[
"
$conf
"
]
env_opterr
=
# Round 2 should not use the value
then
echo
-e
$conf
>>
$config_file
done
fi
shift
`
expr
$OPTIND
- 1
`
if
[
-z
"
$dst_dir
"
]
then
verbose
=
fi
skip
(){
no
=
$1
;
shift
shift
$no
echo
$*
}
}
# --- option parsing done ---
grep
"^ndb: "
$machines
|
while
read
node
do
node
=
`
skip 1
$node
`
add_ndb_node
$node
done
grep
"^api: "
$machines
|
while
read
node
do
node
=
`
skip 1
$node
`
add_api_node
$node
done
grep
"^mgm: "
$machines
|
while
read
nod
e
cat
$1
|
while
read
lin
e
do
do
node
=
`
skip 1
$node
`
case
$line
in
add_mgm_node
$node
baseport:
*
)
baseport
=
`
echo
$line
|
sed
's/baseport[ ]*:[ ]*//g'
`
;;
done
basedir:
*
)
basedir
=
`
echo
$line
|
sed
's/basedir[ ]*:[ ]*//g'
`
;;
mgm:
*
)
add_procs mgm
`
echo
$line
|
sed
's/mgm[ ]*:[ ]*//g'
`
;;
tmp
=
`
grep
"^baseport: "
$machines
|
tail
-1
|
cut
-d
":"
-f
2
`
api:
*
)
add_procs api
`
echo
$line
|
sed
's/api[ ]*:[ ]*//g'
`
;;
if
[
"
$tmp
"
]
ndb:
*
)
add_procs ndb
`
echo
$line
|
sed
's/ndb[ ]*:[ ]*//g'
`
;;
then
mysqld:
*
)
add_procs mysqld
`
echo
$line
|
sed
's/mysqld[ ]*:[ ]*//g'
`
;;
baseport
=
`
echo
$tmp
`
mysql:
*
)
add_procs mysql
`
echo
$line
|
sed
's/mysql[ ]*:[ ]*//g'
`
;;
else
esac
syndie
"Unable to find baseport"
fi
trim
(){
echo
$*
}
tmp
=
`
grep
"^basedir: "
$machines
|
tail
-1
|
cut
-d
":"
-f
2
`
if
[
"
$tmp
"
]
then
basedir
=
`
trim
$tmp
`
fi
# -- Load enviroment --
ndb_nodes
=
`
cat
/tmp/ndb_nodes.
$uniq_id
|
grep
"_host="
|
wc
-l
`
api_nodes
=
`
cat
/tmp/api_nodes.
$uniq_id
|
grep
"_host="
|
wc
-l
`
mgm_nodes
=
`
cat
/tmp/mgm_nodes.
$uniq_id
|
grep
"_host="
|
wc
-l
`
.
/tmp/ndb_nodes.
$uniq_id
.
/tmp/api_nodes.
$uniq_id
.
/tmp/mgm_nodes.
$uniq_id
rm
-f
/tmp/ndb_nodes.
$uniq_id
/tmp/api_nodes.
$uniq_id
/tmp/mgm_nodes.
$uniq_id
# -- Verify
trace
"Verifying arguments"
if
[
!
-r
$template
]
then
syndie
"Unable to read template file:
$template
"
fi
if
[
$ndb_nodes
-le
0
]
then
syndie
"No ndb nodes specified"
fi
if
[
$api_nodes
-le
0
]
then
syndie
"No api nodes specified"
fi
if
[
$mgm_nodes
-gt
1
]
then
syndie
"More than one mgm node specified"
fi
if
[
$mgm_nodes
-eq
0
]
then
trace
"No managment server specified using
`
hostname
`
"
mgm_nodes
=
1
mgm_node_1
=
`
hostname
`
fi
if
[
-n
"
$dst_dir
"
]
then
mkdir
-p
$dst_dir
if
[
!
-d
$dst_dir
]
then
syndie
"Unable to create dst dir:
$dst_dir
"
fi
DST
=
/tmp/
$uniq_id
fi
# --- option verifying done ---
# Find uniq computers
i
=
1
while
[
$i
-le
$mgm_nodes
]
do
echo
`
eval echo
"
\$
"
mgm_node_
${
i
}
_host
`
>>
/tmp/hosts.
$uniq_id
i
=
`
expr
$i
+ 1
`
done
i
=
1
while
[
$i
-le
$ndb_nodes
]
do
echo
`
eval echo
"
\$
"
ndb_node_
${
i
}
_host
`
>>
/tmp/hosts.
$uniq_id
i
=
`
expr
$i
+ 1
`
done
i
=
1
while
[
$i
-le
$api_nodes
]
do
echo
`
eval echo
"
\$
"
api_node_
${
i
}
_host
`
>>
/tmp/hosts.
$uniq_id
i
=
`
expr
$i
+ 1
`
done
done
sort
-u
-o
/tmp/hosts.
$uniq_id
/tmp/hosts.
$uniq_id
cat
$dir_file
| xargs
mkdir
get_computer_id
(){
grep
-w
-n
$1
/tmp/hosts.
$uniq_id
|
cut
-d
":"
-f
1
}
get_mgm_computer_id
(){
a
=
`
eval echo
"
\$
"
mgm_node_
${
1
}
_host
`
get_computer_id
$a
}
get_ndb_computer_id
(){
a
=
`
eval echo
"
\$
"
ndb_node_
${
1
}
_host
`
get_computer_id
$a
}
get_api_computer_id
(){
a
=
`
eval echo
"
\$
"
api_node_
${
1
}
_host
`
get_computer_id
$a
}
# -- Write config files --
mgm_port
=
$baseport
(
i
=
1
#echo "COMPUTERS"
cat
/tmp/hosts.
$uniq_id
|
while
read
host
do
echo
"[COMPUTER]"
echo
"Id:
$i
"
echo
"ByteOrder: Big"
echo
"HostName:
$host
"
echo
i
=
`
expr
$i
+ 1
`
done
node_id
=
1
if
[
"
$2
"
]
echo
# Mgm process
echo
echo
"[MGM]"
echo
"Id:
$node_id
"
echo
"ExecuteOnComputer:
`
get_mgm_computer_id 1
`
"
echo
"PortNumber:
$mgm_port
"
node_id
=
`
expr
$node_id
+ 1
`
# Ndb processes
i
=
1
ndb_nodes
=
`
trim
$ndb_nodes
`
while
[
$i
-le
$ndb_nodes
]
do
echo
echo
"[DB]"
echo
"Id:
$node_id
"
echo
"ExecuteOnComputer:
`
get_ndb_computer_id
$i
`
"
echo
"FileSystemPath:
$basedir
/run/node-
${
node_id
}
-fs"
i
=
`
expr
$i
+ 1
`
node_id
=
`
expr
$node_id
+ 1
`
done
# API processes
i
=
1
while
[
$i
-le
$api_nodes
]
do
echo
echo
"[API]"
echo
"Id:
$node_id
"
echo
"ExecuteOnComputer:
`
get_api_computer_id
$i
`
"
i
=
`
expr
$i
+ 1
`
node_id
=
`
expr
$node_id
+ 1
`
done
# Connections
current_port
=
`
expr
$mgm_port
+ 1
`
echo
# Connect Mgm with all ndb-nodes
i
=
1
while
[
$i
-le
$ndb_nodes
]
do
echo
echo
"[TCP]"
echo
"NodeId1: 1"
echo
"NodeId2:
`
expr
$i
+ 1
`
"
echo
"PortNumber:
$current_port
"
i
=
`
expr
$i
+ 1
`
current_port
=
`
expr
$current_port
+ 1
`
done
# Connect All ndb processes with all ndb processes
i
=
1
while
[
$i
-le
$ndb_nodes
]
do
j
=
`
expr
$i
+ 1
`
while
[
$j
-le
$ndb_nodes
]
do
echo
echo
"[TCP]"
echo
"NodeId1:
`
expr
$i
+ 1
`
"
echo
"NodeId2:
`
expr
$j
+ 1
`
"
echo
"PortNumber:
$current_port
"
j
=
`
expr
$j
+ 1
`
current_port
=
`
expr
$current_port
+ 1
`
done
i
=
`
expr
$i
+ 1
`
done
# Connect all ndb-nodes with all api nodes
i
=
1
while
[
$i
-le
$ndb_nodes
]
do
j
=
1
while
[
$j
-le
$api_nodes
]
do
echo
echo
"[TCP]"
echo
"NodeId1:
`
expr
$i
+ 1
`
"
echo
"NodeId2:
`
expr
$j
+
$ndb_nodes
+ 1
`
"
echo
"PortNumber:
$current_port
"
j
=
`
expr
$j
+ 1
`
current_port
=
`
expr
$current_port
+ 1
`
done
i
=
`
expr
$i
+ 1
`
done
echo
)
>
$DST
trace
"Init config file done"
if
[
-z
"
$dst_dir
"
]
then
then
cat
$DST
cat
$2
$config_file
>>
/tmp/config2.
$$
rm
-f
$DST
mv
/tmp/config2.
$$
$config_file
rm
-f
/tmp/hosts.
$uniq_id
exit
0
fi
fi
###
for
i
in
`
find
.
-type
d
-name
'*.ndb_mgmd'
`
# Create Ndb.cfg files
# nodeid=2;host=localhost:2200
# Mgm node
mkcfg
(){
mkdir
-p
$dst_dir
/
${
2
}
.ndb_
${
1
}
(
echo
"OwnProcessId
$2
"
echo
"host://
${
mgm_node_1_host
}
:
${
mgm_port
}
"
)
>
$dst_dir
/
${
2
}
.ndb_
${
1
}
/Ndb.cfg
if
[
$1
=
"db"
]
then
mkdir
$dst_dir
/node-
${
2
}
-fs
fi
}
mkcfg mgm 1
cat
$DST
>
$dst_dir
/1.ndb_mgm/initconfig.txt
trace
"Creating Ndb.cfg for ndb nodes"
current_node
=
2
i
=
1
while
[
$i
-le
$ndb_nodes
]
do
do
mkcfg db
${
current_node
}
cp
$config_file
$i
/config.ini
i
=
`
expr
$i
+ 1
`
current_node
=
`
expr
$current_node
+ 1
`
done
done
trace
"Creating Ndb.cfg for api nodes"
rm
-f
$config_file
$dir_file
i
=
1
while
[
$i
-le
$api_nodes
]
do
mkcfg api
${
current_node
}
i
=
`
expr
$i
+ 1
`
current_node
=
`
expr
$current_node
+ 1
`
done
rm
-f
$DST
rm
-f
/tmp/hosts.
$uniq_id
exit
0
# vim: set sw=4:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment