Ubuntu PostgreSQL User Guide, ubuntupostgresql

Source: Internet
Author: User
Tags psql postgres createdb

Ubuntu PostgreSQL User Guide, ubuntupostgresql
Install

sudo apt-get install postgresql postgresql-contribapt-cache search postgres
Server Settings

After installation, you must first change the postgres user password and first enter the postgres program,

sudo -u postgres psql postgres

Postgres is a server database program used to manage data and process client requests. Here we use this program to create users and databases. Next we will change the password:

\password postgres

Enter the password.

Create a user)

Databases are controlled by users. Here we create a user in postgres that requires a password to access:

CREATE USER user_name WITH PASSWORD 'password';

Note: The "user_name" here must be the same as the user name on your computer, because postgreSQL uses the System user name by default to open the database. We will know below that if we want to use YCSB for postgreSQL benchmark testing, we must set a password for the user. Otherwise, the YCSB database command cannot pass verification.

Create a database

Use the terminal to create a database under the user you just created:

sudo -u postgres createdb database_name

You can usepsql database_nameThe database is used. To exit the database, enter\q.

Delete users and databases

Enter the S program and run the DROP command.

Prepare for the single-host YCSB Benchmark Test

YCSB is a database performance benchmark tool developed by Yahoo. The source code and instructions for use are stored on github. Here is the simplified procedure:
1. Install JDK (non-JRE)
2. Install maven on the terminal:sudo apt-get install maven
3. Download YCSB on github and install: https://github.com/brianfrankcooper/YCSB/wiki/Getting-Started as instructed
4. Download postgreSQL JDBC (. jar) and modify the CLASSPATH:export CLASSPATH=~/path to .jar file. Note that the. jar file must be placed in the decompressed ycsb source code directory (such as the ycsb-0.1.4), otherwise, the test will report an error saying that the JDBC driver cannot be found.
5. Create a database named "ycsbtest"
6. Create a table named "usertable" in "ycsbtes" t

CREATE TABLE usertable(YCSB_KEY VARCHAR (255) PRIMARY KEY,  FIELD1 TEXT, FIELD2 TEXT,  FIELD3 TEXT, FIELD4 TEXT,  FIELD5 TEXT, FIELD6 TEXT,  FIELD7 TEXT, FIELD8 TEXT,  FIELD9 TEXT, FIELD10 TEXT);
Run Test

Go to the directory where the source code of YCSB is located and load the data to the database:

./bin/ycsb load jdbc -P workloads/workloada -p db.driver=org.postgresql.Driver -p db.url=jdbc:postgresql://localhost/ycsbtest -p db.user=user_name -p db.passwd=password

"User_name" and "password" are your user and user passwords. Then run the test:

./bin/ycsb run jdbc -P workloads/workloada -p db.driver=org.postgresql.Driver -p db.url=jdbc:postgresql://localhost/ycsbtest -p db.user=user_name -p db.passwd=password
Uninstall postgreSQL

To completely delete a file, enter

sudo apt-get --purge remove postgresql

The preceding command does not delete all related packages. We enter

dpkg -l | grep postgres

Will list all packages installed with postgreSQL, and then usesudo apt-get --purge removeDelete all these packages.

Related Article

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.