Create .ssh folder in your user profile and then, don't forget to set environment HOME to %USERPROFILE%
Wednesday, March 22, 2017
Sunday, March 5, 2017
Elasticsearch 5.2 on CentOS 7: ERROR: bootstrap checks failed
Previously, got this error:
So what I do is:
ERROR: bootstrap checks failed max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] max number of threads [1024] for user [username] is too low, increase to at least [2048] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
So what I do is:
vi /etc/security/limits.conf # Add or edit * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096 #EOF /etc/security/limits.conf vi /etc/security/limits.d/90-nproc.conf # changed original soft nproc 1024 to 2048 #* soft nproc 1024 * soft nproc 2048 #EOF /etc/security/limits.d/90-nproc.conf vim /etc/sysctl.conf # Added here vm.max_map_count = 262144 #EOF /etc/sysctl.conf sysctl -p
Tuesday, February 7, 2017
Install GCC 5.3 on CentOS 7.3 with SCL
Another way to enable GCC 5 just for current bash environment,
and then, add this to enablegcc5.sh at /etc/profile.d
There you go
sudo yum install centos-release-scl sudo yum install devtoolset-4-gcc* scl enable devtoolset-4 bash which gcc gcc --version
and then, add this to enablegcc5.sh at /etc/profile.d
#!/bin/bash source scl_source enable devtoolset-4
There you go
sudo cat > /etc/profile.d/gcc5-scl.sh << EOF #!/bin/bash source scl_source enable devtoolset-4 EOF
Friday, February 3, 2017
Simple Advisory Lock for C# via Mono
Mono handled mutex differently from Microsoft dotNET due to platform differences (eventhough the implementation is the same).
So the only simplest method to create mutex-like for advisory lock on mono is by creating a lock file. Criteria:
1. Only one instance of application can be run one time. (not to be confuse application with software and thread!)
2. After the application exit, the application can be run again. (Proper cleanup!)
Hence, this is the simple class for that.
https://gist.github.com/fawildchild/d1ccbf26af5931da6c138599ddd10de6
Straight forward I say.
(ps: Console.ReadKey() at the end)
Walla
So the only simplest method to create mutex-like for advisory lock on mono is by creating a lock file. Criteria:
1. Only one instance of application can be run one time. (not to be confuse application with software and thread!)
2. After the application exit, the application can be run again. (Proper cleanup!)
Hence, this is the simple class for that.
https://gist.github.com/fawildchild/d1ccbf26af5931da6c138599ddd10de6
Straight forward I say.
(ps: Console.ReadKey() at the end)
Walla
Tuesday, January 10, 2017
psql: INSERT, if already exists, SELECT (two cidr version)
It is actually quite weird. I already set that the cidr is not null, but still, i can happily insert null value inside that.
Hence, it come the problem. I can't select if one of the column's value is null. COALESCE didn't help (on its own). Now we have to modify our script a little bit.
One of the solution is setting default value for cidr-typed column. But what value? 0.0.0.0/0 obviously didn't help. Because null is null. 0.0.0.0/0 is everyone.
Now here what i do.
Let say, we have
Hence, the (unoptimized, but working) query is like this:
*change 192.168.43.199 to Address Client and 0.0.0.0 to X Forwarded For Address, both nullable
tadah
Hence, it come the problem. I can't select if one of the column's value is null. COALESCE didn't help (on its own). Now we have to modify our script a little bit.
One of the solution is setting default value for cidr-typed column. But what value? 0.0.0.0/0 obviously didn't help. Because null is null. 0.0.0.0/0 is everyone.
Now here what i do.
Let say, we have
Hence, the (unoptimized, but working) query is like this:
*change 192.168.43.199 to Address Client and 0.0.0.0 to X Forwarded For Address, both nullable
tadah
Monday, January 9, 2017
psql: Insert, if already exists, select
WITH new_browser AS (
INSERT INTO audit_log.browsers ( agent_string )
SELECT 'test8' WHERE NOT EXISTS (SELECT * FROM audit_log.browsers WHERE agent_string = 'test8')
RETURNING browser_id
)
SELECT * FROM new_browser
UNION
SELECT browser_id FROM audit_log.browsers WHERE agent_string = 'test8'
The only problem is that i have to write the insert item/select condition 3 times, for one particular column...
Friday, January 6, 2017
Script to rename hostname and append to /etc/hosts
#!/bin/bash
# save this as anyfile.sh at webserver
# call curl -s http://somewhere.over.the.rainbow/anyfile.sh | sudo bash -s {hostname}
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
if [ $# -eq 0 ]
then echo "Please supply new hostname for this machine."
fi
echo "Hostname entered: " $1
hostnamectl set-hostname $1
echo 127.0.0.1 $1 >> /etc/hosts
cat >> /etc/hosts << EOF
# list of hosts
EOF
systemctl restart systemd-hostnamed
Subscribe to:
Posts (Atom)


