Tutorial for installing and configuring the Redis database on the CenOS system
- 2020-05-13 03:47:03
- OfStack
1: install redis
wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz
tar zxvf redis-2.6.14.tar.gz
cd redis-2.6.14
make PREFIX=/usr/local/redis install
2: configure redis
Use the default configuration file and modify it slightly
1. Customary practice, configuration files in the source installation folder, easy to manage it
mkdir /usr/local/redis/etc/
cp redis-2.6.14/redis.conf /usr/local/redis/etc/
2. Modify the configuration files/usr local redis/etc/redis conf
(1)Redis does not run as a daemon by default, and can be modified with this configuration item to enable the daemon with yes
daemonize yes
(2) close the connection when the client is idle for a long time. If it is specified as 0, it means to close the function
timeout 300
(3) specify the redis log
logfile /var/log/redis.log
(4) specify the local database storage directory
dir /data/redis/redis_db
3. Start redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
3: test redis
1 demonstrates a simple set key, get key operation...
Please install php redis client, under the specific installation reference (https: / / github com/nicolasff/phpredis)
<?php
$redis = new Redis();
try{
$redis->connect('127.0.0.1',6379);
}
catch (Exception $e){
die("Cannot connect to redis server:".$e->getMessage() );
}
$redis->set('name','budong');
echo $redis->get('name');
?>
Output budong and the installation is successful.
2. The playability of redis is too much. The operation and maintenance must check the operation information of redis, as follows:
[root@Cache ~]# /usr/local/redis/bin/redis-cli
redis 127.0.0.1:6379> INFO
Some of the results are as follows:
redis_version:2.4.7
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:64
multiplexing_api:epoll
gcc_version:4.1.2
process_id:26615
uptime_in_seconds:2717407
uptime_in_days:31
lru_clock:117839
used_cpu_sys:102659.58
used_cpu_user:101565.17
used_cpu_sys_children:125215.15
used_cpu_user_children:807371.44