## linux查看redis安装路径
redis-cli -h 127.0.0.1 -p 6379
redis-cli monitor > redis2.log
/usr/local/redis-3.2.5/src/redis-server /usr/local/redis-3.2.5/redis.conf
[root@my-test-01 ~]$free -m
total used free shared buff/cache available
Mem: 64266 27547 16269 0 20450 35959
Swap: 0 0 0
登录redis客户端查看容量
[root@my-test-01 ~]$redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> info memory
# Memory
used_memory:5076792
used_memory_human:4.84M
used_memory_rss:7237632
used_memory_rss_human:6.90M
used_memory_peak:27065200
used_memory_peak_human:25.81M
total_system_memory:67388731392
total_system_memory_human:62.76G
used_memory_lua:52224
used_memory_lua_human:51.00K
maxmemory:134217728
maxmemory_human:128.00M
maxmemory_policy:volatile-lru
mem_fragmentation_ratio:1.43
mem_allocator:jemalloc-4.0.3
将监控日志写入log文件
[root@my-test-01 ~]$redis-cli monitor > redis-op2.log
[root@my-test-01 ~]$redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> info commandstats
# Commandstats
cmdstat_get:calls=3897162,usec=18758665,usec_per_call=4.81
cmdstat_set:calls=7235965,usec=40049820,usec_per_call=5.53
cmdstat_setnx:calls=2724,usec=18518,usec_per_call=6.80
cmdstat_setex:calls=1478703,usec=9878496,usec_per_call=6.68
cmdstat_del:calls=3531634,usec=20050810,usec_per_call=5.68
cmdstat_exists:calls=1625569,usec=6828950,usec_per_call=4.20
cmdstat_mget:calls=572,usec=4397,usec_per_call=7.69
cmdstat_lpush:calls=4,usec=58,usec_per_call=14.50
cmdstat_blpop:calls=4,usec=40,usec_per_call=10.00
cmdstat_sadd:calls=6371,usec=25038,usec_per_call=3.93
cmdstat_sismember:calls=1620372,usec=7241691,usec_per_call=4.47
cmdstat_scard:calls=1621524,usec=5919773,usec_per_call=3.65
cmdstat_spop:calls=6,usec=17,usec_per_call=2.83
cmdstat_smembers:calls=4335,usec=21872,usec_per_call=5.05
cmdstat_zadd:calls=3252,usec=14673,usec_per_call=4.51
cmdstat_zrange:calls=617,usec=4631,usec_per_call=7.51
cmdstat_hset:calls=86,usec=638,usec_per_call=7.42
cmdstat_hget:calls=189,usec=1249,usec_per_call=6.61
cmdstat_hincrby:calls=13,usec=76,usec_per_call=5.85
cmdstat_hdel:calls=204,usec=561,usec_per_call=2.75
cmdstat_hvals:calls=20,usec=96,usec_per_call=4.80
cmdstat_hexists:calls=16,usec=42,usec_per_call=2.62
cmdstat_incrby:calls=114,usec=1050,usec_per_call=9.21
cmdstat_select:calls=8844,usec=10161,usec_per_call=1.15
cmdstat_expire:calls=201,usec=1568,usec_per_call=7.80
cmdstat_pexpire:calls=5150487,usec=22899495,usec_per_call=4.45
cmdstat_pexpireat:calls=104,usec=438,usec_per_call=4.21
cmdstat_keys:calls=3,usec=566,usec_per_call=188.67
cmdstat_scan:calls=2,usec=2028,usec_per_call=1014.00
cmdstat_auth:calls=4,usec=7,usec_per_call=1.75
cmdstat_ping:calls=95046,usec=112657,usec_per_call=1.19
cmdstat_save:calls=1447,usec=6546674,usec_per_call=4524.31
cmdstat_flushall:calls=582,usec=1970201,usec_per_call=3385.23
cmdstat_info:calls=614,usec=49658,usec_per_call=80.88
cmdstat_monitor:calls=1,usec=0,usec_per_call=0.00
cmdstat_ttl:calls=1,usec=5,usec_per_call=5.00
cmdstat_pttl:calls=1,usec=1,usec_per_call=1.00
cmdstat_config:calls=2612,usec=18257,usec_per_call=6.99
cmdstat_subscribe:calls=7,usec=46,usec_per_call=6.57
cmdstat_unsubscribe:calls=1,usec=12,usec_per_call=12.00
cmdstat_psubscribe:calls=2,usec=25,usec_per_call=12.50
cmdstat_publish:calls=12,usec=36,usec_per_call=3.00
cmdstat_eval:calls=45,usec=3015,usec_per_call=67.00
cmdstat_command:calls=279,usec=136413,usec_per_call=488.94
cmdstat_host::calls=2,usec=34,usec_per_call=17.00
linux下如何查看redis服务所在的安装路径?
检测后台进程是否存在
ps -ef | grep redis
[root@my-test-01 ~]$ps -ef | grep redis
root 18637 1 0 Dec24 ? 00:28:59 redis-server *:6379
root 19317 3344 0 17:35 pts/0 00:00:00 redis-cli monitor
root 30999 21658 0 17:37 pts/1 00:00:00 grep --color=auto redis
检测6379端口是否在监听
netstat -lntp | grep 6379
关闭
redis-cli shutdown kill -9 PID
启动
redis-server redis-server & 加上`&`号使redis以后台程序方式运行
redis-server /opt/test/conf/redis.conf # 启动的时候需要带上配置文件的目录。(关键)
127.0.0.1:6379> keys * // 查询keys
[root@my-test-01 etc]$whereis redis-cli
redis-cli: /usr/bin/redis-cli /usr/local/bin/redis-cli /usr/share/man/man1/redis-cli.1.gz
[root@my-test-01 etc]$whereis redis-server
redis-server: /usr/bin/redis-server /usr/local/bin/redis-server /usr/share/man/man1/redis-server.1.gz
[root@my-test-01 ~]$ps -u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
[root@my-test-01 ~]$ps -u root
PID TTY TIME CMD
18637 ? 00:29:00 redis-server
进入进程目录
[root@my-test-01 ~]$cd /proc
[root@my-test-01 proc]$ls -l
total 0
dr-xr-xr-x 9 root root 0 Dec 24 16:40 18637
[root@my-test-01 proc]$cd 18637
[root@my-test-01 18637]$ls -l
total 0
lrwxrwxrwx 1 root root 0 Dec 27 17:42 cwd -> /etc
-r-------- 1 root root 0 Dec 27 17:42 environ
lrwxrwxrwx 1 root root 0 Dec 27 17:42 exe -> /usr/local/bin/redis-server
找到这个文件rc.local就可以定位目录了:
vi /etc/rc.local //在里面添加内容:/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf (意思就是开机调用这段开启redis的命令)
linux在启动一个进程时,系统会在/proc下创建一个以PID命名的文件夹,在该文件夹下会有我们的进程的信息,其中包括一个名为exe的文件即记录了绝对路径,通过ll或ls –l命令即可查看
cwd符号链接的是进程运行目录;
exe符号连接就是执行程序的绝对路径;
cmdline就是程序运行时输入的命令行命令;
environ记录了进程运行时的环境变量;
fd目录下是进程打开或使用的文件的符号连接
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:linux查看redis安装路径 - Python技术站