Skip to content

Commit a091bfb

Browse files
zhuzhengyi1awzhgw
authored andcommitted
update run_docker with more options
Signed-off-by: zhuzhengyi1 <[email protected]>
1 parent 4a7bb8b commit a091bfb

File tree

5 files changed

+139
-66
lines changed

5 files changed

+139
-66
lines changed

.travis.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,5 @@ before_install:
88
- docker pull chubaofs/centos-ltp:1.0
99

1010
script:
11-
#- docker run --rm -v `pwd`:/go/src/github.com/chubaofs/cfs "chubaofs/cfs-build:1.0" /bin/bash -c "cd /go/src/github.com/chubaofs/cfs && make ci-test"
12-
- docker run --rm -v `pwd`:/go/src/github.com/chubaofs/chubaofs "chubaofs/cfs-build:1.0" /bin/bash -c "cd /go/src/github.com/chubaofs/chubaofs && make build_server"
13-
- docker run --rm -v `pwd`:/go/src/github.com/chubaofs/chubaofs "chubaofs/centos-ltp:1.0" /bin/bash -c "cd /go/src/github.com/chubaofs/chubaofs && make build_client"
14-
- docker-compose -f docker/docker-compose.yml up -d servers
15-
- docker-compose -f docker/docker-compose.yml run --rm client
11+
- docker/run_docker.sh -l
1612

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
## Overview
1515

1616

17-
ChubaoFS (储宝文件系统) is a distributed file system for cloud native applications. It has the following features:
17+
ChubaoFS (储宝文件系统) is a distributed file system for cloud native applications. It has the following features:
1818

1919
* scale-out metadata management
2020

@@ -27,13 +27,26 @@ ChubaoFS (储宝文件系统) is a distributed file system for cloud native appl
2727
* POSIX-compatible
2828

2929
For more details, please refer to our SIGMOD 2019 paper "ChubaoFS: A Distributed File System for Large Scale Container Platforms".
30-
30+
3131

3232
## Document
3333
https://chubaofs.readthedocs.io/en/latest/
3434

3535
https://chubaofs.readthedocs.io/zh_CN/latest/
3636

37+
## Docker
38+
39+
Under docker dir, there has run_docker.sh tool to run chubaofs with docker-compose, as follow command:
40+
```
41+
$ docker/run_docker.sh -r -d /data/disk
42+
```
43+
more options with
44+
```
45+
$ docker/run_docker.sh -h
46+
47+
```
48+
49+
3750
## License
3851

3952

docker/docker-compose.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ services:
2020
- datanode1
2121
- datanode2
2222
- datanode3
23+
- datanode4
2324
networks:
2425
extnetwork:
2526

@@ -92,6 +93,7 @@ services:
9293
- "master1"
9394
- "master2"
9495
- "master3"
96+
9597
metanode2:
9698
image: chubaofs/cfs-build:1.0
9799
ports:
@@ -139,6 +141,7 @@ services:
139141
- "17330"
140142
- "17340"
141143
volumes:
144+
- ${DiskPath:-./disk}/1:/cfs/disk
142145
- ./bin:/cfs/bin
143146
- ./conf/datanode.json:/cfs/conf/datanode.json
144147
- ./script/start_datanode.sh:/cfs/script/start.sh
@@ -158,6 +161,7 @@ services:
158161
- "17330"
159162
- "17340"
160163
volumes:
164+
- ${DiskPath:-./disk}/2:/cfs/disk
161165
- ./bin:/cfs/bin
162166
- ./conf/datanode.json:/cfs/conf/datanode.json
163167
- ./script/start_datanode.sh:/cfs/script/start.sh
@@ -177,6 +181,28 @@ services:
177181
- "17330"
178182
- "17340"
179183
volumes:
184+
- ${DiskPath:-./disk}/3:/cfs/disk
185+
- ./bin:/cfs/bin
186+
- ./conf/datanode.json:/cfs/conf/datanode.json
187+
- ./script/start_datanode.sh:/cfs/script/start.sh
188+
command: /bin/sh /cfs/script/start.sh
189+
depends_on:
190+
- "metanode1"
191+
- "metanode2"
192+
- "metanode3"
193+
restart: on-failure
194+
networks:
195+
extnetwork:
196+
197+
datanode4:
198+
image: chubaofs/cfs-build:1.0
199+
ports:
200+
- "17310"
201+
- "17320"
202+
- "17330"
203+
- "17340"
204+
volumes:
205+
- ${DiskPath:-./disk}/4:/cfs/disk
180206
- ./bin:/cfs/bin
181207
- ./conf/datanode.json:/cfs/conf/datanode.json
182208
- ./script/start_datanode.sh:/cfs/script/start.sh
@@ -205,5 +231,7 @@ services:
205231
security_opt:
206232
- "apparmor:unconfiged"
207233
command: /bin/bash /cfs/script/start.sh
234+
depends_on:
235+
- "servers"
208236
networks:
209237
extnetwork:

docker/run_docker.sh

Lines changed: 94 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,107 @@
1-
#! /bin/sh
1+
#! /bin/bash
22

33
RootPath=$(cd $(dirname $0)/..; pwd)
44
GOPATH=/go
55
GoAppName=github.com/chubaofs/chubaofs
66
GoAppSrcPath=$GOPATH/src/$GoAppName
77
ServerBuildDockerImage="chubaofs/cfs-build:1.0"
88
ClientBuildDockerImage="chubaofs/centos-ltp:1.0"
9+
DataNodeNum=4
10+
export DiskPath="./disk"
11+
12+
help() {
13+
cat <<EOF
14+
15+
Usage: ./run_docker.sh [ -h | --help ] [ -d | --disk </disk/path> ] [ -l | --ltptest ]
16+
-h, --help show help info
17+
-d, --disk </disk/path> set datanode local disk path
18+
-c, --clear clear old docker image
19+
-l, --ltptest run ltp test
20+
-r, --run run
21+
EOF
22+
exit 0
23+
}
924

10-
# test & build
11-
docker run --rm -v ${RootPath}:/go/src/github.com/chubaofs/chubaofs $ServerBuildDockerImage /bin/bash -c "cd $GoAppSrcPath && make build_server"
12-
docker run --rm -v ${RootPath}:/go/src/github.com/chubaofs/chubaofs $ClientBuildDockerImage /bin/bash -c "cd $GoAppSrcPath && make build_client"
1325

14-
#docker-compose -f ${RootPath}/docker/docker-compose-demo.yml down
26+
clean() {
27+
docker-compose -f ${RootPath}/docker/docker-compose.yml down
28+
}
29+
30+
# test & build
31+
build() {
32+
docker run --rm -v ${RootPath}:/go/src/github.com/chubaofs/chubaofs $ServerBuildDockerImage /bin/bash -c "cd $GoAppSrcPath && make build_server"
33+
docker run --rm -v ${RootPath}:/go/src/github.com/chubaofs/chubaofs $ClientBuildDockerImage /bin/bash -c "cd $GoAppSrcPath && make build_client"
34+
}
1535

1636
# start server
17-
docker-compose -f ${RootPath}/docker/docker-compose.yml up -d servers
37+
start_servers() {
38+
mkdir -p ${DiskPath}/{1..4}
39+
docker-compose -f ${RootPath}/docker/docker-compose.yml up -d servers
40+
}
41+
42+
start_client() {
43+
docker-compose -f ${RootPath}/docker/docker-compose.yml run --name cfs-client -d client bash -c "/cfs/script/start_client.sh"
44+
}
45+
46+
start_ltptest() {
47+
docker-compose -f ${RootPath}/docker/docker-compose.yml run --name cfs-client -d client bash -c "/cfs/script/start.sh"
48+
}
49+
50+
run_ltptest() {
51+
build
52+
start_servers
53+
start_ltptest
54+
}
55+
56+
run() {
57+
build
58+
start_servers
59+
start_client
60+
}
61+
62+
cmd="run"
63+
64+
ARGS=( "$@" )
65+
for opt in ${ARGS[*]} ; do
66+
case "$opt" in
67+
-h|--help)
68+
help
69+
;;
70+
-l|--ltptest)
71+
cmd=run_ltptest
72+
;;
73+
-r|--run)
74+
cmd=run
75+
;;
76+
-c|--clean)
77+
cmd=clean
78+
;;
79+
*)
80+
;;
81+
esac
82+
done
83+
84+
for opt in ${ARGS[*]} ; do
85+
case "-$1" in
86+
--d|---disk)
87+
shift
88+
export DiskPath=${1:?"need disk dir path"}
89+
shift
90+
;;
91+
-)
92+
break
93+
;;
94+
*)
95+
shift
96+
;;
97+
esac
98+
done
1899

19-
# start client
20-
#docker-compose -f ${RootPath}/docker/docker-compose.yml run client
21-
docker-compose -f ${RootPath}/docker/docker-compose.yml run --name cfs-client -d client bash -c "/cfs/script/start_client.sh ; sleep 10000000000"
100+
case "-$cmd" in
101+
-help) help ;;
102+
-run) run ;;
103+
-run_ltptest) run_ltptest ;;
104+
-clean) clean ;;
105+
*) help ;;
106+
esac
22107

23-
docker exec -it cfs-client /bin/bash

docker/script/start_client.sh

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -98,57 +98,9 @@ start_client() {
9898
echo "ok"
9999
}
100100

101-
wait_proc_done() {
102-
proc_name=$1
103-
pid=$( ps -ef | grep "$proc_name" | grep -v "grep" | awk '{print $2}' )
104-
logfile=$2
105-
logfile2=${logfile}-2
106-
logfile3=${logfile}-3
107-
maxtime=${3:-29000}
108-
checktime=${4:-60}
109-
retfile=${5:-"/tmp/ltpret"}
110-
timeout=1
111-
pout=0
112-
lastlog=""
113-
for i in $(seq 1 $maxtime) ; do
114-
if ! `ps -ef | grep -v "grep" | grep -q "$proc_name" ` ; then
115-
echo "$proc_name run done"
116-
timeout=0
117-
break
118-
fi
119-
sleep 1
120-
((pout+=1))
121-
if [ $(cat $logfile | wc -l) -gt 0 ] ; then
122-
pout=0
123-
cat $logfile > $logfile2 && cat $logfile2 >> $logfile3 && > $logfile
124-
cat $logfile2 && rm -f $logfile2
125-
fi
126-
if [[ $pout -ge $checktime ]] ; then
127-
echo -n "."
128-
pout=0
129-
fi
130-
done
131-
if [[ $timeout -eq 1 ]] ;then
132-
echo "$proc_name run timeout"
133-
exit 1
134-
fi
135-
ret=$(cat /tmp/ltpret)
136-
exit $ret
137-
}
138-
139-
run_ltptest() {
140-
#yum install -y psmisc >/dev/null
141-
echo "run ltp test"
142-
LTPTestDir=$MntPoint/ltptest
143-
LtpLog=/tmp/ltp.log
144-
mkdir -p $LTPTestDir
145-
nohup /bin/sh -c " /opt/ltp/runltp -pq -f fs -d $LTPTestDir > $LtpLog 2>&1; echo $? > /tmp/ltpret " &
146-
wait_proc_done "runltp" $LtpLog
147-
}
148-
149101
getLeaderAddr
150102
check_status "MetaNode"
151103
check_status "DataNode"
152104
create_vol ; sleep 3
153105
create_dp ; sleep 3
154-
start_client
106+
/cfs/bin/cfs-client -c /cfs/conf/client.json >/cfs/log/cfs.out

0 commit comments

Comments
 (0)