亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》
  • 首頁 > 
  • 教程 > 
  • 開發技術 > 
  • Redis的make,make test,make install、單機多實例配置,以及API程序寫數據!

Redis的make,make test,make install、單機多實例配置,以及API程序寫數據!

發布時間:2020-06-10 19:51:28 來源:網絡 閱讀:10173 作者:moviebat 欄目:開發技術

   最近學習王家林老師的大數據蘑菇云行動,要實現將Spark Streaming分析的數據寫入到Redis。今天正好開始入手。

   一、Ubuntu16安裝Redis3.2.1

   遇到了不少的問題,其中,make倒是沒問題,make test的時候,出現了:


!!! WARNING The following tests failed:


*** [err]: Slave should be able to synchronize with the master in tests/integration/replication-psync.tcl

Replication not started.

Cleanup: may take some time... OK

Makefile:215: recipe for target 'test' failed

make[1]: *** [test] Error 1

make[1]: Leaving directory '/home/dyq/Documents/redis-3.2.1/src'

Makefile:6: recipe for target 'test' failed

make: *** [test] Error 2


貌似是沒有和master取得同步連接,但是我這不是還沒安裝的嗎?


百度,看到了一片文章,說是用這個命令:make CFLAGS="-march=i686"

但直接就出錯了,沒辦法。

忽略這個錯誤,直接運行make install吧:

cd src && make install

make[1]: Entering directory '/home/dyq/Documents/redis-3.2.1/src'


Hint: It's a good idea to run 'make test' ;)


    INSTALL install

install: cannot create regular file '/usr/local/bin/redis-server': Permission denied

Makefile:256: recipe for target 'install' failed

make[1]: *** [install] Error 1

make[1]: Leaving directory '/home/dyq/Documents/redis-3.2.1/src'

Makefile:9: recipe for target 'install' failed

make: *** [install] Error 2


權限?

sudo make 

sudo make install

提示錯誤,要進入src

好的,OK!


\o/ All tests passed without errors!

Cleanup: may take some time... OK


繼續出現錯誤:

[exception]: Executing test client: NOREPLICAS Not enough good slaves to write..

NOREPLICAS Not enough good slaves to write.


繼續找度娘:

https://my.oschina.net/u/1049845/blog/203370

  這篇文章有說明:

在make test中可能會遇到時間相關的失敗,比如

Executing test client: NOREPLICAS Not enough good slaves to write..

    這種情況下,可以修改文件tests/integration/replication-2.tcl,將after 1000改為after 10000以延長等待時間。

修改,繼續出錯!

!!! WARNING The following tests failed:


*** [err]: PEXPIRE/PSETEX/PEXPIREAT can set sub-second expires in tests/unit/expire.tcl

Expected 'somevalue {}' to equal or match '{} {}'

*** [err]: Slave should be able to synchronize with the master in tests/integration/replication-psync.tcl

Replication not started.

Cleanup: may take some time... OK

Makefile:215: recipe for target 'test' failed

make: *** [test] Error 1

注意看錯誤信息,注意看錯誤信息,注意看錯誤信息!

是修改tests/unit/expire.tcl:

  tags {"slow"} {

        test {EXPIRE - After 2.1 seconds the key should no longer be here} {

            after 21000

            list [r get x] [r exists x]

        } {{} 0}

    }


    test {EXPIRE - write on expire should work} {

        r del x

        r lpush x foo

        r expire x 10000

        r lpush x bar

        r lrange x 0 -1

    } {bar foo}


終于看到了綠色:

\o/ All tests passed without errors!

有多少坑!!!


dyq@ubuntu:~/Documents/redis-3.2.1$ sudo make install

cd src && make install

make[1]: Entering directory '/home/dyq/Documents/redis-3.2.1/src'


Hint: It's a good idea to run 'make test' ;)


    INSTALL install

    INSTALL install

    INSTALL install

    INSTALL install

    INSTALL install

make[1]: Leaving directory '/home/dyq/Documents/redis-3.2.1/src'



虛擬機中安裝的時候,機器性能不夠的話,很容易出現上述錯誤!換機器或者更換參數,以及在機器不忙的時候進行編譯安裝,會順利通過!

GIT上的說明:


For timing issues, one test isn't very representative. Did you try running them 5-10 times? Is there anything unusual about your machine (very small memory, very slow, shared, overloaded, etc)? Some of the tests are based on timing, so if the machine can't deliver results in time then tests can't complete properly. (you can manually edit some of the tests to increase the timeout waiting)

在src目錄下,輸入redis-server,進入熟悉的界面,看提示,配置文件是

29181:C 06 Oct 13:48:16.321 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server 

/path/to/redis.conf

算了吧,還是指定一個配置文件,在上層目錄下,有一個redis.conf。


 src/redis-server redis.conf


二、配置Redis3.2.1

1、配置生產環境,并設置redis的開機啟動。

    首先,建立存放redis配置文件和持久化RDB數據的文件夾:

sudo mkdir /etc/redis
sudo mkdir /var/redis

    拷貝redis的啟動腳本到/etc/init.d文件夾中:

sudo cp utils/redis_init_script /etc/init.d/redis_6379

    拷貝redis的配置文件到/etc/redis中,并且以端口號作為文件名:

sudo cp redis.conf /etc/redis/6379.conf

    在/var/redis中創建文件夾作為redis實例的數據和工作目錄:

sudo mkdir /var/redis/6379


    按下面要求修改配置文件:

  • 設置 demonize 為 yes(默認是no)

  • 設置 pidfile 為 /var/run/redis_6379.pid

  • 設置 loglevel 為相應級別

  • 設置 logfile 為 /var/log/redis_6379.log

  • 設置 dir 為 /var/redis/6379

redis-server /etc/redis/6379.conf

redis-cli客戶端連接服務器,出現>,輸入set name="dyq"

用get name得到dyq。成功!


redis的官方配置文檔地址為:http://redis.io/topics/quickstart

為了能遠程連接redis服務器,需要修改/etc/redis/6379.conf,將ip_bind從127.0.0.1修改為192.168.0.10。


三、安裝單機多實例Redis


1、拷貝配置文件

cp /etc/6379.conf /etc/6380.conf

 cp /etc/6379.conf /etc/6381.conf


2、修改配置文件

sudo gedit /etc/6380.conf

修改

 bind 192.168.0.10

port 6380     

daemonize yes     

logfile /var/log/redis_6380.log       

dir /var/redis/6380/

pidfile /var/run/redis_6380.pid


創建文件目錄:

sudo mkdir /var/redis/6380/

sudo gedit /var/log/redis_6380.log


3、修改主從設置

將6380.conf中的

slaveof 192.168.0.10 6379


4、驗證主從同步

啟動6380和6381


dyq@ubuntu:~/Documents/redis-3.2.1$ src/redis-server.sh /etc/redis/6380.conf

-bash: src/redis-server.sh: No such file or directory

dyq@ubuntu:~/Documents/redis-3.2.1$ src/redis-server /etc/redis/6380.conf


*** FATAL CONFIG FILE ERROR ***

Reading the configuration file, at line 163

>>> 'logfile /var/log/redis6380.log'

Can't open the log file: Permission denied


可以發現實文件沒有寫權限。sudo chown dyq /var/log/redis6380.log


src/redis-cli -h 192.168.0.10 -p 6379

>set name='testredis'

>get name


從庫登錄:

src/redis-cli -h 192.168.0.10 -p 6380

>get name


src/redis-cli -h 192.168.0.10 -p 6381

>get name


可以看到主從數據實現同步。成功!


四、從IDES遠程訪問Redis,并寫入數據


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

盱眙县| 宁武县| 托克托县| 荔波县| 九寨沟县| 韶山市| 桦川县| 永平县| 松阳县| 丹棱县| 中卫市| 邵武市| 娄底市| 河东区| 泰和县| 临沂市| 西昌市| 中宁县| 贡觉县| 黄龙县| 曲松县| 泸西县| 江口县| 钟祥市| 石狮市| 温州市| 达拉特旗| 碌曲县| 礼泉县| 芦山县| 定远县| 南汇区| 龙陵县| 隆回县| 社会| 水富县| 安图县| 四会市| 馆陶县| 上饶县| 新竹市|