1.修改安装配置文件
wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz
tar xzf oneinstack-full.tar.gz
备分 AND 修改option.cof 文件
# Nginx Apache and PHP-FPM process is run as $run_user(Default "www"), you can freely specify
run_user=www
# set the default install path, you can freely specify
nginx_install_dir=/data/services/nginx
tengine_install_dir=/data/services/tengine
openresty_install_dir=/data/services/openresty
apache_install_dir=/data/services/apache
tomcat_install_dir=/data/webservers/tomcat
mysql_install_dir=/data/services/mysql
mariadb_install_dir=/data/services/mariadb
percona_install_dir=/data/services/percona
alisql_install_dir=/data/services/alisql
pgsql_install_dir=/data/services/pgsql
mongo_install_dir=/data/services/mongodb
php_install_dir=/data/services/php
pureftpd_install_dir=/data/services/pureftpd
memcached_install_dir=/data/services/memcached
redis_install_dir=/data/services/redis
python_install_dir=/data/services/python
openssl_install_dir=/data/services/openssl
imagick_install_dir=/data/services/imagemagick
gmagick_install_dir=/data/services/graphicsmagick
curl_install_dir=/data/services/curl
# Add modules
nginx_modules_options=''
php_modules_options=''
#########################################################################
# database data storage directory, you can freely specify
mysql_data_dir=/data/services/mysql/data
mariadb_data_dir=/data/services/mariadb/data
percona_data_dir=/data/services/percona/data
alisql_data_dir=/data/services/alisql/data
pgsql_data_dir=/data/services/pgsql/data
mongo_data_dir=/data/services/mongodb/data
# web directory, you can customize
wwwroot_dir=/data/wwwroot
# nginx Generate a log storage directory, you can freely specify.
wwwlogs_dir=/data/wwwlogs
#########################################################################
# [MySQL/MariaDB/Percona/AliSQL] automatically generated, You can't change
dbrootpwd=
# [PostgreSQL] automatically generated, You can't change
dbpostgrespwd=
# [MongoDB] automatically generated, You can't change
dbmongopwd=
#########################################################################
# Backup Dest directory, change this if you have someother location
backup_dir=/data/backup
# How many days before the backup directory will be removed
expired_days=5
# local ; remote ; upyun ; local,upyun
backup_destination=
# db ; web, You can't change
backup_content=
# aliyun OSS Bucket, You can't change
oss_bucket=
# qiniu Bucket, You can't change
qiniu_bucket=
# The backup of the database, You can't change
db_name=
# The backup of the website, You can't change
website_name=
# oneinstack.tar.gz md5, You can't change
oneinstack_md5=
./oneinstack/install.sh —nginx_option 1 —tomcat_option 2 —jdk_option 2 —db_option 15 —dbinstallmethod 1 —dbrootpwd oneinstack —pureftpd —redis —memcached —iptables —reboot
./oneinstack/install.sh —nginx_option 1 —tomcat_option 2 —jdk_option 2 —db_option 15 —dbinstallmethod 1 —dbrootpwd oneinstack —pureftpd —redis —memcached —iptables —reboot
p
yum -y install wget screen curl python #for CentOS/Redhat
wget http://mirrors.linuxeye.com/oneinstack-full.tar.gz #包含源码,国内外均可下载
tar xzf oneinstack-full.tar.gz
cd oneinstack #如果需要修改目录(安装、数据存储、Nginx日志),请修改options.conf文件
screen -S oneinstack #如果网路出现中断,可以执行命令screen -R oneinstack
重新连接安装窗口
./install.sh #注:请勿sh install.sh或者bash install.sh这样执行
Nginx/Tengine/OpenResty:service nginx {start|stop|status|restart|reload|configtest}
MySQL/MariaDB/Percona:service mysqld {start|stop|restart|reload|status}
PHP:service php-fpm {start|stop|restart|reload|status}
HHVM(hhvm进程交给supervisord管理):service supervisord {start|stop|status|restart|reload}
Apache:service httpd {start|restart|stop}
Tomcat:service tomcat {start|stop|status|restart}
Pure-Ftpd:service pureftpd {start|stop|restart|status}
Redis:service redis-server {start|stop|status|restart|reload}
Memcached:service memcached {start|stop|status|restart|reload}
2.安装数据库Mongodb4.0.0
2.1 下载
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon2-4.0.0.tgz
2.2 解压
tar -zxvf mongodb-linux-x86_64-amazon2-4.0.0.tgz
2.3 拷贝到自己的所需要的安装目录
mv mongodb-linux-x86_64-amazon2-4.0.0 /data/service/mongodb
2.4 设置环境变量
vim /etc/profile
export PATH=/data/service/mongodb/bin:$PATH
source /etc/profile
2.5创建的数据存储目录、日志存储目录及日志文件
mkdir -p /data/services/mongodb/data/db
mkdir -p /data/services/mongodb/conf/
mkdir -p /data/services/mongodb/logs
touch /data/services/mongodb/logs/mongod.log
chmod -R 777 /data/logs/mongod.log
2.6调整shell资源的设置,以防频繁访问MongoDB产生错误导致无法连接MongoDB实例
ulimit -n 25000 #同一时刻最多开启文件数
ulimit -u 25000 #同一时刻最多开启程序数
2.7配置文件mongod.conf
vim /data/services/mongodb/config/mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /data/services/mongodb/logs/mongod.log
# Where and how to store data.
storage:
dbPath: /data/services/mongodb/data/db
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /data/services/mongodb/data/db/mongod.pid
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
# unixDomainSocket:
# enabled: false
#security:
# authorization: enabled
#operationProfiling:
#replication:
#sharding:
2.8 设置MongoDB开机自启动 (未用)
vim /etc/rc.local
rm -rf /data/mongodb/mongodb1/mongod.lock
/usr/local/mongodb/bin/mongod -f /data/conf/mongodb1.conf //启动实例
2.9 启动MongoDB数据库
mongod -f /data/services/mongodb/config/mongod.conf
如有glibc 2.18 包缺失,要升级一下
2.10 检查MongoDB进程
netstat -tunlp | grep mongod
2.11 停止MongoDB数据库
mongod -f /data/services/mongodb/config/mongod.conf --shutdown
2.12 本地客户端连接并访问MongoDB数据库(默认端口为:27017)
mongo
2.13 相关命令
mongod.exe负责开机
mongo.exe负责运行数据库(开机)
mongoimport.exe负责导入数据库
mongoexport.exe负责输出数据库
mongorestore.exe负责备份数据库
2.14 设置用户与配置开关
设置用户后,开启mongodb权限开关
#切换数据库
use admin
db.createUser({user: "admin",pwd: "Root@123",roles: [ { role: "root", db: "admin" } ]});
#(这个命令是解决问题的重点)
exit
#切换数据库
use bdd
db.createUser({user: "bdd",pwd: "bdd2018",roles: [{ role: "readWrite", db: "bdd" }]});
exit
db.createUser({user: "bdd",pwd: "PlM_pro_pw2018",roles: [{ role: "readWrite", db: "bdd" }]});
vim /data/services/mongodb/config/mongod.conf
security:
authorization: enabled
防火墙设置
vim /etc/sysconfig/iptables
#特别提示:很多网友把这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,正确的应该是添加到默认的22端口这条规则的下面
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 27017 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
-A INPUT -j REJECT –reject-with icmp-host-prohibited
-A FORWARD -j REJECT –reject-with icmp-host-prohibited
COMMIT
vim /etc/sysconfig/iptables
#service iptables restart
Redirecting to /bin/systemctl restart iptable.service
Failed to issue method call: Unit iptable.service failed to load: No such file or directory.
据说从某个版本的Linux系统(CenterOS/RedHat)后就将service命令改了,如下
#systemctl restart iptables.service
#iptables -L
重启防火墙成功~~~~