Centos7上安裝Redis5.05_20190805

Centos7上安裝Redis5.05_20190805

查看系統(tǒng)版本號

cat /etc/redhat-release

以root用戶安裝Redis5.05,進行以下操作:

一、上傳 Redis 安裝包 redis-5.0.5.tar.gz 至 /home/bigdata 目錄下

cd /home/bigdata

ls

解壓redis安裝包

tar -zxvf redis-5.0.5.tar.gz

創(chuàng)建軟鏈接

ln -s redis-5.0.5 redis

修改 Redis 的文件夾權(quán)限為 777

chmod -R 777 redis

二、安裝gcc,進入redis安裝目錄編譯

安裝gcc

yum install gcc

進入redis安裝目錄編譯

cd /home/bigdata/redis

make

三、修改 redis 配置文件 redis.conf

cd /home/bigdata/redis

vi redis.conf

配置所有ip可以訪問并關(guān)閉保護模式

將配置文件中bind 127.0.0.1 改為 bind 0.0.0.0 ,或者直接注釋掉,所有ip可以訪問。

將protected-mode yes 改為 no,關(guān)閉保護模式。

后臺啟動

將daemonize no 改為 yes

備注:配置文件配置項說明

1、daemonize介紹

A、redis.conf配置文件中daemonize守護線程,默認是NO。

B、daemonize是用來指定redis是否要用守護線程的方式啟動。

2、daemonize 設(shè)置yes或者no區(qū)別

daemonize:yes:redis采用的是單進程多線程的模式。當(dāng)redis.conf中選項daemonize設(shè)置成yes時,代表開啟守護進程模式。在該模式下,redis會在后臺運行,并將進程pid號寫入至redis.conf選項pidfile設(shè)置的文件中,此時redis將一直運行,除非手動kill該進程。

daemonize:no: 當(dāng)daemonize選項設(shè)置成no時,當(dāng)前界面將進入redis的命令行界面,exit強制退出或者關(guān)閉連接工具(putty,xshell等)都會導(dǎo)致redis進程退出。

src/redis-server ./redis.conf

四、自定義redis配置啟動,同時啟動redis客戶端連接

4.1、自定義redis配置啟動

/home/bigdata/redis/src/redis-server /home/bigdata/redis/redis.conf

驗證redis是否成功啟動

ps -ef | grep redis

或者

ps aux | grep redis

4.2、啟動redis客戶端連接

/home/bigdata/redis/src/redis-cli

五、Redis Desktop Manager連接

Redis Desktop Manager 漢化版安裝包 redis-desktop-manager.rar 下載地址:

https://www.7down.com/soft/233274.html

需要先關(guān)閉防火墻,no running表示已關(guān)閉。輸入ip就可以連接上。

systemctl stop firewalld.service

systemctl disable firewalld.service

firewall-cmd --state

Redis Desktop Manager 連接配置

名稱: 192.168.1.26 Redis

Redis地址端口: 192.168.1.26:6379

六、

4、啟動、重啟、停止

啟動redis

systemctl start redis

systemctl restart redis

systemctl stop redis

5、開機自啟動

redis服務(wù)加入開機啟動

systemctl enable redis

禁止開機啟動

systemctl disable redis

6、查看狀態(tài)

systemctl status redis

開啟服務(wù)自啟動

sudo chkconfig redis on

加入開機自啟服務(wù)

sudoo chkconfig --add redis

ps -ef | grep redis

ps aux | grep redis

kill -9 8629




Redis 常見命令

hashmap? redis 賦值

hset flink-test 'flink' 'flink'

hashmap 去除 key 為 flink-test 的所有鍵值對

hgetall flink-test





啟動zookeeper(后臺運行)

nohup bin/zookeeper-server-start.sh config/zookeeper.properties &

查看zookeeper是否運行

jps

6740 QuorumPeerMain

關(guān)閉zookeeper

bin/zookeeper-server-stop.sh config/zookeeper.properties &

啟動kafka(后臺運行)

nohup bin/kafka-server-start.sh config/server.properties &

或者

nohup bin/kafka-server-start.sh config/server.properties >/dev/null 2>&1 &

查看kafka是否運行

jps

7587 Kafka

關(guān)閉kafka

bin/kafka-server-stop.sh config/server.properties

1.4、使用kafka

1)、創(chuàng)建topic:

  /home/bigdata/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic apache-flink-test

2)、查看topic:

  /home/bigdata/kafka/bin/kafka-topics.sh --list --zookeeper localhost:2181

3)、生產(chǎn)者

  /home/bigdata/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic apache-flink-test

4)、消費者

/home/bigdata/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic apache-flink-test --from-beginning

該命令中含有過時方法 --zookeeper,該方法在老版本kafka0.90之前使用

/home/bigdata/kafka/bin/kafka-console-consumer.sh --zookeeper localhost:9092 --topic apache-flink-test --from-beginning

備注:消費kafka時遇到的問題:kafka 創(chuàng)建消費者報錯 consumer zookeeper is not a recognized option

在做kafka測試的時候,使用命令bin/kafka-console-consumer.sh --zookeeper 192.168.0.140:2181,192.168.0.141:2181 --topic test --from-beginning啟動消費者,發(fā)現(xiàn)一只報錯consumer zookeeper is not a recognized option,搜索了半天,一只沒有解決,最后,換了一個低版本的kakfa,發(fā)現(xiàn)在啟動的時候說使用 --zookeeper是一個過時的方法,此時,才知道原來在最新的版本中,這種啟動方式已經(jīng)被刪除了,

最后附上0.90版本之后啟動消費者的方法: bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning

CSDN參考鏈接:

kafka 創(chuàng)建消費者報錯 consumer zookeeper is not a recognized option

https://blog.csdn.net/csdn_sunlighting/article/details/81516646

kafka中消費 kafka topic 后應(yīng)該關(guān)閉消費進程

(1)使用消費命令時,用 Ctrl + C 關(guān)閉消費進程

(2)jps -m 查看kafka消費進程號,之后殺死對應(yīng)的進程

jps -m

kill -9 進程號

5)、刪除topic

  /home/bigdata/kafka/bin/kafka-topics --delete --zookeeper 【zookeeper server:port】 --topic 【topic name】

  [server.properties需要 設(shè)置delete.topic.enable=true]

參考鏈接:

kafka偽分布式安裝(2.12版) - Runner_Jack - 博客園

https://www.cnblogs.com/runnerjack/p/8592036.html

testnode1 192.168.1.27

http://192.168.1.27:8081/

關(guān)閉 防火墻

(1)查看防火墻狀態(tài)

systemctl status firewalld.service

(2)關(guān)閉防火墻(下次重啟后,防火墻再次自動開啟)

systemctl stop firewalld.service

(3)禁止防火墻服務(wù)器(即永久關(guān)閉防火墻)

systemctl disable firewalld.service

flink.kafkaFlink.KafkaDemo

flink同樣支持兩種提交方式,默認不指定就是客戶端方式。如果需要使用集群方式提交的話??梢栽谔峤蛔鳂I(yè)的命令行中指定-d或者--detached 進行進群模式提交。

? ? ? ? -d,--detached ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?If present, runs the job in??detached mode(分離模式)

客戶端提交方式:$FLINK_HOME/bin/flink run ? -c com.daxin.batch.App flinkwordcount.jar?,客戶端會多出來一個CliFrontend進程,就是驅(qū)動進程。

集群模式提交:$FLINK_HOME/bin/flink run -d ?-c com.daxin.batch.App flinkwordcount.jar 程序提交完畢退出客戶端,不在打印作業(yè)進度等信息!

更多細節(jié)參考flink的幫助文檔,$FLINK_HOME/bin/flink ?--help

flinkTestConsumeKafka-1.0-SNAPSHOT.jar

$FLINK_HOME/bin/flink run -d -c flink.kafkaFlink flinkTestConsumeKafka-1.0-SNAPSHOT.jar

$FLINK_HOME/bin/flink run -d -c flink.kafkaFlink.KafkaDemo /home/jobs/flink/flinkTestConsumeKafka-1.0-SNAPSHOT.jar

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容