How to start redis-server on a different port than the default port 6379 in ubuntu

微笑、不失礼 提交于 2019-12-19 05:16:24

问题


How to start redis-server on a different port than the default port 6379 in ubuntu

I have used the following steps to install the redis

  1. sudo add-apt-repository ppa:rwky/redis
  2. sudo apt-get update
  3. sudo apt-get -y install redis-server

I installed, but I don't know how to how to start redis-server on a different port than the default port 6379

So kindly tell me the steps to change the default port to different port ?


回答1:


redis-server --port 6380 will start a Redis server listening to port 6380.

redis-cli -p 6380 -- a suggestion made here as well -- does not start a Redis server listening to port 6380, but tries to connect the CLI to a (hopefully running) Redis server that listens to that port.




回答2:


  1. Locate your redis.conf file (it will probably be at /etc/redis/6379.conf).
  2. Copy the file or edit that one and change the port directive to any free port.
  3. Start Redis with the new config file (note that if you've copied the file in the previous step, you'll need to change the service's startup script to use that file).



回答3:


-p <port> Server port (default: 6379).

So if your instance is running under port 1985 just run

$redis-cli -p 1985


来源:https://stackoverflow.com/questions/27895165/how-to-start-redis-server-on-a-different-port-than-the-default-port-6379-in-ubun

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!