CreaPlus 发表于 2024-10-17 22:24:54

【待反馈】Ubuntu24 安装postgresql出错

为了能快速了解并处理您的问题,请提供以下基础信息:面板、插件版本:

9.2.0、 PostgreSQL管理器2.6
系统版本:
Ubuntu24
问题描述:
安装报语法错误
相关截图(日志、错误):
2024-10-17 21:23:39 (42.6 KB/s) - 已保存 ‘postgresql-16.1.tar.gz’ )

/www/server/panel/plugin/pgsql_manager/pgsql_install.sh: 64: [: 0: unexpected operator
pgsql文件解压成功
/www/server/panel/plugin/pgsql_manager/pgsql_install.sh: 76: Syntax error: Bad fd number
31500K .......... .......... .......... .......... .......... 99% 60.8K 3s
31550K .......... .......... .......... .......... .......... 99% 28.2K 2s
31600K .......... .......... .......... .......... .......... 99% 27.7K 1s
31650K .......... .......... ...                           100% 54.3K=12m24s

2024-10-17 21:23:39 (42.6 KB/s) - 已保存 ‘postgresql-16.1.tar.gz’ )

/www/server/panel/plugin/pgsql_manager/pgsql_install.sh: 64: [: 0: unexpected operator
pgsql文件解压成功
/www/server/panel/plugin/pgsql_manager/pgsql_install.sh: 76: Syntax error: Bad fd number

yyu0378 发表于 2024-10-17 23:06:21

这是安装脚本中双目操作符有错误,但安装失败不能说一定就和这个错误有关。还是需要看具体代码和日志。

是山河呀 发表于 2024-10-19 22:28:07

降低系统版本重试

CreaPlus 发表于 2024-10-20 12:40:08

yyu0378 发表于 2024-10-17 23:06
这是安装脚本中双目操作符有错误,但安装失败不能说一定就和这个错误有关。还是需要看具体代码和日志。 ...

#!/bin/bash
#pgsql安装脚本
install_dir=/www/server/pgsql
pgsql_version=$1
down_url=$2

GetCpuStat(){
      time1=$(cat /proc/stat |grep 'cpu ')
      sleep 1
      time2=$(cat /proc/stat |grep 'cpu ')
      cpuTime1=$(echo ${time1}|awk '{print $2+$3+$4+$5+$6+$7+$8}')
      cpuTime2=$(echo ${time2}|awk '{print $2+$3+$4+$5+$6+$7+$8}')
      runTime=$((${cpuTime2}-${cpuTime1}))
      idelTime1=$(echo ${time1}|awk '{print $5}')
      idelTime2=$(echo ${time2}|awk '{print $5}')
      idelTime=$((${idelTime2}-${idelTime1}))
      useTime=$(((${runTime}-${idelTime})*3))
      [ ${useTime} -gt ${runTime} ] && cpuBusy="true"
      if [ "${cpuBusy}" == "true" ]; then
                cpuCore=$((${cpuInfo}/2))
      else
                cpuCore=$((${cpuInfo}-1))
      fi
}

cpuInfo=$(getconf _NPROCESSORS_ONLN)
if [ "${cpuInfo}" -ge "2" ];then
      GetCpuStat
else
      cpuCore="1"
fi

loongarch64Check=$(uname -a|grep loongarch64)
if [ "${loongarch64Check}" ];then
    loongarch64_dis="--disable-spinlocks"
    loongarch64_build="--build=arm-linux"
fi

#进入软件的制定安装目录
echo "进入目录/usr/local,下载pgsql文件"
cd /usr/local
#判断是否有postgre版本的安装包
if [ -d postgresql* ]
then
      rm -rf /usr/local/postgresql*
      echo "安装包删除成功"
fi
#判断是否有旧的编译文件
if [ -d /usr/local/pgsql ]
then
      rm -rf /usr/local/pgsql
      echo "旧的编译文件删除成功"
fi

#开始下载pgsql版本10.5并解压
if [ ! -d /usr/local/src ]
then
      mkdir /usr/local/src
fi

cd /usr/local/src
rm -rf post*
wget $down_url
if [ $? == 0 ]
then
tar -zxf $pgsql_version -C /usr/local/
fi

echo "pgsql文件解压成功"
#判断用户是否存在
user=postgres
group=postgres

#create group if not exists
egrep "^$group" /etc/group >& /dev/null
if [ $? -ne 0 ]
then
    groupadd $group
fi

#create user if not exists
egrep "^$user" /etc/passwd >& /dev/null
if [ $? -ne 0 ]
then
    useradd -m $user -g $group
fi

echo "重命名postgresql并且进入安装目录"
mv /usr/local/post* /usr/local/pgsql
cd /usr/local/pgsql
#-------------------------------安装pgsql------------------------------------
echo "安装一些库文件"
yum install -y zlib zlib-devel >& /dev/null
echo "开始执行configure步骤"
./configure --prefix=$install_dir --without-readline ${loongarch64_dis} ${loongarch64_build}
if [ $? == 0 ]
then
      echo "configure配置通过,开始进行make编译"
      make -j $cpuCore
      if [ $? == 0 ]
      then
                echo "make编译通过,开始进行make install安装步骤"
                make install
                if [ $? != 0 ];then
                        echo "make install安装失败"
                fi
                echo "安装成功"
      else
                echo "make编译失败,检查错误。"
      fi
else
      echo "configure检查配置失败,请查看错误进行安装库文件"
fi
echo "开始进行pgsql的配置"
echo "给pgsql创建data目录"
mkdir -p ${install_dir}/data
mkdir -p ${install_dir}/logs
echo "修改用户组"
chown -R postgres:postgres ${install_dir}
chmod -R 700   ${install_dir}/data

echo "/www/server/pgsql/data" >/www/server/pgsql/data_directory
echo "添加环境变量,进入postgres用户的家目录"
cd /home/postgres
if [ -f /home/postgres/.bash_profile ] ;then
      /bin/cp /home/postgres/.bash_profile /home/postgres/.bash_profile.bak
      echo "export PGHOME=${install_dir}" >> /home/postgres/.bash_profile
      echo "export PGDATA=${install_dir}/data" >> /home/postgres/.bash_profile
      echo "export PATH=${install_dir}/bin:\$PATH " >> /home/postgres/.bash_profile
      echo "MANPATH=$PGHOME/share/man:$MANPATH" >> /home/postgres/.bash_profile
      echo "LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH" >> /home/postgres/.bash_profile
      source /home/postgres/.bash_profile
fi
if [ -f /home/postgres/.profile ] ;then
      /bin/cp /home/postgres/.profile /home/postgres/.profile.bak
      echo "export PGHOME=${install_dir}" >> /home/postgres/.profile
      echo "export PGDATA=${install_dir}/data" >> /home/postgres/.profile
      echo "export PATH=${install_dir}/bin:\$PATH " >> /home/postgres/.profile
      echo "MANPATH=$PGHOME/share/man:$MANPATH" >> /home/postgres/.profile
      echo "LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH" >> /home/postgres/.profile
      source /home/postgres/.profile
fi
alias pg_start='pg_ctl -D $PGDATA -l ${install_dir}/logs/pgsql.log start'
alias ps_stop='pg_ctl -D $PGDATA -l ${install_dir}/logs/pgsql.log stop'
echo "切换至postgres用户来初始化数据库"
su - postgres -c "${install_dir}/bin/initdb -D ${install_dir}/data"

echo "启用慢查询SQL语句跟踪"
cat >> ${install_dir}/data/postgresql.conf <<EOF
logging_collector = on
log_destination = 'stderr'
log_directory = '${install_dir}/logs'
log_filename = 'postgresql-%Y-%m-%d.log'
log_statement = all
log_min_duration_statement = 5000
EOF

su - postgres -c "${install_dir}/bin/postgres -D ${install_dir}/data >>${install_dir}/logs/pgsql.log 2>&1 &"
echo "---------------------------------------------------------------------------------------"
echo "---------------------------------------------------------------------------------------"
echo "----------------------------SUCCESS INSTALLATION OF POSTGRESQL-------------------------"


这文件是宝塔自己的文件,没做过修改

运维技术阿闯 发表于 2024-11-21 18:28:17

您好,您这边尝试其他操作系统是否可以安装
页: [1]
查看完整版本: 【待反馈】Ubuntu24 安装postgresql出错