Postgresql 10 install vernacular

Because I am also a novice, many of them are the description of the program and the search on the Internet plus my own experiments, so the following things are summed up after the actual measurement.

Hardware system nanopi neo #This is a small development board with ARM chip, low cost, the most important thing is to save power, it can be lit 24 hours a day, haha, you can use LINUX system
operating system armbian #It seems to be an ARM version of UBUNTU, all If there is any problem with the operation, you can check the processing method of UBUNTU online to solve it.

1. Download the Postgresql source code

#Switch to root user to download
wget https://ftp.postgresql.org/pub/source/v10.3/postgresql-10.3.tar.bz2


2. Unzip the package
tar jxvf postgresql-10.3.tar.bz2


3. Installation must be A component of
apt-get install libreadline-dev #The
component used can be prompted for what is missing when configuring before installation


4. Start installing
cd postgresql-10.3
./configure --prefix=/usr/local/postgresql
means to install in In this directory, it is convenient to manage
make && make install later


5. Create a postgres user and group, and then use this user and group to start and stop the database

Ubuntu system can use adduser postgres, this command can directly add a group corresponding to this user and add this user to this group, and the HOME directory will be created automatically

The useradd will not create a corresponding HOME directory, but in fact, I have tried adding various parameters to create a user with useradd, and the HOME directory will also be created automatically, but it always feels like something is wrong.

The following is the situation when I use useradd to create an account, it is really tangled -_-

groupadd postgres
useradd -g postgres -d /home/postgres -b/home/postgres -s /bin/bash -m postgres
passwd postgres #See
if there is no /home/postgres, then create a directory yourself
mkdir /home/postgres
chown postgres:postgres /home/postgres
cp /etc/bashrc /home/postgres/.bashrc
cp /etc/profile /home/postgres/.profile


chown postgres:postgres /home/postgres/*


6. Add variables in .profile #This
is to make it easier to use commands later
su - postgres
vim .profile
export PGHOME=/usr/local/postgresql
export PGDATA=~/data
PATH=$PATH:$PGHOME/bin #Reload


configuration file to take effect
soucre ~/.profile


7. Initialize the database
initdb -D $PGDATA #A
bunch of things will come out and finally return to the command line


8. Modify the configuration file
vi $PGDATA/postgresql.conf
Modify the listen_addresses item in it to
listen_addresses = '*' #Originally is localhost


vi $PGDATA/pg_hba.conf
Add a line
host all all 0.0.0.0/0 trust


After these two configurations are saved, start the database After that, you can use other computers to remotely connect to the operation, provided that the network can connect to this database service.


9. Start the server
When initializing the service, you will be prompted with a command to start the server after the last success
pg_ctl -D $PGDATA -l pglog.log start
#Case-sensitive


Parameter vernacular description
-D which data space do you want to start
-l log output file, if there is a problem in the future, you can check the log


and see it, you can only install pgadmin4 on the computer to connect Postgresql 9.6 and later versions , previous versions can connect with pgadmin3

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325616250&siteId=291194637