Home > Database > Redis > body text

How to install Redis3.0 in CentOS environment

WBOY
Release: 2023-05-27 11:43:05
forward
1079 people have browsed it

The online unified chat and push system redis version 2.8.6 has been running well for nearly a year. The reason why we tested redis3.0 is because 3.0 has added many new features compared to 2.8:

redis cluster - a distributed redis implementation
New "embedded string" object encoding results, fewer cache misses, and significant speed improvements under specific workloads
aof child -> parent final data transmission Minimize latency by "last write" during the aof rewrite process
Significantly improve the lru approximation algorithm for key erasure
wait command blocks waiting for the write operation to be transmitted to the specified number of slave nodes
migrate Connection caching, greatly improving the speed of key transplantation
migarte New parameters copy and replace
client pause command: stop processing client requests within the specified time
bitcount performance improvement
config set accepts different units Memory value, such as "config set maxmemory 1gb".
Small adjustment of redis log format for the role of reaction instance (master/slave)
incr performance improvement

Keep exploring technology while you are young Heart!

Start the installation

1. Install dependency packages

Copy the code The code is as follows:

[root@localhost ~]# yum install gcc gcc-c kernel-devel automake autoconf libtool make wget tcl vim ruby ​​rubygems unzip php-devel git -y

2. Install redis server

No need to ./configure, no need to make install just compile it

[root@localhost ~]# wget http://download.redis.io/releases/redis-3.0.6.tar.gz
[root@localhost ~]# tar xzf redis-3.0.6.tar.gz
[root@localhost ~]# cd redis-3.0.6
[root@localhost redis-3.0.6]# make
[root@localhost redis-3.0.6]# src/redis-server
Copy after login

3. Use redis client to test

[root@localhost redis-3.0.6]# src/redis-cli
127.0.0.1:6379> set key val
ok
127.0.0.1:6379> get key
"val"
127.0.0.1:6379> del key
(integer) 1
127.0.0.1:6379> exists key
(integer) 0
Copy after login

4. Install phpredis to facilitate the use of php to operate redis

phpredis download address:

[root@localhost ~]# unzip phpredis-develop.zip
[root@localhost ~]# cd phpredis-develop
[root@localhost phpredis-develop]# phpize
[root@localhost phpredis-develop]# ./configure
[root@localhost phpredis-develop]# make && make install
Copy after login

Tips: installing shared extensions: /usr /lib64/php/modules/

vi /etc/php.ini
Copy after login

Join

extension=redis.so
Copy after login

Restart apache

service httpd restart
Copy after login

How to install Redis3.0 in CentOS environment

##5. PHP connection redis code test

<?php
$redis = new redis();
$redis->connect(&#39;localhost&#39;, 6379);
$rs = $redis->set(&#39;test&#39;,"11111111111");
$result = $redis->get(&#39;test&#39;);
var_dump($result);//结果:string(11) "11111111111"
$redis->delete(&#39;test&#39;);
$redis->sadd("test","111");//往test集合中添加一个元素 111
$redis->sadd("test","222");
$redis->sadd("test","333");
$redis->sadd("test1","111");
$redis->sadd("test1","444");
//将集合test和集合test1的并集存进一个新集合new
var_dump($redis->sinterstore(&#39;new&#39;,"test","test1")); //结果:int(1)
//返回集合元素
var_dump($redis->smembers(&#39;new&#39;)); //结果:array(1) { [0]=> string(3) "111" }
?>
Copy after login

The above is the detailed content of How to install Redis3.0 in CentOS environment. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template