Full Process log for installing Redis in Linux, linuxredis

Source: Internet
Author: User

Full Process log for installing Redis in Linux, linuxredis

Wget http://download.redis.io/redis-stable.tar.gz
Tar xvzf redis-stable.tar.gz
Cd redis-stable
Make
 
There should be no problem in the previous three steps. The main problem is that an exception occurs when you execute make.
Exception 1:
Make [2]: cc: Command not found
Cause of exception: gcc Is Not Installed
Solution: yum install gcc-c ++
Exception 2:
Zmalloc. h: 51: 31: error: jemalloc/jemalloc. h: No such file or directory
Cause of exception: Some compilation dependencies or issues left behind by the original compilation
Solution: make distclean. Clean up and then make.


Make test is required after make is successful. An exception occurred in make test.
Exception 1:
Couldn't execute "tclsh8.5": no such file or directory
Cause of exception: tcl is not installed
Solution: yum install-y tcl.
 
After make is successful, some executable files will be added to the src directory: redis-server, redis-cli, and so on.


During this period, copy the cp command to the usr directory and run it.
Cp redis-server/usr/local/bin/
Cp redis-cli/usr/local/bin/


Create a directory to store the configuration file.
Mkdir/etc/redis
Mkdir/var/redis
Mkdir/var/redis/log
Mkdir/var/redis/run
Mkdir/var/apsaradb for redis/6379


Find the configuration file template in the redis root directory and copy it to the following location.
Cp redis. conf/etc/redis/6379. conf
Use the vim command to modify
Daemonize yes
Pidfile/var/redis/run/redis_62.16.pid
Logfile/var/redis/log/redis_62.16.log
Dir/var/redis/6379
Finally run redis:
$ Redis-server/etc/redis/6379. conf
################################# Automatic startup configuration #### #############################
#! /Bin/sh
#
# Chkconfig: 2345 90 10
# Description: Redis is a persistent key-value database
# Redis Startup script for redis processes
# Processname: redis
Redis_path = "/usr/local/bin/redis-server"
Redis_conf = "/etc/redis/6379. conf"
Redis_pid = "/var/redis/run/redis_62.16.pid"
# Source function library.
./Etc/rc. d/init. d/functions
[-X $ redis_path] | exit 0
RETVAL = 0
Prog = "redis"
# Start daemons.
Start (){
If [-e $ redis_pid-! -Z $ redis_pid]; then
Echo $ prog "already running ...."
Exit 1
Fi
Echo-n $ "Starting $ prog"
# Single instance for all caches
$ Redis_path $ redis_conf
RETVAL =$?
[$ RETVAL-eq 0] & {
Touch/var/lock/subsys/$ prog
Success $ "$ prog"
}
Echo
Return $ RETVAL
}
# Stop daemons.
Stop (){
Echo-n $ "Stopping $ prog"
Killproc-d 10 $ redis_path
Echo
[$ RETVAL = 0] & rm-f $ redis_pid/var/lock/subsys/$ prog
RETVAL =$?
Return $ RETVAL
}
# See how we were called.
Case "$1" in
Start)
Start
;;
Stop)
Stop
;;
Status)
Status $ prog
RETVAL =$?
;;
Restart)
Stop
Start
;;
Condrestart)
If test "x 'pidof redis '"! = X; then
Stop
Start
Fi
;;
*)
Echo $ "Usage: $0 {start | stop | status | restart | condrestart }"
Exit 1
Esac
Exit $ RETVAL
-------------------------------------------------------
: Wq! # Save and exit
Chmod 755/etc/init. d/redis # Add the script execution permission
Chkconfig -- add redis # add enable startup
Chkconfig -- level 2345 redis on # Set the startup level
Chkconfig -- list redis # view the startup level
Service redis restart # restart redis
################################# Set redis configuration file parameters ## ############################
Mkdir-p/usr/local/redis/var # create a directory for storing redis Databases
Vim/etc/redis/6370. conf


Daemonize yes # Run redis in daemon mode later
Pidfile "/var/run/redis. pid" # run on apsaradb for redis later. The default pid file path is/var/run/redis. pid.
Port 6379 # default port
Bind 127.0.0.1 # All ip addresses of the local machine are bound by default. To ensure security, you can only listen to intranet ip addresses.
Timeout 300 # client timeout settings, in seconds
Loglevel verbose # Set the log level. Four levels are supported: debug, notice, verbose, and warning.
Logfile stdout # log record method. The default value is standard output. logs does not write files and is output to an empty device/deb/null.
Logfile "/usr/local/redis/var/redis. log" # You can specify the log file path
Databases 16 # Number of enabled databases
Save 900 1
Save 300 10
Save 60 10000
Create a local database snapshot in the format of save **
1 write operation in 900 seconds
10 write operations performed within 300 seconds
10000 write operations performed within 60 seconds
Rdbcompression yes # enable lzf compression or set it to no
Dbfilename dump. rdb # Name of the local snapshot Database
Dir "/usr/local/redis/var/" # local snapshot database storage directory
Requirepass 123456 # Set the redis database connection password
Maxclients 10000 # maximum number of client connections at the same time, 0 is unlimited
Maxmemory 1024 MB # set the maximum memory used by redis. The value must be smaller than the physical memory.
Appendonly yes # Enable logging, equivalent to MySQL binlog
Appendfilename "appendonly. aof" # log file name. Note: it is not a directory path.
Appendfsync everysec # executes synchronization every second. Two other parameters always and no are generally set to everysec, which is equivalent to the write method of MySQL transaction logs.
: Wq! # Save and exit
Service redis restart # restart
#################################### Test the redis database # ###################################
Redis-cli-a 123456 # connect to the redis database. Note:-a is followed by the redis Database Password
Set name 111cn.net # Write Data
Get name # Read data
Exit # exit the apsaradb for redis Console
Redis-benchmark-h 127.0.0.1-p 6379-c 1000-n 100000 #1000 concurrent connections and 100000 requests, test the performance of the redis server with 127.0.0.1 port 6379


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.