1.启动服务,连接
通过指定的配置文件启动服务
[root@iZbp12fj4dxm8z5uofcvshZ ~]# cd /usr/local/bin [root@iZbp12fj4dxm8z5uofcvshZ bin]# ls chardetect cloud-init easy_install jemalloc-config jsondiff jsonschema luajit-2.0.4 redis-benchmark redis-cli chen_redis_config cloud-init-per easy_install-3.6 jemalloc.sh jsonpatch libmcrypt-config mcrypt redis-check-aof redis-sentinel cloud-id dump.rdb easy_install-3.8 jeprof jsonpointer luajit mdecrypt redis-check-rdb redis-server [root@iZbp12fj4dxm8z5uofcvshZ bin]# redis-server chen_redis_config/redis.conf 2998:C 29 Nov 2021 19:19:39.453 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 2998:C 29 Nov 2021 19:19:39.453 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=2998, just started 2998:C 29 Nov 2021 19:19:39.453 # Configuration loaded
使用redis客户端进行连接、测试,默认端口号是6379,这里我修改成了自己的端口号
[root@iZbp12fj4dxm8z5uofcvshZ bin]# redis-cli -p 2021 127.0.0.1:2021> ping (error) NOAUTH Authentication required. 127.0.0.1:2021> auth 526260 OK 127.0.0.1:2021> ping PONG 127.0.0.1:2021> keys * (empty list or set) 127.0.0.1:2021> set name zhangsan OK 127.0.0.1:2021> keys * 1) "name"
查看redis的进程是否开启
[root@iZbp12fj4dxm8z5uofcvshZ ~]# ps -ef|grep redis root 1653 1 0 19:12 ? 00:00:03 redis-server *:2021 root 7928 2206 0 19:52 pts/1 00:00:00 redis-cli -p 2021 root 8559 8496 0 19:56 pts/0 00:00:00 grep --color=auto redis
关闭redis服务
127.0.0.1:2021> shutdown not connected> exit [root@iZbp12fj4dxm8z5uofcvshZ bin]#
再次查看进程是否存在
[root@iZbp12fj4dxm8z5uofcvshZ ~]# ps -ef|grep redis root 8816 8496 0 19:58 pts/0 00:00:00 grep --color=auto redis [root@iZbp12fj4dxm8z5uofcvshZ ~]#
2. redis性能测试
使用redis-benchmark工具(官方自带的性能测试工具)
100个并发连接,100000次请求,每次写入3个字节
[root@iZbp12fj4dxm8z5uofcvshZ ~]# redis-benchmark -h localhost -p 2021 -c 100 -n 100000 ====== PING_INLINE ====== 100000 requests completed in 2.16 seconds 100 parallel clients 3 bytes payload keep alive: 1 11.54% <= 1 milliseconds 94.56% <= 2 milliseconds 99.36% <= 3 m