Redis开源代码读书笔记零(Ubuntu14.04 64位安装)

来源:互联网 发布:搜狗下载软件 编辑:程序博客网 时间:2024/05/03 13:13
Redis代码可以在Linux, OSX, OpenBSD, NetBSD, FreeBSD系统上进行部署,并且支持大小端CPU类型。学习环境采用了一台Ubuntu14.04 64位的系统,所有代码的学习是基于redis-3.0.7。

请从Redis官网http://redis.io,下载redis-3.0.7.tar.gz源代码

Redis代码编译


32位,64bit的系统需要安装32位系统的一些支持库

# apt-get install libc6-dev-i386 g++-multilib# make distclean# make 32bit


64位,64bit的系统,所以一把过。

# tar -zxvf  redis-3.0.7.tar.gz# cd  redis-3.0.7# make# make test


Redis安装

这里我们学习和测试使用的是64位结果。直接进行安装,这里都采用默认配置。
# make installcd utils./install_server.shWelcome to the redis service installerThis script will help you easily set up a running redis serverYou must run this script as root. Sorry!daniel@ubuntu:~/redis-3.0.7/utils$ sudo ./install_server.shWelcome to the redis service installerThis script will help you easily set up a running redis serverPlease select the redis port for this instance: [6379]Selecting default: 6379Please select the redis config file name [/etc/redis/6379.conf]Selected default - /etc/redis/6379.confPlease select the redis log file name [/var/log/redis_6379.log]Selected default - /var/log/redis_6379.logPlease select the data directory for this instance [/var/lib/redis/6379]Selected default - /var/lib/redis/6379Please select the redis executable path [/usr/local/bin/redis-server]Selected config:Port           : 6379Config file    : /etc/redis/6379.confLog file       : /var/log/redis_6379.logData dir       : /var/lib/redis/6379Executable     : /usr/local/bin/redis-serverCli Executable : /usr/local/bin/redis-cliIs this ok? Then press ENTER to go on or Ctrl-C to abort.Copied /tmp/6379.conf => /etc/init.d/redis_6379Installing service... Adding system startup for /etc/init.d/redis_6379 ...   /etc/rc0.d/K20redis_6379 -> ../init.d/redis_6379   /etc/rc1.d/K20redis_6379 -> ../init.d/redis_6379   /etc/rc6.d/K20redis_6379 -> ../init.d/redis_6379   /etc/rc2.d/S20redis_6379 -> ../init.d/redis_6379   /etc/rc3.d/S20redis_6379 -> ../init.d/redis_6379   /etc/rc4.d/S20redis_6379 -> ../init.d/redis_6379   /etc/rc5.d/S20redis_6379 -> ../init.d/redis_6379Success!Starting Redis server...Installation successful!



安装完成后,可以使用redis_6379脚本进行启动redis服务。当然如果需要每次随机启动redis,可以将以下脚本增加到rc.local等脚本中。
/etc/init.d/redis_6379

命令行客户端


服务启动后,可以采用redis-cli进行连接
% cd src% redis-cliredis> pingPONGredis> set foo barOKredis> get foo"bar"redis> incr mycounter(integer) 1redis> incr mycounter(integer) 2redis> 



其他注意事项

==》glibc, jemalloc, tcmalloc编译配置, make时添加MALLOC宏,默认是glibc,比如"make MALLOC=libc"
==》更多的编译输出,make时添加V宏,比如"make V=1"
==》自定义配置启动,比如"redis-server /path/to/redis.conf"
==》主从配置,比如"redis-server --port 9999 --slaveof 127.0.0.1 6379"
==》运行日志记录级别定义,比如"redis-server /etc/redis/6379.conf --loglevel debug"
0 0
原创粉丝点击