redis安裝和java web如何結合redis?

來源:互聯網
上載者:User

標籤:redis   tcl   redis啟動   

</pre><pre name="code" class="java">java web如何結合redis?**********第一步:安裝redis到linux伺服器.因為redis依賴tcl,所以首先需要安裝tcl.將tcl8.5.10-src.tar.gz拷貝到/opt/tcl目錄下執行如下指令:[email protected]:~/tcl# tar -zxvf tcl8.5.10-src.tar.gz [email protected]:~/tcl# cd tcl8.5.10/unix/[email protected]:~/tcl/tcl8.5.10/unix# ./configure[email protected]:~/tcl/tcl8.5.10/unix# make[email protected]:~/tcl/tcl8.5.10/unix# make install將redis-3.0.1.tar.gz拷貝到/opt/redis目錄下執行如下指令:[email protected]:~/redis# tar -zxvf redis-3.0.1.tar.gz [email protected]:~/redis# cd redis-3.0.1[email protected]:~/redis/redis-3.0.1# make [email protected]:~/redis/redis-3.0.1# make test[email protected]:~/redis/redis-3.0.1# make install**********第二步:啟動redis.注意:預設情況下redis編譯時間會將redis-server等命令拷貝至/usr/local/bin目錄下.同時,redis啟動預設是在前台,可以通過修改如下設定檔將redis啟動模式改為後台.[email protected]:~/redis/redis-3.0.1# vi redis.conf 將daemonize no修改為daemonize yes表示啟動後在後台運行.啟動redis需要指定設定檔,如下:[email protected]:/usr/local/bin# ./redis-server /opt/redis/redis-3.0.1/redis.conf [email protected]:/usr/local/bin# ps -ef | grep redisroot      5968     1  0 10:41 ?        00:00:00 ./redis-server *:6379                           root      5972  5820  0 10:41 pts/1    00:00:00 grep redis[email protected]:/usr/local/bin# **********第三步:停止redis.[email protected]:/usr/local/bin# redis-cli -h 192.168.1.3 -p 6379 shutdown[email protected]:/usr/local/bin# ps -ef | grep redisroot      4799  4658  0 19:53 pts/1    00:00:00 grep redis**********第四步:串連redis.[email protected]:/usr/local/bin# redis-cli -h 192.168.1.3 -p 6379192.168.1.3:6379> set username ISOK192.168.1.3:6379> get username"IS"192.168.1.3:6379> **********第五步:建立java項目,引入jedis2.7.2.jar.馬上開啟你的redis學習之旅吧!public class Test {private static Jedis jedis = null;public static void main(String[] args) {jedis = new Jedis("192.168.1.3");  jedis.set("username", "IluckySi");  System.out.println(jedis.get("username")); //IluckySi  }}


redis安裝和java web如何結合redis?

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.