运维联盟俱乐部

 找回密码
 立即注册
查看: 2858|回复: 0

pg系列一 centos7.7编译安装12.2

[复制链接]
  • TA的每日心情
    开心
    2023-8-9 11:05
  • 发表于 2020-4-26 14:15:49 | 显示全部楼层 |阅读模式
    1.建立用户
    1. [postgres@vm1 ~]$ id postgres
    2. uid=1006(postgres) gid=1008(postgres) groups=1008(postgres)
    复制代码

    2.修改变量
    1. # .bash_profile

    2. # Get the aliases and functions
    3. if [ -f ~/.bashrc ]; then
    4.         . ~/.bashrc
    5. fi

    6. # User specific environment and startup programs

    7. PATH=$PATH:$HOME/.local/bin:$HOME/bin

    8. export PATH
    9. export PGDATA=/app/postgres/12/data
    10. export LD_LIBRARY_PATH=/app/postgres/12/lib
    11. export PATH=/app/postgres/12/bin:$PATH
    复制代码
    3.建立目录
    1. [root@vm1 app]# mkdir -p /app/postgres/12/data
    2. [root@vm1 app]# chown -R postgres:postgres /app/postgres
    复制代码
    4.编译安装
    1. [postgres@vm1 tmp]$ tar -zxvf postgresql-12.2.tar.gz
    2. [postgres@vm1 postgresql-12.2]$ ls
    3. aclocal.m4  config  configure  configure.in  contrib  COPYRIGHT  doc  GNUmakefile.in  HISTORY  INSTALL  Makefile  README  src
    4. [postgres@vm1 postgresql-12.2]$ ll
    5. total 740
    6. -rw-r--r--  1 postgres postgres    522 Feb 11 06:14 aclocal.m4
    7. drwxrwxr-x  2 postgres postgres   4096 Feb 11 06:28 config
    8. -rwxr-xr-x  1 postgres postgres 572134 Feb 11 06:14 configure
    9. -rw-r--r--  1 postgres postgres  83465 Feb 11 06:14 configure.in
    10. drwxrwxr-x 56 postgres postgres   4096 Feb 11 06:28 contrib
    11. -rw-r--r--  1 postgres postgres   1192 Feb 11 06:14 COPYRIGHT
    12. drwxrwxr-x  3 postgres postgres     87 Feb 11 06:28 doc
    13. -rw-r--r--  1 postgres postgres   3909 Feb 11 06:14 GNUmakefile.in
    14. -rw-r--r--  1 postgres postgres    284 Feb 11 06:14 HISTORY
    15. -rw-r--r--  1 postgres postgres  61606 Feb 11 06:29 INSTALL
    16. -rw-r--r--  1 postgres postgres   1665 Feb 11 06:14 Makefile
    17. -rw-r--r--  1 postgres postgres   1212 Feb 11 06:14 README
    18. drwxrwxr-x 16 postgres postgres    328 Feb 11 06:29 src

    复制代码
    ./configure --prefix=/app/postgres/12
    1. [postgres@vm1 postgresql-12.2]$ ./configure --prefix=/app/postgres/12
    2. checking build system type... x86_64-pc-linux-gnu
    3. checking host system type... x86_64-pc-linux-gnu
    4. checking which template to use... linux
    5. checking whether NLS is wanted... no
    6. checking for default port number... 5432
    7. checking for block size... 8kB
    8. checking for segment size... 1GB
    9. checking for WAL block size... 8kB
    10. checking for gcc... no
    11. checking for cc... no
    12. configure: error: in `/tmp/postgresql-12.2':
    13. configure: error: no acceptable C compiler found in $PATH
    14. See `config.log' for more details
    15. [postgres@vm1 postgresql-12.2]$ ./configure --prefix=/app/postgres/12
    16. checking build system type... x86_64-pc-linux-gnu
    17. checking host system type... x86_64-pc-linux-gnu
    18. checking which template to use... linux
    19. checking whether NLS is wanted... no
    20. checking for default port number... 5432
    21. checking for block size... 8kB
    22. checking for segment size... 1GB
    23. checking for WAL block size... 8kB
    24. checking for gcc... gcc
    25. checking whether the C compiler works... yes
    26. checking for C compiler default output file name... a.out
    27. checking for suffix of executables...
    28. checking whether we are cross compiling... no
    29. checking for suffix of object files... o
    30. checking whether we are using the GNU C compiler... yes
    31. checking whether gcc accepts -g... yes
    32. checking for gcc option to accept ISO C89... none needed
    33. checking for gcc option to accept ISO C99... -std=gnu99
    34. checking for g++... no
    35. checking for c++... no
    36. checking whether we are using the GNU C++ compiler... no
    37. checking whether g++ accepts -g... no
    38. checking for gawk... gawk
    39. checking whether gcc -std=gnu99 supports -Wdeclaration-after-statement, for CFLAGS... yes
    40. checking whether gcc -std=gnu99 supports -Werror=vla, for CFLAGS... yes
    41. checking whether gcc -std=gnu99 supports -Wendif-labels, for CFLAGS... yes
    42. checking whether g++ supports -Wendif-labels, for CXXFLAGS... no
    43. checking whether gcc -std=gnu99 supports -Wmissing-format-attribute, for CFLAGS... yes
    44. checking whether g++ supports -Wmissing-format-attribute, for CXXFLAGS... no
    45. checking whether gcc -std=gnu99 supports -Wformat-security, for CFLAGS... yes
    46. checking whether g++ supports -Wformat-security, for CXXFLAGS... no
    47. checking whether gcc -std=gnu99 supports -fno-strict-aliasing, for CFLAGS... yes
    48. checking whether g++ supports -fno-strict-aliasing, for CXXFLAGS... no
    49. checking whether gcc -std=gnu99 supports -fwrapv, for CFLAGS... yes
    50. checking whether g++ supports -fwrapv, for CXXFLAGS... no
    51. checking whether gcc -std=gnu99 supports -fexcess-precision=standard, for CFLAGS... yes
    52. checking whether g++ supports -fexcess-precision=standard, for CXXFLAGS... no
    53. checking whether gcc -std=gnu99 supports -funroll-loops, for CFLAGS_VECTOR... yes
    54. checking whether gcc -std=gnu99 supports -ftree-vectorize, for CFLAGS_VECTOR... yes
    55. checking whether gcc -std=gnu99 supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... no
    56. checking whether gcc -std=gnu99 supports -Wformat-truncation, for NOT_THE_CFLAGS... no
    57. checking whether gcc -std=gnu99 supports -Wstringop-truncation, for NOT_THE_CFLAGS... no
    58. checking whether the C compiler still works... yes
    59. checking how to run the C preprocessor... gcc -std=gnu99 -E
    60. checking allow thread-safe client libraries... yes
    61. checking whether to build with ICU support... no
    62. checking whether to build with Tcl... no
    63. checking whether to build Perl modules... no
    64. checking whether to build Python modules... no
    65. checking whether to build with GSSAPI support... no
    66. checking whether to build with PAM support... no
    67. checking whether to build with BSD Authentication support... no
    68. checking whether to build with LDAP support... no
    69. checking whether to build with Bonjour support... no
    70. checking whether to build with OpenSSL support... no
    71. checking whether to build with SELinux support... no
    72. checking whether to build with systemd support... no
    73. checking for grep that handles long lines and -e... /bin/grep
    74. checking for egrep... /bin/grep -E
    75. checking for ld used by GCC... /bin/ld
    76. checking if the linker (/bin/ld) is GNU ld... yes
    77. checking for ranlib... ranlib
    78. checking for strip... strip
    79. checking whether it is possible to strip libraries... yes
    80. checking for ar... ar
    81. checking for a BSD-compatible install... /bin/install -c
    82. checking for tar... /bin/tar
    83. checking whether ln -s works... yes
    84. checking for a thread-safe mkdir -p... /bin/mkdir -p
    85. checking for bison... no
    86. configure: WARNING:
    87. *** Without Bison you will not be able to build PostgreSQL from Git nor
    88. *** change any of the parser definition files.  You can obtain Bison from
    89. *** a GNU mirror site.  (If you are using the official distribution of
    90. *** PostgreSQL then you do not need to worry about this, because the Bison
    91. *** output is pre-generated.)
    92. checking for flex... no
    93. configure: WARNING:
    94. *** Without Flex you will not be able to build PostgreSQL from Git nor
    95. *** change any of the scanner definition files.  You can obtain Flex from
    96. *** a GNU mirror site.  (If you are using the official distribution of
    97. *** PostgreSQL then you do not need to worry about this because the Flex
    98. *** output is pre-generated.)
    99. checking for perl... /bin/perl
    100. configure: using perl 5.16.3
    101. checking for a sed that does not truncate output... /bin/sed
    102. checking for ANSI C header files... yes
    103. checking for sys/types.h... yes
    104. checking for sys/stat.h... yes
    105. checking for stdlib.h... yes
    106. checking for string.h... yes
    107. checking for memory.h... yes
    108. checking for strings.h... yes
    109. checking for inttypes.h... yes
    110. checking for stdint.h... yes
    111. checking for unistd.h... yes
    112. checking whether gcc -std=gnu99 is Clang... no
    113. checking whether pthreads work with -pthread... yes
    114. checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
    115. checking whether more special flags are required for pthreads... no
    116. checking for PTHREAD_PRIO_INHERIT... yes
    117. checking pthread.h usability... yes
    118. checking pthread.h presence... yes
    119. checking for pthread.h... yes
    120. checking for strerror_r... yes
    121. checking for getpwuid_r... yes
    122. checking for gethostbyname_r... yes
    123. checking whether strerror_r returns int... no
    124. checking for main in -lm... yes
    125. checking for library containing setproctitle... no
    126. checking for library containing dlopen... -ldl
    127. checking for library containing socket... none required
    128. checking for library containing shl_load... no
    129. checking for library containing getopt_long... none required
    130. checking for library containing crypt... -lcrypt
    131. checking for library containing shm_open... -lrt
    132. checking for library containing shm_unlink... none required
    133. checking for library containing clock_gettime... none required
    134. checking for library containing fdatasync... none required
    135. checking for library containing sched_yield... none required
    136. checking for library containing gethostbyname_r... none required
    137. checking for library containing shmget... none required
    138. checking for library containing readline... -lreadline
    139. checking for inflate in -lz... yes
    140. checking for stdbool.h that conforms to C99... yes
    141. checking for _Bool... yes
    142. checking atomic.h usability... no
    143. checking atomic.h presence... no
    144. checking for atomic.h... no
    145. checking copyfile.h usability... no
    146. checking copyfile.h presence... no
    147. checking for copyfile.h... no
    148. checking crypt.h usability... yes
    149. checking crypt.h presence... yes
    150. checking for crypt.h... yes
    151. checking fp_class.h usability... no
    152. checking fp_class.h presence... no
    153. checking for fp_class.h... no
    154. checking getopt.h usability... yes
    155. checking getopt.h presence... yes
    156. checking for getopt.h... yes
    157. checking ieeefp.h usability... no
    158. checking ieeefp.h presence... no
    159. checking for ieeefp.h... no
    160. checking ifaddrs.h usability... yes
    161. checking ifaddrs.h presence... yes
    162. checking for ifaddrs.h... yes
    163. checking langinfo.h usability... yes
    164. checking langinfo.h presence... yes
    165. checking for langinfo.h... yes
    166. checking mbarrier.h usability... no
    167. checking mbarrier.h presence... no
    168. checking for mbarrier.h... no
    169. checking poll.h usability... yes
    170. checking poll.h presence... yes
    171. checking for poll.h... yes
    172. checking sys/epoll.h usability... yes
    173. checking sys/epoll.h presence... yes
    174. checking for sys/epoll.h... yes
    175. checking sys/ipc.h usability... yes
    176. checking sys/ipc.h presence... yes
    177. checking for sys/ipc.h... yes
    178. checking sys/prctl.h usability... yes
    179. checking sys/prctl.h presence... yes
    180. checking for sys/prctl.h... yes
    181. checking sys/procctl.h usability... no
    182. checking sys/procctl.h presence... no
    183. checking for sys/procctl.h... no
    184. checking sys/pstat.h usability... no
    185. checking sys/pstat.h presence... no
    186. checking for sys/pstat.h... no
    187. checking sys/resource.h usability... yes
    188. checking sys/resource.h presence... yes
    189. checking for sys/resource.h... yes
    190. checking sys/select.h usability... yes
    191. checking sys/select.h presence... yes
    192. checking for sys/select.h... yes
    193. checking sys/sem.h usability... yes
    194. checking sys/sem.h presence... yes
    195. checking for sys/sem.h... yes
    196. checking sys/shm.h usability... yes
    197. checking sys/shm.h presence... yes
    198. checking for sys/shm.h... yes
    199. checking sys/sockio.h usability... no
    200. checking sys/sockio.h presence... no
    201. checking for sys/sockio.h... no
    202. checking sys/tas.h usability... no
    203. checking sys/tas.h presence... no
    204. checking for sys/tas.h... no
    205. checking sys/un.h usability... yes
    206. checking sys/un.h presence... yes
    207. checking for sys/un.h... yes
    208. checking termios.h usability... yes
    209. checking termios.h presence... yes
    210. checking for termios.h... yes
    211. checking ucred.h usability... no
    212. checking ucred.h presence... no
    213. checking for ucred.h... no
    214. checking utime.h usability... yes
    215. checking utime.h presence... yes
    216. checking for utime.h... yes
    217. checking wchar.h usability... yes
    218. checking wchar.h presence... yes
    219. checking for wchar.h... yes
    220. checking wctype.h usability... yes
    221. checking wctype.h presence... yes
    222. checking for wctype.h... yes
    223. checking for net/if.h... yes
    224. checking for sys/ucred.h... no
    225. checking for netinet/tcp.h... yes
    226. checking readline/readline.h usability... yes
    227. checking readline/readline.h presence... yes
    228. checking for readline/readline.h... yes
    229. checking readline/history.h usability... yes
    230. checking readline/history.h presence... yes
    231. checking for readline/history.h... yes
    232. checking zlib.h usability... yes
    233. checking zlib.h presence... yes
    234. checking for zlib.h... yes
    235. checking whether byte ordering is bigendian... no
    236. checking for inline... inline
    237. checking for printf format archetype... gnu_printf
    238. checking for flexible array members... yes
    239. checking for signed types... yes
    240. checking for __func__... yes
    241. checking for _Static_assert... yes
    242. checking for typeof... typeof
    243. checking for __builtin_types_compatible_p... yes
    244. checking for __builtin_constant_p... yes
    245. checking for __builtin_unreachable... yes
    246. checking for computed goto support... yes
    247. checking whether struct tm is in sys/time.h or time.h... time.h
    248. checking for struct tm.tm_zone... yes
    249. checking for tzname... yes
    250. checking for union semun... no
    251. checking for struct sockaddr_un... yes
    252. checking for struct sockaddr_storage... yes
    253. checking for struct sockaddr_storage.ss_family... yes
    254. checking for struct sockaddr_storage.__ss_family... no
    255. checking for struct sockaddr_storage.ss_len... no
    256. checking for struct sockaddr_storage.__ss_len... no
    257. checking for struct sockaddr.sa_len... no
    258. checking for struct addrinfo... yes
    259. checking for intptr_t... yes
    260. checking for uintptr_t... yes
    261. checking for unsigned long long int... yes
    262. checking for long long int... yes
    263. checking for locale_t... yes
    264. checking for C/C++ restrict keyword... __restrict
    265. checking for struct cmsgcred... no
    266. checking for struct option... yes
    267. checking for z_streamp... yes
    268. checking whether assembler supports x86_64 popcntq... yes
    269. checking for special C compiler options needed for large files... no
    270. checking for _FILE_OFFSET_BITS value needed for large files... no
    271. checking size of off_t... 8
    272. checking size of bool... 1
    273. checking for int timezone... yes
    274. checking types of arguments for accept()... int, int, struct sockaddr *, socklen_t *
    275. checking whether gettimeofday takes only one argument... no
    276. checking for wcstombs_l declaration... no
    277. checking for cbrt... yes
    278. checking for clock_gettime... yes
    279. checking for copyfile... no
    280. checking for fdatasync... yes
    281. checking for getifaddrs... yes
    282. checking for getpeerucred... no
    283. checking for getrlimit... yes
    284. checking for mbstowcs_l... no
    285. checking for memmove... yes
    286. checking for poll... yes
    287. checking for posix_fallocate... yes
    288. checking for ppoll... yes
    289. checking for pstat... no
    290. checking for pthread_is_threaded_np... no
    291. checking for readlink... yes
    292. checking for setproctitle... no
    293. checking for setproctitle_fast... no
    294. checking for setsid... yes
    295. checking for shm_open... yes
    296. checking for strchrnul... yes
    297. checking for strsignal... yes
    298. checking for symlink... yes
    299. checking for sync_file_range... yes
    300. checking for uselocale... yes
    301. checking for utime... yes
    302. checking for utimes... yes
    303. checking for wcstombs_l... no
    304. checking for __builtin_bswap16... yes
    305. checking for __builtin_bswap32... yes
    306. checking for __builtin_bswap64... yes
    307. checking for __builtin_clz... yes
    308. checking for __builtin_ctz... yes
    309. checking for __builtin_popcount... yes
    310. checking for fseeko... yes
    311. checking for _LARGEFILE_SOURCE value needed for large files... no
    312. checking how gcc -std=gnu99 reports undeclared, standard C functions... error
    313. checking for posix_fadvise... yes
    314. checking whether posix_fadvise is declared... yes
    315. checking whether fdatasync is declared... yes
    316. checking whether strlcat is declared... no
    317. checking whether strlcpy is declared... no
    318. checking whether strnlen is declared... yes
    319. checking whether F_FULLFSYNC is declared... no
    320. checking whether RTLD_GLOBAL is declared... yes
    321. checking whether RTLD_NOW is declared... yes
    322. checking for struct sockaddr_in6... yes
    323. checking for PS_STRINGS... no
    324. checking for isinf... yes
    325. checking for crypt... yes
    326. checking for dlopen... yes
    327. checking for fls... no
    328. checking for getopt... yes
    329. checking for getrusage... yes
    330. checking for inet_aton... yes
    331. checking for mkdtemp... yes
    332. checking for pread... yes
    333. checking for pwrite... yes
    334. checking for random... yes
    335. checking for rint... yes
    336. checking for srandom... yes
    337. checking for strlcat... no
    338. checking for strlcpy... no
    339. checking for strnlen... yes
    340. checking for strtof... yes
    341. checking for unsetenv... yes
    342. checking for getpeereid... no
    343. checking for getaddrinfo... yes
    344. checking for getopt_long... yes
    345. checking for syslog... yes
    346. checking syslog.h usability... yes
    347. checking syslog.h presence... yes
    348. checking for syslog.h... yes
    349. checking for opterr... yes
    350. checking for optreset... no
    351. checking for strtoll... yes
    352. checking for strtoull... yes
    353. checking whether strtoll is declared... yes
    354. checking whether strtoull is declared... yes
    355. checking for rl_completion_append_character... yes
    356. checking for rl_completion_matches... yes
    357. checking for rl_filename_completion_function... yes
    358. checking for rl_reset_screen_size... yes
    359. checking for append_history... yes
    360. checking for history_truncate_file... yes
    361. checking test program... ok
    362. checking whether long int is 64 bits... yes
    363. checking for __builtin_mul_overflow... no
    364. checking size of void *... 8
    365. checking size of size_t... 8
    366. checking size of long... 8
    367. checking whether to build with float4 passed by value... yes
    368. checking whether to build with float8 passed by value... yes
    369. checking alignment of short... 2
    370. checking alignment of int... 4
    371. checking alignment of long... 8
    372. checking alignment of double... 8
    373. checking for int8... no
    374. checking for uint8... no
    375. checking for int64... no
    376. checking for uint64... no
    377. checking for __int128... yes
    378. checking for __int128 alignment bug... ok
    379. checking alignment of PG_INT128_TYPE... 16
    380. checking for builtin __sync char locking functions... yes
    381. checking for builtin __sync int32 locking functions... yes
    382. checking for builtin __sync int32 atomic operations... yes
    383. checking for builtin __sync int64 atomic operations... yes
    384. checking for builtin __atomic int32 atomic operations... yes
    385. checking for builtin __atomic int64 atomic operations... yes
    386. checking for __get_cpuid... yes
    387. checking for __cpuid... no
    388. checking for _mm_crc32_u8 and _mm_crc32_u32 with CFLAGS=... no
    389. checking for _mm_crc32_u8 and _mm_crc32_u32 with CFLAGS=-msse4.2... yes
    390. checking for __crc32cb, __crc32ch, __crc32cw, and __crc32cd with CFLAGS=... no
    391. checking for __crc32cb, __crc32ch, __crc32cw, and __crc32cd with CFLAGS=-march=armv8-a+crc... no
    392. checking which CRC-32C implementation to use... SSE 4.2 with runtime check
    393. checking for library containing sem_init... -lpthread
    394. checking which semaphore API to use... unnamed POSIX
    395. checking for /dev/urandom... yes
    396. checking which random number source to use... /dev/urandom
    397. checking for xmllint... /bin/xmllint
    398. checking for DocBook XML V4.2... yes
    399. checking for dbtoepub... no
    400. checking for xsltproc... /bin/xsltproc
    401. checking for fop... no
    402. checking thread safety of required library functions... yes
    403. checking whether gcc -std=gnu99 supports -Wl,--as-needed... yes
    404. configure: using compiler=gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
    405. configure: using CFLAGS=-Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2
    406. configure: using CPPFLAGS= -D_GNU_SOURCE
    407. configure: using LDFLAGS=  -Wl,--as-needed
    408. configure: creating ./config.status
    409. config.status: creating GNUmakefile
    410. config.status: creating src/Makefile.global
    411. config.status: creating src/include/pg_config.h
    412. config.status: creating src/include/pg_config_ext.h
    413. config.status: creating src/interfaces/ecpg/include/ecpg_config.h
    414. config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
    415. config.status: linking src/backend/port/posix_sema.c to src/backend/port/pg_sema.c
    416. config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
    417. config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
    418. config.status: linking src/makefiles/Makefile.linux to src/Makefile.port
    复制代码
    make
    1. ,-rpath,'/app/postgres/12/lib',--enable-new-dtags  -lpgcommon -lpgport -lpthread -lz -lreadline -lrt -lcrypt -ldl -lm  -o pg_isolation_regress
    2. make[2]: Leaving directory `/tmp/postgresql-12.2/src/test/isolation'
    3. make -C test/perl all
    4. make[2]: Entering directory `/tmp/postgresql-12.2/src/test/perl'
    5. make[2]: Nothing to be done for `all'.
    6. make[2]: Leaving directory `/tmp/postgresql-12.2/src/test/perl'
    7. make[1]: Leaving directory `/tmp/postgresql-12.2/src'
    8. make -C config all
    9. make[1]: Entering directory `/tmp/postgresql-12.2/config'
    10. make[1]: Nothing to be done for `all'.
    11. make[1]: Leaving directory `/tmp/postgresql-12.2/config'
    12. All of PostgreSQL successfully made. Ready to install.
    复制代码
    make install
    1. make[2]: Leaving directory `/tmp/postgresql-12.2/src/test/perl'
    2. /bin/mkdir -p '/app/postgres/12/lib/pgxs/src'
    3. /bin/install -c -m 644 Makefile.global '/app/postgres/12/lib/pgxs/src/Makefile.global'
    4. /bin/install -c -m 644 Makefile.port '/app/postgres/12/lib/pgxs/src/Makefile.port'
    5. /bin/install -c -m 644 ./Makefile.shlib '/app/postgres/12/lib/pgxs/src/Makefile.shlib'
    6. /bin/install -c -m 644 ./nls-global.mk '/app/postgres/12/lib/pgxs/src/nls-global.mk'
    7. make[1]: Leaving directory `/tmp/postgresql-12.2/src'
    8. make -C config install
    9. make[1]: Entering directory `/tmp/postgresql-12.2/config'
    10. /bin/mkdir -p '/app/postgres/12/lib/pgxs/config'
    11. /bin/install -c -m 755 ./install-sh '/app/postgres/12/lib/pgxs/config/install-sh'
    12. /bin/install -c -m 755 ./missing '/app/postgres/12/lib/pgxs/config/missing'
    13. make[1]: Leaving directory `/tmp/postgresql-12.2/config'
    14. PostgreSQL installation complete.
    复制代码
    5.初始化数据库
    1. [postgres@vm1 ~]$ which initdb
    2. /app/postgres/12/bin/initdb
    3. [postgres@vm1 ~]$ initdb -D /app/postgre/12/data
    4. The files belonging to this database system will be owned by user "postgres".
    5. This user must also own the server process.

    6. The database cluster will be initialized with locale "en_US.UTF-8".
    7. The default database encoding has accordingly been set to "UTF8".
    8. The default text search configuration will be set to "english".

    9. Data page checksums are disabled.

    10. creating directory /app/postgre/12/data ... initdb: error: could not create directory "/app/postgre": Permission denied
    11. [postgres@vm1 ~]$ initdb -D /app/postgres/12/data
    12. The files belonging to this database system will be owned by user "postgres".
    13. This user must also own the server process.

    14. The database cluster will be initialized with locale "en_US.UTF-8".
    15. The default database encoding has accordingly been set to "UTF8".
    16. The default text search configuration will be set to "english".

    17. Data page checksums are disabled.

    18. fixing permissions on existing directory /app/postgres/12/data ... ok
    19. creating subdirectories ... ok
    20. selecting dynamic shared memory implementation ... posix
    21. selecting default max_connections ... 100
    22. selecting default shared_buffers ... 128MB
    23. selecting default time zone ... Asia/Shanghai
    24. creating configuration files ... ok
    25. running bootstrap script ... ok
    26. performing post-bootstrap initialization ... ok
    27. syncing data to disk ... ok

    28. initdb: warning: enabling "trust" authentication for local connections
    29. You can change this by editing pg_hba.conf or using the option -A, or
    30. --auth-local and --auth-host, the next time you run initdb.

    31. Success. You can now start the database server using:

    32.     pg_ctl -D /app/postgres/12/data -l logfile start
    复制代码
    6.启动数据库
    1. [postgres@vm1 ~]$ pg_ctl -D /app/postgres/12/data -l logfile start
    2. waiting for server to start.... done
    3. server started
    4. [postgres@vm1 ~]$ psql
    5. psql (12.2)
    6. Type "help" for help.

    7. postgres=# help
    8. You are using psql, the command-line interface to PostgreSQL.
    9. Type:  \copyright for distribution terms
    10.        \h for help with SQL commands
    11.        \? for help with psql commands
    12.        \g or terminate with semicolon to execute query
    13.        \q to quit
    14. postgres=#  \l
    15.                                   List of databases
    16.    Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
    17. -----------+----------+----------+-------------+-------------+-----------------------
    18. postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
    19. template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
    20.            |          |          |             |             | postgres=CTc/postgres
    21. template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
    22.            |          |          |             |             | postgres=CTc/postgres
    23. (3 rows)

    24. postgres=#
    复制代码
    7.建立测试库,测试表
    1. postgres=# create database zhyu;
    2. CREATE DATABASE
    3. postgres=# \c zhyu
    4. You are now connected to database "zhyu" as user "postgres".
    5. zhyu=# create table zhyu(id int,name varchar(50));
    6. CREATE TABLE
    7. zhyu=# insert into zhyu values(1,'zhangyu');
    8. INSERT 0 1
    9. zhyu=# select * from zhyu;
    10. id |  name   
    11. ----+---------
    12.   1 | zhangyu
    13. (1 row)
    复制代码
    8.postgresql得进程
    1. [root@vm1 ~]# ps -ef | grep postgres
    2. postgres  1874     1  0 21:53 ?        00:00:00 /app/postgres/12/bin/postgres -D /app/postgres/12/data
    3. postgres  2023  1874  0 21:53 ?        00:00:00 postgres: checkpointer   
    4. postgres  2024  1874  0 21:53 ?        00:00:00 postgres: background writer   
    5. postgres  2025  1874  0 21:53 ?        00:00:00 postgres: walwriter   
    6. postgres  2026  1874  0 21:53 ?        00:00:00 postgres: autovacuum launcher   
    7. postgres  2027  1874  0 21:53 ?        00:00:00 postgres: stats collector   
    8. postgres  2028  1874  0 21:53 ?        00:00:00 postgres: logical replication launcher   
    9. root      7817  7753  0 23:15 pts/1    00:00:00 grep --color=auto postgres
    复制代码
    9.配置远程访问
    vi postgresql.conf

    1. listen_addresses = '*'
    复制代码
    vi pg_hba.conf
    1. host    all             all             192.168.56.0/24         md5
    复制代码
    10.修改postgres用户密码
    1. [postgres@vm1 ~]$ psql
    2. psql (12.2)
    3. Type "help" for help.
    4. postgres=# alter user postgres with password 'postgres';
    5. ALTER ROLE
    复制代码
    11.远程访问数据库
    1. jdbc:postgresql://192.168.56.101:5432/postgres
    复制代码













    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    运维联盟俱乐部 ( 冀ICP备19036648号 )

    GMT+8, 2024-5-3 03:21 , Processed in 0.051081 second(s), 21 queries , Gzip On.

    Powered by Discuz! X3.4

    © 2001-2023 Discuz! Team.

    快速回复 返回顶部 返回列表