Tuesday, February 4, 2014

Migration Upgrade from TFS 2012 to TFS 2013 (With Reporting and SharePoint)

This blog gives you the step by step actions required for the Migration upgrade from Team Foundation Server 2012 to 2013.
> Prerequisites: (IMPORTANT)
Make sure you have appropriate accounts with permissions for SQL, SharePoint, TFS and Machine level Admin privileges on both the servers.
  1. You must be an Administrator on the Server.
  2. The Account must have Sysadmin privilege in SQL Server.
  3. Must be a part of the Farm Administrator’s group in SharePoint.
A detailed information about this can be found here.
   Back up all the databases from TFS 2012.
Make sure you stop all TFS services, using the TFSServiceControl.exe quiesce command. More info here.
Databases to backup,
  1. The Configuration Database (For instance, Tfs_Configuration)
  2. The Collection Database(s) (For instance, Tfs_DefaultCollection)
  3. The Warehouse Database* (For instance, Tfs_Warehouse)
  4. The Analysis Database* (For instance, Tfs_Analysis)
  5. Report Server Databases* (For instance, ReportServer and ReportServerTempDB)
  6. SharePoint Content Databases** (For instance, WSS_Content)
* If you have configured Reporting in TFS 2012
** If you have configured SharePoint in TFS 2012
Also, you have to back up the Encryption keys of ReportServer database.
   In the new Server,
  1. Install the TFS2013 Binaries.
  2. Install SQL Server 2012 (Enterprise/Standard) with SP1
  3. For a step by step instructions on how to install SQL Server for TFS, refer here.
  4. Install a compatible version of SharePoint (Foundation/Standard/Enterprise) Note: Configuration fails with SQL Server 2012 RTM. You need SP1 update installed.
> Step 1: Restoring Databases.
On the new server, using the SQL Server Management Studio, Connect to the Database engine and restore all the databases (Configuration, Collection(s), SharePoint Content Warehouse and Reporting). Also, connect to the Analysis Engine and restore the Analysis Database.
clip_image002
If you have Reports configured and want to do the same in 2013, go to Step 2, else skip it.
> Step 2: Configure Reporting.
Open Reporting Services Configuration Manager,
clip_image004
Click on Database on the left pane and click on Change Database.
Choose an existing report server database and click on next.
clip_image006
Enter the credentials and click on next.
clip_image009
Select ReportServer database and continue to next. Review and complete the wizard.
clip_image011
Now, you’ll have to restore the Encryption key. To do that Click on Encryption Keys on the left pane and click on Restore.
Specify the file and enter the password you used to back up the encryption key and click on OK.
clip_image013
Go to Report Manager URL, and Click on the URLs to see if you are able to successfully browse through the reports.
clip_image015
> Step 3: Install and Configure SharePoint.
Install a compatible version of SharePoint and run the SharePoint Products Configuration Wizard.
To check compatible versions, refer to the Team Foundation Server 2013 Installation Guide, available here.
Click on Next.
clip_image017
Configuring a new farm would require reset of some services. Confirm by clicking on Yes.
clip_image019
Select Create a new server farm and click on Next.
clip_image021
Enter the Database Server and give a name for the configuration Database. Specify the service account that has the permissions to access that database server.
clip_image023
The recent versions of SharePoint would ask for a passphrase to secure the farm configuration data. Enter a passphrase.
clip_image025
Click on Specify Port Number and give “17012”. TFS usually uses this port for SharePoint. You can however give another unused port number too.
Select NTLM for default security settings.
clip_image027
Review and complete the configuration wizard.
clip_image029
Now that we’ve configured SharePoint, go to SharePoint Central Admin page, give the admin credentials and create a new web application for TFS. It will automatically create a new content database for you.
If you want to restore the content database from the previous version, say SharePoint 2010, youmust first upgrade the content database and attach it to the web application.
  • First, Click on Application Management -> Manage Content Databases.
    Select the web application you created for TFS and remove that content database.
  • Upgrade and Attach the old content database by using the Mount-SPContentDatabase. Example,
    Mount-SPContentDatabase “MyDatabase” -DatabaseServer "MyServer" -WebApplicationhttp://sitename (More information on that command, here.) 
> Step 4: Configure Team Foundation Server.
Once we’ve restored all the databases and the encryption key and/or configured reporting, we are all set to upgrade TFS to the latest version.
Start Team Foundation Administration Console and Click on Application tier.
clip_image031
Click on Configure Installed Features and choose Upgrade.
clip_image032
Enter the SQL Server/Instance name and Click on list available databases.
clip_image033
Confirm that you have taken backup and click on next (Yes, taking a backup is that important)
Choose the Account and Authentication Method.
clip_image034
Select the Configure Reporting for use with Team Foundation Server and click on next.
clip_image035
Note: If your earlier deployment was not using Reporting Service then you would not be able to add Reporting Service during the upgrade (this option would be disabled). You can configure Reporting Service with TFS later on after the upgrade is complete.
Give the Reporting Services Instance name and Click on Populate URLs to populate the Report Server and Report Manager URLs. Click on next.
clip_image036
Since we are configuring with Reports, we need to specify the Warehouse database. Enter the New SQL Instance that hosts the Warehouse database, do a Test and Click on List Available Databases. Select Tfs_Warehouse and click on Next.
clip_image037
In the next screen, Input the New Analysis Services Instance, do a Test and Click on Next.
Note: If you’ve restored the Analysis Database (Tfs_Analysis) from the previous instance, TFS will automatically identify and use the same.
clip_image038
Enter the Report Reader account Credentials, do a Test and click on Next.
clip_image039
Check Configure SharePoint Products for Use with Team Foundation Server. Click on Next.
Note: This is for Single Server Configuration, meaning SharePoint is installed on the same server as TFS.
clip_image040
Note: If your earlier deployment was not using SharePoint then you would not be able to add SharePoint during the upgrade (this option would be disabled). You can configure SharePoint with TFS later on after the upgrade is complete.
In this screen, make sure you point to the correct SharePoint farm. Click on Test to test out the connection to the server. In our case, this is a Single-Server deployment. We’ve configured SharePoint manually, and created a web application for TFS.
clip_image041
Make sure all the Readiness Checks are passed without any errors. Click on Configure.
clip_image042
Now, the basic TFS Configuration is completed successfully. Click on Next to initiate the Project Collection(s) upgrade.
clip_image043
That’s it. Project Collections are now upgraded and attached.
clip_image044
Click on next to review a summary and close this wizard.
clip_image045
We are almost done. Notice that in the summary of TFS Administration Console, we still see the old server URL.
This is very important.
We need to change this to reflect the new server using the Change URLs.
clip_image047
clip_image049
Do a test on both the URLs and Click on OK.
Now, try browsing the Notification URL to see if you are able to view the web access without any errors.
clip_image051
Next, Click on the Team Project Collections in the left pane, Select your Collection(s) and click on Team Projects. See if you have the projects listed.
clip_image053
Under SharePoint site, check if the URL points to the correct location, if not, Click on Edit Default Site Location and edit it.
clip_image055
See if the URL under Reports Folder points to the correct location, if not, Click on Edit Default Folder Location and edit it.
clip_image057
Next, Click on Reporting in the left pane and see if the configurations are saved and jobs are started.
clip_image059
> Step 5: Configuring Extensions for SharePoint (Only when SharePoint is on a different server)
If you’ve configured SharePoint on a different server, you need to add Extensions for SharePoint products manually.
First you need to install Remote SharePoint Extensions on the server available as part of the TFS installation media. Run the configuration wizard for Extensions for SharePoint. For a detailed blog on how to do that click here.
That’s it. With that TFS is configured correctly.
As a final step, install Team ExplorerConnect to the Team Foundation Server and create a new Team Project. See if it creates properly with Reports and a SharePoint site.
Now, your new TFS 2013 is up and running, with upgraded collections.

Wednesday, January 29, 2014

MySQL - Connect to your database remotely

This tutorial will walk you through setting up a user on your MySQL server to connect remotely.
The following items are assumed:
  • You have access to login as the 'root' MySQL user

Contents

Getting your IP address

You will need to know what the IP address you are connecting from. To find this you can go to one of the following sites:

Granting Access

Granting access to a user from a remote host is fairly simple and can be accomplished from just a few steps. First you will need to login to your MySQL server as the root user. You can do this by typing the following command:
# mysql -u root -p
This will prompt you for your MySQL root password.
Once you are logged into MySQL you need to issue the GRANT command that will enable access for your remote user. In this example we will be creating a brand new user (fooUser) that will have full access to the fooDatabase database.
Keep in mind that this statement is not complete and will need some items changed. Please change 1.2.3.4 to the IP address that we obtained above. You will also need to change my_password with the password that you would like to use for fooUser.
mysql> GRANT ALL ON fooDatabase.* TO fooUser@'1.2.3.4' IDENTIFIED BY 'my_password';
This statement will grant ALL permissions to the newly created user fooUser with a password of 'my_password' when they connect from the IP address 1.2.3.4.

Testing Remotely

Now you can test your connection remotely. You can access your MySQL server from another Linux server:
# mysql -u fooUser -p -h 44.55.66.77 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 17 Server version: 5.0.45 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> _
Note that the IP of our MySQL server is 44.55.66.77 in this example.

Notes

There are a few things to note when setting up these remote users:
  • When setting up users a local user is not the same thing as a remote user. For instance fooUser@localhost is not the same as fooUser@1.2.3.4. You will have to duplicate permissions if you want them to have the same permissions.
  • Granting ALL permissions is not advised. Using GRANT SELECT,INSERT,UPDATE,DELETE is a wise alternative for a normal user.
  • If you would like to grant only to a specific table you can use database.table instead of database.*. In respect to our example above you could put fooDatabase.fooTable.
  • If you are using iptables you will need to make an entry in your firewall for TCP port 3306. When creating your firewall rule you can simply use the name 'mysql' for the port number. Search our wiki for iptables and you will find a list of common rule sets which include an entry for MySQL.

Thursday, January 2, 2014

Why we require repo on top of git in development project.

When we talk about Android project, we get a picture of repository with lots of folder inside that. Android project is large, keeping all android OS file into one repository is inefficient and error prone. If repository got corrupted whole project will be in soup as well as all git operation will be very slow in one single repository. So android project has been divided into multiple git repositories. In git any repository is maintained by .git folder.
So android source is having multiple .git folders like below picture
Here bionic.git   is one repository containing file related to bionic.
kernel.git it containing kernel related files.
Other folder like device, framework etc will be having multiple repositories inside them.
Git command like git add git commit git push etc at a time work on one repository mean on one .git folder.  But a normal android mobile development project will be having almost 120 to 180 git repositories.
So question arise how to handle all 180 repositories. One way is ,go into all 180 repository manually perform our work; if we do like this our life will be miserable. So repo comes into picture.
So repo is a tool or set of scripts written in python to handle this situation. It has lot of command to make our life happy which are
1) repo init
2) repo sync
3) repo forall
4) repo prune
5) repo start
6) repo status
1) repo init:-

init

repo init -u url [options ]
Whenever we run repo init with some URL and option, it will create a .repo folder in your current directory. This .repo/ directory will contain Git repositories for our project; mean all .git repositories which I have mentioned above in projects folder.  The .repo/ directory also contain manifest.xml, which is a symlink to the selected manifest in the .repo/manifests/ directory.
This manifest file contain the info of your all repositories, there path in source etc.
It something looks like this
So <project name="platform/cts" path="android/cts" />
Tell us that there is a project platform/cts and it can be found at android/cts path in the source.
To get this .repo folder we have to run repo init command. So let run us  
 $ repo init -u git://android.git.kernel.org/platform/manifest.git
This command will create a .repo folder containing repo specific and project specific files in your current directory. Here -u argument specifies a URL from which to retrieve a manifest repository.
To specify a revision, which is, a particular manifest-branch, use the -b option. For example:
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b release-1.0
here revision is a name of the Git branch the manifest wants to track for this project.
Note: For all remaining Repo commands, the current working directory must either be the parent directory of .repo/ or a subdirectory of the parent directory.

Sync

repo sync [ project-list ]

Using repo init we installed the repo and got the project specific info but till yet we have not synchronized with the remote repository mean; we have not downloaded the source code till yet. So repo sync downloads new changes and updates the working files in your local environment. After successful repo sync, the code in specified projects will be up to date with the code in the remote repository.
You can specify project-list as a list of names or a list of paths to local source directories for the projects:
   repo sync [proj1 proj2 ... projN]
Here proj1 might be kernel/lk or android/bootable/bootloader/lk

Like that we can define multiple project if want specific project files to sync with remote repository. Or give without any parameter if you want to sync files for all projects.
Generally Repo synchronization works like below
When we run repo sync,:
1.            If the project has never been synchronized, then repo sync is equivalent to git clone. All branches in the remote repository are copied to the local project directory.
2.            If the project has already been synchronized once, then repo sync is equivalent to:
git remote update
git rebase origin/branch
where branch is the currently checked-out branch in the local project directory. If the local branch is not tracking a branch in the remote repository, then no synchronization will occur for the project.
Mean if do repo sync in existing repo synced project it fetch the update from remote repository, then it rebase your current branch, here git remote update command is equivalent to git fetch. Basic difference between these two commands is:
git remote update fetch the update or new branch for all remote branches present in remote repository.
git fetch just fetch the changes for specified remote branch.
Sometime in git rebase operation results in merge conflicts, we need to use the normal Git commands (for example, git rebase --continue) to resolve those conflicts.
The repo sync command also updates the private repositories in the .repo/ directory.

start

repo start newbranchname [ project-list ]
when we do the repo sync , we got the copy of remote repository but branch of development is not specified till yet. Mean our commit will go to which branch is not specified or we are not on any branch till yet. So repo start command starts a new branch for development.
The project-list specifies which projects will participate in this topic branch. You can specify project-list as a list of names or a list of paths to local working directories for the projects:
repo start default [proj1 proj2 ... projN]
"." is a useful shorthand for the project in the current working directory.

status

repo status [project-list ]
Show the status of files with respect of current working directory, staging area and most recent commit on the branch (HEAD) in each project specified.
This command compares the working tree to the staging area (index) and the most recent commit on this branch (HEAD) in each project specified. Displays a summary line for each file where there is a difference between these three states.
repo status command shows the file status in current branch with two-letter code. Which is defined as?
In the first column, an uppercase letter indicates how the staging area differs from the last committed state.
 Character
 Meaning
 A
The file is added (brand new). Can only appear in the first column.
 M or m
The file already exists but has been modified in some way.
 D or d
The file has been deleted.
 R
The file has been renamed. Can only appear in the first column. The new name is also shown on the line.
 C
The file has been copied from another file. Can only appear in the first column. The source is also shown.
 T
Only the file's mode (executable or not) has been changed. Can only appear in the first column.
 U
The file has merge conflicts and is still unmerged. Can only appear in the first column.
 -
The file state is unmodified. A hyphen in both columns means this is a new file, unknown to Git. After you run git add on this file, repo status will show A-, indicating the file has been added.

In the second column, a lowercase letter indicates how the working directory differs from the index.

lettermeaningdescription
-new/unknownnot in index, in work tree
mmodifiedin index, in work tree, modified
ddeletedin index, not in work tree
For example, if you edit the file hello.c within the hello world project without staging the changes, then repo status might show
project helloworld/
-m     hello.c
Mean there is no change between staging area and repository, but file has been modified into working tree.
If you go on to stage the changes to hello.c by running git add, then repo status might show
project helloworld/
M-     hello.c
Mean file hello.c has been modified in staging area with respect to repository and in next commit this change will go into repository.
-- secondprogam.c specifies that new untracked file exist in source code.

forall

repo forall [ project-list ] -c command [ arg...]
Runs a shell command in each project.
Some time we want to run some git command in every git project. For that we can use repo forall.
For example if we want to get commit history of android project b/w v1.0 to v2.0 we can run this command
repo forall –c git log v1.0..v2.0

This command will run git log into all project repositories and will give us commit history between v1.o and v2.o
You can specify project-list as a list of names or a list of paths to local source directories for the projects

help

repo help [ command ]
Displays detailed help about a command.

prune

repo prune [ project-list ]
basically this command is used to remove stale branches. Mean branches which are already merged and deleted from remote but not have been removed from the local.
we can specify project-list as a list of names or a list of paths to local source directories for the projects:
repo prune [proj1 proj2 ... projN]