个人工具

“OpenVZ”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
安装 zookeeper 面板 zkdash
安装 zookeeper 面板 zkdash
第221行: 第221行:
 
  cd zkdash
 
  cd zkdash
 
  pip install -r requirements.txt
 
  pip install -r requirements.txt
 +
 +
安装 mysql 数据库
 +
apt-get install mysql-server
 +
mysqladmin create zkdash
 +
 +
修改数据库配置和连接属性:
 +
vim conf/conf.yml
 +
 +
同步数据
 
  python ./bin/syncdb.py
 
  python ./bin/syncdb.py
  
 
启动:
 
启动:
 
  cd zkdash
 
  cd zkdash
  python init.py -port=8888
+
  screen python init.py -port=80

2016年4月27日 (三) 11:04的版本

OpevnVZ 一些自用初始化脚本

服务端

准备

系统 centos 6.7

安装 dnsmasq

yum install dnsmasq
sed -i "[email protected]#resolv-file.*[email protected]resolv-file=/etc/resolv.masqdns"
cp /etc/resolv.conf /etc/resolv.masqdns
echo "nameserver 127.0.0.1" > /etc/resolv.conf
chkconfig dnsmasq on
service dnsmasq start

安装 openvz

wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo
rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ
yum install vzkernel
cat << "EOF" >> /etc/sysctl.conf
# On Hardware Node we generally need
# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0

# Enables source route verification
net.ipv4.conf.all.rp_filter = 1

# Enables the magic-sysrq key
kernel.sysrq = 1

# We do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
EOF

sysctl -p
echo "SELINUX=disabled" > /etc/sysconfig/selinux
yum install vzctl vzquota ploop
reboot

安装 OpenVZ Web Panel

gem sources -a http://rubygems.org
gem update --system 1.8.25
wget -O - https://raw.githubusercontent.com/sibprogrammer/owp/master/installer/ai.sh | \
bash -s DOWNLOAD_URL=http://owp.softunity.com.ru/download/ovz-web-panel-latest.tgz
chkconfig owp on

面板默认登陆用户名密码:admin/admin

注意,安装完毕OpenVZ的内核后,需要重启服务器再安装面板,面板需要将ruby的版本控制在1.8.25。

删除面板的代码:

wget -O - https://raw.githubusercontent.com/sibprogrammer/owp/master/installer/ai.sh | sh -s UNINSTALL=1

配置防火墙

iptables -A INPUT -p tcp -m tcp --dport 3000 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE
/etc/init.d/iptables save

vz 配置

vim /etc/sysconfig/vz
mkdir /home/vz
cp -ra /vz/* /home/vz
mv /vz /vz_bak
ln -s /home/vz /

客户机

基本环境配置

sed -i "s/archive.ubuntu.com/mirrors.163.com/" /etc/apt/sources.list
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3B4FE6ACC0B21F32
apt-get update && apt-get -y dist-upgrade
locale-gen --lang zh_CN.UTF-8
dpkg-reconfigure locales
update-locale LANG=zh_CN.UTF-8
rm /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo "Asia/Shanghai" >/etc/timezone
apt-get install sudo screen
adduser ubuntu
adduser ubuntu sudo

安装java

apt-get install openjdk-7-jdk

安装数据库 postgresql

apt-get install postgresql postgresql-contrib
sed -i "s/#\(include_if_exists.*\)/\1/" /etc/postgresql/9.3/main/postgresql.conf
echo "listen_addresses = '*'" >> /etc/postgresql/9.3/main/exists.conf
echo "host    all             all             0.0.0.0/0            md5" >> /etc/postgresql/9.3/main/pg_hba.conf
/etc/init.d/postgresql restart

设置数据库密码

sudo -u postgres psql postgres
postgres=# \password postgres
postgres=# \quit

安装 uuid 扩展

sudo -u postgres psql postgres
postgres=# CREATE EXTENSION "uuid-ossp";
CREATE EXTENSION
postgres=# select uuid_generate_v4(); 
          uuid_generate_v4           
--------------------------------------
a4829383-e6f9-419f-a567-196ccf72b190
(1 row)

postgres=# select uuid_generate_v1(); 
          uuid_generate_v1           
--------------------------------------
ffc5a0fa-156b-11e5-a568-6f5620948752
(1 row)

下载wildfly

su ubuntu
cd
wget http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.tar.gz
tar xzvf wildfly-8.2.0.Final.tar.gz
mv wildfly-8.2.0.Final wildfly
rm wildfly-8.2.0.Final.tar.gz
echo 'JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address=0.0.0.0"' >> /home/ubuntu/wildfly/bin/standalone.conf
echo 'JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address.management=0.0.0.0"' >> /home/ubuntu/wildfly/bin/standalone.conf
echo 'ubuntu=35291eedea6d270cb71fe7dfd36d0c89' >> /home/ubuntu/wildfly/standalone/configuration/mgmt-users.properties
echo 'ubuntu=' >> /home/ubuntu/wildfly/standalone/configuration/mgmt-groups.properties
cd /home/ubuntu/wildfly/standalone/deployments
wget https://jdbc.postgresql.org/download/postgresql-9.4-1200.jdbc41.jar

建立数据库

sudo -u postgres createdb core -E UTF8 -T template0

配置wildfly数据源

cd /home/ubuntu/wildfly/bin
./jboss-cli.sh --connect

创建数据源的命令为:

data-source add --name=core --jndi-name=java:/core --driver-name=postgresql-9.4-1200.jdbc41.jar --connection-url=java:postgresql:core --user-name=postgres --password=postgres --transaction-isolation==TRANSACTION_READ_COMMITTED --min-pool-size=10 --max-pool-size=250

例如:

[[email protected]:9990 /] data-source add --name=core --jndi-name=java:/core --driver-name=postgresql-9.4-1200.jdbc41.jar --connection-url=java:postgresql:core --user-name=postgres --password=postgres --transaction-isolation==TRANSACTION_READ_COMMITTED --min-pool-size=10 --max-pool-size=250
[[email protected]:9990 /] exit

安装 rabbitmq

echo "deb http://www.rabbitmq.com/debian/ testing main" > /etc/apt/sources.list.d/rabbitmq.list
wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
apt-key add rabbitmq-signing-key-public.asc
apt-get update
apt-get install rabbitmq-server
rabbitmq-plugins enable rabbitmq_management
rabbitmqctl add_user webuser 123456
rabbitmqctl set_user_tags webuser monitoring
----权限----
rabbitmqctl  set_permissions -p / user '.*' '.*' '.*'

访问: http://IP:15672/

安装 mongodb

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org

安装 redis

sudo apt-get install software-properties-common
apt-add-repository ppa:chris-lea/redis-server
apt-get update
apt-get install redis-server

安装 redis群集

至少准备3台服务器 修改 /etc/redis/redis.conf 文件:

bind 0.0.0.0
appendonly yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
service redis-server restart

在其中一台上执行:

wget http://download.redis.io/releases/redis-3.0.7.tar.gz
tar xzvf redis-3.0.7.tar.gz
apt-get install ruby
cd redis-3.0.7
gem install redis

添加群集

./src/create --replicas 0 192.168.X.1:6379 192.168.X.2:6379 192.168.X.3:6379

测试

redis-cli -c
127.0.0.1:6379> set a 1
127.0.0.1:6379> get a 
"1"

安装 zookeeper

wget http://archive.apache.org/dist/zookeeper/stable/zookeeper-3.4.6.tar.gz
tar -zxvf zookeeper-3.4.6.tar.gz -C /opt
ln -s /opt/zookeeper-3.4.6 /opt/zookeeper
cp /opt/zookeeper/conf/zoo_sample.cfg /opt/zookeeper/conf/zoo.cfg
mkdir /opt/zookeeper/data
sed -i 's/dataDir=.*$/dataDir=\/opt\/zookeeper\/data/' /opt/zookeeper/conf/zoo.cfg

启动

/opt/zookeeper/bin/zkServer.sh start

关闭

/opt/zookeeper/bin/zkServer.sh stop

安装 zookeeper 面板 zkdash

apt-get install git python-pip libmysqld-dev python-dev
git clone https://github.com/ireaderlab/zkdash.git
cd zkdash
pip install -r requirements.txt

安装 mysql 数据库

apt-get install mysql-server
mysqladmin create zkdash

修改数据库配置和连接属性:

vim conf/conf.yml

同步数据

python ./bin/syncdb.py

启动:

cd zkdash
screen python init.py -port=80