Spacewalk 1.7 With PostgreSQL

This article will show you how to integrate spacewalk 1.7 with postgreSQL.Before you do,you must configure yum repository.Append following lines to your file:

  1. [Satellite] 
  2. name=Spacewalk Satellite 
  3. baseurl=http://spacewalk.redhat.com/yum/1.7/RHEL/6/x86_64/ 
  4. enabled=1 
  5. gpgcheck=1 
  6. gpgkey=http://spacewalk.redhat.com/yum/RPM-GPG-KEY-spacewalk-2012 
  7.  
  8. [Satellite-Client] 
  9. name=Spacewalk Satellite 
  10. baseurl=http://spacewalk.redhat.com/yum/1.7-client/RHEL/6/x86_64/ 
  11. enabled=1 
  12. gpgcheck=1 
  13. gpgkey=http://spacewalk.redhat.com/yum/RPM-GPG-KEY-spacewalk-2012 
  14.  
  15. [epel] 
  16. name=Red Hat Enterprise Linux $releasever - $basearch - Debug 
  17. baseurl=http://dl.fedoraproject.org/pub/epel/6/x86_64/ 
  18. enabled=1 
  19. gpgcheck=1 
  20. gpgkey=http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6 
  21.  
  22. [Centos] 
  23. name=Centos 
  24. baseurl=http://mirrors.163.com/centos/6.2/os/x86_64/ 
  25. enabled=1 
  26. gpgcheck=1 
  27. gpgkey=http://mirrors.163.com/centos/6.2/os/x86_64/RPM-GPG-KEY-CentOS-6 
  28.  
  29. [Centos-Update] 
  30. name=Centos 
  31. baseurl=http://mirrors.163.com/centos/6.2/updates/x86_64/ 
  32. enabled=1 
  33. gpgcheck=1 
  34. gpgkey=http://mirrors.163.com/centos/6.2/os/x86_64/RPM-GPG-KEY-CentOS-6 
  35.  
  36. [Jpackes] 
  37. name=jpackage 
  38. baseurl=http://mirrors.dotsrc.org/jpackage/5.0/generic/free/ 
  39. enabled=1 
  40. gpgcheck=1 

 After,use following command to install spacewalk:

  1. yum -y install spacewalk-postgresql 

Configure postgreSQL database

You will need to become the operating system user under which PostgreSQL was installed (usually postgres) to create the first user account. It could also be that you were assigned a PostgreSQL user name that is different from your operating system user name.By default,postgreSQL has already created a user postgres.

  1. [root@sate ~]# id -a postgres 
  2. uid=26(postgres) gid=26(postgres) groups=26(postgres) 

1.Create database and user:

Before you do,you must initialize postgrsql and start it by following command.

  1. [root@sate ~]# service postgresql initdb 
  2. Initializing database: [  OK  ] 
  3. [root@sate ~]# service postgresql start 
  4. Starting postgresql service: [  OK  ] 
  1. [root@sate ~]# su - postgres 
  2. -bash-4.1$ PGPASSWORD=redhat  //Set the spaceuser's password
  3. -bash-4.1$ createdb spacewalk  //Create database
  4. -bash-4.1$ createlang plpgsql spacewalk 
  5. -bash-4.1$ createuser -P -sDR spaceuser  //Create user
  6. Enter password for new role:  
  7. Enter it again:  

2.Append following contents to /var/lib/pgsql/data/pg_hba.conf:

  1. host    all         all         172.16.255.0/24       trust 

3.Append following lines to /var/lib/pgsql/data/psotgresql.conf:

  1. listen_addresses = '*' 

4.Restart postgresql service:

  1. [root@sate ~]# service postgresql restart 
  2. Stopping postgresql service: [  OK  ] 
  3. Starting postgresql service: [  OK  ] 

5.Connect to spacewalk database:

  1. [root@sate ~]# su - postgres 
  2. postgres=# \c spacewalk 
  3. psql (8.4.9) 
  4. You are now connected to database "spacewalk". 
  5. spacewalk=#  
  6. spacewalk=# \db 
  7.        List of tablespaces 
  8.     Name    |  Owner   | Location  
  9. ------------+----------+---------- 
  10.  pg_default | postgres |  
  11.  pg_global  | postgres |  
  12. (2 rows) 

Configure Spacewalk by spacewalk-setup command

  1. [root@sate ~]# spacewalk-setup --disconnected 
  2. ** Database: Setting up database connection for PostgreSQL backend. 
  3. Hostname (leave empty for local)? sate.xzxj.edu.cn 
  4. Port [5432]?  
  5. Database? spacewalk 
  6. Username? spaceuser 
  7. Password?  
  8. *** Progress: ################################## 
  9. * Setting up users and groups. 
  10. ** GPG: Initializing GPG and importing key. 
  11. You must enter an email address. 
  12. Admin Email Address? root@localhost 
  13. * Performing initial configuration. 
  14. * Activating Spacewalk. 
  15. ** Loading Spacewalk Certificate. 
  16. ** Verifying certificate locally. 
  17. ** Activating Spacewalk. 
  18. * Enabling Monitoring. 
  19. * Configuring apache SSL virtual host. 
  20. Should setup configure apache's default ssl server for you (saves original ssl.conf) [Y]?  
  21. * Configuring tomcat. 
  22. ** /etc/tomcat6/server.xml has been backed up to server.xml-swsave 
  23. Reversed (or previously applied) patch detected!  Skipping patch. 
  24. 1 out of 1 hunk ignored -- saving rejects to file web.xml.rej 
  25. * Configuring jabberd. 
  26. * Creating SSL certificates. 
  27. CA certificate password?  
  28. Re-enter CA certificate password?  
  29. Organization? xzxj 
  30. Organization Unit [sate.xzxj.edu.cn]?  
  31. Email Address [root@localhost]?  
  32. City? ShangHai 
  33. State? ShangHai 
  34. Country code (Examples: "US", "JP", "IN", or type "?" to see a list)? CN 
  35. ** SSL: Generating CA certificate. 
  36. ** SSL: Deploying CA certificate. 
  37. ** SSL: Generating server certificate. 
  38. ** SSL: Storing SSL certificates. 
  39. * Deploying configuration files. 
  40. * Update configuration in database. 
  41. * Setting up Cobbler.. 
  42. cobblerd does not appear to be running/accessible 
  43. Cobbler requires tftp and xinetd services be turned on for PXE provisioning functionality. Enable these services [Y]?  
  44. cobblerd does not appear to be running/accessible 
  45. * Restarting services. 
  46. Installation complete. 
  47. Visit https://sate.xzxj.edu.cn to create the Spacewalk administrator account. 

Check Spacewalk service

  1. [root@sate ~]# spacewalk-service status 
  2. router (pid 16795) is running... 
  3. sm (pid 16802) is running... 
  4. c2s (pid 16809) is running... 
  5. s2s (pid 16816) is running... 
  6. osa-dispatcher (pid  16832) is running... 
  7. tomcat6 (pid 16901) is running...[  OK  ] 
  8. httpd (pid  17126) is running... 
  9. 2012-03-09 18:41:43 Monitoring: ----------- InstallSoftwareConfig STATUS --------------- 
  10. 2012-03-09 18:41:44 Monitoring: ----------- NotifEscalator STATUS --------------- 
  11. 2012-03-09 18:41:46 Monitoring: ----------- GenerateNotifConfig STATUS --------------- 
  12. 2012-03-09 18:41:47 Monitoring: ----------- NotifLauncher STATUS --------------- 
  13. 2012-03-09 18:41:49 Monitoring: ----------- Notifier STATUS --------------- 
  14. 2012-03-09 18:41:54 Monitoring: ----------- AckProcessor STATUS --------------- 
  15. 2012-03-09 18:41:55 Monitoring: ----------- TSDBLocalQueue STATUS --------------- 
  16. 2012-03-09 18:42:02 MonitoringScout: ----------- InstallSoftwareConfig STATUS --------------- 
  17. rhn-search is running (17338). 
  18. cobblerd (pid 17393) is running... 
  19. RHN Taskomatic is running (17451). 

Create the Spacewalk administrator account

image

After created,use administrator account to access:image

image

View Database information

1.List tables:

  1. [root@sate ~]# su - postgres 
  2. -bash-4.1$ psql spacewalk 
  3. psql (8.4.9) 
  4. Type "help" for help. 
  5. spacewalk=# \dt 
  6.                       List of relations 
  7.  Schema |              Name              | Type  |   Owner    
  8. --------+--------------------------------+-------+----------- 
  9.  public | dual                           | table | spaceuser 
  10.  public | pxtsessions                    | table | spaceuser 
  11.  public | qrtz_blob_triggers             | table | spaceuser 
  12.  public | qrtz_calendars                 | table | spaceuser 
  13.  public | qrtz_cron_triggers             | table | spaceuser 
  14.  public | qrtz_fired_triggers            | table | spaceuser 
  15.  public | qrtz_job_details               | table | spaceuser 
  16.  public | qrtz_job_listeners             | table | spaceuser 
  17.  public | qrtz_locks                     | table | spaceuser 
  18.  public | qrtz_paused_trigger_grps       | table | spaceuser 
  19.  public | qrtz_scheduler_state           | table | spaceuser 
  20.  public | qrtz_simple_triggers           | table | spaceuser 
  21.  public | qrtz_trigger_listeners         | table | spaceuser 
  22.  public | qrtz_triggers                  | table | spaceuser 
  23.  public | rhn_check_probe                | table | spaceuser 
  24.  public | rhn_check_suite_probe          | table | spaceuser 
  25.  public | rhn_check_suites               | table | spaceuser 
  26.  public | rhn_command                    | table | spaceuser 
  27.  public | rhn_command_class              | table | spaceuser 
  28.  public | rhn_command_groups             | table | spaceuser 
  29.  public | rhn_command_param_threshold    | table | spaceuser 
  30.  public | rhn_command_parameter          | table | spaceuser 
  31.  public | rhn_command_queue_commands     | table | spaceuser 
  32.  public | rhn_command_queue_execs        | table | spaceuser 
  33.  public | rhn_command_queue_instances    | table | spaceuser 
  34.  public | rhn_command_queue_params       | table | spaceuser 
  35.  public | rhn_command_queue_sessions     | table | spaceuser 
  36.  public | rhn_command_requirements       | table | spaceuser 
  37.  public | rhn_command_target             | table | spaceuser 
  38.  public | rhn_config_group               | table | spaceuser 
  39.  public | rhn_config_macro               | table | spaceuser 
  40.  public | rhn_config_parameter           | table | spaceuser 
  41.  public | rhn_config_security_type       | table | spaceuser 
  42.  public | rhn_contact_group_members      | table | spaceuser 
  43.  public | rhn_contact_groups             | table | spaceuser 
  44.  public | rhn_contact_methods            | table | spaceuser 
  45.  public | rhn_current_state_summaries    | table | spaceuser 
  46.  public | rhn_deployed_probe             | table | spaceuser 
  47.  public | rhn_host_probe                 | table | spaceuser 
  48.  public | rhn_ll_netsaint                | table | spaceuser 
  49.  public | rhn_method_types               | table | spaceuser 
  50.  public | rhn_metrics                    | table | spaceuser 
  51.  public | rhn_multi_scout_threshold      | table | spaceuser 
  52.  public | rhn_notification_formats       | table | spaceuser 
  53.  ............
  54. (383 rows

2.List views:

  1. spacewalk=# \dv 
  2.                      List of relations 
  3.  Schema |              Name              | Type |   Owner    
  4. --------+--------------------------------+------+----------- 
  5.  public | all_primary_keys               | view | spaceuser 
  6.  public | all_tab_columns                | view | spaceuser 
  7.  public | rhn_contact_monitoring         | view | spaceuser 
  8.  public | rhn_customer_monitoring        | view | spaceuser 
  9.  public | rhn_host_monitoring            | view | spaceuser 
  10.  public | rhnactionoverview              | view | spaceuser 
  11.  public | rhnavailablechannels           | view | spaceuser 
  12.  public | rhncddevice                    | view | spaceuser 
  13.  public | rhnchannelfamilyoverview       | view | spaceuser 
  14.  public | rhnchannelfamilypermissions    | view | spaceuser 
  15.  public | rhnchannelfamilyserverfve      | view | spaceuser 
  16.  public | rhnchannelfamilyserverphysical | view | spaceuser 
  17.  public | rhnchannelfamilyservers        | view | spaceuser 
  18.  public | rhnchannelfamilyservervirtual  | view | spaceuser 
  19.  public | rhnchannelnewestpackageview    | view | spaceuser 
  20.  public | rhnchannelpermissions          | view | spaceuser 
  21.  public | rhnchanneltreeview             | view | spaceuser 
  22.  public | rhnchecksumview                | view | spaceuser 
  23.  public | rhnentitledservers             | view | spaceuser 
  24.  public | rhnhwdevice                    | view | spaceuser 
  25.  public | rhnorgchannelfamilypermissions | view | spaceuser 
  26.  public | rhnorgchanneltreeview          | view | spaceuser 
  27.  public | rhnorgerrata                   | view | spaceuser 
  28.  public | rhnpackagechangelog            | view | spaceuser 
  29.  public | rhnserverentitlementphysical   | view | spaceuser 
  30.  public | rhnserverentitlementview       | view | spaceuser 
  31.  public | rhnserverentitlementvirtual    | view | spaceuser 
  32.  public | rhnservererratatypeview        | view | spaceuser 
  33.  public | rhnserverfeaturesview          | view | spaceuser 
  34.  public | rhnserverfvecapable            | view | spaceuser 
  35.  public | rhnservergroupmembership       | view | spaceuser 
  36.  public | rhnservergroupoverview         | view | spaceuser 
  37.  public | rhnservergroupovlitehelper     | view | spaceuser 
  38.  public | rhnserverneedederratacache     | view | spaceuser 
  39.  public | rhnserverneededpackagecache    | view | spaceuser 
  40.  public | rhnserverneededview            | view | spaceuser 
  41.  ..........
  42. (58 rows

3.List roles:

  1. spacewalk=# \dg 
  2.             List of roles 
  3.  Role name | Attributes  | Member of  
  4. -----------+-------------+----------- 
  5.  postgres  | Superuser   | {} 
  6.            : Create role    
  7.            : Create DB      
  8.  spaceuser | Superuser   | {} 
  9.            : Create role    
  10.            : Create DB      

4.Display table info:

  1. spacewalk-# \d rhnpackage 
  2.                        Table "public.rhnpackage" 
  3.      Column      |            Type             |       Modifiers         
  4. -----------------+-----------------------------+------------------------ 
  5.  id              | numeric                     | not null 
  6.  org_id          | numeric                     |  
  7.  name_id         | numeric                     | not null 
  8.  evr_id          | numeric                     | not null 
  9.  package_arch_id | numeric                     | not null 
  10.  package_group   | numeric                     |  
  11.  rpm_version     | character varying(16)       |  
  12.  description     | character varying(4000)     |  
  13.  summary         | character varying(4000)     |  
  14.  package_size    | numeric                     | not null 
  15.  payload_size    | numeric                     |  
  16.  build_host      | character varying(256)      |  
  17.  build_time      | timestamp without time zone |  
  18.  source_rpm_id   | numeric                     |  
  19.  checksum_id     | numeric                     | not null 
  20.  vendor          | character varying(64)       | not null 
  21.  payload_format  | character varying(32)       |  
  22.  compat          | smallint                    | default 0 
  23.  path            | character varying(1000)     |  
  24.  header_sig      | character varying(64)       |  
  25.  copyright       | character varying(128)      |  
  26.  cookie          | character varying(128)      |  
  27.  last_modified   | timestamp with time zone    | not null default now() 
  28.  created         | timestamp with time zone    | not null default now() 
  29.  modified        | timestamp with time zone    | not null default now() 
  30.  header_start    | numeric                     | not null default (-1) 
  31.  header_end      | numeric                     | not null default (-1) 
  32. ................
  33. spacewalk-#  

5.Query table:

  1. spacewalk=# select count(*) from rhnpackage; 
  2.  count  
  3. ------- 
  4.   4812 
  5. (1 row) 
  6. spacewalk=# select *from rhn_os; 
  7.  recid |   os_name     
  8. -------+-------------- 
  9.      4 | Linux System 
  10.     14 | Satellite 
  11. (2 rows

For more infomation about postgreSQL from following links:

1.PostgreSQL 8.4.11 Documentation

2.PostgreSQL examples

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章