In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
It is very easy to install postgresql.
It's a direct trilogy.
. / configure-- prefix=/usr/local/postgresql
Make
Make install
Create a data directory for postgresql
Mkdir-p / data/postgresql/
Increase users
Useradd postgresql
Change the permissions and owner of the postgresql data directory
Chown-R postgresql. / data/postgresql
Switch users
Su-postgresql
Initialize the database
/ usr/local/pgsql/bin/initdb-D / data/postgresql
Start the database
/ usr/local/pgsql/bin/postgres-D / usr/local/pgsql/data > logfile 2 > & 1 &
Create a test database
/ usr/local/pgsql/bin/createdb test
Using the database
/ usr/local/pgsql/bin/psql test
In fact, use the postgresql account of the system to establish an agreed account in the database, and the system account will be directly associated with the database account.
1. Download the PostgreSQL source package
# wget http://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar.bz2
two。 Decompress the source package
# tar xjf postgresql-9.2.4.tar.bz2
3. Enter the decompressed directory
# cd postgresql-9.2.4
4. View the INSTALL file
The Short Version section of the INSTALL file explains how to install the PostgreSQL command, and the Requirements section describes the lib that the installation of PostgreSQL depends on. If it is long, try configure first. If error appears, then you need to check whether the requirements of Requirements are met.
5. Start compiling and installing the PostgreSQL database.
[root@TS-DEV postgresql-9.2.4] #. / configure
Configure succeeded without errors.
6. Execute gmake
[root@TS-DEV postgresql-9.2.4] # gmake
Gmake succeeded, Ready to install.
7. Execute gmake install
[root@TS-DEV postgresql-9.2.4] # gmake install
Gmake install is successful. At this point, the compilation and installation of the PostgreSQL source code is complete. Let's start configuring PostgreSQL.
8. Set environment variabl
# vi .bash _ profile
Put PATH=$PATH:$HOME/bin
Change it to PATH=$PATH:$HOME/bin:/usr/local/pgsql/bin
Save exit.
Let the environment variable take effect:
# source .bash _ profile
9. Add user postgres
# adduser postgres
* change the user directory (optional)
# vi / etc/passwd
Put postgres:x:528:528::/home/postgres:/bin/bash
Change it to postgres:x:528:528::/usr/local/pgsql:/bin/bash
Move .bash _ profile to a new user directory and modify permissions
# cp / home/postgres/.bash_profile / usr/local/pgsql/
# chown postgres.postgres .bash _ profile
Delete the user directory:
[root@TS-DEV home] # rm-rf postgres/
10. Initialize the database
10.1 New data directory
# mkdir / usr/local/pgsql/data
10.2 change permissions
# chown postgres / usr/local/pgsql/data
10.3 switch to postgres user
# su-postgres
10.4 init db
$/ usr/local/pgsql/bin/initdb-D / usr/local/pgsql/data/
At this point, the data initialization is complete.
11. System service
11.1 back to root users
$exit
11.2 copy the linux file in the installation directory to / etc/init.d/
Go to the postgresql installation directory (that is, the directory you just unzipped with the tar command)
# cd postgresql-9.2.4
# cp contrib/start-scripts/linux / etc/init.d/postgresql
11.3 add execution permissions
# chmod + x / etc/init.d/postgresql
11.4 start the database
11.5 Let the database boot up
# chkconfig-add postgresql
# chkconfig postgresql on
11.6 create a history file for database operations
twelve。 Test use
# su-postgres
$createdb test
$psql test
Test=# create table test (id int)
The source code is compiled and installed successfully.
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.