CentOS 编译安装 Redis (实测 笔记 Centos 7.3 + redis 3.2.8)
环境:
系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡)
系统版本:CentOS-7.0-1406-x86_64-DVD.iso
安装步骤:
1.准备
1.1 显示系统版本
[root@centos ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@centos ~]# uname -r
3.10.0-514.6.1.el7.x86_64
1.2 安装基本软件包
[root@centos ~]# yum install vim wget lsof gcc gcc-c++ -y
1.3 显示IP地址
[root@centos ~]# ip addr|grep inet
inet 127.0.0.1/8 scope host lo
inet 192.168.1.10/24 brd 192.168.1.255 scope global ens160
2.安装redis
2.1 安装依赖
[root@centos ~]# yum install tcl -y
[root@centos ~]# cd /usr/local/src
[root@centos ~]# wget http://download.redis.io/releases/redis-4.0.9.tar.gz
[root@centos ~]# tar -zxvf redis-4.0.9.tar.gz && cd redis-4.0.9
[root@centos ~]# make && make PREFIX=/opt/redis install
[root@centos ~]# groupadd redis
[root@centos ~]# useradd -g redis redis -s /sbin/nologin
[root@centos ~]# mkdir -p /opt/redis/logs
[root@centos ~]# cp redis.conf /opt/redis
[root@centos ~]# ll /opt/redis
[root@centos ~]# chown -R redis:redis /opt/redis
[root@centos ~]# vim /opt/redis/redis.conf
找到相关的行,修改
#bind 127.0.0.1
protected-mode no
requirepass redispwd
daemonize no
supervised no
pidfile /opt/redis/redis_6379.pid
logfile /opt/redis/redis_6379.log
dbfilename dump.rdb
dir /opt/redis
保存,退出
[root@centos ~]# vim /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis Server
After=network.target
[Service]
Type=simple
PIDFile=/opt/redis/redis_6379.pid
ExecStart=/opt/redis/bin/redis-server /opt/redis/redis.conf
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=on-failure
User=redis
[Install]
WantedBy=multi-user.target
保存,退出
[root@centos ~]# systemctl enable redis
[root@centos ~]# systemctl start redis
[root@centos ~]# systemctl daemon-reload
[root@centos ~]# systemctl status firewalld
配置打开端口
[root@centos ~]# iptables -L --line-numbers|grep ACCEPT
[root@centos ~]# firewall-cmd --zone=public --add-port=6379/tcp --permanent
**************************************************************************************************
指定IP可以访问
[root@centos ~]# firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.1.25" port protocol="tcp" port="6379" accept"
移除指定IP可以访问
[root@centos ~]# firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.1.25" port protocol="tcp" port="6379" accept"
**************************************************************************************************
[root@centos ~]# firewall-cmd --reload && iptables -L --line-numbers|grep ACCEPT
安装完成后,打开客户端
[root@centos ~]# /opt/redis/bin/redis-cli -h 127.0.0.1 -p 6379
输入以下命令,测试写入及读取
127.0.0.1:6379 > auth redispwd
127.0.0.1:6379 > set name abc123
127.0.0.1:6379 > get name
退出
quit
手动持久化(保存到硬盘)
[root@centos ~]# /opt/redis/bin/redis-cli save
redis.conf 的配置信息
1、daemonize 如果需要在后台运行,把该项改为yes
2、pidfile 配置多个pid的地址 默认在/var/run/redis.pid
3、bind 绑定ip,设置后只接受来自该ip的请求
4、port 监听端口,默认是6379
5、loglevel 分为4个等级:debug verbose notice warning
6、logfile 用于配置log文件地址
7、databases 设置数据库个数,默认使用的数据库为0
8、save 设置redis进行数据库镜像的频率。
9、rdbcompression 在进行镜像备份时,是否进行压缩
10、dbfilename 镜像备份文件的文件名
11、Dir 数据库镜像备份的文件放置路径
12、Slaveof 设置数据库为其他数据库的从数据库
13、Masterauth 主数据库连接需要的密码验证
14、Requriepass 设置 登陆时需要使用密码
15、Maxclients 限制同时使用的客户数量
16、Maxmemory 设置redis能够使用的最大内存
17、Appendonly 开启append only模式
18、Appendfsync 设置对appendonly.aof文件同步的频率(对数据进行备份的第二种方式)
19、vm-enabled 是否开启虚拟内存支持 (vm开头的参数都是配置虚拟内存的)
20、vm-swap-file 设置虚拟内存的交换文件路径
21、vm-max-memory 设置redis使用的最大物理内存大小
22、vm-page-size 设置虚拟内存的页大小
23、vm-pages 设置交换文件的总的page数量
24、vm-max-threads 设置VM IO同时使用的线程数量
25、Glueoutputbuf 把小的输出缓存存放在一起
26、hash-max-zipmap-entries 设置hash的临界值
27、Activerehashing 重新hash
redis【持久化】配置:
http://blog.csdn.net/vtopqx/article/details/46833513
1、rdb
save 900 1
save 300 10
save 60 10000
2、aof
appendfsync always
appendfsync everysec
appendfsync no
redis【主从】配置:
http://blog.csdn.net/yilukuangpao/article/details/52004257
vi etc/redis.conf
#绑定IP地址
bind 192.168.88.128
#若当前服务为slave,在此处设置主服务的ip及端口
slaveof 10.10.10.200 6379
#若当前服务为slave,设置主服务的认证密码
masterauth 01130229
127.0.0.1:6379> slaveof 10.10.10.200 6379
显示ok,也就OK了
redis【集群】配置:
http://blog.csdn.net/jhq0113/article/details/44134833
http://blog.csdn.net/zj0116/article/details/44673017
bind 127.0.0.1
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile /var/log/redis_6379.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /usr/local/redis
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
CentOS 编译安装 Redis (实测 笔记 Centos 7.3 + redis 3.2.8)的更多相关文章
- CentOS 编译安装 Nodejs (实测 笔记 Centos 7.3 + node 6.9.5)
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...
- CentOS7 编译安装 Mongodb (实测 笔记 Centos 7.0 + Mongodb 2.6.6)
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...
- CentOS7 编译安装 Nginx (实测 笔记 Centos 7.0 + nginx 1.6.2)
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...
- CentOS7 编译安装 Mariadb (实测 笔记 Centos 7.0 + Mariadb 10.0.15)
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...
- CentOS7 编译安装 Nodejs (实测 笔记 Centos 7.0 + node 0.10.33)
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...
- Centos编译安装PHP 5.5笔记
本篇是在 Centos 6.4 32bit 下编译安装 php 5.5.5 的笔记,接上篇 Centos编译安装Apache 2.4.6笔记.php 5.5.x 和 centos 源里面的 php 5 ...
- CentOS编译安装NodeJS+Express
NodeJS是基于Chrome’s Javascript runtime,也就是Google V8引擎执行Javascript的快速构建网络服务及应用的平台,其优点有: 在CentOS编译安装Node ...
- nginx php-fpm安装配置 CentOS编译安装php7.2
CentOS编译安装php7.2 介绍: 久闻php7的速度以及性能那可是比php5系列的任何一版本都要快,具体性能有多好,建议还是先尝试下再说.如果你是升级或新安装,那你首先需要考虑php7和程序是 ...
- Redis学习笔记(2)——Redis的下载安装部署
一.下载Redis Redis的官网下载页上有各种各样的版本,如图 但是官网下载的Redis项目不正式支持Windows.如果需要再windows系统上部署,要去GitHub上下载.我下载的是Redi ...
随机推荐
- spring security 学习笔记
官方文档
- Python爬虫基础之lxml
一.Python lxml的基本应用 <html> <head> <title> The Dormouse's story </title> </ ...
- FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)”
https://stackoverflow.com/questions/29188789/eclipse-mac-os-x-debug-error-fatal-error-in-native-meth ...
- juypter4.4.0 自动补全
python -m pip install jupyter_contrib_nbextensions jupyter contrib nbextension install --user --skip ...
- LeetCode 14.Longest Common Prefix(C++)
最长公共前缀问题,考虑没有或只有一个字符串的情况,然后只需要逐个比对就可以了. class Solution { public: string longestCommonPrefix(vector&l ...
- C# emgu 多模板匹配
public MatchInfo GetMatchPos(string Src, string Template) { MatchInfo myMatchInfo = new MatchInfo(); ...
- Google Python命名规范
Google Python命名规范 module_name, 模块 package_name, 包 ClassName, 类 method_name, 方法 ExceptionName, ...
- Mac 下GitHub 访问慢解决方案
1.GitHub下载是指向了Amazon的服务器 下载地址是http://github-cloud.s3.amazonaws.com/ 解决方案是更改host文件,使该域名指向香港的服务器 2.去 ...
- 非递归并查集——zoj4109
卡常卡的我难受 非递归并查集好像写起来常数小一点 int F[maxn]; int Find(int x){ int r = x; while (F[r] != r)r = F[r]; int i = ...
- WPF使用CefSharp嵌入网页
1.点击项目应用下的管理NuGet程序包 2.在浏览中输入cefsharp-->查找 CefSharp.Wpf-->点击安装,等待安装完成 3.如果遇到一下问题将解决方案和项目都改成64位 ...