[root@biao ~]# yum install redis Loaded plugins: fastestmirror Determining fastest mirrors * epel: mirrors.ustc.edu.cn addons | 1.9 kB 00:00 base | 1.1 kB 00:00 epel | 3.7 kB 00:00 epel/primary_db | 3.1 MB 00:02 extras | 2.1 kB 00:00 update | 1.9 kB 00:00 update/primary_db | 941 kB 00:00 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package redis.i386 0:2.4.10-1.el5 set to be updated --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================= Package Arch Version Repository Size ============================================================================================================================= Installing: redis i386 2.4.10-1.el5 epel 299 k Transaction Summary ============================================================================================================================= Install 1 Package(s) Upgrade 0 Package(s) Total download size: 299 k Is this ok [y/N]: y Downloading Packages: redis-2.4.10-1.el5.i386.rpm | 299 kB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : redis 1/1 Installed: redis.i386 0:2.4.10-1.el5 Complete! 2、检查安装的文件及目录 [root@biao ~]# find / -name "redis*" /usr/share/doc/redis-2.4.10 /usr/sbin/redis-server /usr/bin/redis-check-aof /usr/bin/redis-check-dump /usr/bin/redis-benchmark /usr/bin/redis-cli /var/log/redis /var/lib/redis /var/run/redis /etc/redis.conf /etc/rc.d/init.d/redis /etc/logrotate.d/redis注意主要的的几个安装目录:/usr/sbin/redis-server:redis启动服务目录。/etc/redis.conf:redis服务读取的参数配置文件。 3、在/etc/redis.conf文件中配置参数: 作为简单测试,只需要了解并正确配置其中的几个参数,此版本默认设置即可。 daemonize:指定Redis是否后台运行。 # 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 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 bind:绑定的地址。 # If you want you can bind a single interface, if the bind option is not # specified all the interfaces will listen for incoming connections. # bind 127.0.0.1 4、启动redis-server [root@biao ~]# redis-server /etc/redis.conf 可以通过pstree或者ps aux|grep命令检验redis是否启动成功: [root@biao ~]# pstree ... ├─redis-server───2*[{redis-server}] ... [root@biao ~]# ps aux|grep redis-server root 6508 0.0 0.0 31060 1116 ? Ssl 01:26 0:00 redis-server /etc/redis.conf root 6581 0.0 0.0 4024 684 pts/7 R+ 01:28 0:00 grep redis-server 5、连接Redis并简单测试操作 [root@biao ~]# telnet localhost 6379 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. set test hello +OK get test $5 hello如上所示,Redis安装成功并运行正常。 转载请保留固定链接: https://linuxeye.com/configuration/1788.html |