#在linux系统中安装zabbix_server 1.下载并解压redis tar包 #wget http://download.redis.io/releases/redis-x.x.x.tar.gz #tar -xvf redis-x.x.x.tar.gz 2.使用yum安装依赖包 #yum -y install gcc gcc-c++ make 进入redis目录 #cd PATH/redis-x.x.x #make && make test (执行make test 需要 yum -y install tcl) #make install #指定目录安装则需要执行如下命令 # make PREFIX=/usr/local/redis install 安装完后cd /utils,执行安装脚本进行安装 [root@redis1 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] Selected config: Port : 6379 //端口号 Config file : /etc/redis/6379.conf //配置文件目录 Log file : /var/log/redis_6379.log //日志目录 Data dir : /var/lib/redis/6379 //数据库目录 Executable : /usr/local/bin/redis-server //启动程序的目录 Cli Executable : /usr/local/bin/redis-cli //命令行的连接工具 Is this ok? Then press ENTER to go on or Ctrl-C to abort. //回车完成配置 Copied /tmp/6379.conf => /etc/init.d/redis_6379 //服务启动脚本 Installing service... Successfully added to chkconfig! Successfully added to runlevels 345! Starting Redis server... Installation successful! //安装成功 配置文件 # vim /etc/redis/6379.conf ... bind 192.168.4.51 //修改ip port 6351 //不允许相同,只指定物理接口的ip daemonize yes //以守护进程方式运行 pidfile /var/run/redis_6351.pid cluster-enabled yes //是否启用集群,前提是以守护进程方式运行 cluster-config-file nodes-6351.conf //存储集群信息的配置文件,自动生成,不允许相同 cluster-node-timeout 5000 //集群节点通信超时时间 ... !!redis关闭和起动问题!! 启动: 1):./redis-server & #加上'&'号使redis以后台程序方式运行 2):./redis-server /etc/redis/6379.conf #指定配置文件方式启动,配置文件自定义 3):/etc/init.d/redis_6379 start #使用redis脚本启动 关闭: 1):redis-cli -h 192.168.4.51 -p 6379 shutdown #未修改过默认端口可不加'-p'选项 #默认127.0.0.1可不加'-h'选项 #若有密码则需要添加'-a'选项 2):/etc/init.d/redis_6379 stop #使用redis脚本关闭 3):pgrep redis-server |xargs -i kill {} #使用kill关闭(pkill也一样) 状态: 1):/etc/init.d/redis_6379 status 2):netstat -nutpl | grep redis 3):ps -C redis-server !!其他介绍!! redis-benchmark:性能测试工具 redis-check-aof:修复有问题的AOF文件 redis-check-dump:修复有问题的dump.rdb文件 redis-cli:客户端,操作入口 redis-sentinel:redis集群使用 redis-server:Redis服务器启动命令 #redis依赖 1.安装依赖:gcc gcc-c++ make 2.端口及安装目录说明: 若为安装后修改端口号,需要更改一下文件 redis.conf redis-shutdown redis-sentinel.conf 3.配置文件说明: ze : 如需要在后台运行 , 把该项的值改为 yes pdifile : 把 pid 文件放在 /var/run/redis.pid , 可以配置到其他地址 bind : 指定 Redis 只接收来自该 IP 的请求 , 如果不设置 , 那么将处理所有请求 , 在生产环节中最好设置该项 port : 监听端口 , 默认为 6379 timeout : 设置客户端连接时的超时时间 , 单位为秒 loglevel : 等级分为 4 级 , debug , revbose , notice 和 warning , 生产环境下一般开启 notice logfile : 配置 log 文件地址 , 默认使用标准输出 , 即打印在命令行终端的端口上 database : 设置数据库的个数 , 默认使用的数据库是 0 save : 设置 redis 进行数据库镜像的频率 rdbcompression : 在进行镜像备份时 , 是否进行压缩 dbfilename : 镜像备份文件的文件名 dir : 数据库镜像备份的文件放置的路径 slaveof : 设置该数据库为其他数据库的从数据库 masterauth : 当主数据库连接需要密码验证时 , 在这里设定 requirepass : 设置客户端连接后进行任何其他指定前需要使用的密码 maxclients : 限制同时连接的客户端数量 maxmemory : 设置redis能够使用的最大内存 appendonly : 开启 appendonly 模式后 , Redis 会把每一次所接收到的写操作都追加到 appendonly.aof 文件中 , 当 Redis 重新启动时 , 会从该文件恢复出之前的状态 appendfsync : 设置 appendonly.aof 文件进行同步的频率 vm_enabled : 是否开启虚拟内存支持 vm_swap_file : 设置虚拟内存的交换文件的路径 vm_max_momery : 设置开启虚拟内存后 , Redis 将使用的最大物理内存的大小 , 默认为 0 vm_page_size : 设置虚拟内存页的大小 vm_pages : 设置交换文件的总的page数量 vm_max_thrrads : 设置 vm IO 同时使用的线程数量 客户端连接时 , 提示 DENIED Redis is running in protected mode because protected mode is enabled... 将配置文件里的 protected mode改为了 no , 原本是 yes 客户端连接时 , 提示 Connection refused... 可能是配置文件里面的 bind 字段设置了入口 IP , 将其注释