Author Archives: James Coyle

CockroachDB systemd script

Get Social!

This is a simple systemd script for CockroachDB. It works for single node installations or multiple nodes, however you’ll need to manually join each node to the cluster before using the systemd script. 

Create the systemd file and add the following content:

vi /etc/systemd/system/cockroach.service
[Unit]
Description=CockroachDB

[Install]
WantedBy=multi-user.target

[Service]
ExecStartPre=/bin/bash -c "test -f /etc/cockroachdb/hosts && (/bin/systemctl set-environment JOIN_SWITCH=--join=$(test -f /etc/cockroachdb/hosts && cat /dev/null /etc/cockroachdb/hosts)) || exit 0"
ExecStartPre=/bin/bash -c "test -f /etc/cockroachdb/host && (/bin/systemctl set-environment HOST_SWITCH=--host=$(test -f /etc/cockroachdb/host && cat /dev/null /etc/cockroachdb/host)) || exit 0"

ExecStart=/usr/local/bin/cockroach start --certs-dir=/etc/cockroachdb/certs \
                                         --store=/var/data/cockroachdb/ \
                                         --cache=.40 \
                                         --max-sql-memory=.30 \
                                         --external-io-dir=/tmp/cockroachdb/externalio \
                                         --temp-dir=/tmp/ \
                                         --port=26257 \
                                         --http-port=7005 \
                                         --logtostderr=ERROR \
                                         --log-dir=/var/logs/cockroachdb \
                                         $JOIN_SWITCH $HOST_SWITCH

ExecStop=/usr/local/bin/cockroach quit --certs-dir=/etc/cockroachdb/certs
SyslogIdentifier=cockroachdb
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
LimitNOFILE=35000

Note that there are several paths specified in the above file which may need to be tailored to your installation requirements.

Run the following to enable the service on system start, and to start the CockroachDB service.

systemctl enable cockroach # enable on startup
systemctl start cockroach  # start CockroachDB

If your host belongs to a cluster, create a hosts file containing the hosts of other nodes in your cluster that will be read when starting your local node. For multiple nodes, use a comma to separate each hostname and port combination.

vi /etc/cockroachdb/hosts
server1.jamescoyle.net:26257,server2.jamescoyle.net:26257

gitignore file for Eclipse Projects

Get Social!

This is an example of a .gitignore file for an Eclipse project to ensure temporary files, build files and project settings are not added to repository commits.

See .gitignore for more info.

# Java related
target/**
*.jar
*.war
*.ear
*.class

# eclipse specific
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

How to change the listening port for PostgreSQL Database

Category : How-to

Get Social!

The default TCP port for PostgreSQL is usually 5432, however this can easily be changed in the postgresql.conf configuration file, which is the main configuration file for the database server.

In addition to a TCP listening port, PostgreSQL will also a local socket if the server is running in a Linux/ Unix environment. A local socket is the prefered method of connecting to a database as it removes much of the overhead of creating a TCP connection and transferring data. This comes with the limitation that it can only be used if the application accessing the database is on the same machine. In larger or highly available systems this may not be possible.

A TCP connection is the only option of connecting to your PostgreSQL database server from a remote machine. It incurs a small penalty over a local socket and therefore slightly higher latencies and is limited by the network bandwidth available. PostgreSQL Server can be configured to use a local socket, TCP connections or both.

be editing the postgresql.conf file for the following sections however the location of the file is different depending on OS and PostgreSQL version. In Linux you can use the following command to find the file:

locate postgresql.conf
/etc/postgresql/9.5/main/postgresql.conf

As you can see, the server version is included in the file path so you’ll need to check that before trying to open it.

On Windows it’s usually C:\Program Files\PostgreSQL\9.5\data but again, you’ll have to take the version into account.

I’m using Linux for this example, but adjust the following steps to suit your environment. Open the file in your favourite editor.

vi /etc/postgresql/9.5/main/postgresql.conf

Configuring local socket use (Linux/ Unix only)

The unix_socket_directory option indicates the filesystem path to the location of the directory you’d like to hold your socket. Specify a filesystem directory path, usually /var/run/postgresql/ and the socket will be created when the server next starts. Remove or comment (#) the line to disable socket access.

unix_socket_directory= /var/run/postgresql/

Restart the server for the changes to take effect.

service postgresql restart

Setting or changing the TCP port

The port option sets the PostgreSQL server port number that will be used when listening for TCP/ IP connections. The default port number is 5432 but you can change it as required. Use the port option with the
listen_addresses option to control the interface where the port will be listening. Use ‘*’ to listen on all interfaces on the host, specify a single host name or IP address to listen on a single interface, or separate several hostname or IP addresses by space (such as ‘10.10.0.1 10.11.0.1’). Omit both of these options to disable TCP/ IP connections.

port = 2345
listen_addresses='*'

Restart the server for the changes to take effect.

service postgresqlrestart

gitignore file for Nodejs Projects

Tags :

Category : Supporting Scripts

Get Social!

An example gitignore file for Nodejs projects to ensure that local environment variables, build related output and modules are not committed to the git repository.

See .gitignore for more info.

# NodeJS specific #
.nyc_output/
coverage/
node_modules/
npm-debug.log
package-lock.json
test/*.log

gitignore file for Netbeans Projects

Tags :

Category : Supporting Scripts

Get Social!

A gitignore file for most Netbeans projects to keep the build and local configuration files out of your git repository.

See .gitignore for more info.

# NetBeans specific #
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml

# Class Files #
*.class

# Package Files #
*.jar
*.war
*.ear

.gitignore OS generated files

Tags :

Category : Supporting Scripts

Get Social!

A gitignore file to ignore standard OS (usually Windows) generated files. Often you’d use this in addition to a more technology specific gitignore set.

See .gitignore for more info.

# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.*.sw[op]
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

Visit our advertisers

Quick Poll

How many Proxmox servers do you work with?

Visit our advertisers