如何在CentOS7中修改MemSQL端口以解决9000端口占用问题
Hey there, let's get that MemSQL installation sorted out—port conflicts are super common, so no worries! Here are a couple of straightforward ways to fix this:
Option 1: Specify a Custom Port Directly in the Install Command
The easiest fix is to just tell the installer to use a different port right off the bat. Add the --port flag to your existing command with your preferred port number (I'll use 9001 as an example):
sudo ./install.sh --simple-cluster --host=127.0.0.1 --port=9001
This will configure the entire simple cluster (aggregator and leaf node) to use the new port instead of the default 9000.
Option 2: Update Config Files If Installation Was Partially Done
If you already ran the install command and it failed mid-process, you can tweak the existing config files to switch ports:
- First, locate MemSQL's default config directory—this is usually
/var/lib/memsqlor/opt/memsqldepending on your setup. - For the aggregator node, open the
memsql.cnffile in a text editor (likeviornano):sudo nano /var/lib/memsql/memsql.cnf - Find the line starting with
port =and change the value to your desired port, e.g.:port = 9001 - If you have a leaf node (the simple cluster includes one by default), navigate to its subdirectory (something like
/var/lib/memsql/leaf-<random-id>) and edit itsmemsql.cnffile the same way. - Finally, restart the MemSQL services to apply the changes:
sudo systemctl restart memsql # Or use the MemSQL Ops command if that's what you're using memsql-ops restart-all
Quick Check: See What's Using Port 9000
If you're curious which process is hogging port 9000 (maybe you can just stop it instead of switching ports), run one of these commands:
# Using lsof sudo lsof -i :9000 # Using netstat sudo netstat -tulpn | grep 9000
This will show you the process ID and name—if it's a service you don't need, you can stop it with sudo systemctl stop <service-name> or kill <pid>.
内容的提问来源于stack exchange,提问作者user3399495

