全栈见习读书

Redis的概述、搭建及简单使用(基于CentOS 6.5 Li

2019-05-28  本文已影响0人  我是非著名程序猿
Redis的概述、搭建及简单使用(基于CentOS 6.5 Linux)
1、Redis 简介
2、Redis 优势
3、Redis与其他key-value存储有什么不同?
4、Redis 安装5、定义全局命令

1、Redis 简介

Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库。

Redis 与其他 key – value 缓存产品有以下三个特点:

2、Redis 优势

3、Redis与其他key-value存储有什么不同?

4、Redis 安装

wget下载:

[root@10 opt]# wget http://download.redis.io/releases/redis-4.0.12.tar.gz

tar解压:

[root@10 opt]# tar -zxvf redis-4.0.12.tar.gz

重命名:

[root@10 opt]# mv redis-4.0.12 redis

进入目录 redis 并 make :

[root@10 opt]# cd redis
[root@10 redis]# make

进入src 启动:

[root@10 redis]# cd src
[root@10 src]# ./redis-server

提示:

[root@10 src]# ./redis-server 
30902:C 26 May 05:40:00.253 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
30902:C 26 May 05:40:00.254 # Redis version=4.0.12, bits=64, commit=00000000, modified=0, pid=30902, just started
30902:C 26 May 05:40:00.254 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
30902:M 26 May 05:40:00.255 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.12 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 30902
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

30902:M 26 May 05:40:00.257 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
30902:M 26 May 05:40:00.257 # Server initialized
30902:M 26 May 05:40:00.257 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
30902:M 26 May 05:40:00.259 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis # Redis configuration file example.
must be restarted after THP is disabled.
30902:M 26 May 05:40:00.259 * Ready to accept connections

需要配置 redis.conf:

[root@10 src]# vi ../redis.conf

找到更改以下内容,打开守护进程

# no 改为 yes
daemonize yes

# 日志可以自行添加,不做要求
logfile ./logs/redis.log 

启动redis并应用redis.conf配置文件:

[root@10 src]# ./redis-server ../redis.conf

打开客户端并进行简单测试:

[root@10 src]# ./redis-cli
127.0.0.1:6379> EXISTS mykey
(integer) 0 
127.0.0.1:6379> append mykey hello
(integer) 5
127.0.0.1:6379> append mykey world
(integer) 10
127.0.0.1:6379> get mykey
"helloworld"
127.0.0.1:6379> 

基本配置到此结束。

5、定义全局命令

[root@10 src]# vi /etc/profile
# 增加
export REDIS_HOME=/opt/mongodb
export PATH=$REDIS_HOME/src:$PATH

# 生效
[root@10 src]# source /etc/profile

设置完,就可以在任何目录下,执行:

redis-cli

查看和操作数据库啦。

上一篇 下一篇

猜你喜欢

热点阅读