`
flex_莫冲
  • 浏览: 1074724 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

ubuntu安裝redis

阅读更多
安裝redis的時候需要make工具。ubuntu下沒有。需要參考以下安裝
 $ sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make
 $ sudo apt-get update
Then, installing Ubuntu Make:

 $ sudo apt-get install ubuntu-make


來源:
https://wiki.ubuntu.com/ubuntu-make

之後在redis目錄執行make
還是失敗了。因為沒有安裝cc,繼續安裝:
sudo apt-get install gcc



再次make。又failed了。
這次提示:
#include [jemalloc] jemalloc.h
recipe for adlist.o failed

執行以下操作:
Plz, Just try next step:
[root@localhost redis-2.6.10]# make distclean
[root@localhost redis-2.6.10]# cd deps; make; cd ..
[root@localhost redis-2.6.10]# cd src; make; cd ..


參考https://github.com/antirez/redis/issues/722

make install成功了。然後執行make test 又提示tcl沒安裝
sudo apt-get install tcl8.6-dev
sudo apt-get install tk8.6-dev


或者下载安装,参考:
http://blog.csdn.net/hybaym/article/details/9046565
wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz  
sudo tar xzvf tcl8.6.1-src.tar.gz  -C /usr/local/  
cd  /usr/local/tcl8.6.1/unix/  
sudo ./configure  
sudo make  
sudo make install   


安裝成功後,再執行make test。一大串test OK的結果就打印出來了。

然后执行
whereis redis-cli
会显示
redis-cli: /usr/local/bin/redis-cli

whereis redis-server
会显示
redis-server: /usr/local/bin/redis-server


改成后台运行:
修改/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
daemonize no 改成 daemonize yes

然后执行
/usr/local/bin/redis-server /home/mochong/redis/redis-3.0.3/redis.conf

查看
netstat -tlnp

显示,默认端口是6379
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      47698/redis-server


执行
/usr/local/bin/redis-cli ping 

显示
pong


设置key/value
 redis-cli set mykey davidhuang

读取key
 redis-cli get mykey


参考:
http://www.php100.com/html/webkaifa/PHP/PHPyingyong/2011/0406/7873.html

配置参考:
http://blog.csdn.net/ithomer/article/details/9232891
redis 持久化写入rdb文件因为无权限写入失败

Background saving error
查看redis.conf的log文件地址
logfile ""
logfile /var/log/redis/redis-server.log

将该文件权限设置为755。

再查看
dir ./
dbfilename dump.rdb

dir 默认是在/usr/local/bin/dump.rdb
执行 /usr/local/bin/redis-cli
输入
CONFIG GET dir
CONFIG GET dbfilename

可以看到
1) "dir"
2) "/usr/local/bin"


1) "dbfilename"
2) "dump.rdb"


停止redis
redis-cli shutdown

出错:
ERR Errors trying to SHUTDOWN. Check logs.

请注意:启动redis-server的时候一定要用sudo。
redis-cli也用sudo
否则可能没权限写入rdb。


安装redis gui
https://github.com/ErikDubbelboer/phpRedisAdmin

http://192.168.3.111/phpRedisAdmin/?view&s=0&d=0&key=davidhuang_%3Ajob%3A1

You may also want to copy includes/config.simple.inc.php to includes/config.inc.php and edit it with your specific redis configuration.

Instead of using composer, you can also do a manual install using:

git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
cd phpRedisAdmin
git clone https://github.com/nrk/predis.git vendor



----------------------------------

我遇到过的坑。。
https://argcv.com/articles/3212.c




使用到mongo,redis等数据库的时候,往往会遇到这样一个坑。某mongo跑着跑着突然没了,某redis启动先给个warning,仔细一看log说最大文件打开数不够..
1
2
3

# You requested maxclients of 10000 requiring at least 10032 max file descriptors.
# Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
# Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.

mongo官方也给教程说你修改下ulimit就可以。
但实际上,若该用户是普通用户
1
2

$ ulimit -n 65535
-bash: ulimit: open files: cannot modify limit: Operation not permitted

若你用root当然可以,但你真的想用root跑db么?

正确的打开方式其实应该是修改limit.
打开/etc/security/limits.conf,添加内容如下:
/etc/security/limits.conf
1
2

your_user_name           soft    nofile          65535
your_user_name           hard    nofile          65535

或者若想要一加一个组
/etc/security/limits.conf
1
2

@your_group_name           soft    nofile          65535
@your_group_name           hard    nofile          65535

然后保存。

检查下/etc/pam.d/sudo或者/etc/pam.d/common-session-noninteractive,若没有发现如下这行信息,请自行加上
1

session    required     pam_limits.so

然后普通用户需要重新登录即可生效。若没有生效,这时普通用户应该也可以自行ulimit -n 65535了。

设置master slave

如果要将当前redis server改成slave。要修改redis.conf
将slaveof 的注释删除掉,改成
slaveof master_server_ip port
如果master server有密码,还要将masterauth删除注释
masterauth master_server_password

修改允许绑定的IP地址
bind master_server_ip 127.0.0.1


重启redis server
redis-cli shutdown
redis-server /xxx/redis-3.2.3/redis.conf 


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics