当前位置:网站首页>CentOS deploy PostgreSQL 13
CentOS deploy PostgreSQL 13
2022-07-29 07:53:00 【Lying cat】
Create groups and users ,pg The database cannot be used for security root Start and stop .
grouadd postgres
useradd -g postgres postgres
passwd postgres # Set the password Upload Download the installation package from the official website and extract
tar -zxvf postgresql-13.3.tar.gz
yum -y install gcc readline-devel zlib zlib-devel # Installation dependency
cd postgresql-13.3/ # Go to unzip directory
./configure --prefix=/opt/postgres # Conduct ./configure,make,make install
make && make install # adopt echo $? To check whether the execution is successful


Setup after installation postgres User variables
su - postgres # Switch to postgres user
vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export PGHOME=/opt/postgres # add to Set up pg Database installation directory
export PGDATA=/opt/postgres/data # add to Set up pg Database data Catalog
PATH=$PATH:$HOME/bin:$PGHOME/bin # take PATH Variable
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH
exit # Return to root user
stay pg Under the installation directory of data Catalog
mkdir /opt/postgres/data
to pg Installation directory settings postgres jurisdiction
chown -R postgres:postgres /opt/postgres/
su - postgres # Switch to postgres user
initdb # Perform database initialization

cd /opt/postgres/data # After successful initialization , Get into data Directory modification configuration file
postgresql.conf #pg Profile of the database
pg_hba.conf # Access policy Profile
vim pg_hba.conf # Edit the access policy configuration file ,G Go to the end of the text .
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
host all all 0.0.0.0/0 md5
TYPE Indicates the host type
The value is `local` Said is unix-domain Of socket Connect ,
The value is `host` yes TCP/IP socket
The value is `hostssl` yes SSL Encrypted TCP/IP socket
DATABASE Represents the database name
The value is : `all` ,`sameuser`,`samerole`,`replication`,` Database name ` , Or more Database name is ` comma `, Be careful ALL Mismatch replication
USER Represents the user name
`all( All )`,` A user name `,` A set of user names ` , When there are multiple users , It can be used `,` commas , Or in the user name prefix `+` ;
ADDRESS Parameters
Accessible address , Source address , Local 127.0.0.1/32, Multiple IP Use English comma to separate , Use IP Change the number of mask bits when segment , for example :10.10.10.0/0.
METHOD authentication
trust: Allow connections... Unconditionally , No password is required for login , unsafe .
reject: The connection rejects unconditionally , Often used from a group " Filter " Some hosts .
md5: Ask the client to provide a MD5 Encrypted password for authentication .
password: and "md5" equally , But the password is passed on the network in clear text , We should not use this method on insecure networks .
vim postgresql.conf # Set up pg The configuration file
listen_addresses = '*'
port = 5432
max_connections = 500
shared_buffers = 512MB
logging_collector = on
log_directory = 'pg_log'
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
log_rotation_size = 1GB
log_statement = 'mod'
timezone = 'Asia/Shanghai'listen_addresses : You can connect to the server to use IP, The general initial value is localhost perhaps local, This means that only the local computer can connect to the database . It is generally set to " * " , Allow all IP Connect to database .
port : Listening port , The default is 5432.
max_connections : Maximum number of concurrent connections allowed .
share_buffers: Shared cache size , It mainly stores the recently accessed data pages . It is recommended to set the server 25% system memory .
logging_collector = on: log enable .
log_directory = 'pg_log': Specify where to store the logs , stay data Under the table of contents .
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log':log_filename: The naming format of the log , The default is postgresql-%Y-%m-%d_%H%M%S.log. Support strftime Format .%Y-%m Wait for the year representing time - month - Day, etc. .
log_rotation_size = 1GB: Maximum disk space of log file .
log_statement = 'mod': Record various operations of users after logging into the database ,
mod( Record ddl+insert,delete,update and truncate)
ddl( Record create,drop and alter)
timezone = 'Asia/Shanghai': pg Time zone setting of database .
[[email protected] ~]$ pg_ctl -D /opt/postgres/data start # start-up pg database
waiting for server to start......2022-06-07 11:46:19.757 CST [6625] LOG: redirecting log output to logging collector process
2022-06-09 11:46:19.757 CST [6625] HINT: Future log output will appear in directory "pg_log".
done
server started # Successful launch Log in pg_log Next
start start-up stop stop it restart restart ( It's best to restart after some configuration changes )
[[email protected] ~]$ psql -U postgres
postgres=# ALTER USER postgres WITH PASSWORD '123456'; # change postgres User's password .
ALTER ROLE
postgres=#
That's the end for the time being , We will continue to update about PG Some operation and maintenance of data , Collect some likes !
边栏推荐
- JVM garbage collection mechanism (GC)
- 【无标题】格式保存
- Getting started with JDBC
- MySQL 45 | 08 is the transaction isolated or not?
- 功能自动化测试实施的原则以及方法有哪些?
- Zip gzip tar compression Advanced Edition
- Space shooting Lesson 17: game over (end)
- [cryoEM] Introduction to FSC, Fourier shell correlation
- What are the answers about older bloggers?
- Multi thread shopping
猜你喜欢

Matrix decomposition and gradient descent
![[deep learning] data preparation -pytorch custom image segmentation data set loading](/img/7d/61be445febc140027b5d9d16db8d2e.png)
[deep learning] data preparation -pytorch custom image segmentation data set loading
黑盒测试常见错误类型说明及解决方法有哪些?

Ionicons icon Encyclopedia

Prometheus and grafana

CDM - code division multiplexing (easy to understand)

【无标题】格式保存

Keyboard processing in jetpack compose

Sort out the two NFT pricing paradigms and four solutions on the market

@Use of jsonserialize annotation
随机推荐
Excellent urban design ~ good! Design # visualization radio station will be broadcast soon
NLP introduction + practice: Chapter 5: using the API in pytorch to realize linear regression
Limitations of push down analysis
Data warehouse modeling, what is wide table? How to design? Advantages and disadvantages
flutter只要是数据,都会判空的
Chaos and future of domestic digital collections
In JS, 0 means false, and non-0 means true
207.课程表
LANDSCAPE
输出1234无重复的三位数
The database uses PSQL and JDBC to connect remotely and disconnect automatically from time to time
Basic introduction to pod
Dilworth 定理
Write some DP
The difference between static library and dynamic library of program
Prepare esp32 environment
FLink CDC 的mysql connector中,mysql的字段是varbinary, 官方
在js中,0表示false,非0表示true
Gin abort cannot prevent subsequent code problems
Realize the effect of changing some colors of a paragraph of text