redis安裝和使用

來源:互聯網
上載者:User

1、安裝redis:
上傳檔案到固定目錄下;版本為: redis-3.2.0

tar xzvf redis-3.2.0.tar.gzcd redis-3.2.0make && make install

2、啟動redis

redis-server  redis.conf

3、一般不會在原設定檔上進行修改,原設定檔相當於備份。所以在centos7上建立

mkdir  /etc/redis

4、拷貝redis原設定檔到 /etc/redis

cp redis.conf   /etc/redis/

按照最新的設定檔啟動:

redis-server  /etc/redis/redis.conf

啟動後如果直接關閉命令列視窗,redis會在後台運行,但是不能按ctrl+c,如果按這個會終止redis,所以直接關掉視窗即可

[root@localhost ~]# ps -ef |grep redisroot     30337     1  0 09:10 ?        00:00:00 redis-server 127.0.0.1:6379root     32116 28120  0 09:18 pts/1    00:00:00 grep --color=auto redis

以上redis就啟動了。

5、啟動後,如何關閉redis。

redis-cli  shutdown[root@localhost ~]# redis-cli shutdown[root@localhost ~]# ps -ef |grep redisroot     32257 28120  0 09:19 pts/1    00:00:00 grep --color=auto redis

執行後redis就關閉了。

6、redis添加後台啟動

daemonize  yes

7、配置redis記錄檔位置:

logfile "/Users/wang/Documents/redis.log"

7、添加到
開機啟動配置

echo "/usr/local/bin/redis-server /etc/redis/redis.conf &" >> /etc/rc.local

8、添加密碼

vi /etc/redis/redis.confrequire pass   paas2016

添加密碼paas2016
redis是預設不允許其他用戶端串連的:

需要在設定檔中放開: bind 127.0.0.1 才能允許其他用戶端操作

用戶端串連:

ss:~ wqp$ redis-cli -h hostname -p 6379 -a paas2016hostname:6379> set aa "aaaa"OKhostname:6379> get aa"aaaa"

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.