Redis配置文件redis.conf 详解 1.基本配置 内存单位的表示 # 1k =gt; 1000 bytes# 1kb =gt; 1024 bytes# 1m =gt; 1000000 byt
Redis配置文件redis.conf 详解
1.基本配置
内存单位的表示
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
单位中不区分大小写1GB 1Gb 1gB是一样的
后台运行,yes是后台运行,no前台运行,将输出,输出到终端(默认)
daemonize yes
如果daemonize参数为yes的话就会产生pid文件,一下是pid文件的定义
pidfile /usr/local/redis-master/run/redis.pid
监听的端口
port 6379
绑定监听的IP地址
bind 127.0.0.1
如果在本地调用redis可以直接用sock文件
unixsocket /tmp/redis.sock //sock文件的位置
unixsocketperm 755 //sock文件的权限
如果一个链接在N秒内是空闲的,就将其关闭
timeout 0
如果对方down了或者中间网络断了发送ACK到客户端在指定的时间内没有收到对方的回应就断开TCP链接(时间单位秒记),此参数会受到内核参数的影响,推荐配置60。
tcp-keepalive 0
指定输出消息的级别
# debug (调试级别,详细信息,信息量大)
# verbose (详细信息,信息量较大)
# notice (通知,生产环境推荐)
# warning (错误信息警告信息)
loglevel notice
日志输出文件,默认在前端运行的时候此key的默认值是stdout输出到终端,如果用守护进程运行此key的stdout的时候将日志输入到/dev/null,如果想记录日志,就必须为其指定logfile位置
logfile /var/log/redis.log
将日志记录的哦syslog
syslog-enabled no
指定syslog的身份
syslog-ident redis
指定syslog的级别,必须是LOCAL0-LOCAL7之间
syslog-facility local0
设置数据库的数量
databases 16
设置数据库的数量。默认数据库DB 0,你可以选择一个不同的per-connection的使用SELECT
databases 16
2.快照配置
将DB保存到磁盘的规则定义(快照)
格式:save
例子:save 900 1 //在900秒(15分钟)内如果至少有1个键值发生变化 就保存
save 300 10 //在300秒(6分钟)内如果至少有10个键值发生变化 就保存
save 900 1 //每一条表示一个存盘点
save 300 10
save 60 10000
如果启用如上的快照(RDB),在一个存盘点之后,可能磁盘会坏掉或者权限问题,redis将依然能正常工作
stop-writes-on-bgsave-error yes
是否将字符串用LZF压缩到.rdb 数据库中,如果想节省CPU资源可以将其设置成no,但是字符串存储在磁盘上占用空间会很大,默认是yes
rdbcompression yes
rdb文件的校验,如果校验将避免文件格式坏掉,如果不校验将在每次操作文件时要付出校验过程的资源新能,将此参数设置为no,将跳过校验
rdbchecksum yes
转储数据的文件名
dbfilename dump.rdb
redis的工作目录,它会将转储文件存储到这个目录下,并生成一个附加文件
dir /usr/local/redis-master/db
3.主从参数
如果本地是salve服务器那么配置该项
# slaveof
slaveof 127.0.0.1 65532
master的验证密码
masterauth
当从主机脱离主的链接时,如果此值为yes当客户端查询从时,回响应客户端,如果是第一次同步回返回一个日期数据或这空值,如果设置为no,则返回“SYNC with master in progress”到INFO and SLAVEOF
slave-serve-stale-data yes
从服务器只读(默认)
slave-read-only yes
从发送ping到主的时间间隔(单位:秒)
repl-ping-slave-period 10
批量传输I / O超时和主数据或ping响应超时 默认60s 必须大于repl-ping-slave-period值
repl-timeout 60
此选项如果是“yes”那么Redis的使用数量较少的TCP数据包和更少的带宽将数据发送到,在从主机上延迟40毫秒(linux kernel中的40毫秒)出现。如果是no将在slave中减少延迟,但是流量使用回相对多一些,如果用多个从主机,此处建议设置成yes
repl-disable-tcp-nodelay no
从主机的优先级,如果当主主机挂了的时候,将从从主机中选取一个作为其他从机的主,,首先优先级的数字最低的将成为主,0是一个特殊的级别,0将永远不会成为主。默认值是100.
slave-priority 100
更多详情见请继续阅读下一页的精彩内容:
推荐阅读:
Redis集群明细文档
Ubuntu 12.10下安装Redis(图文详解)+ Jedis连接Redis
Redis系列-安装部署维护篇
CentOS 6.3安装Redis
Redis 的详细介绍:请点这里
Redis 的下载地址:请点这里

MySQL uses a GPL license. 1) The GPL license allows the free use, modification and distribution of MySQL, but the modified distribution must comply with GPL. 2) Commercial licenses can avoid public modifications and are suitable for commercial applications that require confidentiality.

The situations when choosing InnoDB instead of MyISAM include: 1) transaction support, 2) high concurrency environment, 3) high data consistency; conversely, the situation when choosing MyISAM includes: 1) mainly read operations, 2) no transaction support is required. InnoDB is suitable for applications that require high data consistency and transaction processing, such as e-commerce platforms, while MyISAM is suitable for read-intensive and transaction-free applications such as blog systems.

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

There are four main index types in MySQL: B-Tree index, hash index, full-text index and spatial index. 1.B-Tree index is suitable for range query, sorting and grouping, and is suitable for creation on the name column of the employees table. 2. Hash index is suitable for equivalent queries and is suitable for creation on the id column of the hash_table table of the MEMORY storage engine. 3. Full text index is used for text search, suitable for creation on the content column of the articles table. 4. Spatial index is used for geospatial query, suitable for creation on geom columns of locations table.

TocreateanindexinMySQL,usetheCREATEINDEXstatement.1)Forasinglecolumn,use"CREATEINDEXidx_lastnameONemployees(lastname);"2)Foracompositeindex,use"CREATEINDEXidx_nameONemployees(lastname,firstname);"3)Forauniqueindex,use"CREATEU

The main difference between MySQL and SQLite is the design concept and usage scenarios: 1. MySQL is suitable for large applications and enterprise-level solutions, supporting high performance and high concurrency; 2. SQLite is suitable for mobile applications and desktop software, lightweight and easy to embed.

Indexes in MySQL are an ordered structure of one or more columns in a database table, used to speed up data retrieval. 1) Indexes improve query speed by reducing the amount of scanned data. 2) B-Tree index uses a balanced tree structure, which is suitable for range query and sorting. 3) Use CREATEINDEX statements to create indexes, such as CREATEINDEXidx_customer_idONorders(customer_id). 4) Composite indexes can optimize multi-column queries, such as CREATEINDEXidx_customer_orderONorders(customer_id,order_date). 5) Use EXPLAIN to analyze query plans and avoid

Using transactions in MySQL ensures data consistency. 1) Start the transaction through STARTTRANSACTION, and then execute SQL operations and submit it with COMMIT or ROLLBACK. 2) Use SAVEPOINT to set a save point to allow partial rollback. 3) Performance optimization suggestions include shortening transaction time, avoiding large-scale queries and using isolation levels reasonably.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)
