Redis installation and use

Redis key-value nosql database

集群需要3个master,3个从,六个节点。3.0以上支持集群,同时需要安装ruby

1. Installation:

After decompression, execute make
1. gcc command is not recognized in the decompression directory: gcc yum install gcc-c++ (online installation) needs to be installed
error: jemalloc/…. “newer version of jemalloc..” Execute make distclean, and then make
2. Download ruby package, unzip it.
./configure –prefix=/usr/local/ruby Specify the installation directory
make && make install
After successful installation of 3.make, you can manually copy redis-server, redis-cli, redis-check-aof, redis-check-dump, etc. to In the /usr/local/bin directory,
you can also execute make install to automatically generate it.
Note: If you execute redis-server –v (check the version command) at this time, if the prompt redis-server command not found is displayed, you need to install /usr/local/bin The directory is added to the environment variable. How to add it will not be described in detail here. You can view and modify /etc/profile. (View the environment variable command: echo $PATH)

2.. Modify the configuration file.conf

1) 创建配置文件目录,dump file 目录,进程pid目录,log目录等
配置文件一般放在/etc/下,创建redis目录
cd /etc/
mkdir redis
ll 查看创建的redis目录
~
dump file、进程pid、log目录等,一般放在/var/目录下,
cd /var/
mkdir redis
cd redis
mkdir data log run
至此,目录创建完毕
2) 修改配置文件,配置参数
首先拷贝解压包下的redis.conf文件至/etc/redis,dump file、进程pid、log目录等,一般放在/var/目录下,
cd /var/
mkdir redis
cd redis
mkdir data log run
打开redis.conf文件

daemonize
设置 daemonize 为 no,systemd 需要它运行在前台,否则 redis 会突然挂掉。
daemonize no

pidfile
设置 pidfile 为 /var/redis/run/redis.pid。
pidfile /var/redis/run/redis.pid

port
如果不准备用默认端口,可以修改。
port 6379

loglevel
设置日志级别。
loglevel notice

logfile
修改日志文件路径。
logfile /var/redis/log/redis.log

dir
设置目录为 /var/redis/data
dir /var/redis/data

3.启动服务
在/usr/local/bin 下 redis-server /etc/redis/redis.conf
4.客户端连接 bin目录下 redis-cli

****Redis问题****

1.MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
Redis is configured to save RDB snapshots, but it is currently Cannot persist to hard disk. Commands used to modify collection data cannot be used. Please check the Redis log for detailed error messages.

****原因****
强制关闭Redis快照导致不能持久化。

****解决方案****
将stop-writes-on-bgsave-error设置为no

2.The redis service reports an error redis (error) ERR Errors trying to SHUTDOWN. Check logs.

Change dir ./ to the corresponding directory, such as "dir /var/redis/data/" (you need to note that the last slash cannot be forgotten, if the slash is missing, it may be resolved as a file instead of a directory), save.
(and possible permission issues)

Reference:
http://blog.csdn.net/ludonqin/article/details/47211109
https://www.cnblogs.com/boshen-hzb/p/7699783.html

Install under Windows
http://dblab.xmu.edu.cn/blog/131/
Download redis under widnows: https://blog.csdn.net/liyifan687/article/details/80083721

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325272210&siteId=291194637