Wednesday, September 20, 2017

Debian Stretch: Installing MySql (for fresh installation)

Remove all MariaDB
# apt-get --purge remove mysql-server mysql-client 
or 
# apt-get --purge remove mariadb-server-10.1 mariadb-server-core-10.1 mariadb-client-10.1 
# apt-get autoclean && apt-get autoremove
Note: option purge will remove all mariadb database

Install MySql dependency

# apt-get install lsb-release

Download MySql apt configuration from https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb
# wget --no-check-certificate https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb
Note: File name may change without notice, check latest mysql-apt-config at https://dev.mysql.com/downloads/repo/apt/

Install MySql apt configuration.
# dpkg -i mysql-apt-config_0.8.7-1_all.deb
Choose MySql 5.7 for stable version and continue by click Ok. It will create apt repository file like this:
# cat /etc/apt/sources.list.d/mysql.list
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out entries below, but any other modifications may be lost.
# Use command 'dpkg-reconfigure mysql-apt-config' as root for modifications.
deb http://repo.mysql.com/apt/debian/ stretch mysql-apt-config
deb http://repo.mysql.com/apt/debian/ stretch mysql-5.7
deb http://repo.mysql.com/apt/debian/ stretch mysql-tools
#deb http://repo.mysql.com/apt/debian/ stretch mysql-tools-preview
deb-src http://repo.mysql.com/apt/debian/ stretch mysql-5.7

Run apt update
# apt-get update

Now you are ready to install MySql by issuing command
# apt-get install mysql-server mysql-client
Reading package lists... Done
Building dependency tree     
Reading state information... Done
The following additional packages will be installed:
  libmecab2 mysql-community-client mysql-community-server
The following NEW packages will be installed:
  libmecab2 mysql-client mysql-community-client mysql-community-server
  mysql-server
0 upgraded, 5 newly installed, 0 to remove and 3 not upgraded.
Need to get 36.8 MB of archives.
After this operation, 254 MB of additional disk space will be used.
Do you want to continue? [Y/n]

At the end of installation, you will be ask for MySql root password (Note: this is not root Linux user)
# service mysql status
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enable
   Active: active (running) since Wed 2017-09-20 08:04:27 WIB; 24s ago
 Main PID: 15189 (mysqld)
   CGroup: /system.slice/mysql.service
           └─15189 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysql

Sep 20 08:04:23 ca01 systemd[1]: Starting MySQL Community Server...
Sep 20 08:04:27 ca01 systemd[1]: Started MySQL Community Server.
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


Reference:
  1. http://mysqlrelease.com/2017/06/debian-9-and-mysql-watch-out/
  2. https://dev.mysql.com/downloads/repo/apt/

Monday, September 18, 2017

Debian jessie: upgrade to Debian 9 (codename stretch)

Note:
  1. Debian 9 Stretch does not include MySql, your MySql will replace with MariaDB 10.1. Follow this step  to keep your MySql.
  2. PHP 7.0 will be use. Your PHP application may be not support it.
Upgrade your system and application before performing Debian 9 upgrade.
# apt-get update && apt-get upgrade -y
Note: restart your system if needed.

Install apt-listchanges
# apt-get install apt-listchanges

Edit your apt source and add Debian 9 (stretch) repository:
#deb http://security.debian.org/ jessie/updates main
#deb-src http://security.debian.org/ jessie/updates main

# Indonesia (main)
#deb http://kambing.ui.ac.id/debian/ jessie main
deb http://kambing.ui.ac.id/debian/ stretch main contrib

# NON FREE
#deb http://httpredir.debian.org/debian jessie main contrib non-free

# BACKPORT
#deb http://ftp.de.debian.org/debian jessie-backports main

# Google chrome
#deb http://dl.google.com/linux/chrome/deb/ stable main
Note: You can choose other closest mirror to you or use "deb http://mirrors.kernel.org/debian stretch main contrib".

To add CD-ROM
# apt-cdrom add

Do minimal upgrade by running apt update and apt-get upgrade
# apt-get update
...
# apt-get upgrade
...

You are ready for distribution upgrade. Edit /etc/apt/sources.list
#deb http://security.debian.org/ jessie/updates main
#deb-src http://security.debian.org/ jessie/updates main
deb http://security.debian.org/ stretch/updates main
deb-src http://security.debian.org/ stretch/updates main

#optional
#deb  http://deb.debian.org/debian stretch-updates main

# Indonesia (main)
# deb http://mirrors.kernel.org/debian stretch main contrib
deb http://kambing.ui.ac.id/debian/ stretch main contrib

# NON FREE
deb http://httpredir.debian.org/debian stretch main contrib non-free

# BACKPORT
deb http://ftp.de.debian.org/debian stretch-backports main

Note: you need to enable NON FREE repository for firmware upgrade

Do distribution upgrade
# apt-get update && apt-get dist-upgrade

Distribution upgrade will take some times depend on your connection speed. At the end of packages upgrade, you will need to interact with system.
Restart your system and enable 3rd party repository such as google chrome, virtualmin, odoo, etc. Perform final upgrade/update.
# apt-get update && apt-get upgrade -y

Your Debian 9 (stretch) is ready. :)
# uname -an
Linux saturn 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u3 (2017-08-06) x86_64 GNU/Linux

Note:
  1. A new configuration may apply, please carefully to choose a new configuration or your existing one (the option show as keep local).
  2. Default document root apache2 folder will change from /var/www/ to /var/www/html.
  3. Apache2 will run under linux user and group 'www-data'.
  4. To replace php5 to php7.0 follow this step

References: 

Friday, September 8, 2017

Windows 10 Build 15063: Fix Display Brightness on Amd

After upgrade to WIndows 10 build 15063, display brightness can not be change. To fix this we need to change value in registry.
Open regedit and change this value
  • HKEY_LOCAL_MACHINE> SYSTEM> CurrentControlSet> Control> Class> {4d36e968-e325-11ce-bfc1-08002be10318}> 0000 > KMD_EnableBrightnessInterface2 to 0
  • HKEY_LOCAL_MACHINE> SYSTEM> CurrentControlSet> Control> Class> {4d36e968-e325-11ce-bfc1-08002be10318}> 0001 > KMD_EnableBrightnessInterface2 to 0
Restart your Windows.

References:

https://community.amd.com/thread/184667

Friday, August 25, 2017

Android Studio: how to use Google Play service 11.2 release

To use latest Google Play services 11.2 release, we need to meet some requirements.
Here are my environment:
  • Android Studio 2.3.3
  • Android SDK Build-Tools 26.0.1
  • Google Play Service 43
  • Android Support Repository, rev 47
  • Android SDK Platform 26

1. Start from Google Play services 11.2 release, Google Play services dependcies are now abailable via maven.google.com. We need to change our application Grandle build scripts.

  1. Open Tab 1:Project, select Android
  2. Expand Grandle Scripts
  3. Open build.grandle (Project: [your project name])
  4. Find and add google() inside allprojects like this:
allprojects {
  repositories {
    jcenter()
    maven {
      url 'https://dl.google.com/dl/android/maven2/'
      // url 'https://maven.google.com' // NOT WORK
      // Alternative URL is 'https://dl.google.com/dl/android/maven2/'
    }
  }
}

2. Google Play services 11.2 release requires Android SDK Platform 26. You need to install it from SDK Manager and used it.
Open Tab 1:Project, select Android

  1. Expand Grandle Scripts
  2. Open build.grandle (Module: app)
  3. Make sure you use Android SDK Platform 26
android {
  compileSdkVersion 26
  buildToolsVersion "26.0.1"
  defaultConfig {
    ...
    targetSdkVersion 26
    ...
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

3. You can change and use Google Service 11.2 for example to use Google Adsmob
Open Tab 1:Project, select Android

  1. Expand Grandle Scripts
  2. Open build.grandle (Module: app)
dependencies {
  ...
  compile 'com.google.android.gms:play-services-ads:11.2.2'
  ...
}

References:

Monday, August 21, 2017

Debian Jessie: CPU frequency scaling to prevent over heat on laptop's cpu

To prevent over heat on laptop's CPU when used, we need to limit its frequency below maximum. We need cpufrequtils to do that.
To install CPU frequency scaling tools:
# apt-get install cpufrequtils
Show CPU info
# cpufreq-info
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 10.0 us.
  hardware limits: 1000 MHz - 1.67 GHz
  available frequency steps: 1.67 GHz, 1.33 GHz, 1000 MHz
  available cpufreq governors: powersave, userspace, conservative, ondemand, performance
  current policy: frequency should be within 1000 MHz and 1.67 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1.67 GHz (asserted by call to hardware).
  cpufreq stats: 1.67 GHz:30.20%, 1.33 GHz:3.69%, 1000 MHz:66.10%  (10888)
analyzing CPU 1:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 1
  CPUs which need to have their frequency coordinated by software: 1
  maximum transition latency: 10.0 us.
  hardware limits: 1000 MHz - 1.67 GHz
  available frequency steps: 1.67 GHz, 1.33 GHz, 1000 MHz
  available cpufreq governors: powersave, userspace, conservative, ondemand, performance
  current policy: frequency should be within 1000 MHz and 1.67 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1.67 GHz (asserted by call to hardware).
  cpufreq stats: 1.67 GHz:28.63%, 1.33 GHz:3.90%, 1000 MHz:67.47%  (10888)
To show available frequency
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
1667000 1333000 1000000
For kernel 3.16, edit file /etc/init.d/cpufrequtils, change MIN_SPEED to 1000000 and MAX_SPEED to 1333000. For example:
...
MAX_SPEED="1333000"
MIN_SPEED="1000000"
...
NOTE: Frequency must in range in # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
Reload system daemon
# systemctl daemon-reload
References: