执行:[omm@OpenEuler single_node]$ gs_ctl start -D $GAUSSHOME/data/single_node -Z single_node 报错
#报错详情
2023-11-11 10:29:45.031 [unknown] [unknown] localhost 139719988629440 0[0:0#0] 0 [BACKEND] LOG: loaded library "security_plugin"
2023-11-11 10:29:45.031 [unknown] [unknown] localhost 139719988629440 0[0:0#0] 0 [BACKEND] LOG: could not bind IPv4 socket at the 0 time: Cannot assign requested address
2023-11-11 10:29:45.031 [unknown] [unknown] localhost 139719988629440 0[0:0#0] 0 [BACKEND] HINT: Port 5432 is used, run 'netstat -anop|grep 5432' or 'lsof -i:5432'(need root) to see who is using this port.
.2023-11-11 10:29:46.032 [unknown] [unknown] localhost 139719988629440 0[0:0#0] 0 [BACKEND] LOG: could not bind IPv4 socket at the 1 time: Cannot assign requested address
2023-11-11 10:29:46.032 [unknown] [unknown] localhost 139719988629440 0[0:0#0] 0 [BACKEND] HINT: Port 5432 is used, run 'netstat -anop|grep 5432' or 'lsof -i:5432'(need root) to see who is using this port.
.2023-11-11 10:29:47.034 [unknown] [unknown] localhost 139719988629440 0[0:0#0] 0 [BACKEND] LOG: could not bind IPv4 socket at the 2 time: Cannot assign requested address
2023-11-11 10:29:47.034 [unknown] [unknown] localhost 139719988629440 0[0:0#0] 0 [BACKEND] HINT: Port 5432 is used, run 'netstat -anop|grep 5432' or 'lsof -i:5432'(need root) to see who is using this port.
.2023-11-11 10:29:48.036 [unknown] [unknown] localhost 139719988629440 0[0:0#0] 0 [BACKEND] LOG: exec cmd: lsof -i:5432
sh: line 1: lsof: command not found
2023-11-11 10:29:48.037 [unknown] [unknown] localhost 139719988629440 0[0:0#0] 0 [BACKEND] LOG: exec cmd: netstat -anp | grep 5432
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
2023-11-11 10:29:48.041 [unknown] [unknown] localhost 139719988629440 0[0:0#0] 0 [BACKEND] LOG: <netstat>:tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 128982/gaussdb
2023-11-11 10:29:48.041 [unknown] [unknown] localhost 139719988629440 0[0:0#0] 0 [BACKEND] LOG: <netstat>:tcp6 0 0 ::1:5432 :::* LISTEN 128982/gaussdb
2023-11-11 10:29:48.042 [unknown] [unknown] localhost 139719988629440 0[0:0#0] 0 [BACKEND] FATAL: could not create listen socket for "192.168.6.102:5432"
原因:因为我是从vmware的虚拟的openEuler文件拷贝到我的电脑,当时拷贝过来仅仅就改了个ip地址,其余的没有配置,导致openGauss识别的还是之前的主机地址,所以报错
具体修改:
1、#进入到我们的配置文件目录
[omm@OpenEuler single_node]$ pwd
/opt/openGauss/data/single_node
2、#验证我们之前的猜想
[omm@OpenEuler single_node]$ cat postgresql.conf | grep address
listen_addresses = 'localhost,192.168.6.102' # what IP address(es) to listen on;
# comma-separated list of addresses;
#local_bind_address = '0.0.0.0'
[omm@OpenEuler single_node]$
#listen_addresses = 'localhost,192.168.6.102'从这个可以看到我们用的是这个ip地址
3、#查看以下我们正在使用的ip地址
[omm@OpenEuler single_node]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:7e:37:91 brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet 192.168.187.3/24 brd 192.168.187.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::6149:c3ce:469a:7717/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[omm@OpenEuler single_node]$
#通过这个我们可以看出我们使用的ip和openGauss所监听的ip不相同
4、修改配置
[omm@OpenEuler single_node]$ vim postgresql.conf
#具体位置直接搜索吧
/listen_address
修改完保存就可以正常启动了
每次启动都很麻烦,脚本附赠给大家,希望给个免费的赞
#!/bin/bash
if [ $# -lt 1 ]
then
echo "No Args Input..."
exit ;
fi
case $1 in
"start")
echo " =================== 启动单机 Gauss ==================="
echo " --------------- 启动 single_node ---------------"
nohup /opt/openGauss/bin/gs_ctl start -D $GAUSSHOME/data/single_node -Z single_node >/opt/openGauss/logs/log.txt 2>&1 &
;;
"stop")
echo " =================== 关闭单机 Gauss ==================="
echo " --------------- 关闭 single_node ---------------"
nohup /opt/openGauss/bin/gs_ctl stop -D $GAUSSHOME/data/single_node -Z single_node >/opt/openGauss/logs/log.txt 2>&1 &
;;
"restart")
echo " =================== 重启单机 Gauss ==================="
echo " --------------- 重启 single_node ---------------"
nohup /opt/openGauss/bin/gs_ctl restart -D $GAUSSHOME/data/single_node -Z single_node >/opt/openGauss/logs/log.txt 2>&1 &
;;
*)
echo "Input Args Error..."
;;
esac
注意:大家要使用脚本的话需要简单的修改一下里面的目录,并且再logs下面创建log.txt文件才可以正常使用