您的位置:首页 > 数据库 > Redis

redis 简单官方脚本安装方法(linux)

2014-06-06 09:23 507 查看


redis 简单官方脚本安装方法(linux)

redis 简单官方脚本安装方法(linux), 其实也是非常简单的,安装的时候,我用一台刚刚安装好的虚拟机来模拟环境。现在我安装官方网站的最新版本

1.下载redis,现在最新版本是2.6.16
wget http://download.redis.io/releases/redis-2.6.16.tar.gz[/code] 2.解压到当前目录
tar -zxvf redis-2.6.16.tar.gz

3.安装
make PREFIX=/opt/module/redis/release/redis-2.6.16 install
cd redis-2.6.16/utils
ln -s /opt/module/redis/release/redis-2.6.16/bin/redis-* /usr/local/bin/  #添加到环境变量中
./install_server.sh  #执行这个文件他会默认生成一些redis的配置文件
######如果执行这脚本的时候发生下面的错误###########################
[root@localhost utils]# ./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server]
s#^port [0-9]{4}$#port 6379#;s#^logfile .+$#logfile /var/log/redis_6379.log#;s#^dir .+$#dir /var/lib/redis/6379#;s#^pidfile .+$#pidfile /var/run/redis_6379.pid#;s#^daemonize no$#daemonize yes#;
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
./install_server.sh: line 178: update-rc.d: command not found
exists, process is already running or crashed

解析
Welcome to the redis service installer
This script will help you easily set up a running redis server
Please select the redis port for this instance: [6379]     #redis 配置的端口
Selecting default: 6379  #默认为6379
Please select the redis config file name [/etc/redis/6379.conf]  #redis默认文件存放路径
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] #redis 日志文件路径
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [/opt/bin/redis-server]


注意,你安装的时候,有可能出现的bug
#######因为install_server.sh这个安装脚本有bug#####################################
vim install_server.sh

##第一个点
###修改前
-if [ !`which chkconfig` ] ; then
###修改后
+if [ ! `which chkconfig` ] ; then
#combine the header and the template (which is actually a static footer)
echo $REDIS_INIT_HEADER > $TMP_FILE && cat $INIT_TPL_FILE >> $TMP_FILE || die "Could not write init script to $TMP_FILE"
else

##第二个点
###修改前
-if [ !`which chkconfig` ] ; then
###修改后
+if [ ! `which chkconfig` ] ; then
#if we're not a chkconfig box assume we're able to use update-rc.d
update-rc.d redis_$REDIS_PORT defaults && echo "Success!"
else

###修改完成后,再次执行,应该没问题的了


4.启动redis
/etc/init.d/redis_6379 start

5.测试
redis-cli

6.结果:
[root@localhost utils]# redis-cli
redis 127.0.0.1:6379> set name oyhk
OK
redis 127.0.0.1:6379> get name
"oyhk"
redis 127.0.0.1:6379>

安装完成!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: