redis数据库安装

一、redis安装步骤

[root@localhost ~]# mkdir -p /opt/redis_cluster/reddis_6379
[root@localhost ~]# mkdir -p /opt/redis_cluster/reddis_6379/{conf,pid,logs}
[root@localhost ~]# mkdir -p /data/redis_cluster/redis_6379 ###本地数据库目录
[root@localhost ~]# mkdir -p /data/soft       ###用来放安装包
[root@localhost ~]# cd /data/soft/

[root@localhost soft]# wget http://download.redis.io/releases/redis-5.0.5.tar.gz

[root@localhost soft]# tar -zxf  tar zxf redis-5.0.5.tar.gz -C /opt/redis_cluster/

[root@localhost soft]# ln -s /opt/redis_cluster/redis-5.0.5/ /opt/redis_cluster/redis

cd /opt/redis_cluster/redis

make MALLOC=libc  ###如果直接执行make会报错,所以需要指定库

make install

cd /opt/redis_cluster/redis/utils

执行 ./install_server.sh 接下来一直按回车,完成配置的初始化,之后展示详细信息:
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!

二、redis配置文件

单节点的redis配置很简单,手动编写即可.(如果你的配置需求比较多,可以参照/etc/redis/6379.conf,这是官方详细的配置文件.)

cd /opt/redis_cluster/redis_6379/conf/

vim redis_6379.conf

### 以守护进程模式启动
daemonize yes
### 绑定的主机地址
bind 192.168.1.1
### 监听端口
port 6379
### pid文件和log文件的保存地址
pidfile /opt/redis_cluster/redis_6379/pid/redis_6379.pid
logfile /opt/redis_cluster/redis_6379/logs/redis_6379.log
### 设置数据库的数量,默认数据库为0
databases 16
### 制定本地持久化文件的文件名,默认是dump.rdb
dbfilename redis_6379.rdb
### 本地数据库的目录
dir /data/redis_cluster/redis_6379

三、启动和关闭redis

[root@localhost ~]# redis-server /opt/redis_cluster/redis_6379/conf/redis_6379.conf      ###启动redis服务端

[root@localhost ~]# ps aux | grep redis
root      35003  0.1  0.4  46992  4400 ?        Ssl  03:57   0:00 redis-server 192.168.1.1:6379
root      35039  0.0  0.1  12320  1076 pts/1    R+   04:00   0:00 grep --color=auto redis

[root@localhost ~]# redis-cli -h 192.168.1.1  ###登录redis数据库

192.168.1.1:6379> shutdown    ###关闭数据库
not connected> exit

或者:  [root@localhost ~]# redis-cli -h 192.168.146.129 shutdown ###关闭数据库

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值