Search This Blog

Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts

Monday, May 8, 2023

configure logrotate to not delete log files after rotation

copy: Make a copy of the log file, but don’t change the original at all.
copytruncate: Truncate the original log file in place after creating a copy.

An example: /etc/logrotate.d/mds
/var/log/mds/mds-app-*.log {
    daily
    copytruncate
    rotate 30
    dateext
    missingok
    notifempty
    sharedscripts
}

Tuesday, May 2, 2023

Debian network performance tweak

Increase network read and write buffer on debian/Ubuntu server:

Add 2 lines at the end of /etc/sysctl.conf:
# Socket Receive Buffer
net.core.rmem_max = 4194304
# Socket Send Buffer
net.core.wmem_max = 16777216
load the changes:
sudo sysctl -p

4194304 = 4 MB
16777216 = 16 MB

Tuesday, March 28, 2023

Block / Frobid a package installation on Debian

Try to block apparmor automatic install everything doing apt dist-upgrade.

Create a file: /etc/apt/preferences.d/99-apparmor
Package: apparmor
Pin: release *
Pin-Priority: -1
Reference: https://wiki.debian.org/AptConfiguration#Prevent.2Fselective_installation_from_third-party_a_repository

Friday, November 25, 2022

Growing a ext4 disk on a cloud / VMware VM

Normal I use GParted CD boot a VM to growing a Linux ext4 disk partition. Or using LVM. It's way easier on Windows VM. I tried cloud-utils tool on a Debian 10 VM on VMware ESXi 7. Just a bare ext4 partition without LVM. It should works on any other Cloud plantform like: AWS, Oracle or Google. Install cloud-utils after increase the disk size from the Cloud Control Console:
sudo apt-get install -y cloud-utils
################### ### Before ########## ###################
df -h
	Filesystem      Size  Used Avail Use% Mounted on
	/dev/sda1        16G   11G  4.2G  72% /
	/dev/sdb1       295G  247G   33G  89% /data
################### ### grow /dev/sdb1 ### ###################
echo 1 > /sys/class/block/sdb/device/rescan
growpart /dev/sdb 1
	CHANGED: partition=1 start=2048 old: size=629143552 end=629145600 new: size=880801759,end=880803807

resize2fs /dev/sdb1
	resize2fs 1.44.5 (15-Dec-2018)
	Filesystem at /dev/sdb1 is mounted on /data; on-line resizing required
	old_desc_blocks = 38, new_desc_blocks = 53
	The filesystem on /dev/sdb1 is now 110100219 (4k) blocks long.
################### ### grow /dev/sda1 ### ###################
echo 1 > /sys/class/block/sda/device/rescan
growpart /dev/sda 1
	CHANGED: partition=1 start=2048 old: size=33550336 end=33552384 new: size=83883999,end=83886047

resize2fs /dev/sda1
	resize2fs 1.44.5 (15-Dec-2018)
	Filesystem at /dev/sda1 is mounted on /; on-line resizing required
	old_desc_blocks = 2, new_desc_blocks = 5
	The filesystem on /dev/sda1 is now 10485499 (4k) blocks long.
################### ### After ########### ###################
df -h
	Filesystem      Size  Used Avail Use% Mounted on
	/dev/sda1        40G   11G   27G  29% /
	/dev/sdb1       413G  247G  146G  63% /data

Tuesday, October 11, 2022

Fix Ubuntu/Debian server [Systemd Timesyncd Time] checkmk alert [Cannot reasonably calculate time since last synchronization (hosts time is running ahead)]

My checkmk server through alert on Ubuntu/Debian servers: Cannot reasonably calculate time since last synchronization (hosts time is running ahead)
# systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Drop-In: /usr/lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: active (running) since Mon 2022-09-26 17:47:50 EDT; 2 weeks 1 days ago
     Docs: man:systemd-timesyncd.service(8)
 Main PID: 443 (systemd-timesyn)
   Status: "Synchronized to time server for the first time 208.81.1.244:123 (0.debian.pool.ntp.org)."
    Tasks: 2 (limit: 4722)
   Memory: 1.7M
   CGroup: /system.slice/systemd-timesyncd.service
           └─443 /lib/systemd/systemd-timesyncd

Sep 26 17:47:50 Minecraft systemd[1]: Starting Network Time Synchronization...
Sep 26 17:47:50 Minecraft systemd[1]: Started Network Time Synchronization.
Sep 26 17:47:50 Minecraft systemd-timesyncd[443]: Synchronized to time server for the first time 208.81.1.244:123 (0.debian.pool.ntp.org).
Update the configuration: /etc/systemd/timesyncd.conf
[Time]
NTP=ca.pool.ntp.org
FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org
RootDistanceMaxSec=5
PollIntervalMinSec=32
PollIntervalMaxSec=2048
Restart the systemd-timesyncd.service
root@Minecraft:~# systemctl restart systemd-timesyncd.service
root@Minecraft:~# systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
  Drop-In: /usr/lib/systemd/system/systemd-timesyncd.service.d
           └─disable-with-time-daemon.conf
   Active: active (running) since Tue 2022-10-11 20:11:36 EDT; 3s ago
     Docs: man:systemd-timesyncd.service(8)
 Main PID: 1796 (systemd-timesyn)
   Status: "Synchronized to time server for the first time 209.115.181.110:123 (ca.pool.ntp.org)."
    Tasks: 2 (limit: 4722)
   Memory: 1.3M
   CGroup: /system.slice/systemd-timesyncd.service
           └─1796 /lib/systemd/systemd-timesyncd

Oct 11 20:11:36 Minecraft systemd[1]: Starting Network Time Synchronization...
Oct 11 20:11:36 Minecraft systemd[1]: Started Network Time Synchronization.
Oct 11 20:11:36 Minecraft systemd-timesyncd[1796]: Synchronized to time server for the first time 209.115.181.110:123 (ca.pool.ntp.org).

Friday, June 17, 2022

fix gitolite perl error: rebuild locales

I run gitolite3 on a Debian 10 Server. Got this error when try to push from etckeeper by git push:
remote: perl: warning: Setting locale failed.
remote: perl: warning: Please check that your locale settings:
remote:         LANGUAGE = (unset),
remote:         LC_ALL = (unset),
remote:         LANG = "en_CA.UTF-8"
remote:     are supported and installed on your system.
remote: perl: warning: Falling back to the standard locale ("C").
Spent a lot of time try to set the LANGUAG, LC_ALL and LANG on the git client side. None of them works. End up rebuild locales on the gitolite3 host server:
sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales

Thursday, May 27, 2021

Suggestion: disable irqbalance service on Virtual Guests (Virtual Machine)

irqbalance is a Linux daemon that distributes interrupts over among the processors and cores in your computer system. The design goal of irqbalance is to do find a balance between power savings and optimal performance. To a large degree, the work irqbalance does is invisible to you. The daemon balances savings in power consumption with performance. On Virtual Guests (Virtual Machine). It does not really make sense because unless you are pinning the guest to specific CPUs and IRQs and dedicated net/storage hardware, you will likely not see the benefits you would on bare metal. On my Debian VM:
mds@debian:~# dpkg -l|grep irq
ii  irqbalance                    1.5.0-3                      amd64        Daemon to balance interrupts for SMP systems
root@download:~# dpkg --purge irqbalance
(Reading database ... 32086 files and directories currently installed.)
Removing irqbalance (1.5.0-3) ...
Purging configuration files for irqbalance (1.5.0-3) ...
Processing triggers for systemd (241-7~deb10u7) ...

Wednesday, June 3, 2020

Fix apt-get update error on old Debian jessie and wheezy 2020,2021

I have to install packages on some old Debian jessie and wheezy.
They all have backports packages installed.
Here is my apt configuration files /etc/apt/sources.list for Debian jessie:
deb http://deb.debian.org/debian/ jessie main
deb http://security.debian.org/ jessie/updates main
deb http://archive.debian.org/debian/ jessie-backports main
And Debian wheezy: /etc/apt/sources.list
deb http://archive.debian.org/debian/ wheezy main
deb http://archive.debian.org/debian/ wheezy-backports main
deb http://archive.debian.org/debian-security/ wheezy/updates main
Change the file, then:
apt-get clean all
apt-get update
You may get some error like:
Error 1:
W: GPG error: http://archive.debian.org wheezy Release: The following signatures were invalid: KEYEXPIRED 1587841717 KEYEXPIRED 1557241909 The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7638D0442B90D010
W: GPG error: http://archive.debian.org wheezy-backports Release: The following signatures were invalid: KEYEXPIRED 1587841717 The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7638D0442B90D010
W: GPG error: http://archive.debian.org wheezy/updates Release: The following signatures were invalid: KEYEXPIRED 1587841717 The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 9D6D8F6BC857C906
Fix:
apt-key adv --recv-key --keyserver keyserver.ubuntu.com 7638D0442B90D010
apt-key adv --recv-key --keyserver keyserver.ubuntu.com 9D6D8F6BC857C906
Error 2:
E: Release file for http://archive.debian.org/debian-security/dists/wheezy/updates/Release is expired (invalid since 419d 23h 58min 55s). Updates for this repository will not be applied.
Fix:
echo "Acquire::Check-Valid-Until false;" | tee -a /etc/apt/apt.conf.d/10-nocheckvalid
Just keep apt-get clean and apt-get update.
Please left message her if you have any issues that can not be revolved.

Monday, October 8, 2018

Debian 9.3 Stretch Unattended-upgrades not detecting Linux kernel security update by default

All my Debian 9.3 "Stretch" instance is showing a kernel update as being available: linux-image-amd64/stable 4.9+8 amd64 But Default Unattended-upgrades config fails to install kernel security update. My configure of '/etc/apt/apt.conf.d/50unattended-upgrades'
Unattended-Upgrade::Origins-Pattern {
        "origin=Debian,codename=${distro_codename},label=Debian-Security";
        "origin=nginx,label=nginx";
        "site=packages.sury.org";
};
I have to add one extra line:
        "origin=Debian,codename=${distro_codename},label=Debian";
Then the Kernel upgrade got pickup.
Unattended-Upgrade::Origins-Pattern {
        "origin=Debian,codename=${distro_codename},label=Debian";
        "origin=Debian,codename=${distro_codename},label=Debian-Security";
        "origin=nginx,label=nginx";
        "site=packages.sury.org";
};
Reference of the fix for this bug:
https://unix.stackexchange.com/questions/414991/unattended-upgrades-not-detecting-linux-kernel-security-update-by-default
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=886415

Thanks for Sharing and Happy Thanks Giving!

Wednesday, October 3, 2018

Debian 9 unattended upgrades Nginx and PHP 7 repo apt

I install Nginx mainline version from Nginx's officel Repo. PHP 7.2 FPM from packages.sury.org. In order to let the unattended upgrades do the work for me.
  1. I add /etc/apt/apt.conf.d/50unattended-upgrades
  2. Unattended-Upgrade::Origins-Pattern {
      ...
            "origin=nginx,label=nginx";
            "site=packages.sury.org";
    };
    
  3. Testing it out
  4. # unattended-upgrade --debug --dry-run
    Initial blacklisted packages: 
    Initial whitelisted packages: 
    Starting unattended upgrades script
    Allowed origins are: ['origin=Debian,codename=stretch,label=Debian-Security', 'origin=nginx,label=nginx', 'site=packages.sury.org']
    pkgs that look like they should be upgraded: 
    Fetched 0 B in 0s (0 B/s)                                                                                                                                             
    fetch.run() result: 0
    blacklist: []
    whitelist: []
    No packages found that can be upgraded unattended and no pending auto-removals
    

Friday, September 28, 2018

How to Upgrade check-mk to latest version on Debian 8 jessie

You don't need shutdown before the dpkg package upgrade.
  1. Download and upgrade to the latest check-mk package:
  2. # dpkg -l|grep check-mk
    ii  check-mk-agent                 1.2.8p15-1                         all          Check_MK Agent for Linux
    ii  check-mk-raw-1.4.0p8           0.jessie                           amd64        Check_MK is a full featured system monitoring
    
    # wget https://mathias-kettner.de/support/1.4.0p36/check-mk-raw-1.4.0p36_0.jessie_amd64.deb
    
    # sudo dpkg -i check-mk-raw-1.4.0p36_0.jessie_amd64.deb 
    Selecting previously unselected package check-mk-raw-1.4.0p36.
    (Reading database ... 54001 files and directories currently installed.)
    Preparing to unpack check-mk-raw-1.4.0p36_0.jessie_amd64.deb ...
    Unpacking check-mk-raw-1.4.0p36 (0.jessie) ...
    Setting up check-mk-raw-1.4.0p36 (0.jessie) ...
    New default version is 1.4.0p36.cre.
    update-alternatives: using /omd/versions/1.4.0p36.cre to provide /omd/versions/default (omd) in manual mode
    Installing systemd service: omd.init
    Disabling startup through SysV (/etc/init.d/*) scripts
    Activating startup during system boot
    Processing triggers for systemd (215-17+deb8u7) ...
    Processing triggers for man-db (2.7.0.2-5) ...
    
  3. After package upgrade su to omd site user to perform site update:

  4. # su - milllion-doller-server
    OMD[milllion-doller-server]:~$ omd status
    mkeventd:       running
    rrdcached:      running
    npcd:           running
    nagios:         running
    apache:         running
    crontab:        running
    -----------------------
    Overall state:  running
    
    OMD[milllion-doller-server]:~$ omd update
    Please completely stop 'milllion-doller-server' before updating it.
    
    OMD[milllion-doller-server]:~$ omd stop
    Removing Crontab...OK
    Stopping dedicated Apache for site milllion-doller-server....OK
    Stopping nagios......OK
    Stopping npcd...OK
    Stopping rrdcached...waiting for termination...OK
    Stopping mkeventd...killing 21922....OK
    OMD[milllion-doller-server]:~$ omd update
    Unmounting temporary filesystem...OK
    Cleaning up temp filesystem...OK
    
    +-------------------------------------------------------------+
    | You are going to update the site milllion-doller-server     |
    | from version 1.4.0p8.cre to version                         |
    | 1.4.0p36.cre. This will include updating all of             |
    | you configuration files and merging changes in              |
    | the default files with changes made by you. In              |
    | case of conflicts your help will be needed.                 |
    +-------------------------------------------------------------+
    |                 < Abort >                          |
    +-------------------------------------------------------------+
    
    
    2018-09-28 13:32:09 - Updating site 'milllion-doller-server' from version 1.4.0p8.cre to 1.4.0p36.cre...
    
     * Updated        etc/nagvis/nagvis.ini.php
     * Updated        etc/nagvis/conf.d/demo.ini.php
    Finished update.
    
  5. Start the omd site after upgrade and check the status:

  6. OMD[milllion-doller-server]:~$ omd start
    Creating temporary filesystem /omd/sites/milllion-doller-server/tmp...OK
    Starting mkeventd...OK
    Starting rrdcached...OK
    Starting npcd...OK
    Starting nagios...2018-09-28 13:32:15 [6] updating log file index
    2018-09-28 13:32:15 [6] updating log file index
    OK
    Starting dedicated Apache for site milllion-doller-server...OK
    Initializing Crontab...OK
    
    OMD[milllion-doller-server]:~$ omd status
    mkeventd:       running
    rrdcached:      running
    npcd:           running
    nagios:         running
    apache:         running
    crontab:        running
    -----------------------
    Overall state:  running
    

Thursday, May 3, 2018

Redmine 3.45 install Debian 9 stretch with SystemD

Please notice this is a quick and slim example only for non-multi user environment.

It fits my need very well.

Can hold up to 50 Clients at same time.

I am using SQLite as database because I love it.

apt-get install curl dirmngr
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable

source /etc/profile.d/rvm.sh
rvm requirements

rvm install 2.4

rvm use 2.4 --default
ruby -v

echo "gem: --no-ri --no-rdoc" >> ~/.gemrc

gem install bundler --no-ri --no-rdoc
gem install sqlite3 --no-ri --no-rdoc


cd /var/www/redmine/
cp config/database.yml.example config/database.yml

My config/database.yml:
production:
  adapter: sqlite3
  database: db/redmine.sqlite3

Start install:
bundle install --without development test rmagick
bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake redmine:load_default_data

Testing it out:
bundle exec rails server webrick -e production -b 192.168.1.33 -p 80

Run as systemd service: add file

/etc/systemd/system/redmine.service
[Unit]
Description=Redmine server
After=syslog.target
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/bin/bash -c 'source /etc/profile.d/rvm.sh && cd /var/www/redmine && bundle exec rails server webrick -e production -b 192.168.1.33 -p 80'

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300

[Install]
WantedBy=multi-user.target

To start it:
systemctl enable redmine.service
systemctl start redmine.service

What to improve:

  1. I run it as [root] user it may not super safe, but this is just for internal use.

  2. Redmine Log rotation, please reference my old post: Redmine Log rotation

Friday, November 4, 2016

mongodb 3.2 logrotate

Installed latest mongodb 3.2 on Debian 8 Jessie.

It does not came with logrotate configure file.

Here is mine:

Add reopen in /etc/mongod.conf


systemLog:
  logAppend: true
  logRotate: reopen


Using -SIGUSR1 to rotate the log file:

/etc/logrotate.d/mongodb


/var/log/mongodb/*.log {
    daily
    rotate 10
    dateext
    missingok
    notifempty
    sharedscripts
    postrotate
        /bin/kill -SIGUSR1 `cat /var/lib/mongodb/mongod.lock 2> /dev/null` 2> /dev/null || true
    endscript
}

Friday, October 28, 2016

check_mk agent start by systemd Debian Jessie

I use check_mk everywhere.

For the old school, on Debian system you need install xinetd to start it.
But since we have systemd in Debian 8 Jessie, it will be much cleaner to do systemd way.

Here is how I do it:

  1. Fist if you previous using xinetd, stop and remove it.

  2. # service xinetd stop
    # apt-get purge xinetd
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
      libfile-copy-recursive-perl libx265-79 update-inetd
    
    Use 'apt-get autoremove' to remove them.
    The following packages will be REMOVED:
      xinetd*
    0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
    After this operation, 255 kB disk space will be freed.
    Do you want to continue? [Y/n] y
    (Reading database ... 34520 files and directories currently installed.)
    Removing xinetd (1:2.3.15-3) ...
    Purging configuration files for xinetd (1:2.3.15-3) ...
    Processing triggers for man-db (2.7.0.2-5) ...

    And run autoremove to cleanup
    # apt-get autoremove
    
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages will be REMOVED:
      libfile-copy-recursive-perl libx265-79 update-inetd
    0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
    After this operation, 3,244 kB disk space will be freed.
    Do you want to continue? [Y/n] y
    (Reading database ... 34490 files and directories currently installed.)
    Removing update-inetd (4.43) ...
    Removing libfile-copy-recursive-perl (0.38-1) ...
    Removing libx265-79:i386 (1.9-3~bpo8+1) ...
    Processing triggers for man-db (2.7.0.2-5) ...
    Processing triggers for libc-bin (2.19-18+deb8u6) ...

  3. Then check your check_mk agent version:
  4. # dpkg -l|grep check-mk
    ii  check-mk-agent                      1.2.8p12-1                        all          Check_MK Agent for Linux

  5. Next enable the check_mk in systemd autostart.

  6. # systemctl enable check_mk.socket
    Created symlink from /etc/systemd/system/sockets.target.wants/check_mk.socket to /etc/systemd/system/check_mk.socket.

  7. Finally start the service.

  8. # systemctl start check_mk.socket

    A special notice, because the systemd not allow the IP rules like xinetd does.
    You will have to update your firewall to restrict other accessing.

    Hope this helps, please let me know if you have any questions.

Monday, August 8, 2016

Keepalived not detect haproxy status on Debian Jessie

Keepalived not detect haproxy status on Debian Jessie

vi /etc/keepalived/keepalived.conf


vrrp_script chk_haproxy {           # Requires keepalived-1.1.13
script "killall -0 haproxy" # cheaper than pidof
interval 2 # check every 2 seconds
weight 2 # add 2 points of prio if OK
}

vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 51
priority 101 # 101 on master, 100 on backup
virtual_ipaddress {
192.168.0.100
}
track_script {
chk_haproxy
}
}



The reason is keepall command does not installed!

Just install


apt-get install psmisc



Then everything works fine.

Monday, May 16, 2016

Debian Jessie Keepalived simple Redis Cluster

Even though keepalived under Debian Jessi give samples of check local service with killall in /usr/share/doc/keepalived/samples/keepalived.conf.vrrp.localcheck

vrrp_script chk_haproxy {
script "killall -0 haproxy" # cheaper than pidof
interval 2 # check every 2 seconds
}


But Jessie only have SystemD. [killall] has been remove with SystemV.
You can still use killall5 which is the SystemV killall command.

But killall5 simulates the killall command of SysV UNIX; it sends the given signal to all processes owned by the calling UID. When does it root, it can do very bad things. BE VERY CAREFUL with the killall command on!


# cat /etc/keepalived/keepalived.conf

vrrp_script chk_redis {
script "pidof redis-server" # pidof inside of killall, just to be safe.
interval 2 # check every 2 seconds
weight 2 # add 2 points of prio if OK
}

vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 59
priority 100 # 101 on master, 100 on backup
virtual_ipaddress {
192.168.1.10
}
track_script {
chk_redis
}
}


In my opinion pidof is safer than killall or killall5.

Friday, April 8, 2016

OMD ssmtp - extremely simple MTA to get mail off the system to a mailhub

ssmtp - extremely simple MTA to get mail off the system to a mail hub

apt-get purge exim4*
apt-get install ssmtp bsd-mailx
mail -s "OMD test email 7" -S from=test@milliondollarserver.com test@milliondollarserver.com

mail -s "OMD test email 7" test@milliondollarserver.com

root@monitor:/etc/ssmtp# cat ssmtp.conf
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
UseTLS=YES
UseSTARTTLS=Yes
mailhub=smtp.gmail.com:587
AuthUser=test@milliondollarserver.com
AuthPass=IFUseeTHISpassWord
AuthMethod=LOGIN

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=monitor.milliondollarserver.com

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES

Reference:
https://wiki.debian.org/sSMTP
http://www.debiantutorials.com/installing-ssmtp-mta-mail-transfer-agent/

Wednesday, March 23, 2016

etckeeper Debian Jessie howto

etckeeper is another great tool for keep a recorder of /etc configuration files changes on your Linux box.

First install etckeeper, it is simple on Debian Jessie:
# apt-get install etckeeper

Generate the key for git server:
root@milliondollarserver:~# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
f2:20:f2:20:f2:20:f2:20:f2:20:f2:20:f2:20:f2:20 root@milliondollarserver
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|                 |
|                 |
|        o        |
|       oSo E     |
|        +.... .. |
|       .....o .+=|
|         ..o +.**|
|           .o.=.B|
+-----------------+

Setup Git:
root@milliondollarserver:~# git config --global user.email root@milliondollarserver.com
root@milliondollarserver:~# git config --global user.name root@milliondollarserver
root@milliondollarserver:~# cd /etc/
root@milliondollarserver:/etc# etckeeper init
root@milliondollarserver:/etc# git commit -m "initial checkin"
[master 7c33032] initial checkin
 4 files changed, 14 insertions(+), 4 deletions(-)
 delete mode 100644 check_mk/mysql.cfg
 create mode 100644 python/debian_config
 create mode 100644 python2.7/sitecustomize.py

Hook it up with my Git server:
cd /etc
git remote rm origin
git remote add origin gitolite3@git.milliondollarserver.com:etckeeper-milliondollarserver

Add auto push:
cd /etc/etckeeper/commit.d
(echo ‘#!/bin/sh’ ; echo ‘git push origin’) > 60git-push
chmod +x 60git-push

Try to push:
cd /etc
git add .
git commit -m “automatically push commits to backup repository”
/etc# git push

You will got warning:
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master


Run these 2 command to push:
:/etc# git config --global push.default simple
:/etc# git push --set-upstream origin master


You should have output like this:
The authenticity of host 'git.milliondollarserver.com (10.10.10.10)' can't be established.
ECDSA key fingerprint is f2:20:f2:20:f2:20:f2:20:f2:20:f2:20:f2:20:f2:20.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.milliondollarserver.com,10.10.10.10' (ECDSA) to the list of known hosts.
Counting objects: 1080, done.
Compressing objects: 100% (717/717), done.
Writing objects: 100% (1080/1080), 498.42 KiB | 0 bytes/s, done.
Total 1080 (delta 109), reused 0 (delta 0)
To gitolite3@git.milliondollarserver.com:etckeeper-sca-app-lb01
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

Debian Jessie install latest stable HAproxy

Debian did a great job to keep update the latest update from software like HAproxy.

To set up the latest stable HAproxy on Debian Jessie, just head to http://haproxy.debian.net/

Debian_Jessie_HAproxy_2016-03-23

And follow the Instructions below.
It's safe and clean.

Instructions for latest release




You need to enable the backports repository :

# echo deb http://httpredir.debian.org/debian jessie-backports main | \
sed 's/\(.*\)-sloppy \(.*\)/&@\1 \2/' | tr @ '\n' | \
tee /etc/apt/sources.list.d/backports.list


Then, use the following commands:
# apt-get update
# apt-get install haproxy -t jessie-backports


You will get the latest release of HAProxy 1.6.

Wednesday, March 9, 2016

Debian Jessie PHP access SQL Server Database

Use FreeTDS and unixODBC for this task.

  1. Installation of the freetds packages with apt-get


  2. apt-get install freetds-common freetds-bin unixodbc php5-sybase
    service apache2 restart



  3. Add configuration into /etc/freetds/freetds.conf


  4. # Kinamo SQL Server
    [test_sqlserver]
    host = milliondollarserver.com
    port = 1433
    tds version = 8.0