分类目录归档:Linux

centos elasticsearch 安装

download and install via https://www.elastic.co/downloads/

yum install https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.1.0/elasticsearch-2.1.0.rpm

make data and logs dir

mkdir -p /data/elastic/data
mkdir -p /data/elastic/logs
chown -R elasticsearch:elasticsearch /data/elastic/

edit config /etc/elasticsearch.yml

path.data: /data/elastic/data
path.logs: /data/elastic/logs
network.host: 127.0.0.1

edit start script /etc/init.d/elasticsearch

LOG_DIR="/data/elastic/logs"
DATA_DIR="/data/elastic/data"

install java jdk

yum install java-1.8.0-openjdk

start

systemctl enalbe elasticsearch
/etc/init.d/elasticsearch start

test

/etc/init.d/elasticsearch status
curl http://127.0.0.1:9200/

centos Redis 安装

make data dir for redis

mkdir /data/redis
chown -R redis:redis /data/redis

modify config /etc/redis.conf

daemonize yes
dir /data/redis/
appendonly yes
requirepass mypassword

restart

systemctl enalbe redis
systemctl start redis

fedora登录开启numlock

在登录Gnome 桌面时打开小键盘的Num Lock

sudo yum install numlockx
sudo cp /etc/gdm/Init/Default  /etc/gdm/Init/Default_backup
sudo gedit /etc/gdm/Init/Default

在文档末尾增加

if [ -x /usr/bin/numlockx ]; then
  /usr/bin/numlockx on
fi

保存退出,重启X server或下次登录Gnome就可以发现num lock灯亮了

linux crontab 文件位置和日志位置

文件位置

位置一般在/var/spool/cron/下,如果你是root用户,那下面有个root文件,建议日常备份,避免误删除导致crontab 文件丢失;

日志文件位置

默认情况下,crontab中执行的日志写在/var/log下,如:

#ls /var/log/cron*
/var/log/cron /var/log/cron.1 /var/log/cron.2 /var/log/cron.3 /var/log/cron.4

crontab的日志比较简单,当crond执行任务失败时会给用户发一封邮件。恰巧在我们的一台服务器上发现一个任务没有正常执行,而且crond发邮件也失败了。通过看mail的日志,看到是磁盘空间不足造成的。
可以将每条 crontab中的任务增加自己的日志,有利于查找执行失败原因。

0 6 * * * /root/script/ss.sh >> /root/for_crontab/mylog.log 2>&1

把错误输出和标准输出都输出到mylog.log中。

如crontab 没有成功,检测crontab 服务是否启动,

/etc/init.d/crond status 
/etc/init.d/crond restart

cron 是系统守护进程,位置:

/etc/init.d/crond

参数:
start
stop
restart
reload
等等

来源:http://blog.csdn.net/hittata/article/details/7713072

centos 安装 mqtt

安装服务端和客户端

wget -O /etc/yum.repos.d/mqtt.repo download.opensuse.org/repositories/home:/oojah:/mqtt/CentOS_CentOS-6/home:oojah:mqtt.repo
yum update
yum install mosquitto mosquitto-clients
chkconfig mosquitto on
service mosquitto start

amazon aws linux下python环境安装

允许远程通过密码登录

给root设置一个密码,允许远程通过密码登录

chmod 400 xxx.pem
ssh -i xxx.pem ec2-user@host-ip    
sudo passwd root
sudo su -
vim /etc/ssh/sshd_config 

/etc/ssh/sshd_config内容如下

PermitRootLogin yes
PasswordAuthentication yes
UsePAM yes

然后

service sshd reload

开启epel

amazon aws如果采用redhat需要额外收授权费,目前aws官方2014.3基于centos 6,许多软件版本较旧,可以通过epel软件仓库安装一些新软件

yum-config-manager --enable epel
yum update

安装基本环境

yum groupinstall "Development tools" -y
yum install openssl-devel libxslt-devel libxml2-devel libffi-devel -y

安装mysql客户端

vim /etc/yum.repos.d/MariaDB.repo

# MariaDB 5.5 CentOS repository list - created 2014-09-13 05:43 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

安装MariaDB客户端

yum install MariaDB-client mysql-devel -y

安装redis客户端

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum-config-manager --enable remi
yum install redis -y

安装mongodb客户端

vim /etc/yum.repos.d/mongodb.repo

[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1

安装mongodb客户端

yum update
yum install mongodb-org-shell -y

安装python环境

# yum install centos-release-SCL (aliyun only)
yum install python27*
yum install freetype-devel libjpeg-devel libpng-devel
# scl enable python27 bash (aliyun only)
virtualenv --no-site-packages /data/pyenv
source /data/pyenv/bin/activate
pip install redis cryptography sqlalchemy flask simplejson mongoengine python-amazon-product-api scrapy mysql-python gunicorn gevent

安装glusterfs客户端

#install glusterfs repo
wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo
#fix it for amazon linux
sed -i 's/$releasever/6/g' /etc/yum.repos.d/glusterfs-epel.repo 

#install glusterfs
yum install -y glusterfs-fuse

#setup fstab
echo "172.31.42.77:/pcvol /data_pcvol glusterfs defaults,noatime 0 0" >> /etc/fstab

#mount
mkdir /data_pcvol
mount -a
ls /data_pcvol

挂载日志磁盘

lsblk
mkfs -t ext4 /dev/xvdf
echo '/dev/xvdf       /data_log   ext4    defaults,nofail        0       2' >> /etc/fstab
mkdir /data_log
mount -a

centos时区设置

方法1:

tzselect

方法2:

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

安装ntp

yum install ntp

更新时间。连网更新时间,如果成功,将系统时间,写入BOIS

ntpdate time.windows.com && hwclock -w  

启用ntpd

chkconfig ntpd on
/etc/init.d/ntpd start