centos7.8伺服器一台
# hostnamectl set-hostname redishost
# cd /opt # wget https://download.redis.io/releases/redis-5.0.10.tar.gz
# cd /opt # tar -zxf redis-5.0.10.tar.gz
# cd /opt # cd redis-5.0.10 ## 安装gcc编译器 # yum install gcc # make MALLOC=libc # # make install cd src && make install make[1]: Entering directory `/opt/redis-5.0.10/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 `/opt/redis-5.0.10/src
## 修改sysctl.conf # ( cat <<EOF net.core.somaxconn=1024 vm.overcommit_memory=1 EOF ) >> /etc/sysctl.conf
以上操作是解決redis-server預設啟動提示的前兩個警告的持久方案,附redis-server預設啟動的兩個警告訊息如下:
The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
overcommit_memory is set to 0!
## 修改/etc/default/grub ## 在指定行加 transparent_hugepage=never # vi /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet transparent_hugepage=never" GRUB_DISABLE_RECOVERY="true" ## 重新生成grub配置文件 # grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-1127.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-1127.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-385c7efe9475460c95c436866e593af3 Found initrd image: /boot/initramfs-0-rescue-385c7efe9475460c95c436866e593af3.img done
# cd /opt/redis-5.0.10 # mkdir /etc/redis # cp redis.conf /etc/redis/redis.conf
##設定redis連線密碼
在requirepass foobard改為requirepass redis1234##設定systemctl啟動程式
[Unit] Description=Redis 6379 After=syslog.target network.target [Service] Type=forking PrivateTmp=yes Restart=always ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf User=root Group=root LimitCORE=infinity LimitNOFILE=100000 LimitNPROC=100000 [Install] WantedBy=multi-user.target
設定自動啟動
systemctl daemon-reload systemctl enable redis
啟動指令
systemctl enable redis systemctl start redis systemctl restart redis###{{o.name }}######{{m.name}}###
以上是centos7.8怎麼安裝redis5.0.10的詳細內容。更多資訊請關注PHP中文網其他相關文章!