搜索
首页数据库mysql教程Redis系列-安装部署维护篇

redis高性能很大程度上源于它是个内存型数据库,它的高性能表现在:set操作11w/s,get操作8.1w/s,为了进一步加深对redis的理解总

Redis是个高性能的key-value数据库,它的key具有丰富的数据结构:string,hash,list set和sorted set。作为NOSQL,比起memcache之类,不仅仅key数据结构丰富,而且具有持久化的功能,并且能够支持主从复制,,很方便构建集群。

redis高性能很大程度上源于它是个内存型数据库,它的高性能表现在:set操作11w/s,get操作8.1w/s,为了进一步加深对redis的理解总结,我打算写个redis系列的文章。这里主要谈谈redis安装部署及运维维护。

1、下载安装

[root@ ]# wget -c     #下载 
[root@ ]# tar -zxvf redis-2.4.17.tar.gz  #解压 
[root@ ]# cd redis-2.4.17 
[root@ redis-2.4.17]# make  #编译 
[root@ redis-2.4.17]# make install #安装 

安装完毕,常用工具会自动拷贝到/user/loca/bin目录下。做为服务器,我们常常还需要把redis设置成开机自启动,源码包中有个很好用的脚本,执行脚步根据提示输入即可。

[root@ redis-2.4.17]# cd utils/ 
[root@ 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] 
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! 

注意执行install_server.sh,需要先进入utils目录,不然脚本会报错,提示找不到相应文件。安装完服务,redis自动启动,可以用ps命令查看到相关信息:

[root@ utils]# ps -ef | grep redis 
root      4554    1  0 10:55 ?        00:00:02 /usr/local/bin/redis-server /etc/redis/6379.conf 
root      4564  2808  0 10:59 pts/0    00:00:00 grep redis 

2、手动启动关闭服务

[root@ utils]# /etc/init.d/redis_6379 stop  #关闭 
[root@ utils]# /etc/init.d/redis_6379 start  #启动 

3、通过客户端命令行工具连接redis服务查看redis相关信息

a)连接

[root@ utils]# redis-cli 

redis 127.0.0.1:6379> 

b)其他指令

redis 127.0.0.1:6379> info  #查看server版本内存使用连接等信息 
 
redis 127.0.0.1:6379> client list  #获取客户连接列表 
 
redis 127.0.0.1:6379> client kill 127.0.0.1:33441 #终止某个客户端连接 
 
redis 127.0.0.1:6379> dbsize #当前保存key的数量 
 
redis 127.0.0.1:6379> save #立即保存数据到硬盘 
 
redis 127.0.0.1:6379> bgsave #异步保存数据到硬盘 
 
redis 127.0.0.1:6379> flushdb #当前库中移除所有key 
 
redis 127.0.0.1:6379> flushall #移除所有key从所有库中 
 
redis 127.0.0.1:6379> lastsave #获取上次成功保存到硬盘的unix时间戳 
 
redis 127.0.0.1:6379> monitor #实时监测服务器接收到的请求 
 
redis 127.0.0.1:6379> slowlog len #查询慢查询日志条数 
(integer) 3 
 
redis 127.0.0.1:6379> slowlog get #返回所有的慢查询日志,最大值取决于slowlog-max-len配置 
 
redis 127.0.0.1:6379> slowlog get 2 #打印两条慢查询日志 
 
redis 127.0.0.1:6379> slowlog reset #清空慢查询日志信息 

通过以上操作,单台服务器基本跑起来了,不过后面的路还很长很长。

linux

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
mysql blob:有什么限制吗?mysql blob:有什么限制吗?May 08, 2025 am 12:22 AM

mysqlblobshavelimits:tinyblob(255bytes),blob(65,535 bytes),中间布洛布(16,777,215个比例),andlongblob(4,294,967,967,295 bytes).tousebl观察性:1)考虑performance impactsandSandStorelargeblobsextern; 2)管理backbackupsandreplication carecration; 3)usepathsinst

MySQL:自动化用户创建的最佳工具是什么?MySQL:自动化用户创建的最佳工具是什么?May 08, 2025 am 12:22 AM

自动化在MySQL中创建用户的最佳工具和技术包括:1.MySQLWorkbench,适用于小型到中型环境,易于使用但资源消耗大;2.Ansible,适用于多服务器环境,简单但学习曲线陡峭;3.自定义Python脚本,灵活但需确保脚本安全性;4.Puppet和Chef,适用于大规模环境,复杂但可扩展。选择时需考虑规模、学习曲线和集成需求。

mysql:我可以在斑点内搜索吗?mysql:我可以在斑点内搜索吗?May 08, 2025 am 12:20 AM

是的,YouCansearchInIdeAblobInMysqlusingsPecificteChniques.1)转换theblobtoautf-8StringWithConvertFunctionWithConvertFunctionandSearchusiseLike.2)forCompresseBlyblobs,useuncompresseblobs,useuncompressbeforeconversion.3)acpperformance impperformance imperformance imptactsanddataEccoding.4)

MySQL字符串数据类型:综合指南MySQL字符串数据类型:综合指南May 08, 2025 am 12:14 AM

mysqloffersvariousStringDatatYpes:1)charforfixed Lengtth Strings,IdealforConsistLengthDatalikeCountryCodes; 2)varcharforvariable长度长,合适的forfieldslikenames; 3)texttypefesforepesforlargertext,forforlargertext,goodforforblogblogpostsbutcan impactcuctcuctcuctpercrance; 4)biland;

掌握mysql blobs:逐步教程掌握mysql blobs:逐步教程May 08, 2025 am 12:01 AM

TomasterMySQLBLOBs,followthesesteps:1)ChoosetheappropriateBLOBtype(TINYBLOB,BLOB,MEDIUMBLOB,LONGBLOB)basedondatasize.2)InsertdatausingLOAD_FILEforefficiency.3)Storefilereferencesinsteadoffilestoimproveperformance.4)UseDUMPFILEtoretrieveandsaveBLOBsco

MySQL中的BLOB数据类型:开发人员的详细概述MySQL中的BLOB数据类型:开发人员的详细概述May 07, 2025 pm 05:41 PM

blobdatatypesinmysqlareusedforvorvoringlargebinarydatalikeimagesoraudio.1)useblobtypes(tinyblobtolonglongblob)基于dondatasizeneeds。 2)库孔素pet petooptimize绩效。3)考虑Xternal Storage Forel Blob romana databasesizerIndimprovebackupe

如何将用户从命令行添加到MySQL如何将用户从命令行添加到MySQLMay 07, 2025 pm 05:01 PM

toadDuserStomySqlfromtheCommandline,loginasroot,thenusecreateuser'username'@'host'host'Indessifiedby'password'; tocreateanewuser.grantpermissionswithgrantprantallprivilegesondatabase

MySQL中有哪些不同的字符串数据类型?详细的概述MySQL中有哪些不同的字符串数据类型?详细的概述May 07, 2025 pm 03:33 PM

mySqlofferSeightStringDatateTypes:char,varchar,二进制,二进制,varbinary,blob,文本,枚举,枚举和set.1)长度,理想的forconsistentDatatalIkeCountryCodes.2)varcharisvariable长度,长度,效率foriforitifforiticforiticforiticforiticforiticforitic forvaryingdatalikename.3)

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

安全考试浏览器

安全考试浏览器

Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。