配置 Redis 能随系统启动:
./utils/install_server.sh
显示结果信息如下:
- Welcome to the redis service installer
- This script will help you easily set up a running redis server
- Please select the redis port for this instance: [6379]
- Selecting default: 6379
- Please select the redis config file name [/etc/redis/6379.conf]
- Selected default - /etc/redis/6379.conf
- Please select the redis log file name [/var/log/redis_6379.log]
- Selected default - /var/log/redis_6379.log
- Please select the data directory for this instance [/var/lib/redis/6379]
- Selected default - /var/lib/redis/6379
- Please select the redis executable path [/usr/local/bin/redis-server]
- Selected config:
- Port : 6379
- Config file : /etc/redis/6379.conf
- Log file : /var/log/redis_6379.log
- Data dir : /var/lib/redis/6379
- Executable : /usr/local/bin/redis-server
- Cli Executable : /usr/local/bin/redis-cli
- Is this ok? Then press ENTER to go on or Ctrl-C to abort.
- Copied /tmp/6379.conf => /etc/init.d/redis_6379
- Installing service...
- Successfully added to chkconfig!
- Successfully added to runlevels 345!
- Starting Redis server...
- Installation successful!
Redis 服务查看开启关闭:
a. 通过 ps -ef|grep redis 命令查看 Redis 进程
b. 开启 Redis 服务操作通过 / etc/init.d/redis_6379 start 命令, 也可通过 (service redis_6379 start)
c. 关闭 Redis 服务操作通过 / etc/init.d/redis_6379 stop 命令, 也可通过 (service redis_6379 stop)
redis.conf 的配置信息
1daemonize 如果需要在后台运行, 把该项改为 yes
2pidfile 配置多个 pid 的地址 默认在 / var/run/redis.pid
3bind 绑定 ip, 设置后只接受来自该 ip 的请求
4port 监听端口, 默认是 6379
5loglevel 分为 4 个等级: debug verbose notice warning
6logfile 用于配置 log 文件地址
7databases 设置数据库个数, 默认使用的数据库为 0
8save 设置 redis 进行数据库镜像的频率
9rdbcompression 在进行镜像备份时, 是否进行压缩
10dbfilename 镜像备份文件的文件名
11Dir 数据库镜像备份的文件放置路径
12Slaveof 设置数据库为其他数据库的从数据库
13Masterauth 主数据库连接需要的密码验证
14Requriepass 设置 登陆时需要使用密码
15Maxclients 限制同时使用的客户数量
16Maxmemory 设置 redis 能够使用的最大内存
17Appendonly 开启 append only 模式
18Appendfsync 设置对 appendonly.aof 文件同步的频率 (对数据进行备份的第二种方式)
19vm-enabled 是否开启虚拟内存支持 (vm 开头的参数都是配置虚拟内存的)
20vm-swap-file 设置虚拟内存的交换文件路径
21vm-max-memory 设置 redis 使用的最大物理内存大小
22vm-page-size 设置虚拟内存的页大小
23vm-pages 设置交换文件的总的 page 数量
24vm-max-threads 设置 VM IO 同时使用的线程数量
25Glueoutputbuf 把小的输出缓存存放在一起
26hash-max-zipmap-entries 设置 hash 的临界值
27Activerehashing 重新 hash
来源: http://www.bubuko.com/infodetail-2512910.html