1、查看和设置密码
查看命令:config get requirepass
设置命令:config set "12345"
2、配置文件内容
################################## SECURITY ###################################
468469 # Require clients to issue AUTH <PASSWORD> before processing any other(如果设置了密码,访问前需要先输入auth+密码)
470 # commands. This might be useful in environments in which you do not trust
471 # others with access to the host running redis-server.
472 #
473 # This should stay commented out for backward compatibility and because most
474 # people do not need auth (e.g. they run their own servers).
475 #
476 # Warning: since Redis is pretty fast an outside user can try up to
477 # 150k passwords per second against a good box. This means that you should
478 # use a very strong password otherwise it will be very easy to break.
479 #
480 # requirepass foobared
481
482 # Command renaming.
483 #
484 # It is possible to change the name of dangerous commands in a shared
485 # environment. For instance the CONFIG command may be renamed into something
486 # hard to guess so that it will still be available for internal-use tools
487 # but not available for general clients.
488 #
489 # Example:
490 #
491 # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
492 #
493 # It is also possible to completely kill a command by renaming it into
494 # an empty string:
495 #
496 # rename-command CONFIG ""
497 #
498 # Please note that changing the name of commands that are logged into the
499 # AOF file or transmitted to slaves may cause problems.
3、限制
500
501 ################################### LIMITS ####################################
502
503 # Set the max number of connected clients at the same time. By default
504 # this limit is set to 10000 clients, however if the Redis server is not
505 # able to configure the process file limit to allow for the specified limit
506 # the max number of allowed clients is set to the current file limit
507 # minus 32 (as Redis reserves a few file descriptors for internal uses).
508 #
509 # Once the limit is reached Redis will close all the new connections sending
510 # an error 'max number of clients reached'.
511 #
512 # maxclients 10000(最大连接数)
513
514 # Don't use more memory than the specified amount of bytes.
515 # When the memory limit is reached Redis will try to remove keys
516 # according to the eviction policy selected (see maxmemory-policy).
517 #
518 # If Redis can't remove keys according to the policy, or if the policy is
519 # set to 'noeviction', Redis will start to reply with errors to commands
520 # that would use more memory, like SET, LPUSH, and so on, and will continue
521 # to reply to read-only commands like GET.
522 #
523 # This option is usually useful when using Redis as an LRU cache, or to set
524 # a hard memory limit for an instance (using the 'noeviction' policy).
525 #
526 # WARNING: If you have slaves attached to an instance with maxmemory on,
527 # the size of the output buffers needed to feed the slaves are subtracted
528 # from the used memory count, so that network problems / resyncs will
529 # not trigger a loop where keys are evicted, and in turn the output
530 # buffer of slaves is full with DELs of keys evicted triggering the deletion
531 # of more keys, and so forth until the database is completely emptied.
532 #
533 # In short... if you have slaves attached it is suggested that you set a lower
534 # limit for maxmemory so that there is some free RAM on the system for slave
535 # output buffers (but this is not needed if the policy is 'noeviction').
536 #
537 # maxmemory <bytes>(最大内存)
538
539 # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
540 # is reached. You can select among five behaviors:
541 #
542 # volatile-lru -> remove the key with an expire set using an LRU algorithm(使用LRU算法移除key,只对设置了过期时间的键)
543 # allkeys-lru -> remove any key according to the LRU algorithm(使用LRU算法移除key)
544 # volatile-random -> remove a random key with an expire set(在过期集合中移除随机的key,只对设置了过期时间的键)
545 # allkeys-random -> remove a random key, any key(移除随机的key)
546 # volatile-ttl -> remove the key with the nearest expire time (minor TTL)(移除那些TTL值最小的key,即那些最近要过期的key)
547 # noeviction -> don't expire at all, just return an error on write operations(不进行移除。针对写操作,只是返回错误信息)
548 #
549 # Note: with any of the above policies, Redis will return an error on write
550 # operations, when there are no suitable keys for eviction.
551 #
552 # At the date of writing these commands are: set setnx setex append
553 # incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
554 # sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
555 # zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
556 # getset mset msetnx exec sort
557 #
558 # The default is:
559 #
560 # maxmemory-policy noeviction(过期策略)
561
562 # LRU and minimal TTL algorithms are not precise algorithms but approximated
563 # algorithms (in order to save memory), so you can tune it for speed or
564 # accuracy. For default Redis will check five keys and pick the one that was
565 # used less recently, you can change the sample size using the following
566 # configuration directive.
567 #
568 # The default of 5 produces good enough results. 10 Approximates very closely
569 # true LRU but costs a bit more CPU. 3 is very fast but not very accurate.
570 #
571 # maxmemory-samples 5(设置样本数量)
572