Redis企业级开发与运维-初识Redis( 三 )


[root@ittimeline config]# mkdir /opt/redis/data然后使用指定配置文件启动的方式启动redis服务器,并使用ps命令查看6382端口的redis-server进程是否启动
[root@ittimeline config]# redis-server redis-6382.conf [root@ittimeline config]# ps -ef|grep redis-server|grep 6382root1864510 19:10 ?00:00:00 redis-server *:6382服务启动之后可以使用cat命令来查看redis-server的服务启动日志
[root@ittimeline config]# cat /opt/redis/data/redis-6382.log 18819:C 04 Jul 2020 19:16:39.150 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo18819:C 04 Jul 2020 19:16:39.150 # Redis version=6.0.5, bits=64, commit=00000000, modified=0, pid=18819, just started18819:C 04 Jul 2020 19:16:39.150 # Configuration loaded18820:M 04 Jul 2020 19:16:39.152 * Increased maximum number of open files to 10032 (it was originally set to 1024).18820:M 04 Jul 2020 19:16:39.153 * Running mode=standalone, port=6382.18820:M 04 Jul 2020 19:16:39.153 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.18820:M 04 Jul 2020 19:16:39.153 # Server initialized18820:M 04 Jul 2020 19:16:39.153 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.18820:M 04 Jul 2020 19:16:39.153 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.18820:M 04 Jul 2020 19:16:39.153 * Ready to accept connectionsRedis客户端连接使用redis-cli工具连接redis服务器,通过-p选项指定redis服务器的端口,通过-h指定服务器的主机,127.0.0.1表示本机,即客户端和服务器在同一台服务器上 。
[root@ittimeline ~]# redis-cli-p 6379 -h 127.0.0.1127.0.0.1:6379> 当客户端连接服务器成功之后就可以使用set/get命令来设值和取值,当输入set命令时客户端会提示set命令的使用方法 。

Redis企业级开发与运维-初识Redis

文章插图
 
设置name属性的值为tony
Redis企业级开发与运维-初识Redis

文章插图
 
127.0.0.1:6379> set name tonyset值以后就可以使用get来获取对应的属性值
127.0.0.1:6379> get name"tony"当客户端输入ping时,服务端会返回PONG
127.0.0.1:6379> pingPONG如果客户端想要退出,只需要输入exit就可以 。
exit
Redis企业级开发与运维-初识Redis

文章插图
退出连接
redis-cli客户端连接服务端默认的端口是6379,默认的ip就是127.0.0.1,因此如果客户端和服务端在一台机器上时,直接输入redis-cli就可以连接redis服务器 。
Redis企业级开发与运维-初识Redis

文章插图
 




推荐阅读