Linux+Redis实战教程_day02_2、redis简述及安装与启动
2、 redis简述及安装
关系型数据库(SQL):
Mysql,oracle
特点:数据和数据之间,表和字段之间,表和表之间是存在关系的
例如:部门表 001部门, 员工表 001
用户表,用户名、密码
分类表 和 商品表, 一对多关系。
优点:①数据之间有关系,进行数据的增删改查时非常方便的。
②关系型数据库 有事务操作。 保证数据的完整性
缺点:1、因为数据和数据之间有关系的,关系是由底层大量算法保证
大量算法会拉低系统运行速度
大量算法会消耗系统资源
2、海量数据的增删改查时会显得无能为力。
很可能宕(dang)机
3、海量数据环境下对数据表进行维护/扩展,也会变得无能为力
update product set cname = ‘手机数码’;//修改所有数据
把商品表的cname字段,由varchar(64), char(100)
适合处理一般量级数据,安全。
钱
非关系型数据库(NOSQL:不仅仅是sql):
为了处理海量数据,需要将关系型数据库的关系 去掉。
非关系型数据库设计之初 是为了替代关系型数据库的
Redis
优点:1、海量数据的增删改查,非常轻松应对
2、海量数据的维护非常轻松。
缺点:1、数据和数据之间没有关系,所以不能一目了然
2、非关系型数据库,没有关系,没有强大的事务保证数据的完整和安全
适合处理海量数据,效率高。不一定安全
奥运健儿奖牌总数 每秒千万次查询
关系型数据库+非关系型数据库 ====》项目
重要数据 海量操作数据,不重要
2、1 Redis使用环境
1、可以作为关系型数据库的缓存存在
2、可以做任务队列
3、大量数据运算
4、排行榜
Redis非常擅长做大量数据的排行榜
2、2 redis安装
redis是C语言开发,安装redis需要先将官网下载的源码进行编译,编译依赖gcc环境。如果没有gcc环境,需要安装gcc:(环境已经导入完成)
yum install gcc-c++
如果提示是否下载,输入y。
如果提示是否安装,输入y
l 步骤1:将Windows下下载的压缩文件上传到Linux下。通过secureCRT进行上传,步骤如下:
lalt + p
lput F:/redis-3.0.0.tar.gz
l
l 步骤2:解压文件
ltar -zxvf redis-3.0.0.tar.gz
l 步骤3:编译redis (编译,将.c文件编译为.o文件)
l进入解压文件夹,cd redis-3.0.0
l执行make,将里边所有的c代码运行一遍
1)如果没有安装gcc,编译将出现错误提示。(如果安装失败,必须删除文件夹,重写解压)
2)安装成功
l 步骤4:安装
make PREFIX=/usr/local/redis install
lPREFIX必须大写
安装完后,在/usr/local/redis/bin下有几个可执行文件
redis-benchmark----性能测试工具
redis-check-aof----AOF文件修复工具
redis-check-dump----RDB文件检查工具(快照持久化文件)
redis-cli----命令行客户端
redis-server----redis服务器启动命令
l 步骤5:copy文件
redis启动需要一个配置文件,可以修改端口号等信息。
回到根目录,进到redis-3.0.0,复制该目录下的redis.conf到/usr/local/redis
cp redis.conf /usr/local/redis
注:如果没有配置文件redis也可以启动,不过将启用默认配置,这样不方便我们修改端口号等信息
2、3前端启动:(了解)-无法部署集群
先进入redis程序目录中,运行一下命令启动redis服务器。./代表当前目录
./bin/redis-server
[root@yejing redis]# ll
总用量 48 drwxr-xr-x. 2 root root 4096 1月 15 07:28 bin -rw-r--r--. 1 root root 41403 1月 15 07:35 redis.conf [root@yejing redis]# pwd /usr/local/redis [root@yejing redis]# ./bin/redis-server 1631:C 15 Jan 17:57:09.181 # Warning: no config file specified, using the default config. In order to specify a config file use ./bin/redis-server /path/to/redis.conf 1631:M 15 Jan 17:57:09.186 * Increased maximum number of open files to 10032 (it was originally set to 1024). 1631:M 15 Jan 17:57:09.199 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now. _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.0 (00000000/0) 32 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 1631 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 1631:M 15 Jan 17:57:09.204 # Server started, Redis version 3.0.0 1631:M 15 Jan 17:57:09.206 # 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. 1631:M 15 Jan 17:57:09.207 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 1631:M 15 Jan 17:57:09.207 * The server is now ready to accept connections on port 6379
再打开一个窗口运行客户端:
进到redis程序目录,运行以下命令启动客户端
./bin/redis-cli
[root@yejing ~]# cd /usr/local/redis [root@yejing redis]# ./bin/redis-cli 127.0.0.1:6379> set username zhangsan OK 127.0.0.1:6379> get username "zhangsan" 127.0.0.1:6379>
启动redis,客户端连接: 连接6379端口
redis-cli -h ip地址 -p 端口
./bin/redis-cli -p 6379
运行客户端(默认连接本机6379端口):./bin/redis-cli
2、4Redis启动-后端模式
l 修改redis.conf配置文件, daemonize yes 以后端模式启动。
vim /usr/local/redis/redis.conf
l 启动时,指定配置文件
cd /usr/local/redis/
./bin/redis-server ./redis.conf
l Redis默认端口6379,通过当前服务进行查看
ps -ef | grep -i redis
2、5 redis的关闭
① 查询到PID,kill -9 pid 【断电,非正常关闭,一般不用,否则造成数据丢失】
②正常关闭 【正常关闭,数据保存】
./bin/redis-cli shutdown
相关文章
- Redis在Linux环境下安装的常见错误
- 如何win10 上访问虚拟机(linux)上redis方法
- Linux下安装Redis服务
- linux服务器上离线安装redis
- Redis Linux 安装运行实战全记录
- redis 入门(一)——Linux环境安装测试以及基本命令演示
- Redis学习笔记之Linux下Redis的安装和部署
- ***总结:在linux下连接redis并进行命令行操作(设置redis密码)
- linux 下安装redis以及php Redis扩展
- Linux下Redis主从复制以及SSDB主主复制环境部署记录
- Linux环境下Redis安装配置步骤[转]
- linux下Redis与phpredis扩展安装
- Linux+Redis实战教程_day03_Redis-set【重点】_有序set(了解)
- Linux+Redis实战教程_day01_Linux系统上安装tomcat
- Linux+Redis实战教程_day02_Linux系统上安装MySQL
- linux安装jdk、MySQL、nginx、redis
- 虚拟机linux+centos7+docker+springboot+Redis的使用
- linux 安装php扩展swoole redis
- Linux系统在线安装、启动 redis
- 使用redis进行手机验证码的验证、每天只能发送三次验证码 (redis安装在虚拟机linux系统中)
- Linux下iptables 禁止端口和开放端口
- Linux下设置redis访问密码
- Linux下配置redis