Redis Source Installation

Source: Internet
Author: User
Tags redis server


#安装目录

mkdir -p/data/apps//data/tgzwget http://download.redis.io/ releases/redis-3.2.1.tar.gzCD redis-3.2. 1  Make Install #安装到指定目录中

#在安装redis成功后, you will be able to see a bin directory in/data/apps/redis, which includes the following files:

redis-benchmarkredis-check-aofredis-check-dumpredis-cli redis-server

Redis-server:redis Server Daemon Startup program
Redis-cli:redis command-line operation tool. or a plain text protocol operation via Telnet
Redis-benchmark:redis Performance testing tools to test the read and write performance of Redis in your system and in your configuration

#将redis做成一个服务
#必须将其复制到 the/ETC/RC.D/INIT.D directory, copy the Redis_init_script to/etc/rc.d/init.d/and easily name Redis.

CP /data/tgz/redis-3.2. 1/utils/redis_init_script/etc/rc.d/init.d/redis

#如果这时添加注册服务:
Chkconfig--add Redis
#将报以下错误:
Redis service does not support Chkconfig
#为此, we need to change the Redis script.

vim/etc/rc.d/init.d/redis#!/bin/sh2345  #添加这一行 # Also modify the exec=/data/apps/redis/bin/redis-servercliexec=/data/apps/redis/bin/redis-cli


#将redis配置文件拷贝到/etc/redis/${redisport}.conf

mkdir /etc/rediscp /data/tgz/redis-3.0. 7/redis.conf/etc/redis/6379. confCP /data/tgz/redis-3.0. 7/redis.conf/data/apps/redis/bin/redis.conf


Redis configuration password, especially important
Remove the comment before the line, and change the password to the desired password, save the file

#requirepass foobared Requirepass mypasswd

Problems caused by not setting a password:

#安全起见, password must be set, otherwise vulnerable to attack, please see the following blog:
Redis Unauthorized access defects
http://my.oschina.net/huihua/blog/697300
http://blog.csdn.net/u010391029/article/details/51711185
Http://www.th7.cn/db/nosql/201606/193670.shtml
Http://www.tuicool.com/articles/bMFbIzU
http://my.oschina.net/huihua/blog/697300
Solution Solutions
http://blog.csdn.net/fgf00/article/details/51388422
Http://www.8090st.com/linux-bingdu-kill.html
Http://www.ipastimes.com/post/86.html

Redis Security Settings
https://ruby-china.org/topics/28094
http://blog.csdn.net/21aspnet/article/details/50578668
http://blog.csdn.net/hel12he/article/details/46911159
Http://www.111cn.net/sys/centos/85890.htm
Https://www.phpxun.com/post/136.html
http://blog.knownsec.com/2015/11/analysis-of-redis-unauthorized-of-expolit/
Http://www.ctohome.com/FuWuQi/33/627.html


The persistence of Redis has two types of RDB and aof.
An RDB is a record of operations over a period of time, and a set of configurations is persistent over many times over a period of time.
AoF can be persisted for each operation.
Here we use AOF.

Configuration, open the Redis configuration file. Find AppendOnly. The default is AppendOnly No. Change to appendonly yes.

redis.conf parameters, specific reference blog:

Http://www.cnblogs.com/joshua317/p/5635297.html


Daemonize: Whether to run daemon mode later
Pidfile:pid File Location
Port: Port number for listening
Timeout: Request time-out
Loglevel:log Information level
Logfile:log File Location
Databases: number of open databases
Save *: The frequency at which the snapshot is saved, the first * indicates how long (seconds), and the third * indicates how many times the write operation was performed. Snapshots are automatically saved when a certain number of writes are performed within a certain amount of time. You can set multiple conditions.
Rdbcompression: Whether to use compression
Dbfilename: Data Snapshot file name (only file name, excluding directory)
Dir: Save directory for Data snapshot (this is the directory)
AppendOnly: If the appendonlylog is turned on, each write will record a log, which will improve the data anti-risk ability, but affect the efficiency.
Appendfsync:appendonlylog How to sync to disk (three options, each write is forced to call Fsync, Fsync per second, do not call Fsync wait for the system to synchronize itself)
Slaveof: Master-slave configuration, configure the master IP port on the Redis-slave to


In this way, the conf specified by the Redis service script exists. By default, Redis does not have authentication enabled, and you can specify a verification password by turning on the requirepass of 6379.conf.

#注册redis服务:

Chkconfig--add Redischkconfig redis on

Add the directory of the Redis command to the system parameter path
Vi/etc/profile
Append in last line:
Export path= "$PATH:/data/apps/redis/bin"

Then apply this file immediately:
./etc/profile
Or
Source/etc/profile

This makes it possible to invoke the REDIS-CLI command directly, as follows:
Redis-cli
Redis 127.0.0.1:6379> Auth mypasswd
Ok
Redis 127.0.0.1:6379>

#启动redis服务

#1. Direct start

./redis-server./redis.conf &

#如果更改了端口, you also need to specify a port when using the ' redis-cli ' client connection, for example:

6380

#2 use Redis startup script to set up boot (recommended)

Service REDISD Start

#关闭redis

./REDIS-CLI-a mypasswd save# or use the Bgsave command

#关闭

REDIS-CLI shutdown
#因为Redis可以妥善处理SIGTERM信号, so direct kill-9 is also possible.
Kill-9 PID
#指定密码关闭
/data/apps/redis/bin/redis-cli-a mypasswd shutdown

Redis Source Installation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.