From Disk partition to Postgresqlinstallation

Source: Internet
Author: User
Tags auth locale openssl postgresql psql

From Disk partition to Postgresqlinstallation

[Email protected] mnt]# Fdisk/dev/sdb

Welcome to Fdisk (Util-linux 2.23.2).

Changes'll remain in memory only, until the decide to write them.

Be careful before using the Write command.

Command (M for help): N

Partition Type:

P Primary (0 primary, 0 extended, 4 free)

E Extended

Select (default P):

Using Default Response P

Partition number (1-4, default 1):

First sector (2048-1953525167, default 2048):

Using Default Value 2048

Last sector, +sectors or +size{k,m,g} (2048-1953525167, default 1953525167): +100g

Partition 1 of type Linux and of size GiB is set

Command (M for help): M

Command Action

A toggle a bootable flag

b Edit BSD Disklabel

C Toggle the DOS compatibility flag

D Delete a partition

G Create a new empty GPT partition table

G Create an IRIX (SGI) partition table

L list known partition types

M Print this menu

n Add a new partition

o Create a new empty DOS partition table

P Print the partition table

Q Quit without saving changes

s create a new empty Sun Disklabel

t change a partition ' s system ID

U Change display/entry units

V Verify the partition table

W Write table to disk and exit

X Extra functionality (experts only)

Command (M for help): W

The partition table has been altered!

Calling IOCTL () to re-read partition table.

Syncing disks.

[Email protected] mnt]# Fdisk/dev/sdb

Welcome to Fdisk (Util-linux 2.23.2).

Changes'll remain in memory only, until the decide to write them.

Be careful before using the Write command.

Command (M for help): P

disk/dev/sdb:1000.2 GB, 1000204886016 bytes, 1953525168 sectors

Units = sectors of 1 * MB = bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk label Type:dos

Disk identifier:0x0005e2b3

Device Boot Start End Blocks Id System

/DEV/SDB1 2048 209717247 104857600-up Linux

Command (M for help): Q

[Email protected] mnt]# fdisk-l/dev/sdb

disk/dev/sdb:1000.2 GB, 1000204886016 bytes, 1953525168 sectors

Units = sectors of 1 * MB = bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk label Type:dos

Disk identifier:0x0005e2b3

Device Boot Start End Blocks Id System

/DEV/SDB1 2048 209717247 104857600-up Linux

[Email protected] mnt]# mkfs.ext4-b 4096-e stride=2,stripe-width=6/dev/sdb1

MKE2FS 1.42.9 (28-dec-2013)

Filesystem label=

OS Type:linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

stride=2 blocks, Stripe width=6 blocks

6553600 inodes, 26214400 blocks

1310720 blocks (5.00%) reserved for the Super user

First Data block=0

Maximum filesystem blocks=2174746624

Block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000, 7962624, 11239424, 20480000, 23887872

Allocating group Tables:done

Writing Inode Tables:done

Creating Journal (32768 blocks): Done

Writing superblocks and filesystem accounting Information:done

[Email protected] mnt]# mount/dev/sdb1/mnt

[Email protected] ~]# Vim/etc/fstab

/dev/sdb1/mnt EXT4 Defaults 0 0

[Email protected] ~]# cd/mnt/

[[email protected] mnt]# ls

Lost+found

[Email protected] mnt]# mkdir pg945

[[email protected] mnt]# ls

Lost+found pg945

[Email protected] mnt]# useradd-u postgres-p 123456

[Email protected] mnt]# chown-r postgres:postgres/mnt/

[Email protected] mnt]# yum-y install readline-devel zlib zlib-devel OpenSSL openssl-devel gcc make flex bison

[Email protected] mnt]# chown-r postgres:postgres/opt/soft_bak/

[Email protected] mnt]# Su-postgres

Last Login:tue Jan 17:24:08 CST at PTS/1

[Email protected] ~]$ cd/opt/soft_bak/

[Email protected] soft_bak]$ tar jxvf postgresql-9.4.5.tar.bz2

[Email protected] soft_bak]$ CD postgresql-9.4.5

[Email protected] postgresql-9.4.5]$/configure--prefix=/mnt/pg945/

[Email protected] postgresql-9.4.5]$ Gmake World

[Email protected] postgresql-9.4.5]$ gmake Install-world

[Email protected] postgresql-9.4.5]$ mkdir-p/mnt/pg945/data

[[email protected] pg945]$ ls

Bin data include Lib share

[Email protected] pg945]$ CD bin/

[Email protected] bin]$./initdb-d. /data/-e UTF8--locale=c-u postgres-w

The files belonging to this database system is owned by user "Postgres".

This user must also own the server process.

The database cluster is initialized with locale "C".

The default text search configuration is set to "中文版".

Data page checksums is disabled.

Fixing permissions on existing directory. /data ... ok

Creating subdirectories ... ok

Selecting Default Max_connections ... 100

Selecting Default Shared_buffers ... 128MB

Selecting dynamic shared memory implementation ... POSIX

Creating configuration files ... ok

Creating Template1 database in. /data/base/1 ... ok

Initializing Pg_authid ... ok

Enter New Superuser Password:

Enter It again:

Setting password ... ok

Initializing dependencies ... ok

Creating system views ... ok

Loading system objects ' descriptions ... ok

Creating collations ... ok

Creating conversions ... ok

Creating dictionaries ... ok

Setting privileges on built-in objects ... ok

Creating Information Schema ... ok

Loading Pl/pgsql server-side language ... ok

Vacuuming database template1 ... ok

Copying template1 to Template0 ... ok

Copying template1 to Postgres ... ok

Syncing data to disk ... ok

Warning:enabling "Trust" authentication for local connections

You can change this by editing pg_hba.conf or using the option-a, or

--auth-local and--auth-host, the next time you run INITDB.

Success. You can now start the database server using:

./postgres-d. /data/

Or

./pg_ctl-d. /data/-L logfile Start

[Email protected] bin]$ vim. /data/postgresql.conf

listen_addresses = ' * '

Port = 5432

unix_socket_directories = '. '

log_destination = ' Csvlog '

Logging_collector = On

log_directory = ' Pg_log '

Log_filename = ' Postgresql-%y-%m-%d_%h%m%s.log '

Log_file_mode = 0600

Log_truncate_on_rotation = On

[Email protected] bin]$./pg_ctl-d. /data/start

Server starting

[[email protected] bin]$ log:redirecting LOG output to logging collector process

Hint:future log output would appear in directory "Pg_log".

[Email protected] bin]$/psql-h localhost-p 5432-u postgres-w

Password for user postgres:

Psql (9.4.5)

Type ' help ' for help.

postgres=# CREATE DATABASE test;

CREATE DATABASE

postgres=# \c Test

Password for user postgres:

Connected to database "test" as User "Postgres".

test=# CREATE TABLE test_db (id int);

CREATE TABLE

test=# INSERT INTO test_db values (1), (2), (3);

INSERT 0 3

test=# select * from test_db;

Id

----

1

2

3

(3 rows)

test=# \q

[Email protected] bin]$./pg_ctl-d. /data/stop-m Fast

Waiting for server to shut down ... done

Server stopped

From Disk partition to Postgresqlinstallation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.