请选择 进入手机版 | 继续访问电脑版

Redis中国用户组(CRUG)论坛

 找回密码
 立即注册

扫一扫,访问微社区

搜索
热搜: 活动 交友 discuz
查看: 1569|回复: 0

redis源代码学习笔记(1)-- 服务器和客户端启动选项

[复制链接]
  • TA的每日心情
    郁闷
    2016-8-11 14:25
  • 签到天数: 1 天

    [LV.1]初来乍到

    3

    主题

    8

    帖子

    84

    积分

    注册会员

    Rank: 2

    积分
    84
    发表于 2016-8-22 16:33:54 | 显示全部楼层 |阅读模式
    1) 服务器端的使用方法,可以从源代码server.c  3658行usage(void)函数中
    1. void usage(void) {

    2. fprintf(stderr,"Usage: ./redis-server [/path/to/redis.conf] [options]\n"); // 使用 ./redis-server [配置文件] [选项]

    3. fprintf(stderr," ./redis-server - (read config from stdin)\n"); // ./redis-server - 从stdin中读取配置文件

    4. fprintf(stderr," ./redis-server -v or --version\n"); // ./redis-server -v or --version 检查版本

    5. fprintf(stderr," ./redis-server -h or --help\n"); // ./redis-server -h or --hlep 获取帮助

    6. fprintf(stderr," ./redis-server --test-memory \n\n"); // ./redis-server --test-memory 设置测试内存大小

    7. fprintf(stderr,"Examples:\n");

    8. fprintf(stderr," ./redis-server (run the server with default conf)\n"); //.redis-server 使用默认的配置运行服务,在initServerConfig()

    9. fprintf(stderr," ./redis-server /etc/redis/6379.conf\n"); //使用/etc/redis/6379.conf配置

    10. fprintf(stderr," ./redis-server --port 7777\n"); //使用端口号7777

    11. fprintf(stderr," ./redis-server --port 7777 --slaveof 127.0.0.1 8888\n"); //使用端口号7777,从主机为127.0.0.1端口为8888

    12. fprintf(stderr," ./redis-server /etc/myredis.conf --loglevel verbose\n\n"); //使用/etc/myredis.conf,日志等级在verbose以上才会记录

    13. fprintf(stderr,"Sentinel mode:\n");

    14. fprintf(stderr," ./redis-server /etc/sentinel.conf --sentinel\n"); //哨兵模式,并使用/etc/sentinel.conf文件

    15. exit(1);

    16. }
    复制代码
    2)客户端的启动选项

    查看redis-cli.c 1097行
    1. static void usage(void) {

    2. sds version = cliVersion();

    3. fprintf(stderr,

    4. "redis-cli %s\n"

    5. "\n"

    6. "Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]\n"

    7. " -h Server hostname (default: 127.0.0.1).\n"

    8. " -p Server port (default: 6379).\n"

    9. " -s Server socket (overrides hostname and port).\n"

    10. " -a Password to use when connecting to the server.\n"

    11. " -r Execute specified command N times.\n"

    12. " -i When -r is used, waits seconds per command.\n"

    13. " It is possible to specify sub-second times like -i 0.1.\n"

    14. " -n Database number.\n"

    15. " -x Read last argument from STDIN.\n"

    16. " -d Multi-bulk delimiter in for raw formatting (default: \\n).\n"

    17. " -c Enable cluster mode (follow -ASK and -MOVED redirections).\n"

    18. " --raw Use raw formatting for replies (default when STDOUT is\n"

    19. " not a tty).\n"

    20. " --no-raw Force formatted output even when STDOUT is not a tty.\n"

    21. " --csv Output in CSV format.\n"

    22. " --stat Print rolling stats about server: mem, clients, ...\n"

    23. " --latency Enter a special mode continuously sampling latency.\n"

    24. " --latency-history Like --latency but tracking latency changes over time.\n"

    25. " Default time interval is 15 sec. Change it using -i.\n"

    26. " --latency-dist Shows latency as a spectrum, requires xterm 256 colors.\n"

    27. " Default time interval is 1 sec. Change it using -i.\n"

    28. " --lru-test Simulate a cache workload with an 80-20 distribution.\n"

    29. " --slave Simulate a slave showing commands received from the master.\n"

    30. " --rdb Transfer an RDB dump from remote server to local file.\n"

    31. " --pipe Transfer raw Redis protocol from stdin to server.\n"

    32. " --pipe-timeout In --pipe mode, abort with error if after sending all data.\n"

    33. " no reply is received within seconds.\n"

    34. " Default timeout: %d. Use 0 to wait forever.\n"

    35. " --bigkeys Sample Redis keys looking for big keys.\n"

    36. " --scan List all keys using the SCAN command.\n"

    37. " --pattern Useful with --scan to specify a SCAN pattern.\n"

    38. " --intrinsic-latency Run a test to measure intrinsic system latency.\n"

    39. " The test will run for the specified amount of seconds.\n"

    40. " --eval Send an EVAL command using the Lua script at .\n"

    41. " --ldb Used with --eval enable the Redis Lua debugger.\n"

    42. " --ldb-sync-mode Like --ldb but uses the synchronous Lua debugger, in\n"

    43. " this mode the server is blocked and script changes are\n"

    44. " are not rolled back from the server memory.\n"

    45. " --help Output this help and exit.\n"

    46. " --version Output version and exit.\n"

    47. "\n"

    48. "Examples:\n"

    49. " cat /etc/passwd | redis-cli -x set mypasswd\n"

    50. " redis-cli get mypasswd\n"

    51. " redis-cli -r 100 lpush mylist x\n"

    52. " redis-cli -r 100 -i 1 info | grep used_memory_human:\n"

    53. " redis-cli --eval myscript.lua key1 key2 , arg1 arg2 arg3\n"

    54. " redis-cli --scan --pattern '*:12345*'\n"

    55. "\n"

    56. " (Note: when using --eval the comma separates KEYS[] from ARGV[] items)\n"

    57. "\n"

    58. "When no command is given, redis-cli starts in interactive mode.\n"

    59. "Type \"help\" in interactive mode for information on available commands\n"

    60. "and settings.\n"

    61. "\n",

    62. version, REDIS_CLI_DEFAULT_PIPE_TIMEOUT);

    63. sdsfree(version);

    64. exit(1);

    65. }
    复制代码


    生的渺小,活的平常。
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|Redis中国用户组 ( 京ICP备15003959号

    GMT+8, 2018-10-16 02:01 , Processed in 0.211940 second(s), 29 queries .

    Powered by Discuz! X3.2

    © 2001-2013 Comsenz Inc.

    快速回复 返回顶部 返回列表