可以使用 make gotest
进行测试 (可选操作,非必须)
[root@h102 codis]# make gotest
GOPATH=`godep path`:$GOPATH go test ./pkg/... ./cmd/...
ok github.com/wandoulabs/codis/pkg/models 16.501s
ok github.com/wandoulabs/codis/pkg/proxy 9.242s
ok github.com/wandoulabs/codis/pkg/proxy/redis 12.355s
ok github.com/wandoulabs/codis/pkg/proxy/router 1.419s
? github.com/wandoulabs/codis/pkg/utils [no test files]
? github.com/wandoulabs/codis/pkg/utils/assert [no test files]
? github.com/wandoulabs/codis/pkg/utils/atomic2 [no test files]
ok github.com/wandoulabs/codis/pkg/utils/bytesize 0.003s
? github.com/wandoulabs/codis/pkg/utils/errors [no test files]
? github.com/wandoulabs/codis/pkg/utils/log [no test files]
? github.com/wandoulabs/codis/pkg/utils/trace [no test files]
? github.com/wandoulabs/codis/cmd/cconfig [no test files]
? github.com/wandoulabs/codis/cmd/proxy [no test files]
[root@h102 codis]# echo $?
0
[root@h102 codis]#
生成可执行文件
代码语言:javascript复制[root@h102 codis]# ll bin/
total 37632
drwxr-xr-x 4 root root 4096 Dec 4 15:41 assets
-rwxr-xr-x 1 root root 16195952 Dec 4 15:41 codis-config
-rwxr-xr-x 1 root root 16017064 Dec 4 15:41 codis-proxy
-rwxr-xr-x 1 root root 6311083 Dec 4 15:42 codis-server
[root@h102 codis]# file bin/*
bin/assets: directory
bin/codis-config: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
bin/codis-proxy: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
bin/codis-server: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18,
[root@h102 codis]#
Tip: 执行完上面全部指令后,会在 bin 文件夹内生成 codis-config、codis-proxy、codis-server三个可执行文件;另外, bin/assets 文件夹是 codis-config 的 dashboard http 服务需要的前端资源, 需要和 codis-config 放置在同一文件夹下
三个命令的基本帮助信息如下
代码语言:javascript复制[root@h102 codis]# bin/codis-config -h
usage: codis-config [-c <config_file>] [-L <log_file>] [--log-level=<loglevel>]
<command> [<args>...]
options:
-c set config file
-L set output log file, default is stdout
--log-level=<loglevel> set log level: info, warn, error, debug [default: info]
commands:
server
slot
dashboard
action
proxy
[root@h102 codis]# bin/codis-proxy -h
usage: proxy [-c <config_file>] [-L <log_file>] [--log-level=<loglevel>] [--log-filesize=<filesize>] [--cpu=<cpu_num>] [--addr=<proxy_listen_addr>] [--http-addr=<debug_http_server_addr>]
options:
-c set config file
-L set output log file, default is stdout
--log-level=<loglevel> set log level: info, warn, error, debug [default: info]
--log-filesize=<maxsize> set max log file size, suffixes "KB", "MB", "GB" are allowed, 1KB=1024 bytes, etc. Default is 1GB.
--cpu=<cpu_num> num of cpu cores that proxy can use
--addr=<proxy_listen_addr> proxy listen address, example: 0.0.0.0:9000
--http-addr=<debug_http_server_addr> debug vars http server
[root@h102 codis]# bin/codis-server -h
Usage: ./redis-server [/path/to/redis.conf] [options]
./redis-server - (read config from stdin)
./redis-server -v or --version
./redis-server -h or --help
./redis-server --test-memory <megabytes>
Examples:
./redis-server (run the server with default conf)
./redis-server /etc/redis/6379.conf
./redis-server --port 7777
./redis-server --port 7777 --slaveof 127.0.0.1 8888
./redis-server /etc/myredis.conf --loglevel verbose
Sentinel mode:
./redis-server /etc/sentinel.conf --sentinel
[root@h102 codis]#