|
a) 配置redis环境变量
[root@cache ~]# exportPATH=/application/redis/bin/:$PATH
# 该行只是临时生效redis命令的环境变量
[root@cache ~]#redis-server # 在命令行下测试该命令,如果能tab键出来,表示为成功;
[root@cache ~]# echo"PATH=/application/redis/bin/:$PATH" >>/etc/profile
# 写入到配置文件,使其永久生效
[root@cache ~]# tail -1/etc/profile # 查看是否添加正确
PATH=/application/redis/bin/:/application/redis/bin/:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@cache redis-2.8.9]# ./etc/profile # 执行后,使配置立即生效
[root@cache redis-2.8.9]# whichredis-server # 查看是否有redis-server命令及位置
/application/redis/bin/redis-server
b)查看命令帮助
[root@cache redis-2.8.9]# redis-server--help
Usage: ./redis-server[/path/to/redis.conf] [options]
./redis-server - (read config fromstdin)
./redis-server -v or --version
./redis-server -h or --help
./redis-server --test-memory
Examples:
./redis-server (run the server withdefault conf)
./redis-server /etc/redis/6379.conf
./redis-server --port 7777
./redis-server --port 7777 --slaveof127.0.0.1 8888
./redis-server /etc/myredis.conf--loglevel verbose
Sentinel mode:
./redis-server /etc/sentinel.conf--sentinel
c)启动redis服务
[root@cache ~]# mkdir/application/redis/conf
# 1)创建redis的配置文件目录
[root@cache ~]# cp/application/tools/redis-2.8.9/redis.conf /application/redis/conf/
# 2) 拷贝源码包目录下的redis.conf文件
[root@cache ~]# sysctlvm.overcommit_memory=1
# 3) 执行sysctl命令,分配内存大小
vm.overcommit_memory = 1
[root@cache ~]# redis-server/application/redis/conf/redis.conf & # 启动服务
[1] 15623
[root@cache ~]# [15623] 04 Jun20:35:02.093 * Increased maximum number of open files to 10032 (it wasoriginally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 15623
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[15623] 04 Jun 20:35:02.097 #Server started, Redis version 2.8.9
[15623] 04 Jun 20:35:02.097 *The server is now ready to accept connections on port 6379
[root@cache ~]# lsof-i:6379 #查看redis是否启动
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODENAME
redis-ser 15623 root 4u IPv6 31395 0t0 TCP *:6379 (LISTEN)
redis-ser 15623 root 5u IPv4 31397 0t0 TCP*:6379 (LISTEN)
|
|
|
|
|
|
|