1. 复制安装文件到linux(xshell直接拖拽或ssh工具),自行创建目录
如:cd /usr/local/src
mkdir redis
cd redis
2. 解压安装文件:
tar -xvf redis-3.2.8.tar.gz
3. 进入安装文件目录,进行编译和安装
cd redis-3.2.8
make
cd src
make install (or : make PREFIX=/usr/local/src/redis install #指定安装目录)
编译过程可能出现的问题:
1. cc:未找到命令
下载安装gcc:yum -y install gcc automake autoconf libtool make
2. zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
make[1]: *** [adlist.o] Error 1
daemonize yes #默认为no
maxmemory 200mb #在真实环境必须部署,否则物理内存会被耗尽。
redis-server #默认找redis.conf配置文件
redis-server & #上面ctrl+c中断reis会退出,这个不会
redis-server redis6380.conf #指定配置文件,这样可以启动多个实例
注意两种启动方式的差异
ps -ef|grep redis
root 3511 1 0 16:29 ? 00:00:01 redis-server *:6379
root 3515 1 0 16:29 ? 00:00:01 redis-server 127.0.0.1:6380
注释掉redis.conf配置文件中的48行;# bind 127.0.0.1 ::1即可
5. 版本
redis-server –v
Redis server v=3.2.5 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=e6c4c3113548f6b0
redis-cli –v
6. 设置访问密码
默认没有密码,可以随意访问。
redis速度相当快,在一个较好的服务器下,外部用户每秒可以进行15w此的密码尝试,这意味着必须指定非常强大的密码来防止暴力破解。
如果要加,打开redis.conf的requirepass 123456 #480行,设置请求密码,这样访问时都需要先登录
127.0.0.1:6379>auth 123456 #客户端访问方式
jedis.auth(“123456”); #jedis访问方式
7. 详细信息
redis-cli
127.0.0.1:6379> info #查看当前redis节点的详细配置信息启动中遇到的问题:
Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
警告:没有指定的配置文件。
解决办法: ./redis-server /usr/local/src/redis-3.2.8/redis.conf
WARNING overcommit_memory is set to 0! Background save may fail under low memory condition.
To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
警告:过量使用内存设置为0!在低内存环境下,后台保存可能失败。为了修正这个问题,请在/etc/sysctl.conf 添加一项 'vm.overcommit_memory = 1' ,然后重启(或者运行命令'sysctl vm.overcommit_memory=1' )使其生效。
修改后再次启动。
oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo