[go: up one dir, main page]

Menu

[r8]: / rhm_db_creation_steps  Maximize  Restore  History

Download this file

127 lines (83 with data), 3.4 kB

RHM postgres DB creation info

su - postgres
cd /opt/postgres*/bin

If this is a new postgres DB instance, initdb it first, otherwise, just
start it:

LD_LIBRARY_PATH=/opt/postgres/lib /opt/postgres/bin/initdb -D "/opt/postgres/rhmdb"
/opt/postgres-8.3.6/bin/pg_ctl -D /opt/postgres-8.3.6/rhmdb -l logfile start

./pg_ctl -D /opt/postgres*/data -l logging start

If new DB instance, create a user to own rhmdb:

create role rhm_user with login password 'rhmdb_user';

Now create a place to put the data (think separate partition):
#create tablespace ts_rhm1 location '/opt/postgres-8.3.6/rhm1';
create tablespace rhmdb_ts location '/opt/postgres-8.3.6/rhmdb_ts'
(to drop the tablespace, 'drop tablespace rhmdb_ts;' )

Now create the database itself:
#create database rhm1 with owner = rhm template = default encoding = 'UTF=8' tablespace = ts_rhm1;
 create database rhmdb with owner = rhm_user template = default encoding = 'UTF=8' tablespace = rhmdb_ts;
 
Now connect to the DB:
#\c rhm1
\c rhmdb

#Login w/ the newly created rhm_user to the rhmdb
psql -Urhm_user -drhmdb

Everything below is the steps to create it from scratch, but

psql -d rhm1 < ~cerberus/rhm/rhm.pg.out-no-bacula

gives the data from prod rhm db as well.


# SET default_tablespace = ts_rhm1;  

 set default_tablespace = rhmdb_ts;
 
 CREATE SEQUENCE rhm_app_info_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.rhm_app_info_id_seq OWNER TO rhm;

SELECT pg_catalog.setval('rhm_app_info_id_seq', 13197, true);

SET default_with_oids = false;
 
 CREATE TABLE rhm_app_info (
    id integer DEFAULT nextval('rhm_app_info_id_seq'::regclass) NOT NULL,
    tree_name character varying(50),
    tree_ver character varying(50),
    host_id smallint NOT NULL,
    CONSTRAINT rhm_app_info_host_id_check CHECK ((host_id >= 0))
);


ALTER TABLE public.rhm_app_info OWNER TO rhm;

CREATE SEQUENCE rhm_host_info_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.rhm_host_info_id_seq OWNER TO rhm;

SELECT pg_catalog.setval('rhm_host_info_id_seq', 690, true);

CREATE TABLE rhm_host_info (
    id integer DEFAULT nextval('rhm_host_info_id_seq'::regclass) NOT NULL,
    hostname character varying(60) NOT NULL
);


ALTER TABLE public.rhm_host_info OWNER TO rhm;

CREATE SEQUENCE rhm_meta_info_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.rhm_meta_info_id_seq OWNER TO rhm;

SELECT pg_catalog.setval('rhm_meta_info_id_seq', 1, false);

CREATE TABLE rhm_meta_info (
    id integer DEFAULT nextval('rhm_meta_info_id_seq'::regclass) NOT NULL,
    hardware_model character varying(50),
    serial_num character varying(50),
    physical_location character varying(50),
    primary_use character varying(50),
    os_dist character varying(50),
    os_version character varying(50),
    host_id smallint NOT NULL,
    CONSTRAINT rhm_meta_info_host_id_check CHECK ((host_id >= 0))
);


ALTER TABLE public.rhm_meta_info OWNER TO rhm;

ALTER TABLE ONLY rhm_app_info
    ADD CONSTRAINT rhm_app_info_pkey PRIMARY KEY (id);
    
ALTER TABLE ONLY rhm_host_info
    ADD CONSTRAINT rhm_host_info_pkey PRIMARY KEY (id);
    
ALTER TABLE ONLY rhm_meta_info
    ADD CONSTRAINT rhm_meta_info_pkey PRIMARY KEY (id);
    
REVOKE ALL ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO PUBLIC;