Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Connect to Amazon EC2 Instance

Connecting from Windows: http://www.techrepublic.com/blog/the-enterprise-cloud/connect-to-amazon-ec2-with-a-private-key-using-putty-and-pageant/

Connecting from Linux: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html

Install MySQL

To install MySQL, run the following command from a terminal prompt: sudo apt-get install mysql-server

During the installation process you will be prompted to enter a password for the MySQL root user. username / password : root / root

Once the installation is complete, the MySQL server should be started automatically. You can run the following command from a terminal prompt to check whether the MySQL server is running: sudo netstat -tap | grep mysql

When you run this command, you should see the following line or something similar: tcp 0 0 localhost:mysql *:* LISTEN 2759/mysqld

If the server is not running correctly, you can type the following command to start it: sudo service mysql restart

If you would like to change the MySQL root password, in a terminal enter: sudo dpkg-reconfigure mysql-server-5.5

The MySQL daemon will be stopped, and you will be prompted to enter a new password.

MySQL Configuration

  1. Create an empty schema and a sonarqube user. Grant this sonarqube user permissions to create, update and delete objects for this schema. The charset of the database has to be set to "UTF-8" and the language (database and user) to "English".

    1. create and edit a script file create_database.sql

      CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
      CREATE USER ‘sonar’ IDENTIFIED BY ‘sonar';
      GRANT ALL ON sonar.* TO ‘sonar’@’%’ IDENTIFIED BY ‘sonar';
      GRANT ALL ON sonar.* TO ‘sonar’@’localhost’ IDENTIFIED BY ‘sonar';
      FLUSH PRIVILEGES;
    2. To run the script: sudo mysql -u root -p < create_database.sql

    3. To verify the user has been created: SELECT User FROM mysql.user; you should see user with name 'sonar'

    4. To verify the database has been created: show databases; you should see database with name 'sonar'

  2. Set buffer pool size to 50-80% of your computer's memory. Add the following to my.cnf and then restart mysql.

    • innodb_buffer_pool_size = 4096M
    • innodb_buffer_pool_instances = 4
  3. give at least 15Mb to the query_cache_size parameter

    • mysql> SET GLOBAL query_cache_size =67108864;
    • mysql> SHOW VARIABLES LIKE 'query_cache_size';

Install Java

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
  • You will be prompted to accept the Oracle License Agreement.
  • Automatic set up of Java 8 environment variables: sudo apt-get install oracle-java8-set-default
  • Check Java installation: java -version

Installing the Web Server

Install

  1. Add the relevant source entry in your /etc/apt/sources.list
    • sudo vim /etc/apt/sources.list then press o then paste deb http://downloads.sourceforge.net/project/sonar-pkg/deb binary/ into the new line. press ESC then write :wq! then press ENTER
  2. sudo apt-get update
  3. sudo apt-get install sonar
  4. You may get the following warning: 'The following packages cannot be authenticated!'. Enter y to continue with the installation.
  5. ensure user is created "Adding new user 'sonar' (UID 107) with group 'nogroup'"
  6. set sonar user password. sudo passwd sonar

Configure Database

  1. cd /opt/sonar/conf

  2. sudo vi sonar.properties

  3. Comment out the embedded database H2 lines if needed.

  4. Uncomment the lines for the relevant database. Example below. Change server hostname or port if required.

    #----- MySQL 5.x
    sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
    
  5. Add/edit the following properties:

    sonar.jdbc.username=sonar
    sonar.jdbc.password=sonar"
    

Configure WebServer

  • sudo vi /opt/sonar/conf/sonar.properties

     sonar.web.context=/sonar
     sonar.web.port=80
    

Start WebServer

  • For starting the server sudo /opt/sonar/bin/linux-x86-64/sonar.sh start
  • For stopping the server sudo /opt/sonar/bin/linux-x86-64/sonar.sh stop
  • tail -f /opt/sonar/logs/sonar.log
  • ps -ef | grep sonar

Maven

  1. wget http://stingray.cyber.net.pk/pub/apache/maven/maven-3/3.2.3/binaries/apache-maven-3.2.3-bin.tar.gz

  2. tar -zxf apache-maven-3.2.3-bin.tar.gz

  3. sudo mv apache-maven-3.2.3 /usr/local/

  4. Create a symbolic link to /usr/bin using the following command sudo ln -s /usr/local/apache-maven-3.2.3/bin/mvn /usr/bin/mvn

  5. Set up environment variables

    1. Create a script: sudo vim /etc/profile.d/mvn.sh

    2. Add the following commands to the script:

      export M2_HOME=/usr/local/apache-maven-3.2.3
      export M2=$M2_HOME/bin
      export PATH=$M2:$PATH
      
    3. sudo chmod 755 mvn.sh

  6. Edit $M2_HOME/conf/settings.xml

    <settings>
    <profiles>
            <profile>
            	<id>sonar</id>
            	<activation>
                    <activeByDefault>true</activeByDefault>
            	</activation>
            	<properties>
                    <!-- Example for MySQL-->
                	<sonar.jdbc.url>
                  	jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8
                	</sonar.jdbc.url>
                	<sonar.jdbc.username>sonar</sonar.jdbc.username>
                	<sonar.jdbc.password>sonar</sonar.jdbc.password>
    
                    <!-- Optional URL to server. Default value is http://localhost:9000 -->
                	<sonar.host.url>
                  	http://myserver
                	</sonar.host.url>
            	</properties>
        	</profile>
     	</profiles>
    </settings>
@seanmbowen

This comment has been minimized.

Copy link

@seanmbowen seanmbowen commented Jan 5, 2018

Thanks

@cig0

This comment has been minimized.

Copy link

@cig0 cig0 commented Mar 18, 2019

Works great, thanks

@harshblog150

This comment has been minimized.

Copy link

@harshblog150 harshblog150 commented May 30, 2019

great thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment