markdown [Redis]同一台服务器上的多个Redis实例#linux

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown [Redis]同一台服务器上的多个Redis实例#linux相关的知识,希望对你有一定的参考价值。

## FOR MULTIPLE REDIS INSTANCE INSTALLATION ON RHEL7+ USE THE FOLLOWING PATHS AND SETUP PROCESS:
* create a new redis .conf file

```Bash
$ cp /etc/redis.conf /etc/redis-xxx.conf
```

* edit /etc/redis-xxx.conf, illustrated as below

```Bash
...
#modify pidfile
#pidfile /var/run/redis/redis.pid
pidfile /var/run/redis/redis-xxx.pid

...
#dir /var/lib/redis/
dir /var/lib/redis-xxx/

...
#modify port
#port 6379
port 6380

...
#modify logfile
#logfile /var/log/redis/redis.log
logfile /var/log/redis/redis-xxx.log

...
#modify vm-swap-file
#vm-swap-file /tmp/redis.swap
vm-swap-file /tmp/redis-xxx.swap
...
```
* make dir /var/lib/redis-xxx

```Bash
$ mkdir -p /var/lib/redis-xxx
```

* THERE IS NO init.d files RHEL uses systemctl instead so:
* copy existing service over to your new service

```Bash
$ cp /usr/lib/systemd/system/redis.service /usr/lib/systemd/system/redis-xxx.service
```

* modify your new service script to the following: (just change the redis-xxx path)

```Bash
...

#[Unit]
Description=Redis persistent key-value database
After=network.target

#[Service]
ExecStart=/usr/bin/redis-server /etc/redis-xxx.conf --daemonize no
ExecStop=/usr/bin/redis-shutdown
User=redis
Group=redis

#[Install]
WantedBy=multi-user.target
...
```

* if you have sentinel enabled on your system you will need to: (otherwise skip this step)

```Bash
# Copy values from cat /usr/lib/systemd/system/redis.service to /usr/lib/systemd/system/redis-xxx.service
$ cp /usr/lib/systemd/system/redis.service /usr/lib/systemd/system/redis-xxx.service
```

* then edit the contents of /usr/lib/systemd/system/redis-xxx.service (just change the /etc/redis-xxx path again)


* start the new services:

```Bash
$ service redis-xxx start
```

* check the new services status:

```Bash
$ service redis-xxx status
```


* stop the new services status:

```Bash
$ service redis-xxx stop
```


* restart the new services status:

```Bash
$ service redis-xxx restart
```

* if you get some problems with service not found:
* you can do the following:
```Bash
$ systemctl unmask packagekit.service
$ systemctl mask packagekit.service
```
* then try to start the service again

以上是关于markdown [Redis]同一台服务器上的多个Redis实例#linux的主要内容,如果未能解决你的问题,请参考以下文章

基于队列实现生产者消费者

基于队列实现生产者消费者

同一台服务器,启动多个redis实例

ZABBIX监控一台机器上的多tomcat实例落地经验步骤

如何在同一台机器上安装多个MySQL的实例(转)

markdown 在同一台计算机上设置Github和Bitbucket帐户。