forked from owen7005/kjyw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
342 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#!/bin/bash | ||
# | ||
### | ||
# Filename: install_cobbler.el6.sh | ||
# Author: roguo.wei - [email protected] | ||
# Description: | ||
# Last Modified: 2017-04-07 10:20 | ||
# Version: 1.0 | ||
### | ||
|
||
server_ip=10.10.2.100 | ||
|
||
# install epel | ||
echo "install epel..." | ||
#yum list |grep -E '^epel' | ||
rpm -qa |grep -i epel &> /dev/null | ||
if [ $? -eq 0 ];then | ||
echo "epel alread installed" | ||
else | ||
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm | ||
if [ $? -eq 0 ];then | ||
echo "epel install successfully" | ||
else | ||
echo "epel install faild" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# disable selinux | ||
echo "disable selinux..." | ||
sed -i '/^SELINUX=/ s/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config | ||
setenforce 0 | ||
#getenforce | ||
sestatus | ||
|
||
# disable iptables | ||
echo "disable iptables..." | ||
service iptables stop | ||
chkconfig iptables off | ||
|
||
# install cobbler | ||
for i in cobbler cobbler-web tftp tftp-server xinetd dhcp httpd mod_wsgi mod_ssl rsync | ||
do | ||
rpm -qc ${i} &> /dev/null | ||
if [ $? -ne 0 ];then | ||
echo -n "install ${i}..." | ||
yum install -y ${i} &> /dev/null | ||
if [ $? -eq 0 ];then | ||
echo "ok" | ||
else | ||
echo "faild" | ||
fi | ||
else | ||
echo "${i} alread installed" | ||
fi | ||
done | ||
|
||
# install packages what cobbler needs | ||
for i in pykickstart debmirror python-ctypes python-cheetah python-netaddr python-simplejson python-urlgrabber PyYAML syslinux cman fence-agents createrepo mkisofs yum-utils | ||
do | ||
rpm -qc ${i} &> /dev/null | ||
if [ $? -ne 0 ];then | ||
echo -n "install ${i}..." | ||
yum install -y ${i} &> /dev/null | ||
if [ $? -eq 0 ];then | ||
echo "ok" | ||
else | ||
echo "faild" | ||
fi | ||
else | ||
echo "${i} alread installed" | ||
fi | ||
done | ||
|
||
echo -n "configing cobbler..." | ||
# config httpd | ||
sed -i "s/#ServerName www.example.com:80/ServerName ${server_ip}:80/" /etc/httpd/conf/httpd.conf | ||
sed -i 's/#LoadModule/LoadModule/g' /etc/httpd/conf.d/wsgi.conf | ||
|
||
# config tftp | ||
sed -i '/disable/c disable = no' /etc/xinetd.d/tftp | ||
#sed -i '/disable/c disable = no' /etc/cobbler/tftpd.template | ||
|
||
# config rsysnc | ||
sed -i -e 's/= yes/= no/g' /etc/xinetd.d/rsync | ||
|
||
# config debmirror | ||
sed -i -e 's/@dists=.*/#@dists=/' /etc/debmirror.conf | ||
sed -i -e 's/@arches=.*/#@arches=/' /etc/debmirror.conf | ||
|
||
# config cobbler | ||
pwd=$(openssl passwd -1 -salt 'random-phrase-here' '111111') | ||
sed -i "s@default_password_crypted: .*@default_password_crypted: ${pwd}@" /etc/cobbler/settings | ||
sed -i "s/server: 127.0.0.1/server: ${server_ip}/g" /etc/cobbler/settings | ||
sed -i "s/next_server: 127.0.0.1/next_server: ${server_ip}/g" /etc/cobbler/settings | ||
# pxe安装 只允许一次,防止误操作( 在正式环境有用。实际测试来,这个功能可以屏蔽掉 ) | ||
sed -i 's/pxe_just_once: 0/pxe_just_once: 1/g' /etc/cobbler/settings | ||
sed -i 's/manage_rsync: 0/manage_rsync: 1/g' /etc/cobbler/settings | ||
sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings | ||
|
||
# config dhcp | ||
cp /etc/cobbler/dhcp.template{,.ori} | ||
sed -i 's/DHCPDARGS=.*/DHCPDARGS=eth0/' /etc/sysconfig/dhcpd | ||
cat dhcp.template > /etc/cobbler/dhcp.template | ||
|
||
echo "ok" | ||
|
||
chkconfig httpd on | ||
chkconfig xinetd on | ||
chkconfig cobblerd on | ||
chkconfig dhcpd on | ||
/etc/init.d/httpd restart | ||
/etc/init.d/xinetd restart | ||
/etc/init.d/cobblerd restart | ||
echo -e "\ncobbler get-loaders..." | ||
cobbler get-loaders | ||
echo -e "\ncobbler sync..." | ||
cobbler sync | ||
echo -e "\ncobbler check..." | ||
cobbler check | ||
/etc/init.d/dhcpd restart |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
# | ||
### | ||
# Filename: install_keepalived.sh | ||
# Author: roguo.wei - [email protected] | ||
# Description: | ||
# Last Modified: 2016-11-09 00:57 | ||
# Version: 1.0 | ||
### | ||
|
||
KEEPALIVED_USER="keepalived" | ||
KEEPALIVED_VERSION="1.2.24" | ||
KEEPALIVED_INSTALL_DIR="/usr/local" | ||
|
||
yum install -y kernel-devel openssl openssl-devel &> /dev/null | ||
ln -s /usr/src/kernels/`uname -r`/ /usr/src/linux | ||
|
||
# check keepalived user | ||
id -u ${KEEPALIVED_USER=} &> /dev/null | ||
[ $? -ne 0 ] && useradd -M -s /bin/bash ${KEEPALIVED_USER} | ||
|
||
# check tar file | ||
if [ ! -f keepalived-${KEEPALIVED_VERSION}.tar.gz ];then | ||
echo "keepalived tar file not exists." | ||
echo "download from offical website..." | ||
wget http://www.keepalived.org/software/keepalived-1.2.24.tar.gz | ||
else | ||
tar xf keepalived-${KEEPALIVED_VERSION}.tar.gz | ||
fi | ||
|
||
# comline keepalived | ||
pushd keepalived-${KEEPALIVED_VERSION} | ||
./configure --sysconf=/etc &> /dev/null | ||
make &> /dev/null | ||
make install &> /dev/null | ||
popd | ||
/bin/cp /usr/local/sbin/keepalived /usr/bin/ | ||
|
||
# config log | ||
sed -i 's@^KEEPALIVED_OPTIONS=.*@KEEPALIVED_OPTIONS="-D -d -S 0"@' /etc/sysconfig/keepalived | ||
#cat >> "local0.* /var/log/keepalived/keepalived.log" /etc/rsyslog.conf | ||
cat > /etc/rsyslog.d/keepalived.conf << EOF | ||
local0.* /var/log/keepalived.log | ||
&~ | ||
EOF | ||
/etc/init.d/rsyslog restart &> /dev/null | ||
|
||
# man config | ||
|
||
# | ||
/etc/init.d/keepalived start | ||
chmod +x /etc/init.d/keepalived | ||
chkconfig keepalived on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/bin/bash | ||
# | ||
### | ||
# Filename: install_mariadb.sh | ||
# Author: roguo.wei - [email protected] | ||
# Description: | ||
# Last Modified: 2017-01-17 00:31 | ||
# Version: 1.0 | ||
### | ||
|
||
INSTALL_DIR="/opt/app" | ||
DATA_DIR="/opt/data" | ||
MARIADB_GROUP="mysql" | ||
MARIADB_USER="mysql" | ||
MARIADB_VERSION="10.1.20" | ||
ROOT_PASSWD="root" | ||
#mariadb-10.1.20-linux-x86_64.tar.gz | ||
TAR_NAME="mariadb-${MARIADB_VERSION}-linux-x86_64.tar.gz" | ||
UNTAR_NAME="mariadb-${MARIADB_VERSION}-linux-x86_64" | ||
|
||
# check mariadb user | ||
echo -n "check MariaDB user... " | ||
id -u ${MARIADB_USER} &> /dev/null | ||
if [ $? -ne 0 ];then | ||
groupadd ${MARIADB_GROUP} | ||
useradd -g ${MARIADB_GROUP} ${MARIADB_USER} | ||
fi | ||
echo "ok" | ||
|
||
# check install dir | ||
[ ! -d "${INSTALL_DIR}" ] && mkdir -p ${INSTALL_DIR} | ||
[ ! -d "${DATA_DIR}" ] && mkdir -p ${DATA_DIR} | ||
|
||
# check mariadb file | ||
if [ ! -f ${TAR_NAME} ];then | ||
wget http://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-${MARIADB_VERSION}/bintar-linux-x86_64/mariadb-${MARIADB_VERSION}-linux-x86_64.tar.gz | ||
fi | ||
|
||
# untar file | ||
echo -n "untar file ..." | ||
tar -xf ${TAR_NAME} -C ${INSTALL_DIR} | ||
ln -s ${INSTALL_DIR}/${UNTAR_NAME} ${INSTALL_DIR}/mysql | ||
ln -s ${INSTALL_DIR}/${UNTAR_NAME} /usr/local/mysql | ||
echo "ok" | ||
|
||
# init db and config | ||
echo -n "init db..." | ||
${INSTALL_DIR}/mysql/scripts/mysql_install_db --user=${MARIADB_USER} --basedir=${INSTALL_DIR}/mysql --datadir=${DATA_DIR} | ||
[ $? -ne 0 ] && exit 1 | ||
cp ${INSTALL_DIR}/mysql/support-files/mysql.server /etc/init.d/mysqld | ||
echo "ok" | ||
|
||
[ -f /etc/my.cnf ] && mv /etc/my.cnf{,.ori} | ||
\cp -rf $(cd `dirname $0` && pwd)/my.cnf /etc/my.cnf | ||
|
||
# set server id | ||
IPADDR=$(/sbin/ifconfig eth0|grep "inet addr"|awk '{print $2}'|awk -F":" '{print $2}') | ||
SERVER_ID=$(echo $IPADDR|awk -F"." '{print $4}') | ||
sed -i "s#server-id = .*#server-id = ${SERVER_ID}#g" /etc/my.cnf | ||
sed -i "s#datadir = .*#datadir = ${DATA_DIR}#g" /etc/my.cnf | ||
|
||
# set purview | ||
chown -R root ${INSTALL_DIR}/${UNTAR_NAME} | ||
chown -R ${MARIADB_USER} ${DATA_DIR} | ||
chmod +x /etc/init.d/mysqld | ||
|
||
# start mariadb | ||
${INSTALL_DIR}/mysql/bin/mysqld_safe --user=${MARIADB_USER} & &> /dev/null | ||
[ $? -ne 0 ] && exit 1 || echo "mariadb started ok" | ||
|
||
# set root passwd | ||
sleep 10 | ||
${INSTALL_DIR}/mysql/bin/mysqladmin -uroot password "${ROOT_PASSWD}" | ||
if [ $? -ne 0 ];then | ||
echo "change password for root failed!" | ||
exit 1 | ||
else | ||
echo "change password for root to :${ROOT_PASSWD}" | ||
fi | ||
|
||
# | ||
chkconfig mysqld on | ||
ln -sv ${INSTALL_DIR}/mysql/include /usr/include/mysql | ||
echo '/${INSTALL_DIR}/mysql/lib' > /etc/ld.so.conf.d/mysql.conf | ||
ldconfig | ||
|
||
# set path | ||
echo -n "set path... " | ||
cat >> /etc/profile << EOF | ||
# mariadb path | ||
PATH=\$PATH:${INSTALL_DIR}/mysql/bin | ||
export PATH | ||
EOF | ||
echo "ok" | ||
. /etc/profile | ||
|
||
echo "mariadb installed successfully!" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/bin/bash | ||
# | ||
### | ||
# Filename: install_redis.sh | ||
# Author: roguo.wei - [email protected] | ||
# Description: | ||
# Last Modified: 2016-12-09 15:39 | ||
# Version: 1.0 | ||
### | ||
|
||
REDIS_VERSION="3.2.3" | ||
REDIS_USER="" | ||
REDIS_AUTH="123456" | ||
|
||
REDIS_INSTALL_DIR="" | ||
REDIS_PORT="6379" | ||
REDIS_CONF="/etc/redis/6379.conf" | ||
REDIS_LOG="/var/log/redis_6379.log" | ||
REDIS_DATA="/var/lib/redis/6379" | ||
REDIS_EXEC="/usr/local/bin/redis-server" | ||
|
||
|
||
# install needed packages | ||
for P in gcc gcc-c++ tcl | ||
do | ||
rpm -qa $P &> /dev/null | ||
if [ $? -ne 0 ];then | ||
echo -n "install $P..." | ||
yum install -y $P &> /dev/null | ||
echo "ok" | ||
else | ||
echo "$P already installed." | ||
fi | ||
done | ||
|
||
# check tar file | ||
if [ ! -e redis-${REDIS_VERSION}.tar.gz ];then | ||
echo "downloading redis..." | ||
wget -c http://download.redis.io/releases/redis-${REDIS_VERSION}.tar.gz | ||
fi | ||
|
||
tar xf redis-${REDIS_VERSION}.tar.gz | ||
pushd redis-${REDIS_VERSION} | ||
echo -n "install redis..." | ||
make install &> /dev/null | ||
if [ $? -eq 0 ];then | ||
make test &> /dev/null | ||
[ $? -eq 0 ] && echo "ok" || echo "failed" | ||
else | ||
echo "instal redis-${REDIS_VERSION} failed." | ||
exit 1 | ||
fi | ||
|
||
# init redis server | ||
echo "${REDIS_PORT} | ||
${REDIS_CONF} | ||
${REDIS_LOG} | ||
${REDIS_DATA} | ||
${REDIS_EXEC} | ||
" | utils/install_server.sh | ||
|
||
popd | ||
|
||
|
||
# config redis server | ||
sed -i 's@bind 127.0.0.1@bind 0.0.0.0@' /etc/redis/6379.conf | ||
sed -i "s@^# requirepass foobared@requirepass ${REDIS_AUTH}@" /etc/redis/6379.conf | ||
|
||
# start redis service | ||
/etc/init.d/redis_6379 restart |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.