Redis第一篇(Redis单机版本安装及启动)
安装:
|
1
2
3
4
5
|
[root@M2_Redis1 ~]# yum install gcc gcc-c++ (安装依赖)[root@M2_Redis1 tools]# wget http://download.redis.io/releases/redis-3.0.7.tar.gz[root@M2_Redis1 tools]# tar -zxf redis-3.0.7.tar.gz[root@M2_Redis1 tools]# cd redis-3.0.7[root@M2_Redis1 redis-3.0.7]# make |
说明:
执行“make”,会在当前目录的src目录下生成启动执行程序,包括: redis-server, redis-sentinel, redis-benchmark等文件
启动:
|
1
|
[root@M2_Redis1 redis-3.0.7]# src/redis-server (默认启动) |
说明:
后台启动参数:daemonize yes
默认启动为“前台启动”,当推出前台界面时,程序会退出
默认启动不使用配置文件
|
1
2
3
4
|
[root@M2_Redis1 redis-3.0.7]# pwd /home/tools/redis-3.0.7[root@M2_Redis1 redis-3.0.7]# ll redis.conf (redis生成配置文件)rw-rw-r-- 1 root root 41560 Jan 25 2016 redis.conf |
redis配置参数:
|
1
2
3
4
5
6
7
8
9
10
|
daemonize yes 是否一后台daemonize方式运行pidfile pid文件的位置,默认为:/run/redis.pidport 监听端口号,默认为6379bind 127.0.0.1 配置监听网卡的IPlogfile log文件位置,默认值为stdout,使用”标准输出”,默认后台模式会输出到/dev/nullloglevel notice 指定日志记录级别,redis一共支持四个级别:debug,verbose,notice,warning,默认为notice # debug 记录很多信息,用于开发和测试 # verbose 很多精简有用的信息,不像debug会记录那么多 # Notice 普通的verbose,常用于生产环境 # warning 只有非常重要或者严重的信息会记录到日志 |
Redis自启动配置:
Copy配置
|
1
2
3
|
[root@M2_Redis1 ~]# cd /etc/[root@M2_Redis1 etc]# mkdir redis[root@M2_Redis1 etc]# cp /home/tools/redis-3.0.7/redis.conf /etc/redis/6379.conf |
Copy启动脚本
|
1
2
3
4
5
6
7
8
9
|
[root@M2_Redis1 ~]# cd /home/tools/redis-3.0.7/utils/[root@M2_Redis1 utils]# cp redis_init_script /etc/init.d/redisd[root@M2_Redis1 utils]# vim /etc/init.d/redisd# chkconfig: 2345 90 10 (添加启动级别)REDISPORT=6379EXEC=/home/tools/redis-3.0.7/src/redis-serverCLIEXEC=/home/tools/redis-3.0.7/src/redis-cliPIDFILE=/var/run/redis_${REDISPORT}.pid (以redis_port命名)CONF="/etc/redis/${REDISPORT}.conf" (以port命名) |
编辑配置文件
|
1
2
3
4
5
|
[root@M2_Redis1 redis-3.0.7]# vim /etc/redis/6379.conflogfile "/data/log/redis_6379.log"port 6379pidfile /var/run/redis_6379.piddaemonize yes |
启动
|
1
2
3
4
5
6
7
8
|
[root@M2_Redis1 utils]# service redisd start Starting Redis server...[root@M2_Redis1 utils]# netstat -ntulpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 17491/redis-server tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1189/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1280/master |
浙公网安备 33010602011771号