当前位置:网站首页>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 !
边栏推荐
- Cross domain problems when downloading webapi interface files
- Zero technology is deeply involved in the development of privacy computing financial scenario standards of the ICT Institute
- Resize2fs: bad magic number in super block
- In JS, 0 means false, and non-0 means true
- Halcon installation and testing in vs2017, DLL configuration in vs2017
- How to get to the deep-water area when the industrial Internet goes?
- [experience] relevant configuration of remote connection to intranet server through springboard machine
- The smallest positive number that a subset of an array cannot accumulate
- Day 014 2D array exercise
- In the MySQL connector of flynk CDC, the MySQL field is varbinary, which is officially
猜你喜欢

技术分享| 快对讲综合调度系统

Mutationobserver document learning

My entrepreneurial neighbors

Jiamusi Market Supervision Bureau carried out special food safety network training on epidemic and insect prevention

Use custom annotations to verify the size of the list

10 practical uses of NFT
![[cryoelectron microscope | paper reading] emclarity: software for high-resolution cryoelectron tomography and sub fault averaging](/img/1e/9f05862288261e16a6b04508b9b292.png)
[cryoelectron microscope | paper reading] emclarity: software for high-resolution cryoelectron tomography and sub fault averaging

Prometheus and grafana

Amaze UI 图标查询

@JsonSerialize注解的使用
随机推荐
[summer daily question] Luogu p1601 a+b problem (high precision)
准备esp32环境
Pat class a 1146 topology sequence
[note] the art of research - (tell a good story and argument)
Embroidery of little D
20 hacker artifacts
Volatile keyword parsing of C #
监听页面滚动位置定位底部按钮(包含页面初始化定位不对鼠标滑动生效的解决方案)
Dilworth 定理
What are the answers about older bloggers?
Starting process of raspberry pie
How to draw an excellent architecture diagram
[memo] summary of the reasons why SSH failed? Remember to come next time.
10 practical uses of NFT
Monitor the bottom button of page scrolling position positioning (including the solution that page initialization positioning does not take effect on mouse sliding)
How to get to the deep-water area when the industrial Internet goes?
postman接口测试|js脚本之阻塞休眠和非阻塞休眠
性能更佳、使用更简单的懒加载IntersectionObserverEntry(观察者)
Zero technology is deeply involved in the development of privacy computing financial scenario standards of the ICT Institute
Chaos and future of domestic digital collections