Redis installation, redis

Source: Internet
Author: User
Tags benchmark download redis redis download redis windows install redis

Redis installation, redis

I installed redis myself today.

1: Download redisHttp://code.google.com/p/redis/downloads/list


The latest redis-2.6.14 version I downloaded

2: Install redis download decompress tar zxvf redis-2.6.14.tar.gz to any directory, such as/birenjie/redis-2.6.14
Decompress the package and go to the redis directory.
Cd/birenjie/redis-2.6.14
Make

After make, we will get the following executable files:

Redis-server: Daemon Startup Program of the Redis Server

Redis-cli: Redis command line operation tool. Or use telnet for plain text protocol operations.

Redis-benchmark: Redis performance testing tool to test the read/write performance of Redis in your system and your configuration

Copy an object
Configuration File started by redis when cp redis. conf/etc/is used
Cp redis-benchmark redis-cli redis-server/usr/bin/# is very useful, so you do not need to add it during execution. /, and it can be executed anywhere. Note that the directories of these files are under the src directory. If you are not familiar with them, you need to pay attention to them.

3. Optimization

3.1 set the Memory Allocation Policy (optional) based on the actual situation of the server)
/Proc/sys/vm/overcommit_memory
Optional values: 0, 1, and 2.
0 indicates that the kernel will check whether there is enough available memory for use by the process. If there is enough available memory, the memory application will be allowed; otherwise, the memory application will fail, and return the error to the application process.
1 indicates that the kernel allows all physical memory allocation regardless of the current memory status.
2. indicates that the kernel is allowed to allocate more memory than the total physical memory and swap space.
It is worth noting that redis will fork a sub-process when dumping data. In theory, the memory occupied by the child process is the same as that of the parent process, for example, if the memory occupied by parent is 8 GB, 8 GB of memory should be allocated to the child at the same time. If the memory is not sufficient, it will usually cause the redis server to go down or the IO load is too high, reduced efficiency. Therefore, the optimized memory allocation policy should be set to 1 (indicating that the kernel allows allocation of all physical memory, regardless of the current memory status)

Echo 1>/proc/sys/vm/overcommit_memory


3.2 modify the/etc/sysctl. conf file

Vim/etc/sysctl. conf

Append vm. overcommit_memory = 1
Then run sysctl vm. overcommit_memory = 1 to make it take effect:

4: Start redis-server/etc/redis. conf.


Check the process and confirm that redis has been started.
Root@localhost.localdomain: [/root] ps-ef | grep redis
Root 6493 5213 0 00:00:00 pts/1 more/etc/redis. conf
Root 6543 6516 0 00:00:00 pts/4 redis-cli
Root 6692 2221 0 00:00:00 pts/0 redis-server/etc/redis. conf
Root 6697 6606 0 00:00:00 pts/5 grep redis


We recommend that you modify redis. conf and set the redis process as the background daemon.
# 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 no

Change daemonize to yes
5: Test redis
Root@localhost.localdomain: [/root] redis-cli
Redis 127.0.0.1: 6379> set name jack
OK
Redis 127.0.0.1: 6379> get name
"Jack"
6. Disable the redis service.

Redis-cli shutdown

Redis 127.0.0.1: 6379> shutdown

[6467] 23 Oct 14:15:21. 845 # User requested shutdown...
[6467] 23 Oct 14:15:21. 845 * Saving the final RDB snapshot before exiting.
[6467] 23 Oct 14:15:21. 926 * DB saved on disk
[6467] 23 Oct 14:15:21. 926 # Redis is now ready to exit, bye...



When the redis service is disabled, the cached data is automatically dumped to the hard disk. The hard disk address is set by dbfilename dump. rdb, the configuration item in redis. conf.


Use the following command to forcibly back up data to a disk:
Redis-cli save or redis-cli-p 6380 save (specified port)

7. redis Port

The default redis port is 6379. You can modify the redis. conf port.

# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
Port 6379



How to install redis in Windows 7

Github.com/dmajkic/redis/downloads. The downloaded Redis supports 32bit and 64bit. Select 32bit based on your actual situation. Copy the 32bit file content to the directory to be installed, such as: D: \ dev \ redis-2.4.5.
Open a cmd window and use the cd command to switch to the specified directory (D: \ dev \ redis-2.4.5) and run the redis-server.exe redis. conf.

Reopen a cmd window and use the cd command to switch to the specified directory (D: \ dev \ redis-2.4.5) and run redis-cli.exe-h 127.0.0.1-p 6379, where 127.0.0.1 is a local ip, 6379 is the default port of the redis server.

In this way, the Redis windows environment has been built.

The environment has been set up. You have to test it. For example, store a string whose key is test and value is hello word, and then obtain the key value.
 
Redis extension cannot take effect in win7 64-bit WAMP environment (PHP54)

Is the extension loaded in PHP. INI after installation?
 

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.