Ubuntu Server 16.04 LTS下安装postgresql10

add key

wget -q -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

add sources

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

update

apt update

install

lwk@qwfys ~ $ apt install postgresql-10 -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bbswitch-dkms lib32gcc1 libc6-i386 libjansson4 libvdpau1 libxnvctrl0 screen-resolution-extra xserver-xorg-legacy
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libjs-underscore libpq5 libwxbase3.0-0v5 libwxgtk3.0-0v5 pgadmin3-data pgdg-keyring postgresql-client-10 postgresql-client-common postgresql-common
Suggested packages:
  javascript-common postgresql-contrib locales-all postgresql-doc-10 libjson-perl
Recommended packages:
  pgagent sysstat
The following NEW packages will be installed:
  libjs-underscore libwxbase3.0-0v5 libwxgtk3.0-0v5 pgadmin3 pgadmin3-data pgdg-keyring postgresql-10 postgresql-client-10 postgresql-client-common postgresql-common
The following packages will be upgraded:
  libpq5
1 upgraded, 10 newly installed, 0 to remove and 1 not upgraded.
Need to get 17.3 MB of archives.
After this operation, 70.0 MB of additional disk space will be used.
Get:1 http://mirrors.ustc.edu.cn/ubuntu xenial/main amd64 libjs-underscore all 1.7.0~dfsg-1ubuntu1 [46.7 kB]
Get:2 http://mirrors.ustc.edu.cn/ubuntu xenial-updates/universe amd64 libwxbase3.0-0v5 amd64 3.0.2+dfsg-1.3ubuntu0.1 [971 kB]
Get:3 http://mirrors.ustc.edu.cn/ubuntu xenial-updates/universe amd64 libwxgtk3.0-0v5 amd64 3.0.2+dfsg-1.3ubuntu0.1 [4,344 kB]
Get:4 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 libpq5 amd64 10.1-1.pgdg16.04+1 [157 kB]
Get:5 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 pgadmin3-data all 1.22.2-2.pgdg16.04+1 [2,516 kB]
Get:6 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 pgadmin3 amd64 1.22.2-2.pgdg16.04+1 [3,067 kB]                                                                                                                          
Get:7 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 pgdg-keyring all 2017.3 [10.3 kB]                                                                                                                                       
Get:8 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 postgresql-client-common all 188.pgdg16.04+1 [81.5 kB]                                                                                                                  
Get:9 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 postgresql-client-10 amd64 10.1-1.pgdg16.04+1 [1,277 kB]                                                                                                                
Get:10 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 postgresql-common all 188.pgdg16.04+1 [220 kB]                                                                                                                         
Get:11 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 postgresql-10 amd64 10.1-1.pgdg16.04+1 [4,635 kB]                                                                                                                      
Fetched 17.3 MB in 6min 12s (46.5 kB/s)                                                                                                                                                                                                      
Preconfiguring packages ...
Selecting previously unselected package libjs-underscore.
(Reading database ... 210818 files and directories currently installed.)
Preparing to unpack .../libjs-underscore_1.7.0~dfsg-1ubuntu1_all.deb ...
Unpacking libjs-underscore (1.7.0~dfsg-1ubuntu1) ...
Preparing to unpack .../libpq5_10.1-1.pgdg16.04+1_amd64.deb ...
Unpacking libpq5:amd64 (10.1-1.pgdg16.04+1) over (9.5.10-0ubuntu0.16.04) ...
Selecting previously unselected package libwxbase3.0-0v5:amd64.
Preparing to unpack .../libwxbase3.0-0v5_3.0.2+dfsg-1.3ubuntu0.1_amd64.deb ...
Unpacking libwxbase3.0-0v5:amd64 (3.0.2+dfsg-1.3ubuntu0.1) ...
Selecting previously unselected package libwxgtk3.0-0v5:amd64.
Preparing to unpack .../libwxgtk3.0-0v5_3.0.2+dfsg-1.3ubuntu0.1_amd64.deb ...
Unpacking libwxgtk3.0-0v5:amd64 (3.0.2+dfsg-1.3ubuntu0.1) ...
Selecting previously unselected package pgadmin3-data.
Preparing to unpack .../pgadmin3-data_1.22.2-2.pgdg16.04+1_all.deb ...
Unpacking pgadmin3-data (1.22.2-2.pgdg16.04+1) ...
Selecting previously unselected package pgadmin3.
Preparing to unpack .../pgadmin3_1.22.2-2.pgdg16.04+1_amd64.deb ...
Unpacking pgadmin3 (1.22.2-2.pgdg16.04+1) ...
Selecting previously unselected package pgdg-keyring.
Preparing to unpack .../pgdg-keyring_2017.3_all.deb ...
Unpacking pgdg-keyring (2017.3) ...
Selecting previously unselected package postgresql-client-common.
Preparing to unpack .../postgresql-client-common_188.pgdg16.04+1_all.deb ...
Unpacking postgresql-client-common (188.pgdg16.04+1) ...
Selecting previously unselected package postgresql-client-10.
Preparing to unpack .../postgresql-client-10_10.1-1.pgdg16.04+1_amd64.deb ...
Unpacking postgresql-client-10 (10.1-1.pgdg16.04+1) ...
Selecting previously unselected package postgresql-common.
Preparing to unpack .../postgresql-common_188.pgdg16.04+1_all.deb ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Unpacking postgresql-common (188.pgdg16.04+1) ...
Selecting previously unselected package postgresql-10.
Preparing to unpack .../postgresql-10_10.1-1.pgdg16.04+1_amd64.deb ...
Unpacking postgresql-10 (10.1-1.pgdg16.04+1) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for doc-base (0.10.7) ...
Processing 1 added doc-base file...
Registering documents with scrollkeeper...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for desktop-file-utils (0.22+linuxmint1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...
ureadahead will be reprofiled on next reboot
Setting up libjs-underscore (1.7.0~dfsg-1ubuntu1) ...
Setting up libpq5:amd64 (10.1-1.pgdg16.04+1) ...
Setting up libwxbase3.0-0v5:amd64 (3.0.2+dfsg-1.3ubuntu0.1) ...
Setting up libwxgtk3.0-0v5:amd64 (3.0.2+dfsg-1.3ubuntu0.1) ...
Setting up pgadmin3-data (1.22.2-2.pgdg16.04+1) ...
Setting up pgadmin3 (1.22.2-2.pgdg16.04+1) ...
Setting up pgdg-keyring (2017.3) ...
Removing apt.postgresql.org key from trusted.gpg: OK
Setting up postgresql-client-common (188.pgdg16.04+1) ...
Setting up postgresql-client-10 (10.1-1.pgdg16.04+1) ...
update-alternatives: using /usr/share/postgresql/10/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up postgresql-common (188.pgdg16.04+1) ...
Adding user postgres to group ssl-cert

Creating config file /etc/postgresql-common/createcluster.conf with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
  en_us
Removing obsolete dictionary files:
Setting up postgresql-10 (10.1-1.pgdg16.04+1) ...
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/(?<!\\)\${ <-- HERE ([^}]+)}/ at /usr/sbin/pam_getenv line 78.
Creating new PostgreSQL cluster 10/main ...
/usr/lib/postgresql/10/bin/initdb -D /var/lib/postgresql/10/main --auth-local peer --auth-host md5
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locales
  COLLATE:  en_US.UTF-8
  CTYPE:    en_US.UTF-8
  MESSAGES: en_US.UTF-8
  MONETARY: zh_CN.UTF-8
  NUMERIC:  zh_CN.UTF-8
  TIME:     en_US.UTF-8
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/10/main ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    /usr/lib/postgresql/10/bin/pg_ctl -D /var/lib/postgresql/10/main -l logfile start

Ver Cluster Port Status Owner    Data directory              Log file
10  main    5432 down   postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log
update-alternatives: using /usr/share/postgresql/10/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...

参考资料
PostgreSQL packages for Debian and Ubuntu

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,904评论 6 497
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,581评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,527评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,463评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,546评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,572评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,582评论 3 414
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,330评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,776评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,087评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,257评论 1 344
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,923评论 5 338
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,571评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,192评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,436评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,145评论 2 366
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,127评论 2 352

推荐阅读更多精彩内容