mathz.nu Asterisk Blacklist Hobby webbhotell

2015/03/21

Glassfish 4.1 start script

Filed under: Glassfish,Programering,Server — Mathz @ 18:27

GlassFish logo Ubuntu logo Installing GlassFish 4.1 on Ubuntu 14.10 (last updated 2015-02-05)
This HOWTO explains one way of setting up GlassFish 4.1 under Ubuntu 14.10. Questions or suggestions for improvement can be addressed to shadowm at lyonlabs dot org.

Installing GlassFish
Fronting GlassFish with Apache 2.4
Setting up Database Connection Pools
Installing GlassFish

Download the ZIP file from Oracle. Make sure you have a current JDK installed on your machine (Glassfish 4.1 supports Java 8).
As root, enter the directory you want to install to (I install it in /usr/share) and extract the ZIP file there.
Add the binaries directory of your new installation to the PATH. One way of doing this is to use a profile script in /etc/profile.d. Create a file there whose name ends in .sh, make it executable, and add this line:
export PATH=/usr/share/glassfish4/bin/glassfish/bin:$PATH
Log out and back in to make the change take effect.
Create a group and a user for GlassFish:
addgroup –system glassfish
adduser –system –shell /bin/bash –ingroup glassfish glassfish
Add the following lines to /etc/security/limits.conf to increase the maximum number of open files for the user that Glassfish will run as:
glassfish soft nofile 32768
glassfish hard nofile 65536
You will also need to add this line in /etc/pam.d/su:
session required pam_limits.so
As root, in /usr/share, change the permissions of the newly-created GlassFish directory:
chown -R glassfish:glassfish glassfish4
If you want to use your own domain name instead of the default domain1, become the glassfish user (as root, su – glassfish), then delete the default domain and create a new one:
asadmin delete-domain domain1
asadmin create-domain –savemasterpassword
You will be prompted for new admin and master passwords. If you will be installing on several machines, I suggest that you give your domain the same name as the hostname of the machine you are installing on; that way, you can use the same startup scripts on all machines, using $HOSTNAME for the domain.
Start the domain:
asadmin start-domain
Verify that GlassFish is running by opening a browser on localhost:8080. You should also be able to log in to the admin console on localhost:4848
In order for GlassFish to be able to start from a script, you will also need to create a file containing the domain and master passwords. The startup script given below expects to find a file named passwd.gf in the glassfish user’s home directory; make sure it has glassfish:glassfish ownership and 600 permissions (i.e. readable and writable only by the glassfish user). This is the format of that file:
AS_ADMIN_PASSWORD= AS_ADMIN_MASTERPASSWORD= This is a sysvinit script to make GlassFish start at boot time. To use it, copy it to /etc/init.d, then enable it with update-rc.d:
update-rc.d glassfish-4.1 defaults
update-rc.d glassfish-4.1 enable
This script expects the domain name to be same as the hostname (see above); if that is not the case, edit accordingly. It also expects to find Java in /usr/lib; if you have it installed somewhere else, just change the JPS variable. The script writes to a log file that prints any startup errors, so create that first (as root):
touch /var/log/glassfish-4.1
chown glassfish.glassfish /var/log/glassfish-4.1
Verify that the script works by running it as root:
/etc/init.d/glassfish-4.1 start
You’ll want to do some tuning before using GlassFish in production (these suggestions come from Jean-François Arcand’s excellent blog entry). In Configuration / JVM Settings / JVM Options, replace these two options:
-client
-Xmx512m
with these:
-server
-XX:+AggressiveHeap -Xmx3500m -Xms3500m -Xss128k -XX:+DisableExplicitGC -XX:-UseLoopPredicate -XX:+UseCompressedOops
back to top

Fronting GlassFish with Apache 2.4

Many people use Apache to handle redirects, SSL, &c., while leaving the heavy lifting to GlassFish. It also avoids the issue of running GlassFish on port 80 (which is privileged under Linux), since Apache is set up that way to begin with. Here is one way to do it, using the Apache AJP connector (here are links to the reference guides for the jk.conf and workers.properties files given below).
Set MaxRequestWorkers to 400 in /etc/apache2/mods-available/mpm_event.conf. This is the highest value that can be used with the default settings (ServerLimit default of 16, multiplied by ThreadsPerChild, which defaults to 25). For reference, see the Apache documentation. You can verify that the event MPM is the one you’re using with this command:
apache2ctl -t -D DUMP_MODULES | grep event
Back up the original jk.conf file in /etc/apache2/mods-available and create a new one. It should start like this (mind the domain name):

JkWorkersFile /usr/share/glassfish4/glassfish/domains//config/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel error
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] ”
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat “%w %V %T”
JkMountCopy all

You’ll also need to tell Apache to forward any traffic for your GlassFish-hosted web app; it’s also a good idea to disallow access to the WEB-INF directory. If your app’s context is /myapp, add lines like this to the file:
JkMount /myapp/* ajp13

require all denied

Create a workers.properties file in your GlassFish domain’s config directory (referenced in the above file) that looks like this:
worker.list=ajp13
worker.ajp13.type=ajp13
worker.ajp13.host=localhost
worker.ajp13.port=8009
# load balancing only: worker.ajp13.lbfactor=50
connection_pool_size=10
connection_pool_timeout=600
worker.ajp13.socket_keepalive=False
# make same as GlassFish:
worker.ajp13.socket_timeout=30
Create the JK listener in GlassFish using these commands:
asadmin create-http-listener –listenerport 8009 –listeneraddress 0.0.0.0 –defaultvs server jk-listener
asadmin set server-config.network-config.network-listeners.network-listener.jk-listener.jk-enabled=true
After doing this, edit server-config and create a new thread pool called jk-thread-pool with minimum and maximum size of 400, then assign this pool to the jk-listener you just created (in Network Config/Network Listeners). The number 400 is to match the values in /etc/apache2/mods-available/mpm_event.conf (see above). For reference, see the GlassFish 4.0 documentation.
Restart Apache and GlassFish. If you could access your app at e.g. localhost:8080/myapp/index.html before fronting with Apache, you should be able to access it without the :8080 now.
back to top

Setting up Database Connection Pools

Here are the steps to set up a connection pool for a PostgreSQL database:
Put the latest Postgres JDBC driver to the lib/ subdirectory of the GlassFish install (/usr/share/glassfish4/glassfish/lib).
In the admin client, navigate to Resources / JDBC / Connection Pools, and create a new pool named after the database. Set the resource type to javax.sql.DataSource; leave the database vendor field blank.
On the next panel, set the datasource classname to org.postgresql.ds.PGSimpleDataSource. (You could also use javax.sql.XADataSource and org.postgresql.xa.PGXADataSource).
At the bottom of the page is an area to enter additional properties; you must enter values for serverName, databaseName, user, and password. If you want to use entity class generation or the JPQL browser in NetBeans, add a URL parameter that looks like jdbc:postgresql://hostname:5432/databasename.
After saving, select the entry for this pool and click the “Ping” button. You should see a message saying “Ping Succeeded.”
Create a new entry pointing to the pool under Resources / JDBC / JDBC Resources. The name must start with jdbc/.
If you are using EJBs with JPA, your persistence.xml should look something like this (edit to taste):
org.eclipse.persistence.jpa.PersistenceProvider jdbc/your-resource-here
false
For those using MySQL, the datasource class name is com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource. The necessary properties are user, password, and URL; the format for URL is:
jdbc:mysql://:3306/
back to top

2015/03/20

Glassfish remote deploy

Filed under: Config,Glassfish,Programering,Server — Mathz @ 16:07

replace /usr/local/glassfish4/glassfish/modules/nucleus-grizzly-all.jar

./asadmin change-admin-password
./asadmin enable-secure-admin

2015/02/28

Windows – disable ipv6 and teredo

Filed under: Server — Mathz @ 11:18

Ru this from a commandprompt:

netsh int ipv6 isatap set state disabled
netsh int ipv6 6to4 set state disabled
netsh interface teredo set state disable

2015/01/11

Split IBDATA1

Filed under: Hemsidor,MySQL,Server — Mathz @ 23:44
  1. Dump all databases by calling:
    mysqldump --extended-insert --all-databases --add-drop-database --disable-keys --flush-privileges --quick --routines --triggers > all-databases.sql
  2. Stop the MySQL server;
  3. Rename or remove (in case you’ve already backed it up) the MySQL data directory and create an empty one with the same name and permissions;
  4. Make the appropriate changes in my.cnf;
    innodb_file_per_table
  5. Re-initialize the database with the following command (replace the ‘mysqld‘ with the login of the user your MySQL server runs as):
    sudo -u mysqld mysql_install_db
  6. Start the MySQL server;
  7. Get into the ‘mysql‘ console and type:
    SET FOREIGN_KEY_CHECKS=0;
    SOURCE all-databases.sql;
    SET FOREIGN_KEY_CHECKS=1;
  8. Restart the MySQL server.

2014/03/27

Visa procedure i MySQL

Filed under: MySQL,Server — Mathz @ 09:06
SHOW PROCEDURE STATUS;
SHOW FUNCTION STATUS;

2014/01/05

Cisco IP Phone 7941 – reset

Filed under: Asterisk — Mathz @ 21:31

Power Cycle the phone and clear the configuration by holding down the # key and then plugging in the phone. After all the lights cycle on the phone, release the # key and press 123456789*0# followed with the 2 key (if you are using a 79×1, 79×2, 79×5, 7970 phone, plug the phone in and hold the # key till the extension lights blink amber…then press 3491672850*#. The lights will turn red, but if they dont, repeat this step. The phone will then wipe the flash and load whatever firmware is specified in the tftpd32 directory – if the phone just keeps downloading the term.defaults file constantly, just do an incremental upgrade to the firmware version that you want).

2013/12/25

Scrubbing MD (Software RAID)

Filed under: Server — Mathz @ 00:09

cat /sys/block/md0/md/mismatch_cnt if not 0

echo repair >/sys/block/md0/md/sync_action

watch cat /proc/mdstat

2013/11/28

Autologin in Ubuntu

Filed under: Server,Ubuntu — Mathz @ 16:23

In file /etc/lightdm/lightdm.conf add following in section [SeatDefaults]:

autologin-user-timeout=0
autologin-user=

2013/11/02

Driver Windows 2003 Server

Filed under: Server — Mathz @ 19:42

Load SCSI hard drive driver without floppy disk while Install windows server 2003 etc.

i need to load the scsi hard driver by press F6 while installing windows server 2003, then insert the floppy disk,

hand drive and the scsi driver is not included in Windows server 2003……. -_-!

i dun even remember there’s a thing called Floppy Disk or Diskettes… anyway, i need to work around this.

after a bit search, i found the following solution:

basicly this solution integrate the scsi hard drive driver into your Windows Server installation disk.

  • you’ll need 1 extra software, free of cause.
  • and the scsi driver of cause…

1. download and install nLite from http://www.nliteos.com/download.html

2. load your windows server to CD-ROM or load your iso to virtual cd-rom.

3.  run nlite.  follow nLite instructions to Select your Installation Disc CD-ROM

4. follow nLite instructions to Create a new folder to save Disk content

5. follow nLite instructions to the following screen:

integrate_scsi_dirver_in_windows_server_2003

click on “Drivers” then Next;

6. in the following screen,

integrate_scsi_dirver_2

click on “Insert”  –> “Single Driver”. then select the scsi driver from your hard drive.

integrate_scsi_dirver_3

select “Textmode driver” –> chose your driver –> ok

then nLite will integrate the driver into the disk.

7. run nLite again and get to this creen

integrate_scsi_dirver_in_windows_server_2003

click on “Bootable ISO”

8. with the ISO, you can either burn or mont. when you install with this iso, you do not need to press F6 to load driver from floppy, it will be loaded automatically.

9. have fun

2013/10/31

PPTP Ubuntu

Filed under: Server — Mathz @ 11:47

PPTPServer


This guide has been tested with Ubuntu 12.4.2 LTS  Server.

 

Setup PPTP Server

First we need to install pptp server using apt-get

# sudo apt-get install pptpd

Then we need to configure the pptpd.

# sudo nano /etc/pptpd.conf

Add server IP and client IP at the end of the file. You can add like below:

localip 192.168.0.1
remoteip 192.168.0.100-200

This sets up the PPTP server to use IP 192.168.0.1 while distributing the IP range 192.168.0.100 to 192.168.0.200 to PPTP clients. Change these as you wish as long as they are private IP addresses and do not conflict with IP addresses already used by your server.

Configure DNS servers to use when clients connect to this PPTP server

# sudo nano /etc/ppp/pptpd-options

Uncomment the ms-dns and add google like below or OpenDNS

ms-dns 8.8.8.8
ms-dns 8.8.4.4

Now add a VPN user in /etc/ppp/chap-secrets file.

# sudo nano /etc/ppp/chap-secrets

The column is username. Second column is server name, you can put “pptpd” in there. Third column is password. The last column is the IP addresses, you can put * to allow all IP.

# client        server  secret                  IP addresses
username * myPassword *

Finally start your server

# /etc/init.d/pptpd restart

 

Setup IP Forwarding

To enable IPv4 forward. Change /etc/sysctl.conf file, add forward rule blew.

# sudo nano /etc/sysctl.conf

Uncomnent the line

net.ipv4.ip_forward=1

Then reload the configuration

sudo sysctl -p

Add forward rule in iptables

# sudo nano /etc/rc.local

adding to the bottom just before the exit 0

iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
iptables -A FORWARD -p tcp --syn -s 192.168.0.0/24 -j TCPMSS --set-mss 1356

This example is using 192.168.0 for its PPTP subnet. The second rule adjusts the MTU size :

You are done. Just reboot your server and you should be able to connect to using PPTPD and send all your traffic through this server.

« Newer PostsOlder Posts »

Powered by WordPress