PG的安裝與配置
安裝方式很多種:RPM包,YUM安裝,原始碼安裝
1.RPM包安裝
1.1下載RPM包
wget style="display:none;" id="__kindeditor_bookmark_end_82__">
wget
wget
wget
當然版本可以去官網上下載最新的。1.2安裝包;
# rpm -ivh postgresql94-libs-9.4.4-1PGDG.rhel6.i686.rpm
# rpm -ivh postgresql94-9.4.4-1PGDG.rhel6.i686.rpm
# rpm -ivh postgresql94-server-9.4.4-1PGDG.rhel6.i686.rpm
# rpm -ivh postgresql94-contrib-9.4.4-1PGDG.rhel6.i686.rpm
如果出現缺少包的情況,則根據原始碼安裝的包去安裝一下即可。
裝完,資料庫就裝好了。剩下就是初始化資料庫。
1.3初始化資料庫
# service postgresql-9.4 initdb
或者
initdb -D /var/lib/pgsql/9.4/data
pg_ctl -D /var/lib/pgsql/9.4/data
1.4啟動服務# service postgresql-9.4 start
或者
#pg_ctl start
同樣停止資料庫
就是#pg_ctl stop
1.5對postgres使用者的.bash_profile檔案進行設定
和原始碼安裝一樣。
1.6進入資料庫
[postgres@prod ~]$ psql
psql (9.2.2)
Type "help" for help.
postgres=#
1.7還有對postgresql.conf的設定,參考官方文件。
2.YUM安裝
2.1首先配置一些yum源
在【Base】和[Update]之間,新增一句exclude=postgresql*。根據官方文件解釋:是為了解決依賴性問題:
Configure your YUM repository
Locate and edit your distributions .repo file, located:
- On Fedora: /etc/yum.repos.d/fedora.repo and /etc/yum.repos.d/fedora-updates.repo, [fedora] sections
- On CentOS: /etc/yum.repos.d/CentOS-Base.repo, [base] and [updates] sections
- On Red Hat: /etc/yum/pluginconf.d/rhnplugin.conf [main] section
To the section(s) identified above, you need to append a line (otherwise dependencies might resolve to the postgresql supplied by the base repository):
exclude=postgresql*
yum local install /> 2.3安裝資料庫
yum list postgre*檢視相關postgresql相關的包,根據需要安裝。
yum install postgresql94-server
會自動安裝相關的包,這些前面的配置yum就用上了。前幾天我安裝網上一些做法怎麼搞都解決不了依賴性問題。這下去官網上,一下搞定。。呵呵
到此基本資料庫已經安裝完畢。
2.4老活,初始化資料庫。不再多說。
2.4老活,初始化資料庫。不再多說。
3.原始碼安裝
2.1必要的包的安裝
yum -y install lrzsz sysstat e4fsprogs ntp readline-devel zlib zlib-devel openssl openssl-devel pam-devel libxml2-devel libxslt-devel python-devel tcl-devel gcc make smartmontools flex bison perl perl-devel perl-ExtUtils* OpenIPMI-tools systemtap-sdt-devel perl-ExtUtils-Embed
2.2下載一些安裝檔案
2.2下載一些安裝檔案
$ wget style="line-height:normal;orphans:2;widows:2;" />
postgresql:
flex:pgfincore:2.3安裝flex
解壓:xz -d flex-2.5.39.tar.xz
tar xvf flex-2.5.39.tar
,./configure,make,make install
檢視版本:flex -V
2.4修改一些系統引數
vi /etc/sysctl.conf
kernel.shmmni = 4096
kernel.sem = 50100 64128000 50100 1280
fs.file-max = 7672460
net.ipv4.ip_local_port_range = 9000 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.core.netdev_max_backlog = 10000
vm.overcommit_memory = 0
net.ipv4.ip_conntrack_max = 655360
fs.aio-max-nr = 1048576
net.ipv4.tcp_timestamps = 0
sysclt -p
vi /etc/security/limits.conf
* soft nofile 131072
* hard nofile 131072
* soft nproc 131072
* hard nproc 131072
* soft core unlimited
* hard core unlimited
* soft memlock 50000000
* hard memlock 50000000
關閉selinux
vi /etc/sysconfig/selinux
SELINUX=disable
檢視狀態:/usr/sbin/sestatus -v
防火牆關閉或者設定一下只對區域網訪問。
檢視狀態:service iptables status
vi /etc/sysconfig/iptables
-A INPUT -s 192.168.0.0/5432 -j ACCEPT
service network restart
新增使用者
useradd postgres
cd /opt/soft_bak/
tar -jxvf postgresql-9.4.4.tar.bz2
tar -zxvf pgfincore.tar.gz
mv pgfincore postgresql-9.4.4/contrib/
配置postgres使用者的引數檔案
vi /home/postgres/.bash_profile
export PGPORT=5432
export PGDATA=/home/postgres/pgdata
export LANG=en_US.utf8
export PGHOME=/opt/pgsql
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export DATE=`date +"%Y%m%d%H%M"`
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH
export PGUSER=postgres
export PGHOST=$PGDATA
export PGDATABASE=postgres
安裝systemtap環境
vi /etc/yum.repos.d/CentOS-Debuginfo.repo
enabled=1
# uname -r
2.6.32-358.el6.x86_64
yum install -y kernel-devel-2.6.32-358.el6.x86_64 kernel-debuginfo-2.6.32-358.el6.x86_64 kernel-debuginfo-common-x86_64-2.6.32-358.el6.x86_64 systemtap
stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'
或下載systemtap原始碼編譯
2.4.安裝資料庫
cd /opt/soft_bak/postgresql-9.4.4
./configure --prefix=/opt/pgsql9.4.4 --with-pgport=5432 --with-perl --with-tcl --with-python --with-openssl --with-pam --without-ldap --with-libxml --with-libxslt --enablethread-safety --with-wal-blocksize=8 --with-blocksize=8 --enable-dtrace --enable-debug --enable-cassert #除錯用的。
gmake world
gmake install-world
ln -s /opt/pgsql9.4.4 /opt/pgsql(軟連線)
初始化資料庫: initdb -D $PGDATA -E UTF8 --locale=C -U postgres -W
然後psql進入資料庫,
如果報錯:
[postgres@prod pgdata]$ psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/home/postgres/pgdata/.s.PGSQL.5432"?
錯誤原因是沒有找到相應的檔案:
第一,可以透過:
[postgres@prod pgdata]$ psql -h 127.0.0.1
psql (9.4.4)
Type "help" for help.
postgres=# \q
第二:修改postgresql.conf中unix_socket_directories = '/home/postgres/pgdata/'引數
然後:
[postgres@prod pgdata]$ pg_ctl stop -m fast -D $PGDATA
waiting for server to shut down....LOG: received fast shutdown request
LOG: aborting any active transactions
LOG: autovacuum launcher shutting down
LOG: shutting down
LOG: database system is shut down
done
server stopped
[postgres@prod pgdata]$ pg_ctl start -D $PGDATA
server starting
[postgres@prod pgdata]$ LOG: database system was shut down at 2015-08-24 12:50:41 CST
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
[postgres@prod pgdata]$ psql
psql (9.4.4)
Type "help" for help.
postgres=# \q
2.5安裝pgfincore
cd /opt/soft_bak/postgresql-9.4.4/contrib/pgfincore
. /home/postgres/.bash_profile
make clean
make
make install
2.6設定postgresql.conf
詳細見附件postgresql.conf
其中log_statement = 'ddl' 這引數,會記錄建立的使用者和密碼到日誌的。
所以要暫時設定set log_statement =none;臨時不會記錄到日誌了。
3.PGADMIN III安裝使用
windows下載安裝pgadmin III,可以直接官網下載192.168.0.0/0 md5 ---這個的意思就是192.168的這個網段的ip都可以訪問
vi postgresql.conf
listen_addresses = '192.168.0.0' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 1234 # (change requires restart)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25954236/viewspace-1809282/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- centos7 (阿里雲、linux) 單機spark的安裝與配置詳解(jdk安裝與配置,scala安裝與配置,hadoop安裝與配置,spark安裝與配置)CentOS阿里LinuxSparkJDKHadoop
- 本地windows搭建spark環境,安裝與詳細配置(jdk安裝與配置,scala安裝與配置,hadoop安裝與配置,spark安裝與配置)WindowsSparkJDKHadoop
- Redis的安裝與配置Redis
- Vue的安裝與配置Vue
- MariaDB的安裝與配置
- PG-pg資料庫安裝vector資料庫
- Supervisor安裝與配置
- Nginx安裝與配置Nginx
- 【Redis】安裝與配置Redis
- [Redis] 安裝與配置Redis
- 【MySQL】安裝與配置MySql
- jdk安裝與配置JDK
- MacVim安裝與配置Mac
- 【MongoDB】安裝與配置MongoDB
- Nginx 安裝與配置Nginx
- Spark安裝與配置Spark
- Telnet安裝與配置
- vim安裝與配置
- Rabbitmq安裝與配置MQ
- MySQL安裝與配置MySql
- Ubuntu下 hadoop的安裝與配置UbuntuHadoop
- kafka的認識、安裝與配置Kafka
- Munin監控的安裝與配置
- Redis的安裝配置與命令操作Redis
- 【PG】PG在linux上的線上和離線安裝Linux
- macOS Java安裝與配置MacJava
- linux maven安裝與配置LinuxMaven
- Kafka SSL安裝與配置Kafka
- Mac 安裝與配置mongodbMacMongoDB
- Mac Flutter安裝與配置MacFlutter
- sqoop 安裝與配置使用OOP
- Centos安裝與配置RedisCentOSRedis
- 【PG安裝】postgresql10 for linux 原始碼安裝SQLLinux原始碼
- MySQL的安裝與配置——詳細教程MySql
- Tomcat5.5 Admin的安裝與配置Tomcat
- pg_buffercache安裝及使用
- linux基礎:1、linux簡介、虛擬化軟體的安裝與配置、Xshell的安裝與配置Linux
- Flink 1.7.0 安裝、配置與使用
- jenkins安裝與配置學習Jenkins