Redis
主页 > 数据库 > Redis >

CentOS7.9编译安装Redis6.2.5

2026-08-18 | 佚名 | 点击:

Gcc 11是自己编译安装的

所以Redis的Makefile找不到cc,需要手动造一个链接

1

2

cd /usr/bin

sudo ln -s /usr/local/gcc-11.2.0/bin/gcc cc

编译

1

make -j7 USE_SYSTEMD=yes PREFIX=/opt/redis/

安装

1

sudo make PREFIX=/opt/redis install

卸载

1

sudo make uninstall

自带的systemd启动文件有点问题,改为如下

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

[Unit]

Description=Redis data structure server

Documentation=https://redis.io/documentation

#Before=your_application.service another_example_application.service

#AssertPathExists=/var/lib/redis

Wants=network-online.target

After=network-online.target

[Service]

ExecStart=/opt/redis/bin/redis-server /opt/redis/redis.conf --supervised systemd --daemonize no

## Alternatively, have redis-server load a configuration file:

#ExecStart=/usr/local/bin/redis-server /path/to/your/redis.conf

LimitNOFILE=10032

NoNewPrivileges=yes

#OOMScoreAdjust=-900

PrivateTmp=yes

Type=notify

TimeoutStartSec=15

TimeoutStopSec=15

UMask=0077

#User=redis

#Group=redis

#WorkingDirectory=/var/lib/redis

[Install]

WantedBy=multi-user.target

注意修改了timeout的值,否则会经常报timeout错误,例如

1

Job for redis.service failed because a timeout was exceeded. See "systemctl status redis.service" and "journalctl -xe" for details.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

# systemctl status redis.service

● redis.service - Redis data structure server

   Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled)

   Active: failed (Result: timeout) since Mon 2021-08-30 17:11:25 CST; 6min ago

     Docs: https://redis.io/documentation

  Process: 52802 ExecStart=/opt/redis/bin/redis-server /opt/redis/redis.conf --supervised systemd --daemonize no (code=killed, signal=TERM)

 Main PID: 52802 (code=killed, signal=TERM)

Aug 30 17:11:25 elcndc2yfzx01t systemd[1]: Starting Redis data structure server...

Aug 30 17:11:25 elcndc2yfzx01t systemd[1]: redis.service start operation timed out. Terminating.

Aug 30 17:11:25 elcndc2yfzx01t systemd[1]: redis.service stop-sigterm timed out. Killing.

Aug 30 17:11:25 elcndc2yfzx01t systemd[1]: redis.service still around after SIGKILL. Ignoring.

Aug 30 17:11:25 elcndc2yfzx01t systemd[1]: Failed to start Redis data structure server.

Aug 30 17:11:25 elcndc2yfzx01t systemd[1]: Unit redis.service entered failed state.

Aug 30 17:11:25 elcndc2yfzx01t systemd[1]: redis.service failed.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

-- A session with the ID c87 has been terminated.

Aug 30 17:07:43 elcndc2yfzx01t polkitd[1042]: Registered Authentication Agent for unix-process:52658:218121463 (system bus name :1.8843 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/Authe

Aug 30 17:07:43 elcndc2yfzx01t systemd[1]: Starting Redis data structure server...

-- Subject: Unit redis.service has begun start-up

-- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

--

-- Unit redis.service has begun starting up.

Aug 30 17:07:43 elcndc2yfzx01t systemd[1]: redis.service start operation timed out. Terminating.

Aug 30 17:07:43 elcndc2yfzx01t systemd[1]: redis.service stop-sigterm timed out. Killing.

Aug 30 17:07:43 elcndc2yfzx01t systemd[1]: Failed to start Redis data structure server.

-- Subject: Unit redis.service has failed

-- Defined-By: systemd

-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

--

-- Unit redis.service has failed.

--

-- The result is failed.

Aug 30 17:07:43 elcndc2yfzx01t systemd[1]: Unit redis.service entered failed state.

Aug 30 17:07:43 elcndc2yfzx01t systemd[1]: redis.service failed.

Aug 30 17:07:43 elcndc2yfzx01t polkitd[1042]: Unregistered Authentication Agent for unix

原文链接:
相关文章
最新更新