赞
踩
mkdir /opt/postgresql/data
groupadd pgsql
useradd -g pgsql -G pgsql -d /opt/postgresql pgsql
chown -R pgsql:pgsql /opt/postgresql
passwd pgsql #修改密码
密码:rofine@123
rpm -ivh ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm
rpm -Uvh readline-6.2-11.el7.x86_64.rpm
rpm -ivh readline-devel-6.2-11.el7.x86_64.rpm
rpm -ivh mpfr-3.1.1-4.el7.x86_64.rpm
rpm -ivh libmpc-1.0.1-3.el7.x86_64.rpm
rpm -ivh cpp-4.8.5-44.el7.x86_64.rpm
rpm -Uvh libgomp-4.8.5-44.el7.x86_64.rpm
rpm -Uvh libgcc-4.8.5-44.el7.x86_64.rpm
rpm -ivh kernel-headers-3.10.0-1160.el7.x86_64.rpm
rpm -Uvh glibc-common-2.17-317.el7.x86_64.rpm glibc-2.17-317.el7.x86_64.rpm
rpm -ivh glibc-headers-2.17-317.el7.x86_64.rpm
rpm -ivh glibc-devel-2.17-317.el7.x86_64.rpm
rpm -ivh gcc-4.8.5-44.el7.x86_64.rpm
rpm -ivh zlib-devel-1.2.7-18.el7.x86_64.rpm
su pgsql
tar -zxvf postgresql-14.6.tar.gz -C /opt/postgresql
cd /opt/postgresql/postgresql-14.6
./configure --prefix=/opt/postgresql
make && make install
/opt/postgresql/bin/initdb -D /opt/postgresql/data/
touch /opt/postgresql/logfile
vim ~/.bash_profile
export PGDATA=/opt/postgresql/data
export PATH=$PATH:$HOME/bin:/opt/postgresql/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/postgresql/lib
export PGDATABASE=postgres
export PGPORT=5432
source ~/.bash_profile
cd /opt/postgresql ./pgsql/bin/pg_ctl -D ./pgsql/pgsql_data/ -l ./pgsql/logfile start waiting for server to start.... done server started #查看pgsql状态 ps -ef | grep postgres | grep -v grep pgsql 13912 1 0 15:36 pts/2 00:00:00 /home/postgresql/bin/postgres -D ./pgsql/pgsql_data pgsql 13914 13912 0 15:36 ? 00:00:00 postgres: checkpointer process pgsql 13915 13912 0 15:36 ? 00:00:00 postgres: writer process pgsql 13916 13912 0 15:36 ? 00:00:00 postgres: wal writer process pgsql 13917 13912 0 15:36 ? 00:00:00 postgres: autovacuum launcher process pgsql 13918 13912 0 15:36 ? 00:00:00 postgres: stats collector process pgsql 13919 13912 0 15:36 ? 00:00:00 postgres: bgworker: logical replication launcher -bash-4.2$ psql psql.bin (14.6) Type "help" for help. postgres=# \q //退出
使用pgsql用户执行
打开postgresql.conf文件,修改以下参数
cd /opt/postgresql/pgsql/pgsql_data
vim postgresql.conf #编辑文件
listen_addresses= '*' #地址为* port = 5432 #修改端口
打开/etc/hosts文件,修改以下参数
vim /etc/hosts #编辑文件
127.0.0.1 postgresql
sed -i -e"s/^#listen_addresses =.*$/listen_addresses = '*'/" $DATADIR/postgresql.conf
sed -i -e"s/^max_connections = 100.*$/max_connections = 1000/" $DATADIR/postgresql.conf
sed -i -e"s/^shared_buffers =.*$/shared_buffers = 2GB/" $DATADIR/postgresql.conf
sed -i -e"s/^#effective_cache_size = 128MB.*$/effective_cache_size = 4GB/" $DATADIR/postgresql.conf
sed -i -e"s/^#work_mem = 1MB.*$/work_mem = 128MB/" $DATADIR/postgresql.conf
echo "host all all 0.0.0.0/0 md5" >> $DATADIR/pg_hba.conf
cat >> /etc/systemd/system/postgresql.service <<EOF [Unit] Description=PostgreSQL database server After=network.target [Service] Type=forking User=pgsql Group=pgsql #Environment=PGDATA=/opt/postgresql/data #OOMScoreAdjust=-1000 ExecStart=/opt/postgresql/bin/pg_ctl -D /opt/postgresql/data -l /opt/postgresql/logfile start ExecStop=/opt/postgresql/bin/pg_ctl stop -D /opt/postgresql/data ExecReload=/opt/postgresql/bin/pg_ctl reload -D /opt/postgresql/data TimeoutSec=300 [Install] WantedBy=multi-user.target EOF
systemctl daemon-reload
systemctl start postgresql.service
systemctl enable postgresql.service
systemctl restart postgresql.service
EOF
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。