JavaScript is not currently enabled, but is required for full
CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable
JavaScript in your browser: you will also need it for GUI
functionality.
If you opened this file directly from disk, your browser may be
directly suppressing JavaScript functionality: certain browsers
perform this suppression on local files (but not files delivered by
web servers) for security reasons.
-
If you access the manual through the hub's Web GUI, the
functionality will not be suppressed because the hub is a web
server.
-
Alternatively, your browser may allow you to explicitly
disable the security setting that suppresses functionality. See
the CodeSonar
FAQ for more information.
Moving A Hub
This section describes how to change the host or port on which
the hub listens, and how to relocate the hub directory within your file system.
Given a hub listening at interface:port with hub
directory at hubDir, use the following procedure to move the
hub to a new newinterface:newport on the same
machine.
-
Shut down the hub.
codesonar hub-stop interface:port
(You may be prompted for hub user account credentials to
authenticate this command.)
- Shut down the hub database process, if it is not already shut
down.
- Restart the hub.
codesonar hub-start [-no-services] hubDir
newinterface:newport
Given a primary
hub listening at interface:port with hub directory
at oldDir, use the following procedure to move the hub
directory to a new location newDir.
- Make sure newDir is adequately secured.
- Ensure that newDir is not located inside the
CodeSonar installation directory.
- Use file system security controls to restrict access to
newDir: users without hub administration privileges
should not have access to the directory.
-
Shut down the hub.
codesonar hub-stop interface:port
(You may be prompted for hub user account credentials to
authenticate this command.)
This will also shut down any associated satellite hubs.
- Shut down the hub database process, if it is not already shut
down.
- Move the hub directory from oldDir to
newDir.
- Restart the hub.
codesonar hub-start [-no-services] newDir
interface:port
-
Restart the associated
satellite hub or hubs (if any).
codesonar hub-start [-no-services]
[-auth authtype] [-hubuser username] [-hubpwfile pwfile] [-hubbearerfile bearerfile] [-hubcert certfile] [-hubkey privatekeyfile]
-satellite-of
interface:port sat_dir
sathost:satport
- Use the authorization options to provide credentials for a
primary hub user account with G_HUB_INFO permission. These
credentials are used to authenticate the early stages of the
satellite hub-start
process.
- When prompted, enter the primary hub's Administrator password. This is used to
authenticate the database operations involved in starting a
satellite hub.
Given a hub listening at interface:port with hub
directory at hubDir on machine A, use the following procedure
to move the hub to a new newinterface:newport on
machine B with new hub directory newHubDir.
Windows note: perform these steps in
a command prompt (not Cygwin).
- Make sure newHubDir is adequately secured.
- Ensure that newHubDir is not located inside the
CodeSonar installation directory.
- Use file system security controls to restrict access to
newHubDir: users without hub administration privileges
should not have access to the directory.
- Determine the port on machine A that the current hub database
is listening on:
- Navigate to http://interface:port/command/info/
- Find the line that reads Database:
postgres://[::1]:42xxx/cshub
(See the
IPv4 note if your system does not support
IPv6 addresses.)
- Make a note of the 42xxx part. We will call this
listenA.
- On machine A, back up the hub database. You have a choice of
methods:
| Option 1: |
$CSONAR/third-party/postgresql/inst/bin/pg_dump
-U cshubuser
-h ::1 -p listenA -Z 9 -COx
-F c -f BACKUP cshub
You will be prompted for a password.
- Enter the hub Administrator password at the
prompt.
This will create a file called BACKUP in the working directory.
|
| Option 2: |
Click the Backup Hub link on the Settings:
Other Links tab, and use your browser's download
controls to specify a suitable location for the backup file.
Call it BACKUP. |
- On machine B, create a new hub at
newinterface:newport with hub directory
newHubDir:
codesonar hub-start newHubDir
newinterface:newport
You will be prompted to set the Administrator password for the new hub.
- Set the same Administrator
password as you used on the old hub. This is important for the
database transition steps. (You can always change it
later.)
- This creates a new hub database: the remaining steps explain
how to replace this with the hub database in BACKUP.
- On machine B, create a new, empty file:
newHubDir/pgdata/pg_hba.conf.csignore
- On machine B, edit newHubDir/pgdata/pg_hba.conf to append
the following line.
host postgres cshubuser ::1/32 md5
- On machine B, restart the new hub so your changes can take
effect.
-
codesonar hub-stop newinterface:newport
-
codesonar hub-start newHubDir
newinterface:newport
- Determine the port on machine B that the new hub database is
listening on:
- Visit http://newinterface:newport/command/info/
- Find the line that reads Database:
postgres://[::1]:42yyy/cshub
- Make a note of the 42yyy part. We will call this
listenB.
- On machine B, kill the cshub
process (or processes) — but none of its subprocesses — so that you
can drop and restore the database.
- On Windows, use a command line tool such as tskill or taskkill.
tskill cshub
- Avoid using the Task Manager to stop the cshub process: it may shut down the
database process that you need to interact with in later
steps.
- On other systems, locate and kill cshub with kill
-9 or your system's equivalent. There will typically
be several cshub processes, so
you may need to repeat this step several times until they are
all stopped.
- Do not specify alternate kill signals that shut down
the entire process tree: this will shut down the database
process that you need to interact with in later steps.
- Copy the BACKUP file to
machine B.
- On machine B, drop the newly-created
cshub database.
$CSONAR/third-party/postgresql/inst/bin/dropdb
-U cshubuser -h ::1 -p listenB
cshub
You will be prompted for a password.
- Enter the hub Administrator password at the prompt. See
the troubleshooting note if your
password is not accepted.
- On machine B, restore the cshub database from
BACKUP.
$CSONAR/third-party/postgresql/inst/bin/pg_restore
-U cshubuser -h ::1 -p listenB
-COxe -d postgres -F c BACKUP
Did you create BACKUP from a hub
running the same version of CodeSonar that you are using to
restore?
- YES: The command should run successfully.
- NO: Did you create BACKUP
from a hub running CodeSonar version 5.3 or earlier but are
restoring with CodeSonar version 5.4 or later?
You will be prompted for a password.
- Enter the hub Administrator password at the prompt. See
the troubleshooting note if your
password is not accepted.
- On machine B, edit newHubDir/pgdata/pg_hba.conf to remove
the line you appended in step 6.
- On machine B, remove file newHubDir/pgdata/pg_hba.conf.csignore
- Restart the hub on machine B, using the same location and hub
directory as before:
codesonar hub-start newHubDir
newinterface:newport
- Navigate to http://newinterface:newport/ on
machine B to verify that the transfer worked as expected.
- License key configuration information will have been
transferred along with the other hub information. In most cases the
transferred information will not be suitable, because hub license
keys are usually locked to a specific machine.
-
Shut down and restart any satellite hubs
associated with the hub you moved, pointing them to the new hub
location.
- Shut down:
codesonar hub-stop sathost:satport
(You may be prompted for hub user account credentials to
authenticate the hub-stop
commands.)
- Restart:
codesonar hub-start [-no-services]
[-auth authtype] [-hubuser username] [-hubpwfile pwfile] [-hubbearerfile bearerfile] [-hubcert certfile] [-hubkey privatekeyfile]
-satellite-of
newinterface:newport sat_dir
sathost:satport
- Use the authorization options to provide credentials
for a primary hub user account with G_HUB_INFO permission. These
credentials are used to authenticate the early stages of
the satellite hub-start
process.
- When prompted, enter the primary hub's Administrator password. This is used
to authenticate the database operations involved in
starting a satellite hub.
If your Administrator password is
not accepted at step 12 or 13, the problem may be caused by
PostgreSQL having created an additional database. To work around
this, go back to step 7 and amend your changes to newHubDir/pgdata/pg_hba.conf to replace
postgres with all:
host all cshubuser ::1/32 md5
Then continue from step 8 as before.
Related Topics
If you also wish to relocate the files associated with one or more
analyses on this hub, see the instructions in Task: Relocate Analysis
Files.
The notion of 'relocation' does not really apply to
satellite hubs, because their hub directories do not contain any
information that needs to be preserved across different locations.
Instead:
- Shut down the unwanted
satellite hub.
- Start a new satellite
hub at the new location, associated with the same primary hub
as before.
If your system does not support IPv6 addresses, use IPv4 to
specify and identify addresses instead.
- 127.0.0.1 instead of
::1 (including in the PostgreSQL
command lines and newHubDir/pgdata/pg_hba.conf
file).
- 0.0.0.0 instead of
::