admin管理员组

文章数量:1794759

Redis部署

Redis部署

Redis部署
  • Redis入门简介
  • 源码编译安装

Redis入门简介

Redis是一个开源的基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。

Redis是一个key-value存储系统。 和Memcached缓存类似,Redis支持存储的value类型相对更多,包括string(字符串)、list(链表)、set(集合)、hash(哈希类型)。并且支持在服务器端计算集合的并,交和补集(difference)等,还支持多种排序功能。Redis也被看成是一个数据结构服务器。

Redis支持主从同步,数据可以从主服务器向任意数量的从服务器上同步,从服务器可以是关联其他从服务器的主服务器。

源码编译安装

下载源码包并解压

[root@redis ~]# cd /usr/src/ [root@redis src]# wget download.redis.io/releases/redis-5.0.5.tar.gz [root@redis src]# tar -xzvf redis-5.0.5.tar.gz [root@redis src]# ll total 1932 drwxr-xr-x. 2 root root 6 Apr 11 2018 debug drwxr-xr-x. 3 root root 35 Nov 25 23:05 kernels drwxrwxr-x 6 root root 334 May 16 2019 redis-5.0.5 -rw-r--r-- 1 root root 1975750 Jun 27 2020 redis-5.0.5.tar.gz [root@redis src]# cd redis-5.0.5/ [root@redis redis-5.0.5]#

编辑指定路径

[root@redis redis-5.0.5]# vim src/Makefile

执行编译

[root@redis redis-5.0.5]# make && make install

如果不直接编辑上面的配置文件,也可以直接手动指定路径 make PREFIX=/usr/local/redis install

配置脚本启动服务

[root@redis redis-5.0.5]# ./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] /usr/local/redis/6379/6379.conf Please select the redis log file name [/var/log/redis_6379.log] /usr/local/redis/6379/redis_6379.log Please select the data directory for this instance [/var/lib/redis/6379] /usr/local/redis/6379 Please select the redis executable path [] /usr/local/redis/bin/redis-server Selected config: Port : 6379 Config file : /usr/local/redis/6379/6379.conf Log file : /usr/local/redis/6379/redis_6379.log Data dir : /usr/local/redis/6379 Executable : /usr/local/redis/bin/redis-server Cli Executable : /usr/local/redis/bin/redis-cli Is this ok? Then press ENTER to go on or Ctrl-C to abort. 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!

此时服务已经启动,查看日志发现有三个警告

[root@redis redis-5.0.5]# tailf -n 50 /usr/local/redis/6379/redis_6379.log

根据此提示消除警告

[root@redis redis-5.0.5]# vim /etc/sysctl.conf

[root@redis redis-5.0.5]# sysctl -p net.core.somaxconn = 512 vm.overcommit_memory = 1 [root@redis redis-5.0.5]# echo never > /sys/kernel/mm/transparent_hugepage/enabled

重启Redis服务并查看日志

[root@redis redis-5.0.5]# /etc/init.d/redis_6379 restart Stopping ... Redis stopped Starting Redis server... [root@redis redis-5.0.5]# tailf -n 50 /usr/local/redis/6379/redis_6379.log

会发现此时无警告

进入Redis

[root@redis redis-5.0.5]# /usr/local/redis/bin/redis-cli 127.0.0.1:6379>

此时Redis安装成功

本文标签: Redis