常用基础软件安装

备注:

  除部分环境已经给出需要的基础环境之外,其他的请自行安装基础编译环境:

yum install gcc* make openssl openssl-devel openssl-clients -y

1. node环境

下载地址:
    http://nodejs.org/dist/v0.12.2/node-v0.12.2.tar.gz
编译安装:
    ./configure --prefix=/usr/local/nodejs && make &&make install
设置系统环境:
    echo "#set nodejs environment
export PATH=\$PATH:/usr/local/nodejs/bin" >>/etc/profile && source /etc/profile

2.jxcode环境

下载地址:
    https://codeload.github.com/jxcore/jxcore/tar.gz/v0.3.1.1
编译安装:           
    ./configure --prefix=/usr/local/jx && make && make install
设置系统环境:    
    echo "#set rabbitmq environment
export PATH=\$PATH:/usr/local/jx/sbin" >> /etc/profile && source /etc/profile

3. nginx环境

下载地址:
    http://nginx.org/download/nginx-1.10.1.tar.gz
编译安装:
    
    基础依赖环境:
        yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre-devel gd-* GeoIP*
    创建nginx用户及用户组并设置不允许登录系统:
        groupadd -r nginx && useradd -s /sbin/nologin -g nginx -r nginx
    编译:
        ./configure --prefix=/usr/local/nginx --lock-path=/usr/local/nginx/nginx.lock --user=nginx --group=nginx --with-stream --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_geoip_module --with-http_realip_module --with-http_gzip_static_module --http-client-body-temp-path=/usr/local/nginx/client/ --http-proxy-temp-path=/usr/local/nginx/proxy/ --http-fastcgi-temp-path=/usr/local/nginx/fcgi/ --http-uwsgi-temp-path=/usr/local/nginx/uwsgi --http-scgi-temp-path=/usr/local/nginx/scgi --with-pcre --with-file-aio --with-http_image_filter_module --with-http_v2_module && make && make install

 增加设定记录日志内容的模块:

cd /usr/local/src && wget https://codeload.github.com/cfsego/ngx_log_if/zip/master && mkdir -p /usr/local/nginx/module && unzip ngx_log_if-master.zip -d /usr/local/nginx/module/
cd nginx-1.13.4 && ./configure --prefix=/usr/local/nginx --lock-path=/usr/local/nginx/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_geoip_module --with-http_gzip_static_module --http-client-body-temp-path=/usr/local/nginx/client/ --http-proxy-temp-path=/usr/local/nginx/proxy/ --http-fastcgi-temp-path=/usr/local/nginx/fcgi/ --http-uwsgi-temp-path=/usr/local/nginx/uwsgi --http-scgi-temp-path=/usr/local/nginx/scgi --with-pcre --add-module=/usr/local/nginx/module/ngx_log_if --with-file-aio --with-http_image_filter_module && make && make install 

增加tcp 四层代理模块:

--with-stream  

增加mysql 认证模块:

git clone https://github.com/sto/ngx_http_auth_pam_module.git

--add-module=/usr/local/nginx/module/ngx_http_auth_pam_module
pam_mysql-0.7RC1.tar.gz #http://prdownloads.sourceforge.net/pam-mysql/pam_mysql-0.7RC1.tar.gz 

./configure --with-pam=/usr/local/pam_mysql --with-pam-mods-dir=/usr/local/pam_mysql/lib --with-mysql=/usr/local/mysql --with-cyrus-sasl --with-cyrus-sasl2 --with-openssl 

增加http/2支持

--with-http_v2_module

  

  

启动脚本:

  /etc/init.d/nginx  

  chmod +x /etc/init.d/nginx

  chkconfig nginx on

#!/bin/bash
#
# Startup script for Nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid 
# Source function library.
. /etc/rc.d/init.d/functions
  
# Source networking configuration.
. /etc/sysconfig/network
  
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
  
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
  
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
  
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
  
lockfile=/var/lock/subsys/nginx
  
start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}
  
stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}
  
restart() {
    configtest || return $?
    stop
    sleep 1
    start
}
  
reload() {
    configtest || return $?
    echo -n $"Reloading $prog: "
    killproc $nginx -HUP
    RETVAL=$?
    echo
}
  
force_reload() {
    restart
}
  
configtest() {
  $nginx -t -c $NGINX_CONF_FILE
}
  
rh_status() {
    status $prog
}
  
rh_status_q() {
    rh_status >/dev/null 2>&1
}
  
case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart|configtest)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
            ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
        exit 2
esac

  配置文件:

user  nginx;
worker_processes  8;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;


events {
    worker_connections  10240;
}
stream {
	log_format proxy '$remote_addr [$time_local] '
				'$protocol $status $bytes_sent $bytes_received '
				'$session_time "$upstream_addr" '
				'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
 
	access_log logs/tcp.log proxy ;
	open_log_file_cache off;
	tcp_nodelay on;
	include tcp.d/*.conf;

}

http {
	include			mime.types;
	default_type	application/octet-stream;

	log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
					'$status $body_bytes_sent "$http_referer" '
					'"$http_user_agent" "$http_x_forwarded_for"';

	access_log  logs/access.log  main;

	sendfile		on;
	#tcp_nopush		on;

	keepalive_timeout  65;
	server_tokens off; #隐藏版本号
	client_max_body_size 1000m;
	limit_req_zone $binary_remote_addr zone=allips:10m rate=300r/m;
	large_client_header_buffers 4 16k;
	client_body_buffer_size 128k;
	proxy_connect_timeout 600;
	proxy_read_timeout 600;
	proxy_send_timeout 600;
	proxy_buffer_size 64k;
	proxy_buffers   4 32k;
	proxy_busy_buffers_size 64k;
	proxy_temp_file_write_size 64k;

	charset utf8;
	include conf.d/*.conf;  
}

  

  

4. mysql环境

  下载地址:

http://down1.chinaunix.net/distfiles/cmake-2.8.10.2.tar.gz 
http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.32.tar.gz   

  依赖环境:

yum install wget gcc* make openssl openssl-devel openssl-clients ncurses-devel -y && yum groupinstall " Development tools" -y

  cmake编译安装:

./configure --prefix=/usr/local/cmake && make && make install 
echo "#set cmake environment
export PATH=\$PATH:/usr/local/cmake/bin" >> /etc/profile && source /etc/profile

  mysql编译安装:

groupadd mysql && useradd -r -g mysql -s /etc/nologin mysql

mkdir -p /home/mysql/data && mkdir /home/mysql/var

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home/mysql/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/home/mysql/var/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci && make && make install
echo "#set mysql environment
export PATH=\$PATH:/usr/sbin/:/usr/local/mysql/bin" >> /etc/profile && source /etc/profile

  mysql数据库初始化:

 /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/home/mysql/data --user=mysql --default-storage-engine=MyISAM 

  mysql配置文件:my.cnf

[client]
default-character-set=utf8
#auto-rehash
socket = /home/mysql/var/mysql.sock
[mysqld]
port = 3306
slave-skip-errors=1022,1032,1062
skip-name-resolve
basedir = /usr/local/mysql
datadir = /home/mysql/data
socket = /home/mysql/var/mysql.sock
character-set-server=utf8
collation-server=utf8_general_ci
back_log = 300
max_connections = 5000
max_connect_errors = 30
table-definition-cache=2000
table-open-cache=4000
max_allowed_packet = 32M
max_heap_table_size = 128M
sort_buffer_size = 16M
join_buffer_size = 16M
#thread_cache_size = 16
#thread_concurrency = 8
query_cache_size = 128M
query_cache_limit = 4M
ft_min_word_len = 8
default-storage-engine=MYISAM
thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
slow-query-log
long_query_time = 6
#master config
# grant replication slave, replication client on *.* to 'root'@'192.168.1.131' identified by 'password';
# ref : http://blog.csdn.net/seteor/article/details/17261733
server-id = 1
log-bin=mysqlmaster-bin
#binlog-do-db = cad #指定需要进行主从的数据库
binlog_cache_size = 4M
binlog_format=mixed
expire_logs_days=3
#binlog-ignore-db=test #不记录test库的binlog
#replicate-ignore-db=test #不复制test库的binlog
sync_binlog=1
sql_mod=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#lower_case_table_names=1
#slave config
#server_id=2
#binlog-do-db = cad
#binlog-ignore-db=test #不记录test库的binlog
#replicate-ignore-db=test #不复制test库的binlog
#log-bin=mysql-bin
#binlog_cache_size = 1M
#binlog_format=mixed
#expire_logs_days=3
key_buffer_size = 128M
read_buffer_size = 8M
read_rnd_buffer_size = 64M
bulk_insert_buffer_size = 256M
myisam_sort_buffer_size = 256M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
skip-federated
#innodb config
innodb_additional_mem_pool_size = 64M
innodb_buffer_pool_size = 512M
innodb_data_file_path = ibdata1:10M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
[mysqldump]
quick
max_allowed_packet = 32M
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 2048M
sort_buffer_size = 2048M
read_buffer = 32M
write_buffer = 32M
[myisamchk]
key_buffer = 2048M
sort_buffer_size = 2048M
read_buffer = 32M
write_buffer = 32M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192

  备注:增加全日志输出

log-output=FILE
general-log=1
general_log_file=/home/mysql/data/mysql-query.log

  设置启动脚本: 

cp /usr/local/src/mysql-5.6.28/support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql && chkconfig mysql on

  设置权限:  

chown -R mysql:mysql /home/mysql
chown -R mysql:mysql /usr/local/mysql 

5. mongodb环境

  下载地址:  

https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.6.6.tgz

  安装:

tar xf /usr/local/src/mongodb-linux-x86_64-2.6.6.tgz -C /usr/local/    
mv /usr/local/mongodb-linux-x86_64-2.6.6  /usr/local/mongodb2.6
环境变量设置:    
echo "#mongodb2.6 environment
export PATH=\$PATH:/usr/local/mongodb2.6/bin/" >> /etc/profile && source /etc/profile
创建目录:    
groupadd -r mongod && useradd -s /sbin/nologin -g mongod -r mongod
mkdir -p /home/mongodb/mongodata    
mkdir -p /home/mongodb/mongolog
chown -R  mongod:mongod  /home/mongodb/mongodata
chown -R  mongod:mongod  /home/mongodb/mongolog
系统环境设置:
vim  /etc/security/limits.conf    
===============================
* soft nproc 640000
* hard nproc 640000
* soft nofile 640000
* hard nofile 640000
===============================
vim /etc/profile  source /etc/profile 
==================
ulimit -n 640000
ulimit -u 640000
==================

  配置文件:/etc/mongod_27018.conf

logpath=/home/mongodb/mongolog/mongod.log    
logappend=true
destination=file 
logRotate=rename  #日志切割脚本由跟参数配合,仅支持3.0以上版本
fork=true
port=27018
dbpath=/home/mongodb/mongodata
pidfilepath=/home/mongodb/mongolog/27018.pid
oplogSize=4096
maxConns=640000
directoryperdb=true
nojournal=true
master=true 

  启动脚本: /etc/init.d/mongod  chmod +x /etc/init.d/mongod  chkconfig mongod on

#!/bin/sh  
# chkconfig: 2345 93 18  
# author:qingbo.song 
# description:MongoDB(MongoDB-2.6.2)  

#默认参数设置
#mongodb 家目录  
MONGODB_HOME=/usr/local/mongodb2.6

#mongodb 启动命令  
MONGODB_BIN=$MONGODB_HOME/bin/mongod

#mongodb 配置文件
MONGODB_CONF=/etc/mongod_27018.conf

#mongodb PID
MONGODB_PID=/home/mongodb/mongolog/27018.pid

#最大文件打开数量限制
SYSTEM_MAXFD=640000

#mongodb 名字  
MONGODB_NAME="mongodb"
. /etc/rc.d/init.d/functions

if [ ! -f $MONGODB_BIN ]
then
        echo "$MONGODB_NAME startup: $MONGODB_BIN not exists! "  
        exit
fi


start(){
	 ulimit -HSn $SYSTEM_MAXFD
	 $MONGODB_BIN --config="$MONGODB_CONF"  
	 ret=$?
	 if [ $ret -eq 0 ]; then
	    action $"Starting $MONGODB_NAME: " /bin/true
	 else
	    action $"Starting $MONGODB_NAME: " /bin/false
	 fi
      
}

stop(){
        PID=$(ps aux |grep "$MONGODB_NAME" |grep "$MONGODB_CONF" |grep -v grep |wc -l) 
        if [[ $PID -eq 0  ]];then
        action $"Stopping $MONGODB_NAME: " /bin/false
        exit
        fi
        kill -HUP `cat $MONGODB_PID`
        ret=$?
        if [ $ret -eq 0 ]; then
                action $"Stopping $MONGODB_NAME: " /bin/true
                rm -f $MONGODB_PID
        else   
                action $"Stopping $MONGODB_NAME: " /bin/false
        fi

}

restart() {

        stop
        sleep 2
        start
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        status)
        status $prog
                ;;
        restart)
                restart
                ;;
        *)
                echo $"Usage: $0 {start|stop|status|restart}"
esac

  mongodb3.2.X部署安装及主从设置参考:

http://www.cnblogs.com/songqingbo/articles/5409396.html

  mongodb设置用户名和密码

mongodb密码和传统数据如mysql等有些区别:

mongodb的用户名和密码是基于特定数据库的,而不是基于整个系统的。所有所有数据库db都需要设置密码
mongodb设置管理用户和密码:

show dbs
在mongodb新版本里并没有admin数据库,但是并不妨碍第2步操作。
use admin 进入admin数据库
创建超级管理员账户
db.createUser({ user: "useradmin", pwd: "adminpassword", roles: ["root"] })
mongodb中的用户是基于身份role的,该管理员账户的 role是 root。 
验证第3步用户添加是否成功
db.auth("useradmin", "adminpassword") 如果返回1,则表示成功。
exit退出系统
db.auth()方法理解为 用户的验证功能
修改配置
sudo vi /etc/mongod.conf
找到#security: 取消注释,修改为:
 
security:
authorization: enabled #注意缩进,缩进参照配置文件其他配置。缩进错误可能第6步重启不成功。
重启mongodb sudo service mongod restart
进入mongodb,用第3步的 管理员账户登录,用该账户创建其他数据库管理员账号
 
use admin
db.auth("useradmin", "adminpassword")
新建你需要管理的mongodb 数据的账号密码。

 
use yourdatabase
db.createUser({ user: "youruser", pwd: "yourpassword", roles: [{ role: "dbOwner", db: "yourdatabase" }] })
rote:dbOwner 代表数据库所有者角色,拥有最高该数据库最高权限。比如新建索引等

新建数据库读写账户

 
use yourdatabase
db.createUser({ user: "youruser2", pwd: "yourpassword2", roles: [{ role: "readWrite", db: "yourdatabase" }] })
该用户用于该数据的读写,只拥有读写权限。

现在数据的用户名和密码就建好了。
可以使用:mongodb://youruser2:yourpassword2@localhost/yourdatabase来链接

 

6. tomcat +java环境

  下载地址:

tomcat下载地址:
    http://apache.opencas.org/tomcat/tomcat-9/v9.0.0.M4/bin/apache-tomcat-9.0.0.M4.tar.gz
jdk下载地址:
    http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.rpm?AuthParam=1459060338_576a5595d42fe20dacf501814e2064d3
   http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz

  tomcat安装:

tar xf apache-tomcat-9.0.0.M4.tar.gz && mv apache-tomcat-9.0.0.M4 /usr/local/tomcat

  jdk安装:

rpm包:yum localinstall jdk-8u77-linux-x64.rpm
tar包:tar xf jdk-8u77-linux-x64.tar.gz -C /usr/local/jdk
    echo "#set java environment
export PATH=\$PATH:/usr/local/jdk/bin:/usr/local/src/jdk/jre/bin" >> /etc/profile && source /etc/profile

7. redis环境

  下载地址:

http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz 
http://download.redis.io/releases/redis-3.0.0.tar.gz

  编译安装:

tcl编译安装:  
tar xf /usr/local/src/tcl8.6.1-src.tar.gz -C /usr/local/
cd /usr/local/tcl8.6.1/unix/ && ./configure && make && make install

redis编译安装:    
tar xf /usr/local/src/redis-3.0.0.tar.gz -C /usr/local/src
cd /usr/local/src/redis-3.0.0 && make test && make PREFIX=/usr/local/redis install

  创建目录:

mkdir -p /home/redis/data/6380  && mkdir -p /home/redis/log && mkdir -p /home/redis/var

  配置文件:/etc/redis/6380.conf

daemonize yes
pidfile /home/redis/var/redis_6380.pid
port 6380
tcp-backlog 511
maxclients 20000
timeout 30
tcp-keepalive 60
loglevel warning
logfile /home/redis/log/redis_6380.log
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /home/redis/data/6380
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
#设置密码
requirepass zesG!rw&#s@qmT!UjV

  

 1 daemonize yes
 2 pidfile /home/redis/redis_6380.pid
 3 port 6380
 4 tcp-backlog 511
 5 maxclients 20000
 6 timeout 30
 7 tcp-keepalive 60
 8 loglevel warning
 9 logfile /home/redis/log/redis_6380.log
10 databases 16
11 save 900 1
12 save 300 10
13 save 60 10000
14 stop-writes-on-bgsave-error yes
15 rdbcompression yes
16 rdbchecksum yes
17 dbfilename dump.rdb
18 dir /home/redis/data/6380
19 slave-serve-stale-data yes
20 slave-read-only yes
21 repl-disable-tcp-nodelay no
22 slave-priority 100
23 appendonly no
24 appendfilename "appendonly.aof"
25 appendfsync everysec
26 no-appendfsync-on-rewrite no
27 auto-aof-rewrite-percentage 100
28 auto-aof-rewrite-min-size 64mb
29 lua-time-limit 5000
30 slowlog-log-slower-than 10000
31 slowlog-max-len 128
32 latency-monitor-threshold 0
33 notify-keyspace-events ""
34 hash-max-ziplist-entries 512
35 hash-max-ziplist-value 64
36 list-max-ziplist-entries 512
37 list-max-ziplist-value 64
38 set-max-intset-entries 512
39 zset-max-ziplist-entries 128
40 zset-max-ziplist-value 64
41 hll-sparse-max-bytes 3000
42 activerehashing yes
43 client-output-buffer-limit normal 0 0 0
44 client-output-buffer-limit slave 256mb 64mb 60
45 client-output-buffer-limit pubsub 32mb 8mb 60
46 hz 10
47 aof-rewrite-incremental-fsync yes
48 notify-keyspace-events Ex
49 protected-mode no
redis3.2.6配置文件

  启动脚本:/etc/init.d/redis-6380   chmod +x /etc/init.d/redis-6380 && chkconfig redis-6380 on

#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig:   - 85 15
# description:  Redis for uzAll session
# processname: redis-server-6379
 
REDISPORT=6380
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli
 
PIDFILE=/home/redis/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
 
case "$1" in
    start)
        if [ -f $PIDFILE ]
        then
                echo "$PIDFILE exists, process is already running or crashed"
        else
                echo "Starting Redis server..."
                $EXEC $CONF
        fi
        ;;
    stop)
        if [ ! -f $PIDFILE ]
        then
                echo "$PIDFILE does not exist, process is not running"
        else
                PID=$(cat $PIDFILE)
                echo "Stopping ..."
                $CLIEXEC -p $REDISPORT shutdown
                while [ -x /proc/${PID} ]
                do
                    echo "Waiting for Redis to shutdown ..."
                    sleep 1
                done
                echo "Redis stopped"
        fi
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac

8. rabbitmq环境

  下载地址:

http://erlang.org/download/otp_src_19.3.tar.gz
https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-generic-unix-3.6.10.tar.xz  #二进制文件不需要编译
https://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10.tar.xz

  依赖环境安装:

yum -y install xmlto python-simplejson python

  编译安装:

otp编译安装:
    tar xf /usr/local/src/otp_src_19.3.tar.gz -C /usr/local/src
    #--with-ssl=/usr 开启ssl支持  erl-ssl
cd /usr/local/src/otp_src_19.3 && ./configure --prefix=/usr/local/erlang --with-ssl=/usr --enable-threads --enable-smp-support --enable-kernel-poll --enable-hipe --without-javac && make && make install echo "#set erlang environment export PATH=\$PATH:/usr/local/erlang/bin" >> /etc/profile && source /etc/profile rabbit编译安装: tar xf rabbitmq-server-3.6.10.tar.gz -C /usr/local/src cd /usr/local/src/rabbitmq-server-3.6.10 && make TARGET_DIR=/usr/local/rabbitmq SBIN_DIR=/usr/local/rabbitmq/bin MAN_DIR=/usr/local/rabbitmq/man DOC_INSTALL_DIR=/usr/local/rabbitmq/doc install 
echo "#set rabbitmq environment export PATH=\$PATH:/usr/local/rabbitmq/sbin" >> /etc/profile && source /etc/profile

  创建用户&&目录:

groupadd -r rabbitmq && useradd -s /sbin/nologin -g rabbitmq -r rabbitmq
mkdir -p /usr/local/rabbitmq/var/log/ /usr/local/rabbitmq/plugins /usr/local/rabbitmq/data
备注:日志存放位置/usr/local/rabbitmq/var/log/
         pid文件存放/usr/local/rabbitmq/var/

  启动脚本:/etc/init.d/rabbit  chmod +x /etc/init.d/rabbit && chkconfig rabbit on

#!/bin/sh
#
# rabbitmq-server RabbitMQ broker
#
# chkconfig: - 80 05
# description: Enable AMQP service provided by RabbitMQ
#
### BEGIN INIT INFO
# Provides:          rabbitmq-server
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Description:       RabbitMQ broker
# Short-Description: Enable AMQP service provided by RabbitMQ broker
### END INIT INFO
# Source function library.
. /etc/init.d/functions
export HOME=/usr/local/rabbitmq
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/erlang/bin/
NAME=rabbitmq-server
DAEMON=/usr/local/rabbitmq/sbin/${NAME}
CONTROL=/usr/local/rabbitmq/sbin/rabbitmqctl
DESC=rabbitmq-server
USER=rabbitmq
ROTATE_SUFFIX=
INIT_LOG_DIR=/usr/local/rabbitmq/var/log/
PID_FILE=/usr/local/rabbitmq/var/rabbitmq.pid
START_PROG="daemon"
LOCK_FILE=/var/lock/subsys/$NAME
test -x $DAEMON || exit 0
test -x $CONTROL || exit 0
RETVAL=0
set -e
[ -f /etc/default/${NAME} ] && . /etc/default/${NAME}
start_rabbitmq () {
    status_rabbitmq quiet
    if [ $RETVAL = 0 ] ; then
        echo RabbitMQ is currently running
    else
        RETVAL=0
        set +e
        RABBITMQ_PID_FILE=$PID_FILE $START_PROG $DAEMON \
            > "${INIT_LOG_DIR}/startup_log" \
            2> "${INIT_LOG_DIR}/startup_err" \
            0<&- &
        $CONTROL wait $PID_FILE >/dev/null 2>&1
        RETVAL=$?
        set -e
        case "$RETVAL" in
            0)
                echo SUCCESS
                if [ -n "$LOCK_FILE" ] ; then
                    touch $LOCK_FILE
                fi
                ;;
            *)
                echo FAILED - check ${INIT_LOG_DIR}/startup_\{log, _err\}
                RETVAL=1
                ;;
        esac
    fi
}
stop_rabbitmq () {
    status_rabbitmq quiet
    if [ $RETVAL = 0 ] ; then
        set +e
        $CONTROL stop ${PID_FILE} > ${INIT_LOG_DIR}/shutdown_log 2> ${INIT_LOG_DIR}/shutdown_err
        RETVAL=$?
        set -e
        if [ $RETVAL = 0 ] ; then
            if [ -n "$LOCK_FILE" ] ; then
                rm -f $LOCK_FILE
            fi
        else
            echo FAILED - check ${INIT_LOG_DIR}/shutdown_log, _err
        fi
    else
        echo RabbitMQ is not running
        RETVAL=0
    fi
}
status_rabbitmq() {
    set +e
    if [ "$1" != "quiet" ] ; then
        $CONTROL status 2>&1
    else
        $CONTROL status > /dev/null 2>&1
    fi
    if [ $? != 0 ] ; then
        RETVAL=3
    fi
    set -e
}
rotate_logs_rabbitmq() {
    set +e
    $CONTROL rotate_logs ${ROTATE_SUFFIX}
    if [ $? != 0 ] ; then
        RETVAL=1
    fi
    set -e
}
restart_running_rabbitmq () {
    status_rabbitmq quiet
    if [ $RETVAL = 0 ] ; then
        restart_rabbitmq
    else
        echo RabbitMQ is not runnning
        RETVAL=0
    fi
}
restart_rabbitmq() {
    stop_rabbitmq
    start_rabbitmq
}
case "$1" in
    start)
        echo -n "Starting $DESC: "
        start_rabbitmq
        echo "$NAME."
        ;;
    stop)
        echo -n "Stopping $DESC: "
        stop_rabbitmq
        echo "$NAME."
        ;;
    status)
        status_rabbitmq
        ;;
    rotate-logs)
        echo -n "Rotating log files for $DESC: "
        rotate_logs_rabbitmq
        ;;
    force-reload|reload|restart)
        echo -n "Restarting $DESC: "
        restart_rabbitmq
        echo "$NAME."
        ;;
    try-restart)
        echo -n "Restarting $DESC: "
        restart_running_rabbitmq
        echo "$NAME."
        ;;
    *)
        echo "Usage: $0 {start|stop|status|rotate-logs|restart|condrestart|try-restart|reload|force-reload}" >&2
        RETVAL=1
        ;;
esac
exit $RETVAL

  设置rabbitmq配置文件:/etc/rabbitmq/rabbitmq-env.conf

RABBITMQ_MNESIA_BASE=/usr/local/rabbitmq/data
RABBITMQ_LOG_BASE=/usr/local/rabbitmq/var/log
RABBITMQ_PLUGINS_DIR=/usr/local/rabbitmq/plugins

  开启rabbit-plugins

rabbitmq-plugins enable rabbitmq_management
service rabbit restart

  设置用户并禁用guest用户

#新增用户
rabbitmqctl  add_user  server  HcvqNFDEuE8ps4OPg70T
#设置权限
rabbitmqctl set_user_tags server administrator

#删除guest用户
rabbitmqctl  delete_user  guest

#修改用户密码
rabbitmqctl  change_password  Username  Newpassword

#查看用户列表
rabbitmqctl  list_users


附录用户级别:

1、administrator 可以登录控制台、查看所有信息、可以对rabbitmq进行管理

2、monitoring  监控者 登录控制台,查看所有信息

3、policymaker  策略制定者  登录控制台,指定策略

4、managment 普通管理员 登录控制台

  

问题:

[root@test rabbitmq]# rabbitmq-plugins enable rabbitmq_management --online
Plugin configuration unchanged.

Applying plugin configuration to rabbit@test... failed.
Error: unable to connect to node rabbit@test: nodedown

DIAGNOSTICS
===========

attempted to contact: [rabbit@test]

rabbit@test:
  * connected to epmd (port 4369) on test
  * epmd reports node 'rabbit' running on port 25672
  * TCP connection succeeded but Erlang distribution failed

  * Authentication failed (rejected by the remote node), please check the Erlang cookie


current node details:
- node name: 'rabbitmq-cli-47@test'
- home dir: /root
- cookie hash: /zJvGPlr21THO6YWIta1BQ==  

解决办法:

/root/.erlang.cookie  与 /usr/local/rabbimq/.erlang.cookie  保持一致即可解决

9. python2.7.8环境:

  依赖环境:

yum -y install zlib zlib-devel openssl-devel gcc python-devel mysql mysql-devel mysql-connector-odbc

  下载地址:

https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
https://pypi.python.org/packages/source/s/setuptools/setuptools-20.6.7.tar.gz
https://pypi.python.org/packages/source/p/pip/pip-8.1.1.tar.gz
https://sourceforge.net/code-snapshots/git/m/my/mysql-python/code.git/mysql-python-code-947b1a2cb72eacb78c86a0a025a3f2110fe14caf.zip
(MySQLdb-1.2)

  安装:

python 2.7.8安装
    cd /usr/local/src/ && tar xf Python-2.7.8.tgz && cd Python-2.7.8
    ./configure --prefix=/usr/local/python2.7.8 && make && make install
    mv /usr/bin/python /usr/bin/python_old && ln -s /usr/local/python2.7.8/bin/python2.7 /usr/bin/python
    sed 's/^#!\/usr\/bin\/python/#!\/usr\/bin\/python2.6' /usr/bin/yum

setuptools编译安装:

    tar xf setuptools-20.6.7.tar.gz 
    cd setuptools-20.6.7
    python setup.py build  
    python setup.py install 

pip编译安装:

    tar xf pip-8.1.1.tar.gz
    cd pip-8.1.1
    python setup.py build  
    python setup.py install

配置系统环境:

    echo "#set python_pip environment
export PATH=\$PATH:/usr/local/python2.7.8/bin" >> /etc/profile && source /etc/profile

MySQLdb编译安装:

  unzip -o mysql-python-code-947b1a2cb72eacb78c86a0a025a3f2110fe14caf.zip
  cd mysql-python-code-947b1a2cb72eacb78c86a0a025a3f2110fe14caf/MySQLdb
  >>vim site.cfg
=============================
threadsafe = False
mysql_config = /usr/bin/mysql_config
===================================
  python setup.py build  
    python setup.py install

 simplejson安装
  pip install simplejson

  

   

posted @ 2016-06-23 17:22  南非波波  阅读(893)  评论(0编辑  收藏  举报