最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2020年02月14日 14:15:38   作者:魚與于玉  
這篇文章主要介紹了編譯安裝redisd的方法示例詳解,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下

安裝方法:

yum安裝

查看yum倉庫redis版本

[root@centos ~]# yum list redis
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Available Packages
redis.x86_64  3.2.12-2.el7  myepel

yum安裝

[root@centos ~]# yum install redis -y

啟動服務(wù)并設(shè)為開機(jī)啟動

[root@centos ~]# systemctl enable --now redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service. 

查看redis端口

[root@centos ~]# ss -ntl
State 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

[root@centos ~]# redis-cli
127.0.0.1:6379> info
# Server
redis_version:3.2.12
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:7897e7d0e13773f
redis_mode:standalone
os:Linux 3.10.0-1062.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.8.5
process_id:2914
run_id:c75137717c54caa78bb05757d05c91471ef5817f
tcp_port:6379
uptime_in_seconds:175
uptime_in_days:0
hz:10
lru_clock:4329484
executable:/usr/bin/redis-server
config_file:/etc/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

測試使用

127.0.0.1:6379> set key1 value1
OK
127.0.0.1:6379> get key1
"value1"

編譯安裝

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

編譯安裝命令

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

# 源碼包存放目錄
[root@centos ~]# cd /usr/local/src/
# 下載源碼包
[root@centos 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.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 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]
# 查看下載好的源碼包
[root@centos src]# ll
total 1940
-rw-r--r-- 1 root root 1984203 Nov 20 01:06 redis-5.0.7.tar.gz

解壓源碼包

[root@centos src]# tar xf redis-5.0.7.tar.gz 
[root@centos src]# ll
total 1940
drwxrwxr-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

創(chuàng)建配置文件、日志、數(shù)據(jù)等目錄

[root@centos ~]# mkdir /apps/redis/{etc,logs,data,run} -p
# 查看目錄結(jié)構(gòu)
[root@centos ~]# tree /apps/
/apps/
└── redis
 ├── data
 ├── etc
 ├── logs
 └── run

進(jìn)入redis目錄編譯安裝

[root@centos ~]# cd /usr/local/src/redis-5.0.7/
[root@centos redis-5.0.7]# make PREFIX=/apps/redis install
cd src && make install
make[1]: Entering directory `/usr/local/src/redis-5.0.7/src'
 CC Makefile.dep
make[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 found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/usr/local/src/redis-5.0.7/src'
make: *** [install] Error 2

# 出現(xiàn)以上報錯是沒有g(shù)cc編譯器導(dǎo)致的
# 下載gcc編譯器
[root@centos redis-5.0.7]# yum install gcc
# 記得這里要把之前的redis目錄刪除重新解壓
[root@centos src]# rm -rf redis-5.0.7
[root@centos src]# tar xf redis-5.0.7.tar.gz 

# 重新進(jìn)入目錄進(jìn)行編譯
[root@centos src]# cd redis-5.0.7/
[root@centos redis-5.0.7]# make PREFIX=/apps/redis install # 指定安裝目錄
cd src && make install
make[1]: Entering directory `/usr/local/src/redis-5.0.7/src'
 CC Makefile.dep
make[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 install
make[1]: Leaving directory `/usr/local/src/redis-5.0.7/src'
# 最后報這個就是編譯完成

拷貝配置文件

[root@centos 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 COPYING
drwxrwxr-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.conf
drwxrwxr-x 3 root root 8192 Feb 11 11:33 src
drwxrwxr-x 11 root root 182 Nov 20 01:05 tests
drwxrwxr-x 8 root root 4096 Nov 20 01:05 utils
[root@centos redis-5.0.7]# cp redis.conf /apps/redis/etc/

啟動redis(這個啟動方式)

[root@centos 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 oO0OoO0OoO0Oo
8315:C 11 Feb 2020 11:40:12.016 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=8315, just started
8315:C 11 Feb 2020 11:40:12.016 # Configuration loaded
8315: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 initialized
8315: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

解決當(dāng)前的警告提示

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參數(shù)控制的是三次握手的時候server端收到client ack確認(rèn)號之后的隊列值。

[root@centos ~]# echo 511 > /proc/sys/net/core/somaxconn
vm.overcommit_memory

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

[root@centos ~]# echo "vm.overcommit_memory = 1" >/etc/sysctl.conf
transparent hugepage
大頁內(nèi)存動態(tài)分配,需要關(guān)閉讓redis 負(fù)責(zé)內(nèi)存管理。
[root@centos ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled

重啟一下服務(wù)

# 再次啟動服務(wù),警告信息沒有了。
[root@centos ~]# /apps/redis/bin/redis-server /apps/redis/etc/redis.conf 
1847:C 13 Feb 2020 12:03:59.281 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1847:C 13 Feb 2020 12:03:59.281 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=1847, just started
1847:C 13 Feb 2020 12:03:59.281 # Configuration loaded
1847: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 initialized
1847:M 13 Feb 2020 12:03:59.282 * DB loaded from disk: 0.000 seconds
1847:M 13 Feb 2020 12:03:59.282 * Ready to accept connections

編輯redis服務(wù)啟動腳本

[root@centos ~]# cat /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis persistent key-value database
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
#ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd
ExecStart=/apps/redis/bin/redis-server /apps/redis/etc/redis.conf --supervised systemd
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Type=notify
User=redis
Group=redisRuntimeDirectory=redis
RuntimeDirectoryMode=0755
[Install]
WantedBy=multi-user.target

添加redis用戶

# 添加用戶和組
[root@centos ~]# groupadd -g 1001 redis && useradd -u 1001 -g 1001 redis -s /sbin/nologin
# 數(shù)據(jù)目錄設(shè)置所有者所屬組
[root@centos ~]# chown redis.redis -R /apps/redis/
system啟動測試
# 開啟redis并設(shè)為開機(jī)啟動
[root@centos ~]# systemctl enable --now redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.
# 查看端口
[root@centos ~]# ss -tnl
State 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變量里
[root@centos ~]# /apps/redis/bin/redis-cli 
127.0.0.1:6379> info
# Server
redis_version:5.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:b0887378c143d6e9
redis_mode:standalone
os:Linux 3.10.0-1062.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.8.5
process_id:2088
run_id:e0bbd2dc1561d1610565c6c8fb61aa817e30924c
tcp_port:6379

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

[root@centos ~]# 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'
# 命令連接測試
[root@centos ~]# redis-cli 
127.0.0.1:6379> info
# Server
redis_version:5.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:b0887378c143d6e9
redis_mode:standalone
os:Linux 3.10.0-1062.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.8.5
process_id:2088
run_id:e0bbd2dc1561d1610565c6c8fb61aa817e30924c
tcp_port:6379
uptime_in_seconds:755
uptime_in_days:0
[root@centos ~]# 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 服務(wù)啟動命令

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

總結(jié)

以上所述是小編給大家介紹的編譯安裝redisd的方法示例詳解,希望對大家有所幫助,也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

  • Redis高并發(fā)情況下并發(fā)扣減庫存項目實戰(zhàn)

    Redis高并發(fā)情況下并發(fā)扣減庫存項目實戰(zhàn)

    本文主要介紹了Redis高并發(fā)情況下并發(fā)扣減庫存項目實戰(zhàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-04-04
  • 如何使用Redis保存用戶會話Session詳解

    如何使用Redis保存用戶會話Session詳解

    這篇文章主要給大家介紹了關(guān)于如何使用Redis保存用戶會話Session的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-01-01
  • Redis處理高并發(fā)機(jī)制原理及實例解析

    Redis處理高并發(fā)機(jī)制原理及實例解析

    這篇文章主要介紹了Redis處理高并發(fā)機(jī)制原理及實例解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值析,需要的朋友可以參考下
    2020-08-08
  • Redis隊列和阻塞隊列的實現(xiàn)

    Redis隊列和阻塞隊列的實現(xiàn)

    本文主要介紹了Redis隊列和阻塞隊列的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-11-11
  • CentOS 6.6下Redis安裝配置記錄

    CentOS 6.6下Redis安裝配置記錄

    這篇文章主要介紹了CentOS 6.6下Redis安裝配置記錄,本文給出了安裝需要的支持環(huán)境、安裝redis、測試Redis、配置redis等步驟,需要的朋友可以參考下
    2015-03-03
  • Java實現(xiàn)多級緩存的方法詳解

    Java實現(xiàn)多級緩存的方法詳解

    對于高并發(fā)系統(tǒng)來說,有三個重要的機(jī)制來保障其高效運(yùn)行,它們分別是:緩存、限流和熔斷,所以本文就來和大家探討一下多級緩存的實現(xiàn)方法,希望對大家有所幫助
    2024-02-02
  • redis實現(xiàn)分布式全局唯一id的示例代碼

    redis實現(xiàn)分布式全局唯一id的示例代碼

    在某些場景中,我們需要生成全局的唯一ID,本文主要介紹了redis實現(xiàn)分布式全局唯一id的示例代碼,具有一定的參考價值,感興趣的可以了解一下
    2024-04-04
  • Redisson分布式限流器RRateLimiter的使用及原理小結(jié)

    Redisson分布式限流器RRateLimiter的使用及原理小結(jié)

    本文主要介紹了Redisson分布式限流器RRateLimiter的使用及原理小結(jié),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2024-06-06
  • Python交互Redis的實現(xiàn)

    Python交互Redis的實現(xiàn)

    本文主要介紹了Python交互Redis的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-08-08
  • Redis執(zhí)行Lua腳本的好處與示例代碼

    Redis執(zhí)行Lua腳本的好處與示例代碼

    Redis在2.6推出了腳本功能,允許開發(fā)者使用Lua語言編寫腳本傳到Redis中執(zhí)行。下面這篇文章主要給大家介紹了關(guān)于Redis執(zhí)行Lua腳本的好處與示例代碼,文中通過示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2018-10-10

最新評論

东台市| 高要市| 平南县| 天长市| 许昌市| 额尔古纳市| 澄城县| 江陵县| 绥宁县| 富阳市| 汉阴县| 高淳县| 高台县| 肇州县| 和静县| 红原县| 凤城市| 遵化市| 娄底市| 河曲县| 南康市| 南木林县| 徐州市| 渭南市| 东台市| 孝昌县| 五原县| 集安市| 峡江县| 元朗区| 丽水市| 涟源市| 洪雅县| 台南市| 凌海市| 玉林市| 五指山市| 本溪市| 运城市| 昌吉市| 清河县|