編譯安裝redisd的方法示例詳解_Redis

來源:腳本之家  責任編輯:小易  

我正在編譯一個只有幾M大小的源碼,等半天了。無聊來回回提問┓(′?`)┏我用的CENTOS7,nginx+php+mysql一般都是用yum install 就搞定了不用麻煩的自己編譯www.13333515.buzz防采集請勿采集本網。

安裝方法:

yum安裝

查看yum倉庫redis版本

你可以,安裝vc+,這個編譯器簡便,學校里的學生大部分用的都是這個 還可以使用vs,最新版應該是2015了吧,這個編譯器更加專業,但是文件較大,所以安裝比較麻煩,但是功能很強大,用的人也很多

[[email protected] ~]# yum list redisLoaded plugins: fastestmirror, langpacksLoading mirror speeds from cached hostfileAvailable Packagesredis.x86_64 3.2.12-2.el7 myepel

yum安裝

方法一:假如現在有兩個Fortran程序1.f90和2.f90,其中1.f90是主程序,2.f90是在主程序中調用的子程序,將這兩個程序傳到Linux的一個目錄下,使用fortran編譯命令,如PGI的pgf90,Intel的ifort,

[[email protected] ~]# yum install redis -y

我建議也是使用web QQ吧,我前兩天剛裝了一個Linux在QQ就沒有下載到能用的安裝軟件 我現在使用的就是web qq

啟動服務并設為開機啟動

編譯64位程序,不一定要編譯機器是64位的,但是32位機器默認安裝的gcc編譯環境還是不能用來編譯64位程序。編譯64位程序,需要加上-m64編譯器參數,默認安裝的gcc已經支持該參數,但是缺少64位

[[email protected] ~]# systemctl enable --now redisCreated symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.

Linux編譯安裝相關命令,下面以Linux安裝MySQL工具為例進行說明,代碼如下: 1、測試環境在Linux MySQL下進行,版本系統為CentOS5,以下為相關軟件: mysql-5.1.30 memcached-1.2.6 libevent-1.4

查看redis端口

[[email protected] ~]# ss -ntlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 127.0.0.1:631 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 127.0.0.1:6010 *:* LISTEN 0 128 *:54909 *:* LISTEN 0 128 127.0.0.1:6379 *:* # 這個是redis端口LISTEN 0 128 *:111 *:* LISTEN 0 5 192.168.122.1:53 *:*

測試登錄redis

[[email protected] ~]# redis-cli127.0.0.1:6379> info# Serverredis_version:3.2.12redis_git_sha1:00000000redis_git_dirty:0redis_build_id:7897e7d0e13773fredis_mode:standaloneos:Linux 3.10.0-1062.el7.x86_64 x86_64arch_bits:64multiplexing_api:epollgcc_version:4.8.5process_id:2914run_id:c75137717c54caa78bb05757d05c91471ef5817ftcp_port:6379uptime_in_seconds:175uptime_in_days:0hz:10lru_clock:4329484executable:/usr/bin/redis-serverconfig_file:/etc/redis.conf# Clientsconnected_clients:1client_longest_output_list:0client_biggest_input_buf:0blocked_clients:0

測試使用

127.0.0.1:6379> set key1 value1OK127.0.0.1:6379> get key1"value1"

編譯安裝

下載當前最新release版本redis源碼包:http://download.redis.io/releases/

編譯安裝命令

官方安裝命令:https://redis.io/download

# 源碼包存放目錄[[email protected] ~]# cd /usr/local/src/# 下載源碼包[[email protected] src]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz--2020-02-11 10:37:54-- http://download.redis.io/releases/redis-5.0.7.tar.gzResolving download.redis.io (download.redis.io)... 109.74.203.151Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 1984203 (1.9M) [application/x-gzip]Saving to: ‘redis-5.0.7.tar.gz'100%[===============================================>] 1,984,203 6.75KB/s in 3m 35s 2020-02-11 10:41:39 (9.02 KB/s) - ‘redis-5.0.7.tar.gz' saved [1984203/1984203]# 查看下載好的源碼包[[email protected] src]# lltotal 1940-rw-r--r-- 1 root root 1984203 Nov 20 01:06 redis-5.0.7.tar.gz

解壓源碼包

[[email protected] src]# tar xf redis-5.0.7.tar.gz [[email protected] src]# lltotal 1940drwxrwxr-x 6 root root 334 Nov 20 01:05 redis-5.0.7-rw-r--r-- 1 root root 1984203 Nov 20 01:06 redis-5.0.7.tar.gz

創建配置文件、日志、數據等目錄

[[email protected] ~]# mkdir /apps/redis/{etc,logs,data,run} -p# 查看目錄結構[[email protected] ~]# tree /apps//apps/└── redis ├── data ├── etc ├── logs └── run

進入redis目錄編譯安裝

[[email protected] ~]# cd /usr/local/src/redis-5.0.7/[[email protected] redis-5.0.7]# make PREFIX=/apps/redis installcd src && make installmake[1]: Entering directory `/usr/local/src/redis-5.0.7/src' CC Makefile.depmake[1]: Leaving directory `/usr/local/src/redis-5.0.7/src'make[1]: Entering directory `/usr/local/src/redis-5.0.7/src' CC adlist.o/bin/sh: cc: command not foundmake[1]: *** [adlist.o] Error 127make[1]: Leaving directory `/usr/local/src/redis-5.0.7/src'make: *** [install] Error 2# 出現以上報錯是沒有gcc編譯器導致的# 下載gcc編譯器[[email protected] redis-5.0.7]# yum install gcc# 記得這里要把之前的redis目錄刪除重新解壓[[email protected] src]# rm -rf redis-5.0.7[[email protected] src]# tar xf redis-5.0.7.tar.gz # 重新進入目錄進行編譯[[email protected] src]# cd redis-5.0.7/[[email protected] redis-5.0.7]# make PREFIX=/apps/redis install # 指定安裝目錄cd src && make installmake[1]: Entering directory `/usr/local/src/redis-5.0.7/src' CC Makefile.depmake[1]: Leaving directory `/usr/local/src/redis-5.0.7/src'make[1]: Entering directory `/usr/local/src/redis-5.0.7/src'rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep dict-benchmark(cd ../deps && make distclean)make[2]: Entering directory `/usr/local/src/redis-5.0.7/deps'(cd hiredis && make clean) > /dev/null || true(cd linenoise && make clean) > /dev/null || true(cd lua && make clean) > /dev/null || true(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true(rm -f .make-*)make[2]: Leaving directory `/usr/local/src/redis-5.0.7/deps'(rm -f .make-*)....(省略)Hint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL installmake[1]: Leaving directory `/usr/local/src/redis-5.0.7/src'# 最后報這個就是編譯完成

拷貝配置文件

[[email protected] redis-5.0.7]# ll total 276-rw-rw-r-- 1 root root 115100 Nov 20 01:05 00-RELEASENOTES-rw-rw-r-- 1 root root 53 Nov 20 01:05 BUGS-rw-rw-r-- 1 root root 2381 Nov 20 01:05 CONTRIBUTING-rw-rw-r-- 1 root root 1487 Nov 20 01:05 COPYINGdrwxrwxr-x 6 root root 192 Feb 11 11:32 deps-rw-rw-r-- 1 root root 11 Nov 20 01:05 INSTALL-rw-rw-r-- 1 root root 151 Nov 20 01:05 Makefile-rw-rw-r-- 1 root root 6888 Nov 20 01:05 MANIFESTO-rw-rw-r-- 1 root root 20555 Nov 20 01:05 README.md-rw-rw-r-- 1 root root 61797 Nov 20 01:05 redis.conf-rwxrwxr-x 1 root root 275 Nov 20 01:05 runtest-rwxrwxr-x 1 root root 280 Nov 20 01:05 runtest-cluster-rwxrwxr-x 1 root root 373 Nov 20 01:05 runtest-moduleapi-rwxrwxr-x 1 root root 281 Nov 20 01:05 runtest-sentinel-rw-rw-r-- 1 root root 9710 Nov 20 01:05 sentinel.confdrwxrwxr-x 3 root root 8192 Feb 11 11:33 srcdrwxrwxr-x 11 root root 182 Nov 20 01:05 testsdrwxrwxr-x 8 root root 4096 Nov 20 01:05 utils[[email protected] redis-5.0.7]# cp redis.conf /apps/redis/etc/

啟動redis(這個啟動方式)

[[email protected] redis-5.0.7]# /apps/redis/bin/redis-server /apps/redis/etc/redis.conf 8315:C 11 Feb 2020 11:40:12.016 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo8315:C 11 Feb 2020 11:40:12.016 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=8315, just started8315:C 11 Feb 2020 11:40:12.016 # Configuration loaded8315:M 11 Feb 2020 11:40:12.017 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 5.0.7 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 8315 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 8315:M 11 Feb 2020 11:40:12.017 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.8315:M 11 Feb 2020 11:40:12.017 # Server initialized8315:M 11 Feb 2020 11:40:12.017 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.8315:M 11 Feb 2020 11:40:12.017 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.8315:M 11 Feb 2020 11:40:12.018 * Ready to accept connections

解決當前的警告提示

tcp-backlog

The backlog argument defines the maximum length to which the queue of pending connections for sockfdmay grow. If a connection request arrives when the queue is full, the client may receive an error with an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may be ignored so that a later reattempt at connection succeeds.

backlog參數控制的是三次握手的時候server端收到client ack確認號之后的隊列值。

[[email protected] ~]# echo 511 > /proc/sys/net/core/somaxconnvm.overcommit_memory

0、表示內核將檢查是否有足夠的可用內存供應用進程使用;如果有足夠的可用內存,內存申請允許;否則,內存申請失敗,并把錯誤返回給應用進程。 1、表示內核允許分配所有的物理內存,而不管當前的內存狀態如何。 2、表示內核允許分配超過所有物理內存和交換空間總和的內存

[[email protected] ~]# echo "vm.overcommit_memory = 1" >/etc/sysctl.conftransparent hugepage大頁內存動態分配,需要關閉讓redis 負責內存管理。[[email protected] ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled

重啟一下服務

# 再次啟動服務,警告信息沒有了。[[email protected] ~]# /apps/redis/bin/redis-server /apps/redis/etc/redis.conf 1847:C 13 Feb 2020 12:03:59.281 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo1847:C 13 Feb 2020 12:03:59.281 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=1847, just started1847:C 13 Feb 2020 12:03:59.281 # Configuration loaded1847:M 13 Feb 2020 12:03:59.282 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 5.0.7 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 1847 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 1847:M 13 Feb 2020 12:03:59.282 # Server initialized1847:M 13 Feb 2020 12:03:59.282 * DB loaded from disk: 0.000 seconds1847:M 13 Feb 2020 12:03:59.282 * Ready to accept connections

編輯redis服務啟動腳本

[[email protected] ~]# cat /usr/lib/systemd/system/redis.service[Unit]Description=Redis persistent key-value databaseAfter=network.targetAfter=network-online.targetWants=network-online.target[Service]#ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemdExecStart=/apps/redis/bin/redis-server /apps/redis/etc/redis.conf --supervised systemdExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDType=notifyUser=redisGroup=redisRuntimeDirectory=redisRuntimeDirectoryMode=0755[Install]WantedBy=multi-user.target

添加redis用戶

# 添加用戶和組[[email protected] ~]# groupadd -g 1001 redis && useradd -u 1001 -g 1001 redis -s /sbin/nologin# 數據目錄設置所有者所屬組[[email protected] ~]# chown redis.redis -R /apps/redis/system啟動測試# 開啟redis并設為開機啟動[[email protected] ~]# systemctl enable --now redisCreated symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.# 查看端口[[email protected] ~]# ss -tnlState Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 127.0.0.1:631 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 127.0.0.1:6010 *:* LISTEN 0 128 127.0.0.1:6011 *:* LISTEN 0 128 *:43108 *:* LISTEN 0 511 127.0.0.1:6379 *:* # 這個為redis端口 LISTEN 0 128 *:111 *:* LISTEN 0 5 192.168.122.1:53 *:* LISTEN 0 128 *:22 *:* LISTEN 0 128 [::1]:631 [::]:* LISTEN 0 100 [::1]:25 [::]:* LISTEN 0 128 [::1]:6010 [::]:* LISTEN 0 128 [::1]:6011 [::]:* LISTEN 0 128 [::]:59279 [::]:* LISTEN 0 128 [::]:111 [::]:* LISTEN 0 128 [::]:22 [::]:*

客戶端連接redis測試

# 這里還沒有把這個命令加到PATH變量里[[email protected] ~]# /apps/redis/bin/redis-cli 127.0.0.1:6379> info# Serverredis_version:5.0.7redis_git_sha1:00000000redis_git_dirty:0redis_build_id:b0887378c143d6e9redis_mode:standaloneos:Linux 3.10.0-1062.el7.x86_64 x86_64arch_bits:64multiplexing_api:epollatomicvar_api:atomic-builtingcc_version:4.8.5process_id:2088run_id:e0bbd2dc1561d1610565c6c8fb61aa817e30924ctcp_port:6379

創建命令軟連接(也可以把這個路徑加到PATH變量里面)

[[email protected] ~]# ln -sv /apps/redis/bin/redis-* /usr/bin/‘/usr/bin/redis-benchmark' -> ‘/apps/redis/bin/redis-benchmark'‘/usr/bin/redis-check-aof' -> ‘/apps/redis/bin/redis-check-aof'‘/usr/bin/redis-check-rdb' -> ‘/apps/redis/bin/redis-check-rdb'‘/usr/bin/redis-cli' -> ‘/apps/redis/bin/redis-cli'‘/usr/bin/redis-sentinel' -> ‘/apps/redis/bin/redis-sentinel'‘/usr/bin/redis-server' -> ‘/apps/redis/bin/redis-server'# 命令連接測試[[email protected] ~]# redis-cli 127.0.0.1:6379> info# Serverredis_version:5.0.7redis_git_sha1:00000000redis_git_dirty:0redis_build_id:b0887378c143d6e9redis_mode:standaloneos:Linux 3.10.0-1062.el7.x86_64 x86_64arch_bits:64multiplexing_api:epollatomicvar_api:atomic-builtingcc_version:4.8.5process_id:2088run_id:e0bbd2dc1561d1610565c6c8fb61aa817e30924ctcp_port:6379uptime_in_seconds:755uptime_in_days:0[[email protected] ~]# ll /apps/redis/bin/total 32772-rwxr-xr-x 1 redis redis 4366824 Feb 11 11:33 redis-benchmark # redis性能測試工具-rwxr-xr-x 1 redis redis 8125216 Feb 11 11:33 redis-check-aof # AOF文件檢查工具-rwxr-xr-x 1 redis redis 8125216 Feb 11 11:33 redis-check-rdb # RDB文件檢查工具 -rwxr-xr-x 1 redis redis 4807896 Feb 11 11:33 redis-cli # 客戶端工具lrwxrwxrwx 1 redis redis 12 Feb 11 11:33 redis-sentinel -> redis-server # 哨兵軟連接到server-rwxr-xr-x 1 redis redis 8125216 Feb 11 11:33 redis-server # redis 服務啟動命令

**以上就是redis的安裝方法和一些小問題的解決方法了!**

總結

以上所述是小編給大家介紹的編譯安裝redisd的方法示例詳解,希望對大家有所幫助,也非常感謝大家對真格學網網站的支持!

本著什么都要攙和的原則,一起來看看React Native是如何開發iOS APP。圍觀本文需自備Mac OSX,XCode,node 以及 npm。做好準備之后,打開你的終端(或其他命令行利器),鍵入下面命令:npm install-g react-native-cli和react-native init AwesomeProject此時,我們會看到一個名為AwesomeProject的文件夾,這就是工程文件的位置。使用XCode打開AwesomeProject.xcodeproj,并點擊RUN,會看到iOS模擬器以及此項目對應的內容,效果如下:如果想要修改顯示內容,請打開index.ios.js,里面是一堆Javascript模樣的東西。修改之后,在iOS模擬器中cmd+R就可以看到修改后的效果。接下來,我們按照教程,來展示一張電影海報,為了方便,我們直接修改index.ios.js內容來自www.13333515.buzz請勿采集。


  • 本文相關:
  • ubuntu 16.04安裝redis的兩種方式教程詳解(apt和編譯方式)
  • linux平臺編譯安裝php7并安裝redis擴展與swoole擴展實例教程
  • linux下編譯redis和phpredis的方法
  • linux下redis安裝教程詳解
  • windows 64位下redis安裝教程
  • 詳解linux下redis安裝、啟動與停止,redis做成服務
  • redis獲取某個前綴的key腳本實例
  • redis中實現查找某個值的范圍
  • 詳解redis scan命令實現有限保證的原理
  • centos7.3安裝redis4.0.6詳細圖文教程
  • redis實戰記錄之限制操作頻率
  • redis教程(九):主從復制配置實例
  • redis數據庫的安裝配置方法
  • nosql和redis簡介及redis在windows下的安裝和使用教程
  • 淺談redis在分布式系統中的協調性運用
  • 為啥懶 redis 是更好的 redis
  • 如何編譯ReactNative示例程序Examples
  • linux安裝軟件為什么這么難,即使你熟悉了很多命令,但是編譯安裝軟件的時候很麻煩
  • 怎么在linux上安裝windows上的程序?什么是編譯安裝?編譯安裝可以安裝windows下的程序嗎?
  • 求助,編譯安裝gnome
  • 如何安裝C語言編譯器
  • 如何安裝gfortran編譯器
  • 求Linux kubuntu QQ.tar版具體安裝方法,最后編譯那步不會了,先cd到那,之后用編譯安裝的第一步命令后提...
  • 如何在64位Linux上編譯安裝32位wine
  • linux編譯安裝命令
  • 我安裝的codeblocks總是沒編譯器,怎么辦
  • 網站首頁網頁制作腳本下載服務器操作系統網站運營平面設計媒體動畫電腦基礎硬件教程網絡安全mssqlmysqlmariadboracledb2mssql2008mssql2005sqlitepostgresqlmongodbredisaccess數據庫文摘數據庫其它首頁redisubuntu 16.04安裝redis的兩種方式教程詳解(apt和編譯方式)linux平臺編譯安裝php7并安裝redis擴展與swoole擴展實例教程linux下編譯redis和phpredis的方法linux下redis安裝教程詳解windows 64位下redis安裝教程詳解linux下redis安裝、啟動與停止,redis做成服務redis獲取某個前綴的key腳本實例redis中實現查找某個值的范圍詳解redis scan命令實現有限保證的原理centos7.3安裝redis4.0.6詳細圖文教程redis實戰記錄之限制操作頻率redis教程(九):主從復制配置實例redis數據庫的安裝配置方法nosql和redis簡介及redis在windows下的安裝和使用教程淺談redis在分布式系統中的協調性運用為啥懶 redis 是更好的 redis超強、超詳細redis數據庫入門教程redis常用命令、常見錯誤、配置技redis操作命令總結redis中5種數據結構的使用場景介64位windows下安裝redis教程redis中使用redis-dump導出、導入redis中統計各種數據大小的方法redis常用命令小結讓redis在你的系統中發揮更大作用centos 6.6下redis安裝配置記錄如何利用redis鎖解決高并發問題詳解利用redis實現sql伸縮的方法簡介mac下redis安裝、設置、啟動停止方法詳解redis中key的設置方法步驟如何操作redis和zookeeper實現分布式鎖redis學習之rdb、aof與復制時對過期鍵的處異步redis隊列實現 數據入庫的方法用redis實現微博關注關系詳解redis是如何實現隊列消息的ackredis4.0入門小結
    免責聲明 - 關于我們 - 聯系我們 - 廣告聯系 - 友情鏈接 - 幫助中心 - 頻道導航
    Copyright © 2017 www.13333515.buzz All Rights Reserved
    3排列五开奖结果