AWS EC2 CentOS release 6.5 deploys redis

AWS EC2 CentOS release 6.5 deployment redis
reference: http://blog.csdn.net/ludonqin/article/details/47211109One


. Install redis
1) Download the redis installation
package , go to the official website http://redis.io, or use the wget command:
[root@ip-172-31-46-4 ~]# wget http://download.redis.io /redis-stable.tar.gz


2) Unzip
Execute the command:
[root@ip-172-31-46-4 ~]# tar –zxvf redis-stable.tar.gz


3) Compile and install
Execute the command:
[root@ ip-172-31-46-4 ~]# cd redis-stable


execute the command:
[root@ip-172-31-46-4 redis-stable]# make


After the make is successful, you need to execute the command:
[root@ip -172-31-46-4 redis-stable]# After the make test


is successful, you can manually copy redis-server, redis-cli, redis-check-aof, redis-check-dump, etc. in the src directory to /usr/local/bin In the directory, you can also execute the command:
[root@ip-172-31-46-4 redis-stable]# make install


verify the startup script in the system directory:
[root@ip-172-31-46-4 ~]# cd /usr/local/bin
[root @ip-172-31-46-4 bin]# ls -ltrh
total 26M
-rwxr-xr-x 1 root root 7.5M Jan 7 08:03 redis-server
-rwxr-xr-x 1 root root 5.4M Jan 7 08:03 redis-benchmark
-rwxr-xr-x 1 root root 5.5M Jan 7 08:03 redis-cli
-rwxr-xr-x 1 root root 7.5M Jan 7 08:03 redis-check-rdb
lrwxrwxrwx 1 root root 12 Jan 7 08:03 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 22K Jan 7 08:03 redis-check-aof




II. Modify configuration file.conf


1) Create configuration file directory, dump file directory, process pid directory, log directory, etc.
Configuration files are generally placed under /etc/, and create a redis directory
[root@ip-172-31-46-4 bin] # cd /etc/
[root@ip-172-31-46-4 etc]# mkdir redis


ll View the created redis directory
~
dump file, process pid, log directory, etc., usually placed in the /var/ directory,
[root@ip-172- 31-46-4 etc]# cd /var/
[root@ip-172-31-46-4 var]# mkdir redis
[root@ip-172-31-46-4 var]# cd redis
[root@ip -172-31-46-4 redis]# mkdir data log run


At this point, the directory creation is completed


2) Modify the configuration file, configure the parameters
First copy the redis.conf file under the decompressed package to /etc/redis
[root@ip-172- 31-46-4 redis]# cp ~/redis-stable/redis.conf /etc/redis/


Open the configuration file:
[root@ip-172-31-46-4 redis]# vi /etc/redis/redis. conf


modifies the port (default 6379)
# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379


修改pid目录为新建目录
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
pidfile /var/redis/run/redis_6379.pid


修改dump目录为新建目录
# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /var/redis/data


修改log存储目录为新建目录
# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile /var /redis/log/redis.log


Modify the configuration file to make redis run in the background (the default redis service runs in console mode)
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes


3) Persistence The
default rdb, you can choose whether to enable aof, if enabled, modify the configuration file appendonly


4) Start redis and view the files in each directory
[ root@ip-172-31-46-4 redis]# cd /usr/bin/
[root@ip-172-31-46-4 bin]# redis-server /etc/redis/redis.conf


Redis has been started, check the process, dump, log, pid, etc.


5) The client connects to redis
[root@ip-172-31-46-4 bin]# redis-cli

default port 6379


6) At this point, the basic configuration of redis is completed, if There are other related configuration adjustments, you can find




the . 1) Create a redis startup
script
Copy the redis startup script under utils under the decompressed package to /etc/init.d/
[root@ip-172-31-46-4 bin]# cp ~/redis-stable/ utils/redis_init_script /etc/init.d/


Modify the script name (or not) to redis
[root@ip-172-31-46-4 bin]# mv /etc/init.d/redis_init_script /etc/init.d /redis


modify the script pid and conf path to the actual path
[root@ip-172-31-46-4 bin]# vi /etc/init.d/redis_init_script
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli


PIDFILE=/var/redis/run/redis_${REDISPORT}.pid
CONF="/etc/redis/redis.conf" So
 


far, in the /etc/init.d/ directory, you can
start and close redis through the service redis start/stop command.
 
If it is in another directory, you cannot use these 2 A command, please continue to configure 2), add permissions
2) Add permissions to the startup script
chmod +x /etc/init.d/redis


The actual command will be different depending on the directory The
corresponding deletion permission is
chmod –x /etc /init.d/redis
If you need the redis service to start automatically at boot time, you can continue 3)
3) Set the self-starting
chkconfig redis on
If the operation reports an error, the prompt


is because the redis startup priority information is not added to the startup script, you can Add the following Execute chkconfig redis on


again , successful
 
At this point, the self-starting configuration is complete


----------------------------------- ---------------------


Where the installation may go wrong:
a. If the prompt:
gcc command is not recognized, please install gcc by yourself;
(execute: yum -y install gcc )
b. If prompted:
couldn't execute tcl : no such file or dicrectory, please install tcl by yourself;
(execute: yum install -y tcl)
c. If prompted:
zmalloc.h:51:31: error: jemalloc/jemalloc.h: No such file or directory
is due to compilation dependencies or problems left over from the original compilation
(execute: make distclean)
d. If prompted:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55 :2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/data0/src/redis-2.6.2/src'
make: *** [all] Error 2zmalloc.h:50:31: error: jemalloc/jemalloc.h:; The
reason is that jemalloc overloads the ANSI C malloc and free functions under Linux

(execute: make MALLOC=libc)


Advanced:

For configuration file description, please refer to: http://www.cnblogs.com/kreo/p/4423362.html

To build a redis cluster, please refer to: http://www.cnblogs.com/wuxl360/p/5920330.html




Guess you like

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