这篇文章主要介绍了Redis 5.05中单独模式安装及配置的示例分析,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

操作系统Centos7

1、下载redis

wgethttp://download.redis.io/releases/redis-5.0.5.tar.gztarxzfredis-5.0.5.tar.gzcdredis-5.0.5make

2、启动服务

命令执行完成之后,既可以启动Redis 服务

[root@zk02redis]#src/redis-server5265:C23Oct201916:58:04.682#oO0OoO0OoO0OoRedisisstartingoO0OoO0OoO0Oo5265:C23Oct201916:58:04.682#Redisversion=5.0.5,bits=64,commit=00000000,modified=0,pid=5265,juststarted5265:C23Oct201916:58:04.682#Warning:noconfigfilespecified,usingthedefaultconfig.Inordertospecifyaconfigfileusesrc/redis-server/path/to/redis.conf5265:M23Oct201916:58:04.683*Increasedmaximumnumberofopenfilesto10032(itwasoriginallysetto1024)._.__.-``__''-.__.-```.`_.''-._Redis5.0.5(00000000/0)64bit.-``.-```.```\/_.,_''-._(',.-`|`,)Runninginstandalonemode|`-._`-...-`__...-.``-._|'`_.-'|Port:6379|`-._`._/_.-'|PID:5265`-._`-._`-./_.-'_.-'|`-._`-._`-.__.-'_.-'_.-'||`-._`-.__.-'_.-'|http://redis.io`-._`-._`-.__.-'_.-'_.-'|`-._`-._`-.__.-'_.-'_.-'||`-._`-.__.-'_.-'|`-._`-._`-.__.-'_.-'_.-'`-._`-.__.-'_.-'`-.__.-'`-.__.-'5265:M23Oct201916:58:04.684#WARNING:TheTCPbacklogsettingof511cannotbeenforcedbecause/proc/sys/net/core/somaxconnissettothelowervalueof128.5265:M23Oct201916:58:04.684#Serverinitialized5265:M23Oct201916:58:04.684#WARNINGovercommit_memoryissetto0!Backgroundsavemayfailunderlowmemorycondition.Tofixthisissueadd'vm.overcommit_memory=1'to/etc/sysctl.confandthenrebootorrunthecommand'sysctlvm.overcommit_memory=1'forthistotakeeffect.5265:M23Oct201916:58:04.684#WARNINGyouhaveTransparentHugePages(THP)supportenabledinyourkernel.ThiswillcreatelatencyandmemoryusageissueswithRedis.Tofixthisissuerunthecommand'echonever>/sys/kernel/mm/transparent_hugepage/enabled'asroot,andaddittoyour/etc/rc.localinordertoretainthesettingafterareboot.RedismustberestartedafterTHPisdisabled.5265:M23Oct201916:58:04.684*Readytoacceptconnections

3、通过内置的客户端与redis 交互

[root@zk02redis]#src/redis-cli127.0.0.1:6379>setfoobarOK127.0.0.1:6379>getfoo"bar"127.0.0.1:6379>

日志的打开文件数,可通过如下命令设置

ulimit -n 10032

ps:下面看下Redis 5.0.5 单节点 安装配置

下载

http://download.redis.io/releases/redis-5.0.5.tar.gz

解压

tar -C /usr/local -xvf redis-5.0.5.tar.gz

编译安装

cd/usr/local/redis-5.0.5makeinstall

使用make install 安装,默认安装目录是/usr/local/bin/

Redis配置文件

将示例配置文件拷贝到/etc/redis/639.conf

mkdir/etc/rediscp/usr/local/redis-5.0.5/redis.conf/etc/redis/6379.conf

关闭保护模式

protected-mode no

开放其他主机访问,注释掉bind 127.0.0.1

bind 127.0.0.1

更改为后台启动

daemonize yes

日志记录,需要先创建目录/var/applogs/redis

logfile "/var/applogs/redis/redis.log"

数据存储目录

mkdir-p/var/redis-data/dir/var/redis-data

设置密码

requirepass xxxx

Redis配置开机启动服务

使用Redis自带的启动脚本

cp/root/share/deploy-ready/redis-5.0.5/utils/redis_init_script/etc/init.d/redisd

配置开启自启动

chkconfig redisd on

设置开机自启动

chkconfig redisd on

防火墙开发6379端口

firewall-cmd--permanent--add-port=6379/tcpfirewall-cmd--reload

客户端连接Redis

redis-cli-h192.168.43.197-p6379-axxxx

感谢你能够认真阅读完这篇文章,希望小编分享的“Redis 5.05中单独模式安装及配置的示例分析”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!