PostgreSQL安装日志
第一步:安装pg基本软件
注:在安装pg之前,建议先创建好postgres账户,然后用此账户安装pg软件
1: ./configure –prefix=…(指向你想安装的目录)
2:make & sudo make
3:创建pg数据存贮目录
mkdir ~/data
4:初始化pg
initdb ~/data
第二步:安装pg连接池pgbouncer
安装libevent&c-areq,pgbouncer所需要的库
1:安装libevent
wget https://github.com/downloads/libevent/libevent/libevent-2.0.22-stable
tar -zxvf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure && make && make install
//所有用的动态库进系统缓存
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
2:安装c-areq
wget http://c-ares.haxx.se/download/c-ares-1.10.0.tar.gz
tar -zxvf c-ares-1.10.0.tar.gz
cd c-ares-1.10.0
./configure && make && make install
ldconfig
3:安装pgbouncer
git clone git://git.postgresql.org/git/pgbouncer.git
cd pgbouncer
git submodule init
git submodule update
./autogen.sh
./configure --prefix=/home/postgres/pgbouncer --with-libevent=/usr/local/lib --with-cares=/usr/local/lib
make && make install
配置pgbouncer
mkdir -p ~/pgbouncer/etc
vim config.ini
[databases] testdb= host=127.0.0.1 port=5432 pool_size=50 dbname=testdb [pgbouncer] pool_mode = transaction listen_port = 6543 listen_addr = 0.0.0.0 auth_type = md5 auth_file = /home/postgres/pgbouncer/etc/users.txt logfile = /home/postgres/pgbouncer/log/pgbouncer.log pidfile = /home/postgres/pgbouncer/pgbouncer.pid unix_socket_dir = /home/postgres/pgbouncer/etc admin_users = pgadmin stats_users = pgstat server_reset_query = DISCARD ALL server_check_query = select 1 server_check_delay = 30 max_client_conn = 50000 default_pool_size = 20 reserve_pool_size = 5 dns_max_ttl = 15 ignore_startup_parameters = extra_float_digits
vim users.txt
postgres用户密码为postgres
"postgres" "md53175bce1d3201d16594cebf9d7eb3f9d" "pgadmin" "pgadmin" "pgstat" "md510a90e7529bc649302c9bfabefd51b93"
第三步:安装本地告诉缓存pgfincore(请自行去网上下载)
下载好文件后,解压
make&&make install 即可
至此,pg服务安装完成,而且还有一个相当好的性能哦!