In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to install PostgreSQL with source code". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Database version:
PostgreSQL 9.6.3
System version:
CentOS release 6.6 (Final)
Download the software (Download software):
[root@Darren2 tools] # wget https://ftp.postgresql.org/pub/source/v9.6.3/postgresql-9.6.3.tar.gz
Check to see if it is installed (Check is not instatll):
[root@Darren2 tools] # ps-ef | grep pgsql
Root 28590 18695 0 20:24 pts/0 00:00:00 grep pgsql
[postgres@sht-sgmhadoopdn-02 ~] $rpm-qa | grep postgres
Postgresql-libs-8.4.18-1.el6_4.x86_64
Decompression (Extract software):
[root@Darren2 tools] # tar xf postgresql-9.6.3.tar.gz
Compile and install (Complie):
[root@Darren2 tools] # cd postgresql-9.6.3
[root@Darren2 postgresql-9.6.3] #. / configure-prefix=/usr/local/pgsql
Compile everything that can be compiled, including documentation (HTML and man pages) and add-ins (contrib):
[root@Darren2 postgresql-9.6.3] # make world & & make install-world
.
Make [2]: Leaving directory `/ home/tools/postgresql-9.6.3/contrib/vacuumlo'
Make [1]: Leaving directory `/ home/tools/postgresql-9.6.3/contrib'
PostgreSQL, contrib, and documentation installation complete.
Create user groups and users (Create group and user)
[root@Darren2] # groupadd-g 101dba
[root@Darren2 ~] # cat / etc/group | grep dba
Dba:x:101:
[root@Darren2] # useradd-u 516-g dba-G root-d / usr/local/pgsql postgres
[root@Darren2 ~] # id postgres
Uid=516 (postgres) gid=101 (dba) groups=101 (dba), 0 (root)
-u UID
-g initial user group
-G secondary user group
-m create user home directory (system users do not create home directory by default)
-M does not create a user's home directory (ordinary users create a home directory by default)
-s shell defaults to / bin/bash
-d specify home directory
[root@Darren2 home] # groups postgres
Postgres: dba root
Configure postgres password
[root@Darren2 home] # passwd postgres
[root@Darren2 skel] # ls-al / etc/skel/
Total 20
Drwxr-xr-x. 2 root root 4096 Dec 20 2016.
Drwxr-xr-x. 84 root root 4096 Jul 11 22:27..
-rw-r--r--. 1 root root 18 Jul 18 2013 .bash _ logout
-rw-r--r--. 1 root root 176 Jul 18 2013 .bash _ profile
-rw-r--r--. 1 root root 124 Jul 18 2013 .bashrc
[root@Darren2 skel] # cp / etc/skel/.* / usr/local/pgsql/
Create a data directory (Create data folder)
[root@Darren2] # mkdir-p / usr/local/pgsql/data
Configure .bash _ profile (Configure .bash _ profile)
[root@Darren2 pgsql] # cat / usr/local/pgsql/.bash_profile
# .bash _ profile
# Get the aliases and functions
If [- f ~ / .bashrc]; then
. ~ / .bashrc
Fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
Export PGHOME=/usr/local/pgsql
Export PGDATA=/usr/local/pgsql/data
Export PATH=$PATH:/usr/local/pgsql/bin
Set umask to 022
Umask 022
PS1= `uname-n` ":"'$USER' ":"'$PWD' ": >"; export PS1
Modify file permissions and owners (Chmod and chown)
[root@Darren2 pgsql] # chmod-R 755 / usr/local/pgsql
[root@Darren2 pgsql] # chown-R postgres:dba / usr/local/pgsql
[root@Darren2 pgsql] # chmod-R 700 / usr/local/pgsql/data
Configure postgresql service startup and set up self-startup (Configure postgresql service and boot auto start)-- this step can be avoided
[root@Darren2 start-scripts] # cp / home/tools/postgresql-9.6.3/contrib/start-scripts/linux / etc/init.d/postgresql
[root@Darren2 start-scripts] # chmod + x / etc/init.d/postgresql
[root@Darren2 start-scripts] # chkconfig-- list | grep postgresql
[root@Darren2 start-scripts] # chkconfig-- add postgresql
[root@Darren2 start-scripts] # chkconfig-- list | grep postgresql
Postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Initialization data and startup (Initialize database and start database)
[root@Darren2 start-scripts] # su-postgres
[postgres@Darren2 start-scripts] $cd
[postgres@Darren2 ~] $pwd
/ usr/local/pgsql
[postgres@Darren2] $. .bash _ profile
# initialize the generated data file
Darren2:postgres:/usr/local/pgsql: > / usr/local/pgsql/bin/initdb-D / usr/local/pgsql/data
# start the database
Darren2:postgres:/usr/local/pgsql: > pg_ctl start
Server starting
Darren2:postgres:/usr/local/pgsql: > LOG: database system was shut down at 2017-07-12 00:49:17 CST
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
Create users and databases (Create user and database)
Psql
Psql (9.6.3)
Type "help" for help.
Postgres=# create user admin password'admin' login
CREATE ROLE
Postgres=# create database testdb with owner=admin
CREATE DATABASE
Darren2:postgres:/usr/local/pgsql: > pg_ctl status
Pg_ctl: server is running (PID: 51498)
/ usr/local/pgsql/bin/postgres
Common errors are reported during installation
Compile time error:
[root@Darren2 postgresql-9.6.3] # / configure-- prefix=/usr/local/pgsql-- without-zlib
.
Configure: error: readline library not found-- prompt readline not found
If you have readline already installed, see config.log for details on the
Failure. It is possible the compiler isn't looking in the proper directory.
Use-- without-readline to disable readline support.
Check that readline is installed on the system:
[root@Darren2 postgresql-9.6.3] # rpm-qa | grep readline
Compat-readline5-5.2-17.1.el6.x86_64
Readline-6.0-4.el6.x86_64
Through yum search, you can find that readline-devel is not installed:
[root@Darren2 postgresql-9.6.3] # yum search readline
.
Readline-devel.i686: Files needed to develop programs which use the readline library
Readline-devel.x86_64: Files needed to develop programs which use the readline library
.
After installing through yum, you can compile through:
[root@Darren2 postgresql-9.6.3] # yum install-y readline-devel
This is the end of "how to install PostgreSQL with source code". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.