CentOS 7 Redis-3.2.8 安装配置

Redis英文官方网站:https://redis.io

Redis中文文档网站:http://doc.redisfans.com

Redis优点
【1】高性能
【2】丰富的数据类型(String字符串、Hash哈希、List列表、Set集合、SortedSet有序集合)
【3】原子性
【4】丰富的特性
【5】主从复制
【6】持久化存储数据

Redis安装
[root@linux-node1 ~]# cd /usr/local/src/
[root@linux-node1 src]# wget http://download.redis.io/releases/redis-3.2.8.tar.gz
[root@linux-node1 src]# tar xvfz redis-3.2.8.tar.gz
[root@linux-node1 src]# cd redis-3.2.8
[root@linux-node1 redis-3.2.8]# make PREFIX=/usr/local/redis-3.2.8 install
[root@linux-node1 redis-3.2.8]# ln -s /usr/local/redis-3.2.8/ /usr/local/redis
[root@linux-node1 redis-3.2.8]# ls -ld /usr/local/redis
lrwxrwxrwx 1 root root 23 2017-03-22 14:01 /usr/local/redis -> /usr/local/redis-3.2.8/
[root@linux-node1 redis-3.2.8]# cp -a utils/redis_init_script /etc/init.d/redis
[root@linux-node1 redis-3.2.8]# ll /etc/init.d/redis
-rwxrwxr-x 1 root root 1098 2017-02-12 23:14 /etc/init.d/redis
[root@linux-node1 redis-3.2.8]# vim /etc/init.d/redis
7 EXEC=/usr/local/redis/bin/redis-server
8 CLIEXEC=/usr/local/redis/bin/redis-cli
[root@linux-node1 redis-3.2.8]# mkdir /etc/redis -p
[root@linux-node1 redis-3.2.8]# cp -a redis.conf /etc/redis/6379.conf
[root@linux-node1 redis-3.2.8]# vim /etc/redis/6379.conf
61 bind 192.168.100.133
80 protected-mode yes
84 port 6379
93 tcp-backlog 511
128 daemonize yes
150 pidfile /var/run/redis_6379.pid
163 logfile "/var/log/redis_6379.log"
178 databases 16
247 dir /var/lib/redis_6379
480 requirepass axbc1kof
[root@linux-node1 redis-3.2.8]# grep "^[a-Z]" /etc/redis/6379.conf
bind 192.168.100.133
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "/var/log/redis_6379.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis_6379
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
requirepass axbc1kof
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
[root@linux-node1 redis-3.2.8]# echo 1 > /proc/sys/vm/overcommit_memory
[root@linux-node1 redis-3.2.8]# cat /proc/sys/vm/overcommit_memory
1
[root@linux-node1 redis-3.2.8]# echo "512" > /proc/sys/net/core/somaxconn
[root@linux-node1 redis-3.2.8]# cat /proc/sys/net/core/somaxconn
512
[root@linux-node1 redis-3.2.8]# mkdir /var/lib/redis_6379 -p
[root@linux-node1 redis-3.2.8]# /etc/init.d/redis start
Starting Redis server...
[root@linux-node1 redis-3.2.8]# netstat -tnlup|grep "6379"|grep -v "grep"
tcp        0      0 192.168.100.133:6379        0.0.0.0:*                   LISTEN      32253/redis-server
[root@linux-node1 redis-3.2.8]# lsof -i:6379
COMMAND     PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
redis-ser 32253 root    4u  IPv4  34207      0t0  TCP linux-node1:6379 (LISTEN)
[root@linux-node1 redis-3.2.8]# ps -ef|grep "redis"|grep -v "grep"
root     32253     1  3 14:22 ?        00:00:00 /usr/local/redis/bin/redis-server 192.168.100.133:6379
[root@linux-node1 redis-3.2.8]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
[root@linux-node1 redis-3.2.8]# sysctl vm.overcommit_memory=1
vm.overcommit_memory = 1

[root@linux-node1 redis-3.2.8]# redis-cli -h 192.168.100.133 -p 6379
192.168.100.133:6379> AUTH axbc1kof
OK
192.168.100.133:6379> set name linux
OK
192.168.100.133:6379> get name
"linux"
192.168.100.133:6379> keys *
1) "name"
192.168.100.133:6379> exists name
(integer) 1
192.168.100.133:6379> del name
(integer) 1
192.168.100.133:6379> exists name
(integer) 0
192.168.100.133:6379> type name
string

192.168.100.133:6379> HSET car price 200000
(integer) 1
192.168.100.133:6379> HSET car name BMW
(integer) 1
192.168.100.133:6379> type car
hash
192.168.100.133:6379> HGET car price
"200000"
192.168.100.133:6379> HGET car name
"BMW"
192.168.100.133:6379> HGETALL car
1) "price"
2) "200000"
3) "name"
4) "BMW"
192.168.100.133:6379> HLEN car
(integer) 2


作者头像
南宫俊逸创始人

君子好学,自强不息~

上一篇:运维监控之zabbix
下一篇:自动化运维之ELK

相关推荐

4

发表评论

阿里云2021年 618 年中钜惠活动