Linux(CentOS7)Redis修改配置文件redis.conf

修redis.conf配置文件操作步骤:

[root@CentOS7 bin]# pwd
/usr/local/bin
[root@CentOS7 bin]# ll
总用量 15052
-rw-r--r--. 1 root root      88 8月  22 11:34 dump.rdb
-rwxr-xr-x. 1 root root 2431728 8月  22 10:10 redis-benchmark
-rwxr-xr-x. 1 root root   25173 8月  22 10:10 redis-check-aof
-rwxr-xr-x. 1 root root 5178502 8月  22 10:10 redis-check-rdb
-rwxr-xr-x. 1 root root 2584451 8月  22 10:10 redis-cli
lrwxrwxrwx. 1 root root      12 8月  22 10:10 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 5178502 8月  22 10:10 redis-server
[root@CentOS7 bin]# cd ../
[root@CentOS7 local]# ll
总用量 4
drwxr-xr-x. 2 root root 4096 8月  22 11:34 bin
drwxr-xr-x. 2 root root    6 8月  12 2015 etc
drwxr-xr-x. 2 root root    6 8月  12 2015 games
drwxr-xr-x. 2 root root    6 8月  12 2015 include
drwxr-xr-x. 2 root root    6 8月  12 2015 lib
drwxr-xr-x. 2 root root    6 8月  12 2015 lib64
drwxr-xr-x. 2 root root    6 8月  12 2015 libexec
drwxr-xr-x. 3 root root   24 8月  22 10:05 redis
drwxr-xr-x. 2 root root    6 8月  12 2015 sbin
drwxr-xr-x. 5 root root   46 8月  19 19:56 share
drwxr-xr-x. 2 root root    6 8月  12 2015 src
[root@CentOS7 local]# cd redis/redis-3.2.3/
[root@CentOS7 redis-3.2.3]# ll
总用量 200
-rw-r--r--.  1 root root 75147 8月  22 10:05 00-RELEASENOTES
-rw-r--r--.  1 root root    53 8月  22 10:05 BUGS
-rw-r--r--.  1 root root  1805 8月  22 10:05 CONTRIBUTING
-rw-r--r--.  1 root root  1487 8月  22 10:05 COPYING
drwxr-xr-x.  7 root root  4096 8月  22 10:07 deps
-rw-r--r--.  1 root root    11 8月  22 10:05 INSTALL
-rw-r--r--.  1 root root   151 8月  22 10:05 Makefile
-rw-r--r--.  1 root root  4223 8月  22 10:05 MANIFESTO
-rw-r--r--.  1 root root  6834 8月  22 10:05 README.md
-rw-r--r--.  1 root root 46695 8月  22 10:05 redis.conf
-rwxr-xr-x.  1 root root   271 8月  22 10:05 runtest
-rwxr-xr-x.  1 root root   280 8月  22 10:05 runtest-cluster
-rwxr-xr-x.  1 root root   281 8月  22 10:05 runtest-sentinel
-rw-r--r--.  1 root root  7109 8月  22 10:05 sentinel.conf
drwxr-xr-x.  2 root root  4096 8月  22 10:08 src
drwxr-xr-x. 10 root root  4096 8月  22 10:05 tests
drwxr-xr-x.  7 root root  4096 8月  22 10:05 utils
[root@CentOS7 redis-3.2.3]# cp ./redis.conf /etc/redis/redis.conf
cp: 无法创建普通文件"/etc/redis/redis.conf": 没有那个文件或目录
[root@CentOS7 redis-3.2.3]# mkdir /etc/redis
[root@CentOS7 redis-3.2.3]# cp ./redis.conf /etc/redis/redis.conf
[root@CentOS7 redis-3.2.3]# vi /etc/redis/redis.conf

修改配置文件:

1、将 bind 127.0.0.1 注释 // 若不注释就只能本地连接

2、将 daemonize no 改为 daemonize yes // 后台运行

3、将 # requirepass foobared 注释去掉 ,并修改为 requirepass 123456 //修改密码,redis安全性

[root@CentOS7 redis-3.2.3]# cd /usr/local/bin/
[root@CentOS7 bin]# ll
总用量 15052
-rw-r--r--. 1 root root      88 8月  22 11:34 dump.rdb
-rwxr-xr-x. 1 root root 2431728 8月  22 10:10 redis-benchmark
-rwxr-xr-x. 1 root root   25173 8月  22 10:10 redis-check-aof
-rwxr-xr-x. 1 root root 5178502 8月  22 10:10 redis-check-rdb
-rwxr-xr-x. 1 root root 2584451 8月  22 10:10 redis-cli
lrwxrwxrwx. 1 root root      12 8月  22 10:10 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 5178502 8月  22 10:10 redis-server
[root@CentOS7 bin]# ./redis-server /etc/redis/redis.conf
[root@CentOS7 bin]# ps -ef |grep redis
root      4194  3995  0 11:37 pts/0    00:00:12 ./redis-server *:6379
root      6130  3995  0 13:21 pts/0    00:00:00 grep --color=auto redis
[root@CentOS7 bin]# kill -9 4194
[1]+  已杀死               ./redis-server
[root@CentOS7 bin]# ./redis-server /etc/redis/redis.conf
[root@CentOS7 bin]# ps -ef |grep redis
root      6138     1  0 13:21 ?        00:00:00 ./redis-server *:6379
root      6145  3995  0 13:21 pts/0    00:00:00 grep --color=auto redis
[root@CentOS7 bin]# ./redis-cli -a 123456

注:

1、[root@CentOS7 bin]# ./redis-server /etc/redis/redis.conf 重启redis服务并加载配置

2、[root@CentOS7 bin]# ps -ef |grep redis 查看redis的进程,查看进程id

3、kill -9 4194 根据进程id,停止(杀死)进程

转载于:https://my.oschina.net/cqyj/blog/736450

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值